X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLength.cpp;h=10cdd2972615768ec518ef688adf2cd20ad1ac8b;hb=a213faf20adbb99c8d76a8038c59329425812fd1;hp=4b269aa31517e1ee7bd72dd40f3aa4b3333e3caa;hpb=969a8356b8e9e93c37a855f3402b55f582f8831d;p=lyx.git diff --git a/src/Length.cpp b/src/Length.cpp index 4b269aa315..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(); } @@ -96,11 +98,13 @@ string const Length::asLatexString() const case PLW: os << val_ / 100.0 << "\\linewidth"; break; + case PTH: + os << val_ / 100.0 << "\\textheight"; + break; case PPH: os << val_ / 100.0 << "\\paperheight"; break; - case PTH: - os << val_ / 100.0 << "\\textheight"; + case UNIT_NONE: break; default: os << val_ << unit_name[unit_]; @@ -320,20 +324,7 @@ int Length::inBP() const Length::UNIT Length::defaultUnit() { - // FIXME user a proper pref, since we should get rid of - // default_papersize in lyxrc. - UNIT u = Length::CM; - switch (lyxrc.default_papersize) { - case PAPER_USLETTER: - case PAPER_USLEGAL: - case PAPER_USEXECUTIVE: - u = Length::IN; - break; - default: - break; - } - - return u; + return lyxrc.default_length_unit; } @@ -376,6 +367,9 @@ GlueLength::GlueLength(string const & data) string const GlueLength::asString() const { + if (len_.empty()) + return string(); + ostringstream buffer; buffer << len_.value();