]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlength.C
fix reading the author field.
[lyx.git] / src / lyxlength.C
index e94b90e0d6bd138900da25f8b04e596bd89e79ec..027e17b21a67e7789b5e185115f6d03791cc2d78 100644 (file)
 #include "lengthcommon.h"
 #include "lyxrc.h"
 
+#include <sstream>
 
-#include "support/std_sstream.h"
 
-using std::abs;
 using std::ostringstream;
 using std::string;
 
@@ -52,45 +51,41 @@ LyXLength::LyXLength(string const & data)
 
 string const LyXLength::asString() const
 {
-       ostringstream buffer;
-       buffer << val_ << unit_name[unit_]; // setw?
-       return buffer.str();
+       ostringstream os;
+       os << val_ << unit_name[unit_]; // setw?
+       return os.str();
 }
 
 
 string const LyXLength::asLatexString() const
 {
-       ostringstream buffer;
+       char buffer[80];
        switch (unit_) {
        case PTW:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(val_)%100) << "\\textwidth";
-           break;
+               snprintf(buffer, 78, "%.2f\\textwidth", val_/100.0);
+               break;
        case PCW:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(val_)%100) << "\\columnwidth";
-           break;
+               snprintf(buffer, 78, "%.2f\\columnwidth", val_/100.0);
+               break;
        case PPW:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(val_)%100) << "\\paperwidth";
-           break;
+               snprintf(buffer, 78, "%.2f\\paperwidth", val_/100.0);
+               break;
        case PLW:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(val_)%100) << "\\linewidth";
-           break;
+               snprintf(buffer, 78, "%.2f\\linewidth", val_/100.0);
+               break;
        case PPH:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(val_)%100) << "\\paperheight";
-           break;
+               snprintf(buffer, 78, "%.2f\\paperheight", val_/100.0);
+               break;
        case PTH:
-           buffer << abs(static_cast<int>(val_/100)) << '.'
-                  << abs(static_cast<int>(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 buffer.str();
+       // paranoia
+       buffer[79] = 0;
+       return buffer;
 }
 
 
@@ -150,10 +145,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_) {