minipage width compatibility fix

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3882 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-04-02 13:23:35 +00:00
parent d1830fc935
commit ce96d71421
2 changed files with 43 additions and 0 deletions

View 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

View 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_;