]> git.lyx.org Git - features.git/blobdiff - src/lyxlength.C
remove NO_PEXTRA_STUFF
[features.git] / src / lyxlength.C
index 2a0b2fa0b57ad1fbc3629268d7b7403bb599ea03..fc6504ce4ddcfdfb8104a0ddcc4aae899d6df2f6 100644 (file)
@@ -36,48 +36,12 @@ LyXLength::LyXLength(double v, LyXLength::UNIT u)
 {}
 
 
-#ifndef NO_PEXTRA_REALLY
-// compatibility stuff < version 1.2.0pre and for 
-// "old" 1.2.0 files before the pre
-namespace {
-string const convertOldRelLength(string const & oldLength) 
-{
-       // we can have only one or none of the following
-       if (oldLength.find("c%") != string::npos) {
-               return subst(oldLength,"c%","col%");
-                   
-       } else if (oldLength.find("t%") != string::npos) {
-               if (oldLength.find("text%") != string::npos)
-                   return oldLength;
-               else
-                   return subst(oldLength,"t%","text%");
-
-       } else if (oldLength.find("l%") != string::npos) {
-               if (oldLength.find("col%") != string::npos)
-                   return oldLength;
-               else
-                   return subst(oldLength,"l%","line%");
-
-       } else if (oldLength.find("p%") != string::npos)
-               return subst(oldLength,"p%","page%");
-
-       return oldLength;
-}
-} // end anon
-#endif
-
 LyXLength::LyXLength(string const & data)
        : val_(0), unit_(LyXLength::PT)
 {
        LyXLength tmp;
 
-#ifndef NO_PEXTRA_REALLY
-       // this is needed for 1.1.x minipages with width like %t
-       if (!isValidLength (convertOldRelLength(data), &tmp))
-#else
-       if (!isValidLength (data, &tmp))
-#endif
-               if (!isValidLength (convertOldRelLength(data), &tmp))
+       if (!isValidLength(data, &tmp))
                return; // should raise an exception
 
        val_  = tmp.val_;
@@ -113,6 +77,14 @@ string const LyXLength::asLatexString() const
            buffer << abs(static_cast<int>(val_/100)) << "."
                   << abs(static_cast<int>(val_)%100) << "\\linewidth";
            break;
+       case PH:
+           buffer << abs(static_cast<int>(val_/100)) << "."
+                  << abs(static_cast<int>(val_)%100) << "\\paperheight";
+           break;
+       case TH:
+           buffer << abs(static_cast<int>(val_/100)) << "."
+                  << abs(static_cast<int>(val_)%100) << "\\textheight";
+           break;
        default:
            buffer << val_ << unit_name[unit_]; // setw?
            break;
@@ -165,6 +137,10 @@ int LyXLength::inPixels(int default_width, int default_height) const
 
        // we don't care about sign of value, we
        // display negative space with text too
+#ifdef WITH_WARNINGS
+#warning if you don't care than either call this function differently or let it return negative values and call abs() explicitly when needed (Andre')
+#endif
+
        double result = 0.0;
        int val_sign = val_ < 0.0 ? -1 : 1;
 
@@ -231,6 +207,10 @@ int LyXLength::inPixels(int default_width, int default_height) const
        case LyXLength::PL:
                result = val_ * default_width / 100;
                break;
+       case LyXLength::PH:
+       case LyXLength::TH:
+               result = val_ * default_height / 100;
+               break;
        case LyXLength::UNIT_NONE:
                result = 0;  // this cannot happen
                break;
@@ -244,7 +224,6 @@ int LyXLength::inBP() const
        // return any LyXLength value as a one with
        // the PostScript point, called bp (big points)
        double result = 0.0;
-       int val_sign = val_ < 0.0 ? -1 : 1;
        switch (unit_) {
        case LyXLength::CM:
                // 1bp = 0.2835cm
@@ -263,7 +242,7 @@ int LyXLength::inBP() const
                result = val_;
                break;
        }
-       return static_cast<int>(result * val_sign + 0.5);
+       return static_cast<int>(result + 0.5);
 }