From: Jean-Marc Lasgouttes Date: Tue, 2 Apr 2002 13:23:35 +0000 (+0000) Subject: minipage width compatibility fix X-Git-Tag: 1.6.10~19520 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ce96d714211fc54fb5d3baf697c967695f641464;p=features.git minipage width compatibility fix git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3882 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 420e7da327..12fb1c39e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-03-28 Herbert Voss + + * 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 * lyx_main.C (init): use environment variable LYX_DIR_12x instead diff --git a/src/lyxlength.C b/src/lyxlength.C index 1067ac7a75..67be44c917 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -18,6 +18,8 @@ #include "lengthcommon.h" #include "lyxrc.h" +#include "support/lstrings.h" + #include "Lsstream.h" #include @@ -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_;