X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FVSpace.cpp;h=9003951e912a514ee58e1f827d26950d6d7d98b1;hb=4056f0ddb150d0e5d60bc5941d51e365eed0ac86;hp=bae4c799e540e772dfc6563644236b4f32a6c667;hpb=e0d54dd3b497b78094ea16ab0f38ccdc8c1642e2;p=lyx.git diff --git a/src/VSpace.cpp b/src/VSpace.cpp index bae4c799e5..9003951e91 100644 --- a/src/VSpace.cpp +++ b/src/VSpace.cpp @@ -11,37 +11,37 @@ #include #include "VSpace.h" + #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" -#include "gettext.h" -#include "lengthcommon.h" +#include "support/gettext.h" +#include "Length.h" #include "Text.h" +#include "TextMetrics.h" // for defaultRowHeight() #include "support/convert.h" #include "support/lstrings.h" +#include -namespace lyx { - -using support::compare; -using support::isStrDbl; -using support::ltrim; -using support::prefixIs; -using support::rtrim; - -using std::string; +using namespace std; +using namespace lyx::support; +namespace lyx { namespace { /// used to return numeric values in parsing vspace double number[4] = { 0, 0, 0, 0 }; + /// used to return unit types in parsing vspace -Length::UNIT unit[4] = { Length::UNIT_NONE, - Length::UNIT_NONE, - Length::UNIT_NONE, - Length::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; @@ -49,16 +49,14 @@ int number_index; int unit_index; /// skip n characters of input -inline -void lyx_advance(string & data, string::size_type n) +inline void lyx_advance(string & data, size_t n) { data.erase(0, n); } /// return true when the input is at the end -inline -bool isEndOfData(string const & data) +inline bool isEndOfData(string const & data) { return ltrim(data).empty(); } @@ -103,7 +101,7 @@ char nextToken(string & data) return '-'; } - string::size_type i = data.find_first_not_of("0123456789."); + size_t i = data.find_first_not_of("0123456789."); if (i != 0) { if (number_index > 3) @@ -115,8 +113,9 @@ char nextToken(string & data) if (i == string::npos) { buffer = data; i = data.size() + 1; - } else + } else { buffer = data.substr(0, i); + } lyx_advance(data, i); @@ -139,8 +138,9 @@ char nextToken(string & data) if (i == string::npos) { buffer = data; i = data.size() + 1; - } else + } else { buffer = data.substr(0, i); + } // possibly we have "mmplus" string or similar if (buffer.size() > 5 && @@ -249,17 +249,19 @@ bool isValidGlueLength(string const & data, GlueLength * 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'; // search "pattern" in "table" table_index = 0; - while (compare(pattern, table[table_index].pattern)) { + while (strcmp(pattern, table[table_index].pattern)) { ++table_index; if (!*table[table_index].pattern) return false; @@ -324,7 +326,8 @@ bool isValidLength(string const & data, Length * result) pattern[pattern_index] = '\0'; // only the most basic pattern is accepted here - if (compare(pattern, "nu") != 0) return false; + if (strcmp(pattern, "nu") != 0) + return false; // It _was_ a correct length string. // Store away the values we found. @@ -345,7 +348,7 @@ VSpace::VSpace() {} -VSpace::VSpace(vspace_kind k) +VSpace::VSpace(VSpaceKind k) : kind_(k), len_(), keep_(false) {} @@ -368,7 +371,7 @@ VSpace::VSpace(string const & data) string input = rtrim(data); - string::size_type const length = input.length(); + size_t const length = input.length(); if (length > 1 && input[length - 1] == '*') { keep_ = true; @@ -397,30 +400,6 @@ VSpace::VSpace(string const & data) } -VSpace::vspace_kind VSpace::kind() const -{ - return kind_; -} - - -GlueLength 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 +498,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.