X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FinsetgraphicsParams.C;h=405368d2fff93711a48d207ddd486cf875bf461a;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=870f8d18dd9c8ad2e5115ae77c908c144b85f837;hpb=e173216d0aed9ea76bbd0d2916d77259a4b93223;p=lyx.git diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 870f8d18dd..405368d2ff 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -18,13 +18,16 @@ #include "insetgraphicsParams.h" -#include "lyxrc.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 @@ -99,27 +102,22 @@ void InsetGraphicsParams::init() bb = string(); // bounding box draft = false; // draft mode clip = false; // clip image - if (lyxrc.display_graphics == "mono") - display = MONOCHROME; - else if (lyxrc.display_graphics == "gray") - display = GRAYSCALE; - else if (lyxrc.display_graphics == "color") - display = COLOR; - else - display = NONE; + display = DEFAULT; // see pref subcaption = false; // subfigure + noUnzip = false; // unzip files width = LyXLength(); // set to 0pt height = LyXLength(); lyxwidth = LyXLength(); // for the view in lyx - lyxheight = LyXLength(); - scale = 0; + lyxheight = LyXLength(); // also set to 0pt + scale = 0; // unit is % + lyxscale = 0; // same for lyxview size_type = DEFAULT_SIZE; // do nothing - keepAspectRatio = false; // - rotateOrigin = "center"; // + lyxsize_type = DEFAULT_SIZE; // do nothing + keepAspectRatio = false; // only for latex + rotate = false; // Rotating + rotateOrigin = "center"; // Origin rotateAngle = 0.0; // in degrees special = string(); // userdefined stuff - - testInvariant(); } void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) @@ -131,37 +129,20 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) display = igp.display; subcaption = igp.subcaption; subcaptionText = igp.subcaptionText; + noUnzip = igp.noUnzip; keepAspectRatio = igp.keepAspectRatio; width = igp.width; height = igp.height; scale = igp.scale; size_type = igp.size_type; + lyxsize_type = igp.lyxsize_type; lyxwidth = igp.lyxwidth; lyxheight = igp.lyxheight; + lyxscale = igp.lyxscale; + rotate = igp.rotate; rotateOrigin = igp.rotateOrigin; rotateAngle = igp.rotateAngle; special = igp.special; - - testInvariant(); -} - -void InsetGraphicsParams::testInvariant() const -{ - // Filename might be empty (when the dialog is first created). - // Assert(!filename.empty()); - lyx::Assert(display == DEFAULT || - display == COLOR || - display == MONOCHROME || - display == GRAYSCALE || - display == NONE - ); - // Angle is in degrees and ranges -360 < angle < 360 - // The reason for this is that in latex there is a meaning for the - // different angles and they are not necessarliy interchangeable, - // it depends on the rotation origin. - lyx::Assert(rotateAngle < 360.0); - lyx::Assert(rotateAngle > -360.0); - } bool operator==(InsetGraphicsParams const & left, @@ -173,18 +154,22 @@ bool operator==(InsetGraphicsParams const & left, 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; @@ -211,13 +196,15 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const os << "\tclip\n"; if (draft) // draft mode os << "\tdraft\n"; - // Save the display type + // Save the display type for the view inside lyx os << "\tdisplay " << displayTranslator.find(display) << '\n'; // Save the subcaption status if (subcaption) os << "\tsubcaption\n"; if (!subcaptionText.empty()) os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n'; + if (noUnzip) + os << "\tnoUnzip\n"; // we always need the size type // 0: no special // 1: width/height combination @@ -231,16 +218,22 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const os << "\tscale " << scale << '\n'; if (keepAspectRatio) os << "\tkeepAspectRatio\n"; + if (rotate) + os << "\trotate\n"; if (!lyx::float_equal(rotateAngle, 0.0, 0.001)) os << "\trotateAngle " << rotateAngle << '\n'; if (!rotateOrigin.empty()) os << "\trotateOrigin " << rotateOrigin << '\n'; if (!special.empty()) os << "\tspecial " << special << '\n'; + // the values for the view in lyx + os << "\tlyxsize_type " << lyxsize_type << '\n'; if (!lyxwidth.zero()) // the lyx-viewsize os << "\tlyxwidth " << lyxwidth.asString() << '\n'; if (!lyxheight.zero()) os << "\tlyxheight " << lyxheight.asString(); + if (lyxscale != 0) + os << "\tlyxscale " << lyxscale << '\n'; } @@ -272,19 +265,8 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, } else if (token == "subcaptionText") { lex.next(); subcaptionText = lex.getString(); - } 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 == "noUnzip") { + noUnzip = true; } else if (token == "size_type") { lex.next(); switch (lex.getInteger()) { @@ -298,9 +280,6 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, lex.next(); width = LyXLength(lex.getString()); size_type = WH; - } else if (token == "heightResize") { - if (lex.next()) - height = convertResizeValue(lex.getString(), lex); } else if (token == "height") { lex.next(); height = LyXLength(lex.getString()); @@ -310,20 +289,53 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, } else if (token == "scale") { lex.next(); scale = lex.getInteger(); + } else if (token == "rotate") { + rotate = true; } else if (token == "rotateAngle") { lex.next(); rotateAngle = lex.getFloat(); } else if (token == "rotateOrigin") { lex.next(); rotateOrigin=lex.getString(); + } else if (token == "lyxsize_type") { + lex.next(); + switch (lex.getInteger()) { + case 0 : lyxsize_type = DEFAULT_SIZE; + break; + case 1 : lyxsize_type = WH; + break; + case 2 : lyxsize_type = SCALE; + } } else if (token == "lyxwidth") { lex.next(); lyxwidth = LyXLength(lex.getString()); } else if (token == "lyxheight") { lex.next(); lyxheight = LyXLength(lex.getString()); - } else { - // If it's none of the above, its not ours. + } 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 it's none of the above, its not ours. return false; } return true;