From ec0c2e5bc05335e2d9eda502f29778fffe242519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 28 Dec 2004 11:23:05 +0000 Subject: [PATCH] float2string changes #1 (Graphics) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9404 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 4 ++++ src/insets/insetgraphics.C | 20 +++++++++++--------- src/insets/insetgraphicsParams.C | 22 +++++++++++----------- src/insets/insetgraphicsParams.h | 4 ++-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index fd9ae88b08..c1cb9653f3 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2004-12-28 Jürgen Spitzmüller + + * insetgraphics.C: + * insetgraphicsParams.[Ch]: store all values as strings. 2004-12-17 Alfredo Braunstein diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 453c9891d5..3ec93e551c 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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( (params().scale) + 0.5 ) + if (!params().scale.empty() && params().scale != "0") { + if (params().scale != "100") + options << " scale=\"" + << static_cast( (strToDbl(params().scale)) + 0.5 ) << "\" "; } else { if (!params().width.zero()) { diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index a38cca4177..8b7981fce0 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -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; diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index b96343836f..68924a64f5 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -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?