R. Lahaye wrote:

> I'm using non-eps graphics files, Grace-"agr" that is.
> 
> In the Bounding-Box tab of the Graphics dialog is the
> "Get values from file", which seems to have no effect on
> the "agr" file.
> 
> However, the agr file is converted to "eps"; then why not using
> this eps file for the getting the Bounding-Box values.
> 
> Would that be feasible for all non-(e)ps graphics files?
> 
> The problem arises, since I need to clip my Grace file to a
> smaller bounding-box area. I'm now guessing the values, but
> it would be much easier to "get them from file" first and
> then shrink the bounding box values accordingly.


please try the attached patch. it works perfectly for me, but
it looks at bit too easy ... ;-)

Herbert



-- 
http://www.lyx.org/help/
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 9 Apr 2002 05:03:32 -0000
@@ -28,7 +28,9 @@
 #include "Dialogs.h"
 #include "LyXView.h"
 #include "gettext.h"
+#include "converter.h"
 #include "lyxrc.h"
+#include "Alert.h"
 
 #include "insets/insetgraphics.h"
 #include "insets/insetgraphicsParams.h" // need operator!=()
@@ -104,7 +110,25 @@
 
 string const ControlGraphics::readBB(string const & file)
 {
-       return readBB_from_PSFile(MakeAbsPath(file, lv_.buffer()->filePath()));
+       string file_ = MakeAbsPath(file, lv_.buffer()->filePath());
+       
+       bool const zipped = zippedFile(file_);
+//     Path p(buf->filePath());
+       if (zipped)
+               file_ = unzipFile(file_);
+       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 convert
+       string const temp = AddName(lv_.buffer()->tmppath, file_);
+       string const outfile_base = ChangeExtension(temp, string());
+
+       converters.convert(lv_.buffer(), file_, outfile_base, from, "eps");
+       return readBB_from_PSFile(ChangeExtension(outfile_base,"eps"));
+       
 }
 
 

Reply via email to