+2005-04-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * GGraphics.C: more precise checks for the value strings.
+
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
- * GGraphics.C: store all values as strings.
+ * GGraphics.C: store all float/double values as strings.
2004-12-19 Angus Leeming <leeming@lyx.org>
unitsComboFromLength(heightunitscombo_, stringcol_,
igp.height, defaultUnit);
- if (!igp.scale.empty() && igp.scale != "0") {
+ if (!igp.scale.empty()
+ && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
// scaling sizing mode
setscalingradio_->set_active(true);
} else {
+2005-01-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * QExternal.C: store all float/double values as strings.
+ * GGraphics.C: more precise checks for the value strings.
+
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
- * QGraphics.C: store all values as strings.
+ * QGraphics.C: store all float/double values as strings.
2004-12-19 Angus Leeming <leeming@lyx.org>
external::RotationData const & data)
{
originCO.setCurrentItem(int(data.origin()));
- angleED.setText(toqstr(tostr(data.angle())));
+ angleED.setText(toqstr(data.angle));
}
typedef external::RotationData::OriginType OriginType;
data.origin(static_cast<OriginType>(originCO.currentItem()));
- data.angle(strToDbl(fromqstr(angleED.text())));
+ data.angle = fromqstr(angleED.text());
}
external::ResizeData const & data)
{
bool using_scale = data.usingScale();
- double scale = data.scale;
+ std::string scale = data.scale;
if (data.no_resize()) {
// Everything is zero, so default to this!
using_scale = true;
- scale = 100;
+ scale = "100";
}
if (using_scale) {
- widthED.setText(toqstr(tostr(scale)));
+ widthED.setText(toqstr(scale));
widthUnitCO.setCurrentItem(0);
} else {
widthED.setText(toqstr(tostr(data.width.value())));
else
data.width = LyXLength();
- data.scale = 0.0;
+ data.scale = string();
} else {
// scaling instead of a width
- data.scale = strToDbl(width);
+ data.scale = width;
data.width = LyXLength();
}
for (int i = 0; i < num_units; i++)
dialog_->widthUnit->insertItem(unit_name_gui[i], -1);
- if (!igp.scale.empty() && igp.scale != "0") {
+ if (!igp.scale.empty()
+ && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
dialog_->width->setText(toqstr(igp.scale));
dialog_->widthUnit->setCurrentItem(0);
} else {
+2005-01-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * FormExternal.C: store all float/double values as strings.
+ * FormGraphics.C: more precise checks for the value strings.
+
2005-01-03 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* freebrowser.c (browser_cb):
BOOST_ASSERT(originCO && originCO->objclass == FL_CHOICE);
fl_set_choice(originCO, 1 + int(data.origin()));
- fl_set_input(angleED, tostr(data.angle()).c_str());
+ fl_set_input(angleED, data.angle.c_str());
}
typedef external::RotationData::OriginType OriginType;
data.origin(static_cast<OriginType>(fl_get_choice(originCO) - 1));
- data.angle(strToDbl(getString(angleED)));
+ data.angle = getString(angleED);
}
aspectratioCB->objclass == FL_CHECKBUTTON);
bool using_scale = data.usingScale();
- double scale = data.scale;
+ std::string scale = data.scale;
if (data.no_resize()) {
// Everything is zero, so default to this!
using_scale = true;
- scale = 100;
+ scale = "100";
}
if (using_scale) {
- fl_set_input(widthED, tostr(scale).c_str());
+ fl_set_input(widthED, scale.c_str());
fl_set_choice(widthUnitCO, 1);
} else {
fl_set_input(widthED, tostr(data.width.value()).c_str());
else
data.width = LyXLength();
- data.scale = 0.0;
+ data.scale = string();
} else {
// scaling instead of a width
- data.scale = strToDbl(width);
+ data.scale = width;
data.width = LyXLength();
}
// first item in choice_width means scaling
if (fl_get_choice(file_->choice_width) == 1) {
igp.scale = getString(file_->input_width);
- if (igp.scale.empty() || igp.scale == "0" || igp.scale == "100") {
+ if (igp.scale.empty()
+ || float_equal(strToDbl(igp.scale), 0.0, 0.05)
+ || float_equal(strToDbl(igp.scale), 100.0, 0.05)) {
igp.scale = string();
}
igp.width = LyXLength();
}
// set width input fields according to scaling or width/height input
- if (!igp.scale.empty() && igp.scale != "0") {
+ if (!igp.scale.empty() && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
fl_set_input_maxchars(file_->input_width, 0);
fl_set_input(file_->input_width, igp.scale.c_str());
igp.height, defaultUnit);
// disable height input in case of scaling
- bool const disable_height = (!igp.scale.empty() && igp.scale != "0");
+ bool const disable_height = (!igp.scale.empty()
+ && !float_equal(strToDbl(igp.scale), 0.0, 0.05));
setEnabled(file_->input_height, !disable_height);
setEnabled(file_->choice_height, !disable_height);
+2005-01-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * ExternalTransforms.C: fix LaTeX output of \scalebox.
+
+ * ExternalTransforms.[Ch]:
+ * insetexternal.C: store all float/double values as strings.
+
+ * insetgraphics.C:
+ * insetgraphicsParams.C: more precise checks for the value strings.
+
2004-12-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insettext.C (doDispatch): remove unused variable was_empty
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetgraphics.C:
- * insetgraphicsParams.[Ch]: store all values as strings.
+ * insetgraphicsParams.[Ch]: store all float/double values as strings.
2004-12-17 Alfredo Braunstein <abraunst@lyx.org>
#include "support/lstrings.h"
#include "support/lyxlib.h" // float_equal
+#include "support/tostr.h"
#include "support/translator.h"
#include <boost/regex.hpp>
#include <sstream>
using lyx::support::float_equal;
+using lyx::support::strToDbl;
using std::string;
bool ResizeData::usingScale() const
{
- return !float_equal(scale, 0.0, 0.05);
+ return (!scale.empty() && !float_equal(strToDbl(scale), 0.0, 0.05));
}
bool RotationData::no_rotation() const
{
- return (std::abs(angle()) < 0.1);
+ return (angle.empty() || std::abs(strToDbl(angle)) < 0.1);
}
-void RotationData::angle(double a)
+string const RotationData::adjAngle() const
{
- // Ensure that angle_ lies in the range -360 < angle_ < 360.
- int const multiples = int(a) / 360;
- angle_ = a - (multiples * 360);
+ // Ensure that angle lies in the range -360 < angle < 360
+ double rotAngle = strToDbl(angle);
+ if (std::abs(rotAngle) > 360.0) {
+ rotAngle -= 360.0 * floor(rotAngle / 360.0);
+ return tostr(rotAngle);
+ }
+ return angle;
}
std::ostringstream os;
if (data.usingScale()) {
- double const scl = data.scale / 100.0;
- os << "\\scalebox{" << scl << "}{" << scl << "}{";
+ double const scl = strToDbl(data.scale) / 100.0;
+ os << "\\scalebox{" << scl << "}[" << scl << "]{";
} else {
string width = "!";
string height = "!";
if (data.origin() != RotationData::DEFAULT)
os << "[origin=" << data.origin() << ']';
- os << '{' << data.angle() << "}{";
+ os << '{' << data.angle << "}{";
return os.str();
}
std::ostringstream os;
if (data.usingScale()) {
- if (!float_equal(data.scale, 100.0, 0.05))
- os << "scale=" << data.scale / 100.0 << ',';
+ double scl = strToDbl(data.scale);
+ if (!float_equal(scl, 100.0, 0.05))
+ os << "scale=" << scl / 100.0 << ',';
return os.str();
}
return string();
std::ostringstream os;
- os << "angle=" << data.angle() << ',';
+ os << "angle=" << data.angle << ',';
if (data.origin() != RotationData::DEFAULT)
os << "origin=" << data.origin() << ',';
class ResizeData {
public:
- ResizeData() : scale(0), keepAspectRatio(false) {}
+ ResizeData() : scale(), keepAspectRatio(false) {}
bool no_resize() const;
bool usingScale() const;
- float scale;
+ std::string scale;
LyXLength width;
LyXLength height;
bool keepAspectRatio;
BASELINERIGHT
};
- RotationData() : angle_(0), origin_(DEFAULT) {}
+ RotationData() : angle("0"), origin_(DEFAULT) {}
bool no_rotation() const;
- void angle(double a);
- double angle() const { return angle_; }
+ std::string const adjAngle() const;
+ std::string angle;
void origin(OriginType o) { origin_ = o; }
OriginType origin() const { return origin_; }
std::string const originString() const;
private:
- double angle_;
OriginType origin_;
};
}
if (!rotationdata.no_rotation()) {
- os << "\trotateAngle " << rotationdata.angle() << '\n';
+ os << "\trotateAngle " << rotationdata.adjAngle() << '\n';
if (rotationdata.origin() != external::RotationData::DEFAULT)
os << "\trotateOrigin "
<< rotationdata.originString() << '\n';
if (!resizedata.no_resize()) {
using support::float_equal;
-
- if (!float_equal(resizedata.scale, 0.0, 0.05)) {
- if (!float_equal(resizedata.scale, 100.0, 0.05))
+ double scl = support::strToDbl(resizedata.scale);
+ if (!float_equal(scl, 0.0, 0.05)) {
+ if (!float_equal(scl, 100.0, 0.05))
os << "\tscale "
<< resizedata.scale << '\n';
} else {
case EX_ROTATEANGLE:
lex.next();
- rotationdata.angle(lex.getFloat());
+ rotationdata.angle = lex.getString();
break;
case EX_ROTATEORIGIN:
case EX_SCALE:
lex.next();
- resizedata.scale = lex.getFloat();
+ resizedata.scale = lex.getString();
break;
case EX_WIDTH:
gparams.scale = eparams.lyxscale;
if (eparams.clipdata.clip)
gparams.bb = eparams.clipdata.bbox;
- gparams.angle = eparams.rotationdata.angle();
+ gparams.angle = lyx::support::strToDbl(eparams.rotationdata.adjAngle());
switch (eparams.display) {
case external::DefaultDisplay:
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;
options << " draft,\n";
if (params().clip)
options << " clip,\n";
- if (!params().scale.empty() && params().scale != "0") {
- if (params().scale != "100")
- options << " scale=" << strToDbl(params().scale) / 100.0
+ double const scl = strToDbl(params().scale);
+ if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
+ if (!float_equal(scl, 100.0, 0.05))
+ options << " scale=" << scl / 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 (!params().rotateAngle.empty() && params().rotateAngle != "0") {
+ if (!params().rotateAngle.empty()
+ && !float_equal(strToDbl(params().rotateAngle), 0.0, 0.001)) {
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 (!params().scale.empty() && params().scale != "0") {
- if (params().scale != "100")
+ double const scl = strToDbl(params().scale);
+ if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
+ if (!float_equal(scl, 100.0, 0.05))
options << " scale=\""
- << static_cast<int>( (strToDbl(params().scale)) + 0.5 )
+ << static_cast<int>( (scl) + 0.5 )
<< "\" ";
} else {
if (!params().width.zero()) {
using lyx::support::float_equal;
using lyx::support::readBB_from_PSFile;
+using lyx::support::strToDbl;
using lyx::support::strToInt;
using lyx::support::token;
os << "\tlyxscale " << lyxscale << '\n';
if (display != lyx::graphics::DefaultDisplay)
os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
- if (!scale.empty() && scale != "0") {
- if (scale != "100")
+ if (!scale.empty() && !float_equal(strToDbl(scale), 0.0, 0.05)) {
+ if (!float_equal(strToDbl(scale), 100.0, 0.05))
os << "\tscale " << scale << '\n';
} else {
if (!width.zero())
if (clip) // clip image
os << "\tclip\n";
- if (!rotateAngle.empty() && rotateAngle != "0")
+ if (!rotateAngle.empty()
+ && !float_equal(strToDbl(rotateAngle), 0.0, 0.001))
os << "\trotateAngle " << rotateAngle << '\n';
if (!rotateOrigin.empty())
os << "\trotateOrigin " << rotateOrigin << '\n';