+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>
#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"
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;
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())
// 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];
// 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()) {
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
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
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 &&
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())
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';
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") {
clip = true;
} else if (token == "rotateAngle") {
lex.next();
- rotateAngle = lex.getFloat();
+ rotateAngle = lex.getString();
} else if (token == "rotateOrigin") {
lex.next();
rotateOrigin=lex.getString();
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;
/// 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;
///
bool clip;
/// Rotation angle.
- float rotateAngle;
+ std::string rotateAngle;
/// Origin point of rotation
std::string rotateOrigin;
/// Do we have a subcaption?