Juergen Spitzmueller wrote:
> I see that the
> latter might cause problems
Georg, are you more happy with the attached version?
J�rgen
Index: frontends/qt2/QExternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QExternal.C,v
retrieving revision 1.39
diff -u -r1.39 QExternal.C
--- frontends/qt2/QExternal.C 20 May 2004 09:36:27 -0000 1.39
+++ frontends/qt2/QExternal.C 31 Dec 2004 09:20:45 -0000
@@ -142,7 +142,7 @@
external::RotationData const & data)
{
originCO.setCurrentItem(int(data.origin()));
- angleED.setText(toqstr(tostr(data.angle())));
+ angleED.setText(toqstr(data.angle));
}
@@ -152,7 +152,7 @@
typedef external::RotationData::OriginType OriginType;
data.origin(static_cast<OriginType>(originCO.currentItem()));
- data.angle(strToDbl(fromqstr(angleED.text())));
+ data.angle = fromqstr(angleED.text());
}
@@ -162,15 +162,15 @@
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())));
@@ -216,11 +216,11 @@
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();
}
Index: frontends/xforms/FormExternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormExternal.C,v
retrieving revision 1.55
diff -u -r1.55 FormExternal.C
--- frontends/xforms/FormExternal.C 19 May 2004 15:11:35 -0000 1.55
+++ frontends/xforms/FormExternal.C 31 Dec 2004 09:20:47 -0000
@@ -156,7 +156,7 @@
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());
}
@@ -169,7 +169,7 @@
typedef external::RotationData::OriginType OriginType;
data.origin(static_cast<OriginType>(fl_get_choice(originCO) - 1));
- data.angle(strToDbl(getString(angleED)));
+ data.angle = getString(angleED);
}
@@ -186,15 +186,15 @@
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());
@@ -248,11 +248,11 @@
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();
}
Index: insets/ExternalTransforms.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ExternalTransforms.C,v
retrieving revision 1.9
diff -u -r1.9 ExternalTransforms.C
--- insets/ExternalTransforms.C 28 Oct 2004 10:59:19 -0000 1.9
+++ insets/ExternalTransforms.C 31 Dec 2004 09:20:48 -0000
@@ -16,6 +16,7 @@
#include "support/lstrings.h"
#include "support/lyxlib.h" // float_equal
+#include "support/tostr.h"
#include "support/translator.h"
#include <boost/regex.hpp>
@@ -24,6 +25,7 @@
#include <sstream>
using lyx::support::float_equal;
+using lyx::support::strToDbl;
using std::string;
@@ -52,21 +54,25 @@
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;
}
@@ -97,8 +103,8 @@
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 = "!";
@@ -194,7 +200,7 @@
if (data.origin() != RotationData::DEFAULT)
os << "[origin=" << data.origin() << ']';
- os << '{' << data.angle() << "}{";
+ os << '{' << data.angle << "}{";
return os.str();
}
@@ -229,8 +235,9 @@
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();
}
@@ -251,7 +258,7 @@
return string();
std::ostringstream os;
- os << "angle=" << data.angle() << ',';
+ os << "angle=" << data.angle << ',';
if (data.origin() != RotationData::DEFAULT)
os << "origin=" << data.origin() << ',';
Index: insets/ExternalTransforms.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ExternalTransforms.h,v
retrieving revision 1.3
diff -u -r1.3 ExternalTransforms.h
--- insets/ExternalTransforms.h 26 Sep 2004 13:34:57 -0000 1.3
+++ insets/ExternalTransforms.h 31 Dec 2004 09:20:49 -0000
@@ -56,12 +56,12 @@
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;
@@ -84,11 +84,11 @@
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_; }
@@ -97,7 +97,6 @@
std::string const originString() const;
private:
- double angle_;
OriginType origin_;
};
Index: insets/insetexternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v
retrieving revision 1.154
diff -u -r1.154 insetexternal.C
--- insets/insetexternal.C 25 Nov 2004 19:13:04 -0000 1.154
+++ insets/insetexternal.C 31 Dec 2004 09:20:50 -0000
@@ -220,7 +220,7 @@
}
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';
@@ -228,9 +228,9 @@
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 {
@@ -354,7 +354,7 @@
case EX_ROTATEANGLE:
lex.next();
- rotationdata.angle(lex.getFloat());
+ rotationdata.angle = lex.getString();
break;
case EX_ROTATEORIGIN:
@@ -364,7 +364,7 @@
case EX_SCALE:
lex.next();
- resizedata.scale = lex.getFloat();
+ resizedata.scale = lex.getString();
break;
case EX_WIDTH:
@@ -524,7 +524,7 @@
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: