X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxlength.C;h=70a8aaad4204d20c66f3ec7a7b6330bc8c2fc357;hb=fd2124c83dfcfeaf33b64d1d33c8ceb8d9f5f9b9;hp=8ca01187834022cab315abb9dc14cd02622d6756;hpb=c4762f94524c53ffc2200016678b4d032013b366;p=lyx.git diff --git a/src/lyxlength.C b/src/lyxlength.C index 8ca0118783..70a8aaad42 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -19,10 +19,10 @@ #include "lengthcommon.h" #include "lyxrc.h" +#include +#include -#include "support/std_sstream.h" -using std::abs; using std::ostringstream; using std::string; @@ -60,33 +60,31 @@ string const LyXLength::asString() const string const LyXLength::asLatexString() const { - char buffer[80]; + ostringstream os; switch (unit_) { case PTW: - snprintf(buffer, 78, "%.2f\\textwidth", val_/100.0); + os << val_ / 100.0 << "\\textwidth"; break; case PCW: - snprintf(buffer, 78, "%.2f\\columnwidth", val_/100.0); + os << val_ / 100.0 << "\\columnwidth"; break; case PPW: - snprintf(buffer, 78, "%.2f\\paperwidth", val_/100.0); + os << val_ / 100.0 << "\\paperwidth"; break; case PLW: - snprintf(buffer, 78, "%.2f\\linewidth", val_/100.0); + os << val_ / 100.0 << "\\linewidth"; break; case PPH: - snprintf(buffer, 78, "%.2f\\paperheight", val_/100.0); + os << val_ / 100.0 << "\\paperheight"; break; case PTH: - snprintf(buffer, 78, "%.2f\\textheight", val_/100.0); + os << val_ / 100.0 << "\\textheight"; break; default: - snprintf(buffer, 78, "%f%s", val_, unit_name[unit_]); + os << val_ << unit_name[unit_]; break; } - // paranoia - buffer[79] = 0; - return buffer; + return os.str(); } @@ -146,10 +144,6 @@ int LyXLength::inPixels(int text_width, int em_width_base) const // between lengths and font sizes on the screen // is the same as on paper. -#ifdef WITH_WARNINGS -#warning if you don't care than either call this function differently or let it return negative values and call abs() explicitly when needed (Andre') -#endif - double result = 0.0; switch (unit_) {