The transformation proceeds...
OK to apply?
J�rgen
BTW: I found some problems with the External dialog.
1. Scaling did not work with xfig images, because
\scalebox{<horizontal>}{<verical>}{<content>}
was used instead of the correct
\scalebox{<horizontal>}[<verical>]{<content>}
(2. arg is optional). This one gets fixed by the patch.
2. Raster images do not get converted -> LaTeX error (Including a png image
via the External dialog also fails in 1.3)
No idea how to fix this.
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 28 Dec 2004 17:23:04 -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 28 Dec 2004 17:23:07 -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 28 Dec 2004 17:23:08 -0000
@@ -15,7 +15,7 @@
#include "debug.h"
#include "support/lstrings.h"
-#include "support/lyxlib.h" // float_equal
+#include "support/tostr.h"
#include "support/translator.h"
#include <boost/regex.hpp>
@@ -23,7 +23,7 @@
#include <cmath> // std::abs
#include <sstream>
-using lyx::support::float_equal;
+using lyx::support::strToDbl;
using std::string;
@@ -52,21 +52,25 @@
bool ResizeData::usingScale() const
{
- return !float_equal(scale, 0.0, 0.05);
+ return (!scale.empty() && scale != "0");
}
bool RotationData::no_rotation() const
{
- return (std::abs(angle()) < 0.1);
+ return (angle.empty() || angle == "0");
}
-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
+ float rotAngle = strToDbl(angle);
+ if (std::abs(rotAngle) > 360.0) {
+ rotAngle -= 360.0 * floor(rotAngle / 360.0);
+ return tostr(rotAngle);
+ }
+ return angle;
}
@@ -97,8 +101,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 +198,7 @@
if (data.origin() != RotationData::DEFAULT)
os << "[origin=" << data.origin() << ']';
- os << '{' << data.angle() << "}{";
+ os << '{' << data.angle << "}{";
return os.str();
}
@@ -229,8 +233,8 @@
std::ostringstream os;
if (data.usingScale()) {
- if (!float_equal(data.scale, 100.0, 0.05))
- os << "scale=" << data.scale / 100.0 << ',';
+ if (data.scale != "100")
+ os << "scale=" << strToDbl(data.scale) / 100.0 << ',';
return os.str();
}
@@ -251,7 +255,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 28 Dec 2004 17:23:09 -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 28 Dec 2004 17:23:10 -0000
@@ -220,17 +220,16 @@
}
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))
+ if (!resizedata.scale.empty() && resizedata.scale != "0") {
+ if (resizedata.scale != "100")
os << "\tscale "
<< resizedata.scale << '\n';
} else {
@@ -354,7 +353,7 @@
case EX_ROTATEANGLE:
lex.next();
- rotationdata.angle(lex.getFloat());
+ rotationdata.angle = lex.getString();
break;
case EX_ROTATEORIGIN:
@@ -364,7 +363,7 @@
case EX_SCALE:
lex.next();
- resizedata.scale = lex.getFloat();
+ resizedata.scale = lex.getString();
break;
case EX_WIDTH:
@@ -524,7 +523,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: