Angus Leeming wrote:

> 
> Or call them raw_dimensions and return a pair<uint, uint>. Your call.


please apply.

Herbert


-- 
http://www.lyx.org/help/
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.157
diff -u -r1.157 ChangeLog
--- src/frontends/controllers/ChangeLog 9 Apr 2002 10:02:10 -0000       1.157
+++ src/frontends/controllers/ChangeLog 11 Apr 2002 14:05:53 -0000
@@ -1,3 +1,7 @@
+2002-04-11  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * ControlGraphics.C: read BoundingBox also from non (e)ps files.
+
 2002-04-08  Adrien Rebollo  <[EMAIL PROTECTED]>
 
        * ControlAboutlyx.C (getVersion): two _() forgotten
Index: src/frontends/controllers/ControlGraphics.C
===================================================================
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v
retrieving revision 1.31
diff -u -r1.31 ControlGraphics.C
--- src/frontends/controllers/ControlGraphics.C 8 Apr 2002 16:47:50 -0000       1.31
+++ src/frontends/controllers/ControlGraphics.C 11 Apr 2002 14:05:53 -0000
@@ -36,12 +38,14 @@
 #include "support/FileInfo.h"  // for FileInfo
 #include "helper_funcs.h"
 #include "support/lstrings.h"
-#include "support/filetools.h" // for AddName, zippedFile
+#include "support/filetools.h"
+#include "support/path.h"
 
 using std::pair;
 using std::make_pair;
 using std::ifstream;
-
+using std::endl;
+ 
 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
        : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
 {
@@ -104,7 +108,17 @@
 
 string const ControlGraphics::readBB(string const & file)
 {
-       return readBB_from_PSFile(MakeAbsPath(file, lv_.buffer()->filePath()));
+       string const from = getExtFromContents(file);   
+       // check if we have a postscriptfile, than it's easy
+       if (contains(from, "ps"))
+               return readBB_from_PSFile(file);
+       
+       // we don't, so let's ask the inset.
+       // first make the right path
+       Path p(lv_.buffer()->filePath());
+       return ("0 0 " + 
+               tostr(inset()->raw_image_width()) + ' ' + 
+               tostr(inset()->raw_image_height()));
 }
 
 
 }
Index: src/graphics/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/ChangeLog,v
retrieving revision 1.48
diff -u -r1.48 ChangeLog
--- src/graphics/ChangeLog      8 Apr 2002 16:51:46 -0000       1.48
+++ src/graphics/ChangeLog      11 Apr 2002 14:05:55 -0000
@@ -1,3 +1,9 @@
+2002-04-10  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * GraphicsCache.[Ch]:
+       * GraphicsCacheItem.[Ch]: add width/height functions from Angus
+       to read "BB" from non (e)ps files.
+
 2002-04-08  Angus Leeming  <[EMAIL PROTECTED]>
 
        * GraphicsParams.C (c-tor): if clipping, then check the Bounding Box of
Index: src/graphics/GraphicsCache.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsCache.C,v
retrieving revision 1.22
diff -u -r1.22 GraphicsCache.C
--- src/graphics/GraphicsCache.C        22 Mar 2002 16:37:51 -0000      1.22
+++ src/graphics/GraphicsCache.C        11 Apr 2002 14:05:55 -0000
@@ -165,4 +165,25 @@
        return cache->end();
 }
 
+
+unsigned int GCache::raw_width(string const & filename) const
+{
+       CacheType::const_iterator it = cache->find(filename);
+       if (it == cache->end())
+               return 0;
+
+       return it->second->raw_width();
+}
+
+
+unsigned int GCache::raw_height(string const & filename) const
+{
+       CacheType::const_iterator it = cache->find(filename);
+       if (it == cache->end())
+               return 0;
+
+       return it->second->raw_height();
+}
+
 } // namespace grfx
+
Index: src/graphics/GraphicsCache.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsCache.h,v
retrieving revision 1.16
diff -u -r1.16 GraphicsCache.h
--- src/graphics/GraphicsCache.h        22 Mar 2002 16:37:51 -0000      1.16
+++ src/graphics/GraphicsCache.h        11 Apr 2002 14:05:55 -0000
@@ -67,6 +67,10 @@
        /// How far have we got in loading the image?
        ImageStatus status(InsetGraphics const &) const;
 
+       // for getting the "bb" of non (e)ps files
+       unsigned int raw_width(string const & filename) const;
+       unsigned int raw_height(string const & filename) const;
+       
 private:
        /** Make the c-tor private so we can control how many objects
         *  are instantiated.
Index: src/graphics/GraphicsCacheItem.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsCacheItem.C,v
retrieving revision 1.30
diff -u -r1.30 GraphicsCacheItem.C
--- src/graphics/GraphicsCacheItem.C    26 Mar 2002 12:43:21 -0000      1.30
+++ src/graphics/GraphicsCacheItem.C    11 Apr 2002 14:05:55 -0000
@@ -392,6 +393,24 @@
 }
 
 
+unsigned int GCacheItem::raw_width() const
+{
+       if (!image_.get())
+               return 0;
+       
+       return image_->getWidth();
+}
+
+
+unsigned int GCacheItem::raw_height() const
+{
+       if (!image_.get())
+               return 0;
+       
+       return image_->getHeight();
+}
+
+
 namespace {
 
 string const findTargetFormat(string const & from)
Index: src/graphics/GraphicsCacheItem.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsCacheItem.h,v
retrieving revision 1.21
diff -u -r1.21 GraphicsCacheItem.h
--- src/graphics/GraphicsCacheItem.h    21 Mar 2002 17:27:08 -0000      1.21
+++ src/graphics/GraphicsCacheItem.h    11 Apr 2002 14:05:56 -0000
@@ -89,6 +89,10 @@
         */
        void changeDisplay(bool changed_background);
 
+       /// for getting the "bb" of non (e)ps- files
+       unsigned int raw_width() const;
+       unsigned int raw_height() const;
+       
 private:
        /** Start the image conversion process, checking first that it is
         *  necessary. If it is necessary, then a conversion task is started.
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.383
diff -u -r1.383 ChangeLog
--- src/insets/ChangeLog        8 Apr 2002 17:26:33 -0000       1.383
+++ src/insets/ChangeLog        11 Apr 2002 14:05:57 -0000
@@ -1,3 +1,8 @@
+2002-04-11  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * insetgraphic.[Ch]: add two functions from Angus to get 
+       the "bb" from non (e)ps files
+
 2002-04-07  Herbert Voss  <[EMAIL PROTECTED]>
 
        * insetgraphic.C (readFigInset): fix bug with subcaption and
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.103
diff -u -r1.103 insetgraphics.C
--- src/insets/insetgraphics.C  8 Apr 2002 17:26:33 -0000       1.103
+++ src/insets/insetgraphics.C  11 Apr 2002 14:05:57 -0000
@@ -365,6 +363,20 @@
 }
 
 
+unsigned int InsetGraphics::raw_image_width() const
+{      
+       grfx::GCache & gc = grfx::GCache::get();
+       return gc.raw_width(MakeAbsPath(params().filename));
+}
+
+
+unsigned int InsetGraphics::raw_image_height() const
+{      
+       grfx::GCache & gc = grfx::GCache::get();
+       return gc.raw_height(MakeAbsPath(params().filename));
+}
+
+
 void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
 {
        bv->owner()->getDialogs()->showGraphics(this);
Index: src/insets/insetgraphics.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.h,v
retrieving revision 1.47
diff -u -r1.47 insetgraphics.h
--- src/insets/insetgraphics.h  22 Mar 2002 16:37:52 -0000      1.47
+++ src/insets/insetgraphics.h  11 Apr 2002 14:05:57 -0000
@@ -44,6 +44,9 @@
        int descent(BufferView *, LyXFont const &) const;
        ///
        int width(BufferView *, LyXFont const &) const;
+       // for the bb of non (e)ps-files
+       unsigned int raw_image_width() const;
+       unsigned int raw_image_height() const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///

Reply via email to