#endif
#include "lyxlength.h"
+#include "lengthcommon.h"
#include "Lsstream.h"
-namespace {
-// this is now here and in lyxgluelength.C
-
-int const num_units = LyXLength::UNIT_NONE;
-
-// I am not sure if "mu" should be possible to select (Lgb)
-char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
- "mm", "pc", "cc", "cm",
- "in", "ex", "em", "mu",
- "%", "c%", "p%", "l%" };
-
-
-LyXLength::UNIT unitFromString(string const & data)
-{
- int i = 0;
- while (i < num_units && data != unit_name[i])
- ++i;
- return static_cast<LyXLength::UNIT>(i);
-}
-
-}
+#include <cstdlib>
LyXLength::LyXLength()
LyXLength::LyXLength(string const & data)
+ : val_(0), unit_(LyXLength::PT)
{
LyXLength tmp;
case PW:
case PE:
buffer << abs(static_cast<int>(val_/100)) << "."
- << abs(static_cast<int>(val_)%100) << "\\columnwidth";
+ << abs(static_cast<int>(val_)%100) << "\\columnwidth";
break;
case PP:
buffer << abs(static_cast<int>(val_/100)) << "."
- << abs(static_cast<int>(val_)%100) << "\\pagewidth";
+ << abs(static_cast<int>(val_)%100) << "\\pagewidth";
break;
case PL:
buffer << abs(static_cast<int>(val_/100)) << "."
- << abs(static_cast<int>(val_)%100) << "\\linewidth";
+ << abs(static_cast<int>(val_)%100) << "\\linewidth";
break;
default:
buffer << val_ << unit_name[unit_]; // setw?
}
+bool LyXLength::zero() const
+{
+ return val_ == 0.0;
+}
+
+
bool operator==(LyXLength const & l1, LyXLength const & l2)
{
return l1.value() == l2.value() && l1.unit() == l2.unit();
}
+
+
+bool operator!=(LyXLength const & l1, LyXLength const & l2)
+{
+ return !(l1 == l2);
+}
+