]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphicsParams.C
Translate labels for float:algorithm, float:figure and float:table.
[lyx.git] / src / insets / insetgraphicsParams.C
index 94aa851d5b1d0fd6ead4cd8873424590373828e2..9cb6ceb70a67682ceb26404ea37af51f73d39f00 100644 (file)
@@ -1,6 +1,6 @@
 /* This file is part of
  * =================================================
- * 
+ *
  *          LyX, The Document Processor
  *          Copyright 1995 Matthias Ettrich.
  *          Copyright 1995-2001 The LyX Team.
  *
  * ================================================= */
 
-#include <config.h> 
+#include <config.h>
 
 #ifdef __GNUG__
 #pragma implementation
-#endif 
+#endif
 
 #include "insetgraphicsParams.h"
+
 #include "support/translator.h"
 #include "support/filetools.h"
 #include "support/lyxlib.h"
 #include "support/LOstream.h"
 #include "support/LAssert.h"
 
+
+using std::ostream;
+
+
 namespace {
 
 /// This variable keeps a tab on whether the translator was set with the
@@ -34,26 +39,6 @@ bool translatorsSet = false;
 Translator< InsetGraphicsParams::DisplayType, string >
 displayTranslator(InsetGraphicsParams::DEFAULT, "default");
 
-// this is only compatibility stuff for the first 1.2 version
-// it is obselete until 1.3
-LyXLength convertResizeValue(string const token, LyXLex & lex) {
-    lex.next();
-    string value = lex.getString();    // "width" or "height"  
-    lex.next();                                // anyway not interesting
-    value = lex.getString();
-    if (token == "default")
-       return (LyXLength(value+"pt"));
-    else if (token == "cm")
-       return (LyXLength(value+"cm"));
-    else if (token == "inch")
-       return (LyXLength(value+"in"));
-    else if (token == "percentOfColumn")
-       return (LyXLength(value+"c%"));
-    else if (token == "percentOfPage")
-       return (LyXLength(value+"p%"));
-    else return LyXLength("0pt");      // nothing with figinset
-}
-
 } // namespace anon
 
 
@@ -109,7 +94,7 @@ void InsetGraphicsParams::init()
        size_type = DEFAULT_SIZE;       // do nothing
        lyxsize_type = DEFAULT_SIZE;    // do nothing
        keepAspectRatio = false;        // only for latex
-       rotate = false;                 // Rotating 
+       rotate = false;                 // Rotating
        rotateOrigin = "center";        // Origin
        rotateAngle = 0.0;              // in degrees
        special = string();             // userdefined stuff
@@ -141,49 +126,47 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
 }
 
 bool operator==(InsetGraphicsParams const & left,
-                InsetGraphicsParams const & right)
+               InsetGraphicsParams const & right)
 {
        if (left.filename == right.filename &&
-               left.bb == right.bb &&
-               left.draft == right.draft &&
-               left.clip == right.clip &&
-               left.display == right.display &&
-               left.subcaption == right.subcaption &&
+               left.bb == right.bb &&
+               left.draft == right.draft &&
+               left.clip == right.clip &&
+               left.display == right.display &&
+               left.subcaption == right.subcaption &&
                left.noUnzip == right.noUnzip &&
-               left.subcaptionText == right.subcaptionText &&
-               left.keepAspectRatio == right.keepAspectRatio &&
-               left.width == right.width &&
-               left.height == right.height &&
-               left.scale == right.scale &&
-               left.size_type == right.size_type &&
-               left.lyxsize_type == right.lyxsize_type &&
-               left.lyxwidth == right.lyxwidth &&
-               left.lyxheight == right.lyxheight &&
-               left.lyxscale == right.lyxscale &&
-               left.rotate == right.rotate &&
-               left.rotateOrigin == right.rotateOrigin &&
-               lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
-               left.special == right.special) 
-          )
+               left.subcaptionText == right.subcaptionText &&
+               left.keepAspectRatio == right.keepAspectRatio &&
+               left.width == right.width &&
+               left.height == right.height &&
+               left.scale == right.scale &&
+               left.size_type == right.size_type &&
+               left.lyxsize_type == right.lyxsize_type &&
+               left.lyxwidth == right.lyxwidth &&
+               left.lyxheight == right.lyxheight &&
+               left.lyxscale == right.lyxscale &&
+               left.rotate == right.rotate &&
+               left.rotateOrigin == right.rotateOrigin &&
+               lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
+               left.special == right.special)
+         )
                return true;
 
        return false;
 }
 
 bool operator!=(InsetGraphicsParams const & left,
-                InsetGraphicsParams const & right)
+               InsetGraphicsParams const & right)
 {
-       return  !(left == right);
+       return  !(left == right);
 }
 
 
-void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
+void InsetGraphicsParams::Write(ostream & os) const
 {
        // If there is no filename, write nothing for it.
-       if (! filename.empty()) {
-               os << "\tfilename "
-               << MakeRelPath(filename, buf->filePath())
-               << '\n';
+       if (!filename.empty()) {
+               os << "\tfilename " << filename << '\n';
        }
        if (!bb.empty())                // bounding box
                os << "\tBoundingBox " << bb << '\n';
@@ -215,7 +198,7 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
                os << "\tkeepAspectRatio\n";
        if (rotate)
                os << "\trotate\n";
-       if (!lyx::float_equal(rotateAngle, 0.0, 0.001))
+       if (rotateAngle != 0.0)
                os << "\trotateAngle " << rotateAngle << '\n';
        if (!rotateOrigin.empty())
                os << "\trotateOrigin " << rotateOrigin << '\n';
@@ -232,16 +215,11 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
 }
 
 
-bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
-                               string const& token)
+bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
 {
        if (token == "filename") {
                lex.next();
                filename = lex.getString();
-               if (!filename.empty()) {
-                       // Make the filename with absolute directory.
-                       filename = MakeAbsPath(filename, buf->filePath());
-               }
        } else if (token == "BoundingBox") {
                for (int i=0; i<4 ;i++) {
                    lex.next();
@@ -310,26 +288,9 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
        } else if (token == "lyxscale") {
                lex.next();
                lyxscale = lex.getInteger();
-       // now the compytibility stuff for "old" 1.2.0 files which uses
-       // the first try of the new graphic inset. Can be deleted, when
-       // 1.3 comes out
-       } else if (token == "widthResize") {
-               if (lex.next()) {
-                   string const token = lex.getString();
-                   if (token == "scale") {
-                       lex.next();
-                       scale = lex.getInteger();
-                       size_type = SCALE;
-                   }
-                   else {
-                       width = convertResizeValue(token, lex);
-                       size_type = WH;
-                   }
-               }
-       } else if (token == "heightResize") {
-               if (lex.next())
-                       height = convertResizeValue(lex.getString(), lex);
-       // end compytibility stuff
+       } else if (token == "special") {
+               lex.eatLine();
+               special = lex.getString();
        } else {        // If it's none of the above, its not ours.
                return false;
        }