]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphicsParams.C
Revert this change as it sneaked in and wasn't discussed yet.
[lyx.git] / src / insets / insetgraphicsParams.C
index da8f0b1d4d2bb2f11592d78400f177449b1c4ffc..e402934d0e679918515200bb6dda5ab741a0bc18 100644 (file)
@@ -39,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
 
 
@@ -149,27 +129,27 @@ bool operator==(InsetGraphicsParams const & left,
                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.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.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)
+               )
                return true;
 
        return false;
@@ -182,13 +162,11 @@ bool operator!=(InsetGraphicsParams const & left,
 }
 
 
-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';
@@ -200,27 +178,27 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
        os << "\tdisplay " << displayTranslator.find(display) << '\n';
        // Save the subcaption status
        if (subcaption)
-           os << "\tsubcaption\n";
+               os << "\tsubcaption\n";
        if (!subcaptionText.empty())
-           os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n';
+               os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n';
        if (noUnzip)
-           os << "\tnoUnzip\n";
-    // we always need the size type
-    // 0: no special
-    // 1: width/height combination
-    // 2: scale
+               os << "\tnoUnzip\n";
+       // we always need the size type
+       // 0: no special
+       // 1: width/height combination
+       // 2: scale
        os << "\tsize_type " <<  size_type << '\n';
        if (!width.zero())
-           os << "\twidth " << width.asString() << '\n';
+               os << "\twidth " << width.asString() << '\n';
        if (!height.zero())
-           os << "\theight " << height.asString() << '\n';
+               os << "\theight " << height.asString() << '\n';
        if (scale != 0)
-           os << "\tscale " << scale << '\n';
+               os << "\tscale " << scale << '\n';
        if (keepAspectRatio)
                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';
@@ -229,11 +207,11 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
        // the values for the view in lyx
        os << "\tlyxsize_type " <<  lyxsize_type << '\n';
        if (!lyxwidth.zero())           // the lyx-viewsize
-           os << "\tlyxwidth " << lyxwidth.asString() << '\n';
+               os << "\tlyxwidth " << lyxwidth.asString() << '\n';
        if (!lyxheight.zero())
-           os << "\tlyxheight " << lyxheight.asString();
+               os << "\tlyxheight " << lyxheight.asString();
        if (lyxscale != 0)
-           os << "\tlyxscale " << lyxscale << '\n';
+               os << "\tlyxscale " << lyxscale << '\n';
 }
 
 
@@ -244,8 +222,8 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
                filename = lex.getString();
        } else if (token == "BoundingBox") {
                for (int i=0; i<4 ;i++) {
-                   lex.next();
-                   bb += (lex.getString()+" ");
+                       lex.next();
+                       bb += (lex.getString()+" ");
                }
        } else if (token == "clip") {
                clip = true;
@@ -265,20 +243,22 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
        } else if (token == "size_type") {
                lex.next();
                switch (lex.getInteger()) {
-                   case 0 : size_type = DEFAULT_SIZE;
+               case 0:
+                       size_type = DEFAULT_SIZE;
                        break;
-                   case 1 : size_type = WH;
+               case 1:
+                       size_type = WH;
+                       break;
+               case 2:
+                       size_type = SCALE;
                        break;
-                   case 2 : size_type = SCALE;
                }
        } else if (token == "width") {
                lex.next();
                width = LyXLength(lex.getString());
-               size_type = WH;
        } else if (token == "height") {
                lex.next();
                height = LyXLength(lex.getString());
-               size_type = WH;
        } else if (token == "keepAspectRatio") {
                keepAspectRatio = true;
        } else if (token == "scale") {
@@ -295,11 +275,15 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
        } else if (token == "lyxsize_type") {
                lex.next();
                switch (lex.getInteger()) {
-                   case 0 : lyxsize_type = DEFAULT_SIZE;
+               case 0:
+                       lyxsize_type = DEFAULT_SIZE;
                        break;
-                   case 1 : lyxsize_type = WH;
+               case 1:
+                       lyxsize_type = WH;
+                       break;
+               case 2:
+                       lyxsize_type = SCALE;
                        break;
-                   case 2 : lyxsize_type = SCALE;
                }
        } else if (token == "lyxwidth") {
                lex.next();
@@ -310,26 +294,9 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
        } 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;
        }