http://bugzilla.lyx.org/show_bug.cgi?id=490
the only way I see to solve this is to set the LyXLength default unit to
UNIT_NONE instead of PT (which is very arbitrary anyway) and add a bool
empty() to lyxlength (see attached patch).
Would this be o.k. or have I overseen some side effects? With the modified
xforms_helpers.C (cf. the patch), it works in xforms (empty margins and zero
margins are now treated differently, as they should).
QDocument needs some code, else it will break. What is the best way to do
something like this in a method (for several widgets in QDocument)?
if (LyXLength(params.paperwidth).unit().empty()) {
dialog_->paperModule->paperwidthUnitCO->setCurrentItem(
default_unit);
dialog_->paperModule->paperwidthLE->setText("");
} else {
dialog_->paperModule->paperwidthUnitCO->setCurrentItem(
LyXLength(params.paperwidth).unit());
dialog_->paperModule->paperwidthLE->setText(
tostr(LyXLength(params.paperwidth).value()).c_str());
}
Thanks,
J�rgen.
Index: src/lyxlength.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxlength.C,v
retrieving revision 1.24
diff -u -r1.24 lyxlength.C
--- src/lyxlength.C 2002/11/04 02:12:29 1.24
+++ src/lyxlength.C 2002/11/07 19:09:28
@@ -27,7 +27,7 @@
using std::abs;
LyXLength::LyXLength()
- : val_(0), unit_(LyXLength::PT)
+ : val_(0), unit_(LyXLength::UNIT_NONE)
{}
@@ -120,6 +120,12 @@
bool LyXLength::zero() const
{
return val_ == 0.0;
+}
+
+
+bool LyXLength::empty() const
+{
+ return unit_ == LyXLength::UNIT_NONE;
}
Index: src/lyxlength.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxlength.h,v
retrieving revision 1.10
diff -u -r1.10 lyxlength.h
--- src/lyxlength.h 2002/10/24 18:31:45 1.10
+++ src/lyxlength.h 2002/11/07 19:09:29
@@ -63,6 +63,8 @@
void unit(LyXLength::UNIT unit);
///
bool zero() const;
+ ///
+ bool empty() const;
/// return string representation
string const asString() const;
/// return string representation for LaTeX
Index: src/frontends/xforms/xforms_helpers.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/xforms_helpers.C,v
retrieving revision 1.52
diff -u -r1.52 xforms_helpers.C
--- src/frontends/xforms/xforms_helpers.C 2002/10/23 08:31:10 1.52
+++ src/frontends/xforms/xforms_helpers.C 2002/11/07 19:09:31
@@ -163,7 +163,7 @@
lyx::Assert(input && input->objclass == FL_INPUT &&
choice && choice->objclass == FL_CHOICE);
- if (len.zero()) {
+ if (len.empty()) {
fl_set_input(input, "");
fl_set_choice_text(choice, default_unit.c_str());
} else {