From 7c49abda63c6e26e6ad75eef72f93ed3dee3c84b Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 1 Feb 2002 09:57:44 +0000 Subject: [PATCH] A couple of fixes from Herbert. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3467 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 5 +++++ src/frontends/controllers/ControlGraphics.C | 13 ++++++++----- src/insets/ChangeLog | 4 ++++ src/insets/insetgraphics.C | 20 +++++++++++++++----- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index c93c39e324..db1ded68ac 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2002-02-01 Herbert Voss + + * ControlGraphics.[C] (readBB): search only, if it is a + ".?ps" file and look for bb's at end of file + 2002-01-30 Herbert Voss * ControlGraphic.[C]: do not search the whole file, when diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index a6df4b5d3d..63aa81561b 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -104,17 +104,20 @@ string const ControlGraphics::readBB(string const & file) // in a file it's an entry like %%BoundingBox:23 45 321 345 // the first number can following without a space, so we have // to check a bit more. -// ControlGraphics::bbChanged = false; +// on the other hand some plot programs write the bb at the +// end of the file. Than we have in the header a +// %%BoundingBox: (atend) +// In this case we must check until the end. std::ifstream is(file.c_str()); - int count = 0; - int const max_count = 50; // don't search the whole file - while (is && (++count < max_count)) { + if (!contains(getExtFromContents(file),"ps")) // bb exists? + return string(); + while (is) { string s; is >> s; if (contains(s,"%%BoundingBox:")) { string a, b, c, d; is >> a >> b >> c >> d; - if (is) { + if (is && !contains(a,"atend")) { // bb at the end? if (s != "%%BoundingBox:") return (s.substr(14)+" "+a+" "+b+" "+c+" "); else diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b67afb22c0..81c2a05f4a 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-01-31 Herbert Voss + + * insetgraphic.C: (readfigInset) set display to pref-default + 2002-01-30 Herbert Voss * insetgraphic.C: get the filetyp from it's contents diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index bd03664fe3..c75b0fe898 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -373,7 +373,15 @@ void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex) std::vector const oldUnits = getVectorFromString("pt,cm,in,p%,c%"); bool finished = false; - + // set the display default + if (lyxrc.display_graphics == "mono") + params.display = InsetGraphicsParams::MONOCHROME; + else if (lyxrc.display_graphics == "gray") + params.display = InsetGraphicsParams::GRAYSCALE; + else if (lyxrc.display_graphics == "color") + params.display = InsetGraphicsParams::COLOR; + else + params.display = InsetGraphicsParams::NONE; while (lex.isOK() && !finished) { lex.next(); @@ -409,13 +417,15 @@ void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex) if (lex.next()) params.lyxheight = LyXLength(lex.getString()+"pt"); } else if (token == "flags") { - InsetGraphicsParams::DisplayType tmp = InsetGraphicsParams::COLOR; if (lex.next()) switch (lex.getInteger()) { - case 1: tmp = InsetGraphicsParams::MONOCHROME; break; - case 2: tmp = InsetGraphicsParams::GRAYSCALE; break; + case 1: params.display = InsetGraphicsParams::MONOCHROME; + break; + case 2: params.display = InsetGraphicsParams::GRAYSCALE; + break; + case 3: params.display = InsetGraphicsParams::COLOR; + break; } - params.display = tmp; } else if (token == "subfigure") { params.subcaption = true; } else if (token == "width") {