]> git.lyx.org Git - features.git/commitdiff
minipage width compatibility fix
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 2 Apr 2002 13:23:35 +0000 (13:23 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 2 Apr 2002 13:23:35 +0000 (13:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3882 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxlength.C

index 420e7da327027add98e8f707130177f6b8c50a6c..12fb1c39e6c464c12dc3c900ad3b6f4f41e31e90 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-28  Herbert Voss  <voss@lyx.org>
+
+       * lyxlength.C: compatibility stuff for < 1.1.6fix4 and 
+       "old" 1.2.0 files which use c%, l%, p% t% instead of text%, ...
+
 2002-04-02  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * lyx_main.C (init): use environment variable LYX_DIR_12x instead
index 1067ac7a75f373bced679b6d43495c10404727a1..67be44c917df7c0dba587c603acebdbc1e18846a 100644 (file)
@@ -18,6 +18,8 @@
 #include "lengthcommon.h"
 #include "lyxrc.h"
 
+#include "support/lstrings.h"
+
 #include "Lsstream.h"
 
 #include <cstdlib>
@@ -33,12 +35,48 @@ 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))
                return; // should raise an exception
 
        val_  = tmp.val_;