]> git.lyx.org Git - features.git/commitdiff
float2string changes #1 (Graphics)
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 28 Dec 2004 11:23:05 +0000 (11:23 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 28 Dec 2004 11:23:05 +0000 (11:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9404 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetgraphics.C
src/insets/insetgraphicsParams.C
src/insets/insetgraphicsParams.h

index fd9ae88b087cb14747efc62204220d3c01bddc04..c1cb9653f390ef74cb08384580e39206475259bc 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-28  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * insetgraphics.C: 
+       * insetgraphicsParams.[Ch]: store all values as strings.
 
 2004-12-17  Alfredo Braunstein  <abraunst@lyx.org>
 
index 453c9891d58384070ee386458edbfe5ab41db30b..3ec93e551c99c80eeb2dca07806fd0a705f84dcc 100644 (file)
@@ -76,7 +76,8 @@ TODO
 
 #include "support/filetools.h"
 #include "support/lyxalgo.h" // lyx::count
-#include "support/lyxlib.h" // float_equal
+#include "support/lyxlib.h" // lyx::sum
+#include "support/lstrings.h"
 #include "support/os.h"
 #include "support/systemcall.h"
 
@@ -93,12 +94,12 @@ using lyx::support::ChangeExtension;
 using lyx::support::compare_timestamps;
 using lyx::support::contains;
 using lyx::support::FileName;
-using lyx::support::float_equal;
 using lyx::support::GetExtension;
 using lyx::support::IsFileReadable;
 using lyx::support::LibFileSearch;
 using lyx::support::OnlyFilename;
 using lyx::support::rtrim;
+using lyx::support::strToDbl;
 using lyx::support::subst;
 using lyx::support::Systemcall;
 using lyx::support::unzipFile;
@@ -298,9 +299,9 @@ string const InsetGraphics::createLatexOptions() const
            options << " draft,\n";
        if (params().clip)
            options << " clip,\n";
-       if (!float_equal(params().scale, 0.0, 0.05)) {
-               if (!float_equal(params().scale, 100.0, 0.05))
-                       options << " scale=" << params().scale / 100.0
+       if (!params().scale.empty() && params().scale != "0") {
+               if (params().scale != "100")
+                       options << " scale=" << strToDbl(params().scale) / 100.0
                                << ",\n";
        } else {
                if (!params().width.zero())
@@ -313,7 +314,7 @@ string const InsetGraphics::createLatexOptions() const
 
        // Make sure rotation angle is not very close to zero;
        // a float can be effectively zero but not exactly zero.
-       if (!float_equal(params().rotateAngle, 0, 0.001)) {
+       if (!params().rotateAngle.empty() && params().rotateAngle != "0") {
            options << "  angle=" << params().rotateAngle << ",\n";
            if (!params().rotateOrigin.empty()) {
                options << "  origin=" << params().rotateOrigin[0];
@@ -402,9 +403,10 @@ string const InsetGraphics::createDocBookAttributes() const
        // Right now it only works with my version of db2latex :-)
 
        ostringstream options;
-       if (!float_equal(params().scale, 0.0, 0.05)) {
-               if (!float_equal(params().scale, 100.0, 0.05))
-                       options << " scale=\"" << static_cast<int>( (params().scale) + 0.5 )
+       if (!params().scale.empty() && params().scale != "0") {
+               if (params().scale != "100")
+                       options << " scale=\"" 
+                               << static_cast<int>( (strToDbl(params().scale)) + 0.5 )
                                << "\" ";
        } else {
                if (!params().width.zero()) {
index a38cca4177e3a2c86812b4f27612c1e4aea4b0dc..8b7981fce0d2305b47ea9d9883514e8fa34d16fa 100644 (file)
@@ -66,7 +66,7 @@ void InsetGraphicsParams::init()
        filename.erase();
        lyxscale = 100;                 // lyx scaling in percentage
        display = lyx::graphics::DefaultDisplay; // display mode; see preferences
-       scale = 100.0;                  // output scaling in percentage
+       scale = string();                       // output scaling in percentage
        width = LyXLength();
        height = LyXLength();
        keepAspectRatio = false;        // for LaTeX output
@@ -76,7 +76,7 @@ void InsetGraphicsParams::init()
        bb = string();                  // bounding box
        clip = false;                   // clip image
 
-       rotateAngle = 0.0;              // angle of rotation in degrees
+       rotateAngle = "0";              // angle of rotation in degrees
        rotateOrigin.erase();           // Origin of rotation
        subcaption = false;             // subfigure
        subcaptionText.erase();         // subfigure caption
@@ -124,7 +124,7 @@ bool operator==(InsetGraphicsParams const & left,
            left.bb == right.bb &&
            left.clip == right.clip &&
 
-           float_equal(left.rotateAngle, right.rotateAngle, 0.001) &&
+           left.rotateAngle == right.rotateAngle &&
            left.rotateOrigin == right.rotateOrigin &&
            left.subcaption == right.subcaption &&
            left.subcaptionText == right.subcaptionText &&
@@ -154,8 +154,8 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
                os << "\tlyxscale " << lyxscale << '\n';
        if (display != lyx::graphics::DefaultDisplay)
                os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
-       if (!float_equal(scale, 0.0, 0.05)) {
-               if (!float_equal(scale, 100.0, 0.05))
+       if (!scale.empty() && scale != "0") {
+               if (scale != "100")
                        os << "\tscale " << scale << '\n';
        } else {
                if (!width.zero())
@@ -176,7 +176,7 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
        if (clip)                       // clip image
                os << "\tclip\n";
 
-       if (rotateAngle != 0.0)
+       if (!rotateAngle.empty() && rotateAngle != "0")
                os << "\trotateAngle " << rotateAngle << '\n';
        if (!rotateOrigin.empty())
                os << "\trotateOrigin " << rotateOrigin << '\n';
@@ -203,15 +203,15 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
                display = lyx::graphics::displayTranslator().find(type);
        } else if (token == "scale") {
                lex.next();
-               scale = lex.getFloat();
+               scale = lex.getString();
        } else if (token == "width") {
                lex.next();
                width = LyXLength(lex.getString());
-               scale = 0.0;
+               scale = string();
        } else if (token == "height") {
                lex.next();
                height = LyXLength(lex.getString());
-               scale = 0.0;
+               scale = string();
        } else if (token == "keepAspectRatio") {
                keepAspectRatio = true;
        } else if (token == "draft") {
@@ -230,7 +230,7 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
                clip = true;
        } else if (token == "rotateAngle") {
                lex.next();
-               rotateAngle = lex.getFloat();
+               rotateAngle = lex.getString();
        } else if (token == "rotateOrigin") {
                lex.next();
                rotateOrigin=lex.getString();
@@ -265,7 +265,7 @@ lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
        lyx::graphics::Params pars;
        pars.filename = filename.absFilename();
        pars.scale = lyxscale;
-       pars.angle = rotateAngle;
+       pars.angle = lyx::support::strToDbl(rotateAngle);
 
        if (clip) {
                pars.bb = bb;
index b96343836f71a14e30d40200f1a6918bc3f0c858..68924a64f53bbd554aabb164570a981354dd95a2 100644 (file)
@@ -37,7 +37,7 @@ struct InsetGraphicsParams
        /// How to display the image inside LyX
        lyx::graphics::DisplayType display;
        /// Scaling for output (LaTeX)
-       float scale;
+       std::string scale;
        /// sizes for output (LaTeX)
        LyXLength width;
        ///
@@ -55,7 +55,7 @@ struct InsetGraphicsParams
        bool clip;
 
        /// Rotation angle.
-       float rotateAngle;
+       std::string rotateAngle;
        /// Origin point of rotation
        std::string rotateOrigin;
        /// Do we have a subcaption?