]> git.lyx.org Git - lyx.git/blobdiff - src/VSpace.cpp
pimpl not needed here
[lyx.git] / src / VSpace.cpp
index e88833e2f42533cf37b59dba389e125de16f8496..f377edebaed284f1f69f99c1a7f92ca088a7ccde 100644 (file)
 #include <config.h>
 
 #include "VSpace.h"
+
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "gettext.h"
-#include "lengthcommon.h"
-#include "LyXText.h"
+#include "Length.h"
+#include "Text.h"
+#include "TextMetrics.h" // for defaultRowHeight()
 
 #include "support/convert.h"
 #include "support/lstrings.h"
@@ -38,10 +40,10 @@ namespace {
 /// used to return numeric values in parsing vspace
 double number[4] = { 0, 0, 0, 0 };
 /// used to return unit types in parsing vspace
-LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
-                           LyXLength::UNIT_NONE,
-                           LyXLength::UNIT_NONE,
-                           LyXLength::UNIT_NONE };
+Length::UNIT unit[4] = { Length::UNIT_NONE,
+                           Length::UNIT_NONE,
+                           Length::UNIT_NONE,
+                           Length::UNIT_NONE };
 
 /// the current position in the number array
 int number_index;
@@ -154,7 +156,7 @@ char nextToken(string & data)
                        unit[unit_index] = unitFromString(buffer);
                }
 
-               if (unit[unit_index] != LyXLength::UNIT_NONE) {
+               if (unit[unit_index] != Length::UNIT_NONE) {
                        ++unit_index;
                        return 'u';
                }
@@ -203,7 +205,7 @@ const char * stringFromUnit(int unit)
 }
 
 
-bool isValidGlueLength(string const & data, LyXGlueLength * result)
+bool isValidGlueLength(string const & data, GlueLength * result)
 {
        // This parser is table-driven.  First, it constructs a "pattern"
        // that describes the sequence of tokens in "data".  For example,
@@ -211,7 +213,7 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result)
        // numbers and units are stored into static arrays.  Then, "pattern"
        // is searched in the "table".  If it is found, the associated
        // table entries tell us which number and unit should go where
-       // in the LyXLength structure.  Example: if "data" has the "pattern"
+       // in the Length structure.  Example: if "data" has the "pattern"
        // "nu+nu-nu", the associated table entries are "2, 3, 2, 3".
        // That means, "plus_val" is the second number that was seen
        // in the input, "minus_val" is the third number, and "plus_uni"
@@ -249,10 +251,12 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result)
        unit_index = 1;  // entries at index 0 are sentinels
 
        // construct "pattern" from "data"
-       while (!isEndOfData (buffer)) {
-               if (pattern_index > 20) return false;
-               pattern[pattern_index] = nextToken (buffer);
-               if (pattern[pattern_index] == 'E') return false;
+       while (!isEndOfData(buffer)) {
+               if (pattern_index > 20)
+                       return false;
+               pattern[pattern_index] = nextToken(buffer);
+               if (pattern[pattern_index] == 'E')
+                       return false;
                ++pattern_index;
        }
        pattern[pattern_index] = '\0';
@@ -280,7 +284,7 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result)
 }
 
 
-bool isValidLength(string const & data, LyXLength * result)
+bool isValidLength(string const & data, Length * result)
 {
        // This is a trimmed down version of isValidGlueLength.
        // The parser may seem overkill for lengths without
@@ -324,7 +328,8 @@ bool isValidLength(string const & data, LyXLength * result)
        pattern[pattern_index] = '\0';
 
        // only the most basic pattern is accepted here
-       if (compare(pattern, "nu") != 0) return false;
+       if (compare(pattern, "nu") != 0)
+               return false;
 
        // It _was_ a correct length string.
        // Store away the values we found.
@@ -345,17 +350,17 @@ VSpace::VSpace()
 {}
 
 
-VSpace::VSpace(vspace_kind k)
+VSpace::VSpace(VSpaceKind k)
        : kind_(k), len_(), keep_(false)
 {}
 
 
-VSpace::VSpace(LyXLength const & l)
+VSpace::VSpace(Length const & l)
        : kind_(LENGTH), len_(l), keep_(false)
 {}
 
 
-VSpace::VSpace(LyXGlueLength const & l)
+VSpace::VSpace(GlueLength const & l)
        : kind_(LENGTH), len_(l), keep_(false)
 {}
 
@@ -392,35 +397,11 @@ VSpace::VSpace(string const & data)
                // without units in added_space_top/bottom.
                // Let unit default to centimeters here.
                kind_ = LENGTH;
-               len_  = LyXGlueLength(LyXLength(convert<double>(input), LyXLength::CM));
+               len_  = GlueLength(Length(convert<double>(input), Length::CM));
        }
 }
 
 
-VSpace::vspace_kind VSpace::kind() const
-{
-       return kind_;
-}
-
-
-LyXGlueLength const & VSpace::length() const
-{
-       return len_;
-}
-
-
-bool VSpace::keep() const
-{
-       return keep_;
-}
-
-
-void VSpace::setKeep(bool val)
-{
-       keep_ = val;
-}
-
-
 bool VSpace::operator==(VSpace const & other) const
 {
        if (kind_ != other.kind_)
@@ -519,7 +500,7 @@ int VSpace::inPixels(BufferView const & bv) const
        switch (kind_) {
 
        case DEFSKIP:
-               return bv.buffer()->params().getDefSkip().inPixels(bv);
+               return bv.buffer().params().getDefSkip().inPixels(bv);
 
        // This is how the skips are normally defined by LateX.
        // But there should be some way to change this per document.