#include "lengthcommon.h"
#include "lyxrc.h"
+#include "support/docstream.h"
#include <sstream>
+#include <iomanip>
+
+
+namespace lyx {
using std::ostringstream;
}
+docstring const LyXLength::asDocstring() const
+{
+ odocstringstream os;
+ os << val_ << unit_name[unit_]; // setw?
+ return os.str();
+}
+
+
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();
}
? 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.
{
return !(l1 == l2);
}
+
+
+} // namespace lyx