]> git.lyx.org Git - features.git/blobdiff - src/frontends/controllers/ControlGraphics.C
(Herbert): discover the "Bounding Box" of non-(e)ps graphics files, and
[features.git] / src / frontends / controllers / ControlGraphics.C
index 8c459d13eecee161c89bcdfafde89dd0c8eeb55a..4437f0f7819ea6a7a95d5e0c8739530ee991caaf 100644 (file)
@@ -23,6 +23,9 @@
 #include "ButtonControllerBase.h"
 #include "ControlGraphics.h"
 #include "ControlInset.tmpl"
+
+#include "helper_funcs.h"
+
 #include "buffer.h"
 #include "BufferView.h"
 #include "Dialogs.h"
 #include "gettext.h"
 #include "lyxrc.h"
 
+#include "graphics/GraphicsCache.h"
+
 #include "insets/insetgraphics.h"
-#include "insets/insetgraphicsParams.h" // need operator!=()
+#include "insets/insetgraphicsParams.h"
 
-#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/FileInfo.h"
+
 
 using std::pair;
 using std::make_pair;
 using std::ifstream;
-
 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
        : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
 {
@@ -104,7 +109,18 @@ string const ControlGraphics::Browse(string const & in_name)
 
 string const ControlGraphics::readBB(string const & file)
 {
-       return readBB_from_PSFile(MakeAbsPath(file, lv_.buffer()->filePath()));
+       string const abs_file = MakeAbsPath(file, lv_.buffer()->filePath());
+
+       string const from = getExtFromContents(abs_file);       
+       // Check if we have a Postscript file, then it's easy
+       if (contains(from, "ps"))
+               return readBB_from_PSFile(abs_file);
+
+       // we don't, so ask the Graphics Cache if it has loaded the file
+       grfx::GCache & gc = grfx::GCache::get();
+       return ("0 0 " + 
+               tostr(gc.raw_width(abs_file)) + ' ' + 
+               tostr(gc.raw_height(abs_file)));
 }