]> git.lyx.org Git - lyx.git/blobdiff - src/lyxlength.C
John's Layout Tabular UI improvements and Martins fixes to clearing the
[lyx.git] / src / lyxlength.C
index 2c52c7dbb8dd04937b923fcd12c52d7ec3efb251..c1e08dd4448746a8036f8495098470712d3a351c 100644 (file)
 #endif
 
 #include "lyxlength.h"
+#include "lengthcommon.h"
 
 #include "Lsstream.h"
 
-#include <cmath>
-
-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()
@@ -54,6 +33,7 @@ LyXLength::LyXLength(double v, LyXLength::UNIT u)
 
 
 LyXLength::LyXLength(string const & data)
+       : val_(0), unit_(LyXLength::PT)
 {
        LyXLength tmp;
        
@@ -122,7 +102,20 @@ void LyXLength::unit(LyXLength::UNIT u)
 }
 
 
+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);
+}
+