X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxlength.C;h=fded92c19bcfe53b595f0d24e86a7cc713607f6f;hb=46bd598fc5b0b1bb61e713428c54aedf9c6e6d98;hp=d91890e864513eda70e127b41e6bca7cbaf31442;hpb=e13d9157bca1cfce49ed43de7df3c6619bf42a1f;p=lyx.git diff --git a/src/lyxlength.C b/src/lyxlength.C index d91890e864..fded92c19b 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -19,12 +19,15 @@ #include "lengthcommon.h" #include "lyxrc.h" +#include "support/docstream.h" #include #include +namespace lyx { + + using std::ostringstream; -using std::setprecision; using std::string; @@ -59,30 +62,38 @@ string const LyXLength::asString() const } +docstring const LyXLength::asDocstring() const +{ + odocstringstream os; + os << val_ << unit_name[unit_]; // setw? + return os.str(); +} + + string const LyXLength::asLatexString() const { ostringstream os; switch (unit_) { case PTW: - os << setprecision(2) << val_/100.0 << "\\textwidth"; + os << val_ / 100.0 << "\\textwidth"; break; case PCW: - os << setprecision(2) << val_/100.0 << "\\columnwidth"; + os << val_ / 100.0 << "\\columnwidth"; break; case PPW: - os << setprecision(2) << val_/100.0 << "\\paperwidth"; + os << val_ / 100.0 << "\\paperwidth"; break; case PLW: - os << setprecision(2) << val_/100.0 << "\\linewidth"; + os << val_ / 100.0 << "\\linewidth"; break; case PPH: - os << setprecision(2) << val_/100.0 << "\\paperheight"; + os << val_ / 100.0 << "\\paperheight"; break; case PTH: - os << setprecision(2) << val_/100.0 << "\\textheight"; + os << val_ / 100.0 << "\\textheight"; break; default: - os << setprecision(2) << val_ << unit_name[unit_]; + os << val_ << unit_name[unit_]; break; } return os.str(); @@ -137,7 +148,7 @@ int LyXLength::inPixels(int text_width, int em_width_base) const ? em_width_base : 10*(dpi/72.27)*zoom; // A different estimate for em_width is - // font_metrics::width('M', LyXFont(LyXFont::ALL_SANE)) + // theFontMetrics(LyXFont(LyXFont::ALL_SANE)).width('M') // but this estimate might not be more accurate as the screen font // is different then the latex font. @@ -265,3 +276,6 @@ bool operator!=(LyXLength const & l1, LyXLength const & l2) { return !(l1 == l2); } + + +} // namespace lyx