X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLength.cpp;h=10cdd2972615768ec518ef688adf2cd20ad1ac8b;hb=a213faf20adbb99c8d76a8038c59329425812fd1;hp=4a7434435f78ace9441882c8560ba167fc8b83a8;hpb=269695aa5f50651cc7e49a480bc426e540b577b6;p=lyx.git diff --git a/src/Length.cpp b/src/Length.cpp index 4a7434435f..10cdd29726 100644 --- a/src/Length.cpp +++ b/src/Length.cpp @@ -67,7 +67,8 @@ void Length::swap(Length & rhs) string const Length::asString() const { ostringstream os; - os << val_ << unit_name[unit_]; // setw? + if (unit_ != UNIT_NONE) + os << val_ << unit_name[unit_]; // setw? return os.str(); } @@ -75,7 +76,8 @@ string const Length::asString() const docstring const Length::asDocstring() const { odocstringstream os; - os << val_ << unit_name[unit_]; // setw? + if (unit_ != UNIT_NONE) + os << val_ << unit_name[unit_]; // setw? return os.str(); } @@ -102,6 +104,8 @@ string const Length::asLatexString() const case PPH: os << val_ / 100.0 << "\\paperheight"; break; + case UNIT_NONE: + break; default: os << val_ << unit_name[unit_]; break; @@ -320,8 +324,7 @@ int Length::inBP() const Length::UNIT Length::defaultUnit() { - // FIXME: use a preference - return Length::CM; + return lyxrc.default_length_unit; } @@ -364,6 +367,9 @@ GlueLength::GlueLength(string const & data) string const GlueLength::asString() const { + if (len_.empty()) + return string(); + ostringstream buffer; buffer << len_.value();