]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphicsParams.C
Make it compile when USE_BOOST_FORMAT is unset
[lyx.git] / src / insets / insetgraphicsParams.C
index e9fcd3dc909f47394a6f3aa57c1de2857f6749a8..ad012fd9fe73d4fe8442592b7aa47ca3fb2cb4a8 100644 (file)
@@ -1,14 +1,13 @@
-/* This file is part of
- * =================================================
- *
- *          LyX, The Document Processor
- *          Copyright 1995 Matthias Ettrich.
- *          Copyright 1995-2001 The LyX Team.
+/**
+ * \file insetgraphicsParams.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Baruch Even
  * \author Herbert Voss
  *
- * ================================================= */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
@@ -59,7 +58,7 @@ void InsetGraphicsParams::init()
        filename.erase();
        lyxscale = 100;                 // lyx scaling in percentage
        display = grfx::DefaultDisplay; // display mode; see preferences
-       scale = 100;                    // output scaling in percentage
+       scale = 100.0;                  // output scaling in percentage
        width = LyXLength();
        height = LyXLength();
        keepAspectRatio = false;        // for LaTeX output
@@ -143,16 +142,16 @@ void InsetGraphicsParams::Write(ostream & os) const
                os << "\tlyxscale " << lyxscale << '\n';
        if (display != grfx::DefaultDisplay)
                os << "\tdisplay " << grfx::displayTranslator.find(display) << '\n';
-       if (scale) {
-               if (scale != 100)
+       if (!lyx::float_equal(scale, 0.0, 0.05)) {
+               if (!lyx::float_equal(scale, 100.0, 0.05))
                        os << "\tscale " << scale << '\n';
        } else {
                if (!width.zero())
                        os << "\twidth " << width.asString() << '\n';
+               if (!height.zero())
+                       os << "\theight " << height.asString() << '\n';
        }
 
-       if (!height.zero())
-               os << "\theight " << height.asString() << '\n';
        if (keepAspectRatio)
                os << "\tkeepAspectRatio\n";
        if (draft)                      // draft mode
@@ -192,14 +191,15 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
                display = grfx::displayTranslator.find(type);
        } else if (token == "scale") {
                lex.next();
-               scale = lex.getInteger();
+               scale = lex.getFloat();
        } else if (token == "width") {
                lex.next();
                width = LyXLength(lex.getString());
-               scale = 0;
+               scale = 0.0;
        } else if (token == "height") {
                lex.next();
                height = LyXLength(lex.getString());
+               scale = 0.0;
        } else if (token == "keepAspectRatio") {
                keepAspectRatio = true;
        } else if (token == "draft") {
@@ -207,9 +207,12 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
        } else if (token == "noUnzip") {
                noUnzip = true;
        } else if (token == "BoundingBox") {
-               for (int i=0; i<4 ;i++) {
+               bb.erase();
+               for (int i = 0; i < 4; ++i) {
+                       if (i != 0)
+                               bb += " ";
                        lex.next();
-                       bb += (lex.getString()+" ");
+                       bb += lex.getString();
                }
        } else if (token == "clip") {
                clip = true;
@@ -229,11 +232,14 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
                special = lex.getString();
 
        // catch and ignore following two old-format tokens and their arguments.
-       // e.g. "size_kind scale" clashes with the setting of the "scale" keyword.
+       // e.g. "size_kind scale" clashes with the setting of the
+       // "scale <value>" keyword.
        } else if (token == "size_kind" || token == "lyxsize_kind") {
                lex.next();
                lex.getString();
-       } else {        // If it's none of the above, it's not ours.
+
+       } else {
+               // If it's none of the above, it's not ours.
                return false;
        }
        return true;