]> git.lyx.org Git - lyx.git/blobdiff - src/Length.cpp
tex2lyx: support for glue lengths in InsetSpace
[lyx.git] / src / Length.cpp
index 288a54de6230ec3661b3dc00d661d5a553db4765..0deed7481c915f3e2e70b6f2f100c80d7d993d64 100644 (file)
@@ -57,17 +57,11 @@ Length::Length(string const & data)
 }
 
 
-void Length::swap(Length & rhs)
-{
-       std::swap(val_, rhs.val_);
-       std::swap(unit_, rhs.unit_);
-}
-
-
 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 +69,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 +97,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,20 +317,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 +360,9 @@ GlueLength::GlueLength(string const & data)
 
 string const GlueLength::asString() const
 {
+       if (len_.empty())
+               return string();
+
        ostringstream buffer;
 
        buffer << len_.value();