From cbd7c1daf41b111efe60625adaf16c20531be966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 22 Oct 2004 09:08:55 +0000 Subject: [PATCH] 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 --- src/ChangeLog | 5 +++++ src/lyxlength.C | 40 ++++++++++++++++++---------------------- status.13x | 3 +++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 21ed259911..1a7b9b8c13 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-10-22 Jürgen Spitzmüller + + * lyxlength.C (asLaTeXString): rewrite macros (using snprintf), because + the old ones were broken with values < 10% (bug 1523) + 2004-10-05 Jean-Marc Lasgouttes * version.C.in: update release date diff --git a/src/lyxlength.C b/src/lyxlength.C index 62ef59b666..4fea5e703b 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -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(val_/100)) << '.' - << abs(static_cast(val_)%100) << "\\textwidth"; - break; + snprintf(buffer, 78, "%.2f\\textwidth", val_/100.0); + break; case PCW: - buffer << abs(static_cast(val_/100)) << '.' - << abs(static_cast(val_)%100) << "\\columnwidth"; - break; + snprintf(buffer, 78, "%.2f\\columnwidth", val_/100.0); + break; case PPW: - buffer << abs(static_cast(val_/100)) << '.' - << abs(static_cast(val_)%100) << "\\paperwidth"; - break; + snprintf(buffer, 78, "%.2f\\paperwidth", val_/100.0); + break; case PLW: - buffer << abs(static_cast(val_/100)) << '.' - << abs(static_cast(val_)%100) << "\\linewidth"; - break; + snprintf(buffer, 78, "%.2f\\linewidth", val_/100.0); + break; case PPH: - buffer << abs(static_cast(val_/100)) << '.' - << abs(static_cast(val_)%100) << "\\paperheight"; - break; + snprintf(buffer, 78, "%.2f\\paperheight", val_/100.0); + break; case PTH: - buffer << abs(static_cast(val_/100)) << '.' - << abs(static_cast(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; } diff --git a/status.13x b/status.13x index d8032b5b8d..ede5600a57 100644 --- a/status.13x +++ b/status.13x @@ -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