#include "lengthcommon.h"
#include "lyxrc.h"
+#include "support/docstream.h"
+#include <sstream>
+#include <iomanip>
+
+
+namespace lyx {
-#include "support/std_sstream.h"
-using std::abs;
using std::ostringstream;
+using std::string;
LyXLength::LyXLength()
string const LyXLength::asString() const
{
- ostringstream buffer;
- buffer << val_ << unit_name[unit_]; // setw?
- return STRCONV(buffer.str());
+ ostringstream os;
+ os << val_ << unit_name[unit_]; // setw?
+ return os.str();
+}
+
+
+docstring const LyXLength::asDocstring() const
+{
+ odocstringstream os;
+ os << val_ << unit_name[unit_]; // setw?
+ return os.str();
}
string const LyXLength::asLatexString() const
{
- ostringstream buffer;
+ ostringstream os;
switch (unit_) {
case PTW:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\textwidth";
- break;
+ os << val_ / 100.0 << "\\textwidth";
+ break;
case PCW:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\columnwidth";
- break;
+ os << val_ / 100.0 << "\\columnwidth";
+ break;
case PPW:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\paperwidth";
- break;
+ os << val_ / 100.0 << "\\paperwidth";
+ break;
case PLW:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\linewidth";
- break;
+ os << val_ / 100.0 << "\\linewidth";
+ break;
case PPH:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\paperheight";
- break;
+ os << val_ / 100.0 << "\\paperheight";
+ break;
case PTH:
- buffer << abs(static_cast<int>(val_/100)) << '.'
- << abs(static_cast<int>(val_)%100) << "\\textheight";
- break;
+ os << val_ / 100.0 << "\\textheight";
+ break;
default:
- buffer << val_ << unit_name[unit_]; // setw?
- break;
+ os << val_ << unit_name[unit_];
+ break;
}
- return STRCONV(buffer.str());
+ 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.
// 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_) {
{
return !(l1 == l2);
}
+
+
+} // namespace lyx