backport fix for the broken calculation of percentual LaTeXStrings (bug 1523)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@9102 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2004-10-22 09:08:55 +00:00
parent 040b1ad7ed
commit cbd7c1daf4
3 changed files with 26 additions and 22 deletions

View File

@ -1,3 +1,8 @@
2004-10-22 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* lyxlength.C (asLaTeXString): rewrite macros (using snprintf), because
the old ones were broken with values < 10% (bug 1523)
2004-10-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* version.C.in: update release date

View File

@ -59,37 +59,33 @@ string const LyXLength::asString() const
string const LyXLength::asLatexString() const
{
ostringstream buffer;
char buffer[80];
switch (unit_) {
case PTW:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\textwidth";
break;
snprintf(buffer, 78, "%.2f\\textwidth", val_/100.0);
break;
case PCW:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\columnwidth";
break;
snprintf(buffer, 78, "%.2f\\columnwidth", val_/100.0);
break;
case PPW:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\paperwidth";
break;
snprintf(buffer, 78, "%.2f\\paperwidth", val_/100.0);
break;
case PLW:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\linewidth";
break;
snprintf(buffer, 78, "%.2f\\linewidth", val_/100.0);
break;
case PPH:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\paperheight";
break;
snprintf(buffer, 78, "%.2f\\paperheight", val_/100.0);
break;
case PTH:
buffer << abs(static_cast<int>(val_/100)) << '.'
<< abs(static_cast<int>(val_)%100) << "\\textheight";
break;
snprintf(buffer, 78, "%.2f\\textheight", val_/100.0);
break;
default:
buffer << val_ << unit_name[unit_]; // setw?
break;
snprintf(buffer, 78, "%f%s", val_, unit_name[unit_]);
break;
}
return STRCONV(buffer.str());
// paranoia
buffer[79] = 0;
return buffer;
}

View File

@ -25,6 +25,9 @@ What's new
- fix lyxpreview2ppm.py to work with python versions older than 2.1
- fix LaTeX output of percentage length values <10% [bug 1523]
* User Interface:
- fix math fonts display in LyX/Mac