#include "support/convert.h"
#include "support/lstrings.h"
-using namespace std;
+#include "support/lassert.h"
-namespace lyx {
+#include <cstring>
-using support::compare;
-using support::isStrDbl;
-using support::ltrim;
-using support::prefixIs;
-using support::rtrim;
+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;
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();
}
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)
if (i == string::npos) {
buffer = data;
i = data.size() + 1;
- } else
+ } else {
buffer = data.substr(0, i);
+ }
lyx_advance(data, i);
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 &&
}
// end of hack
- int pattern_index = 0;
- int table_index = 0;
- char pattern[20];
-
- number_index = 1;
- unit_index = 1; // entries at index 0 are sentinels
+ number_index = unit_index = 1; // entries at index 0 are sentinels
// construct "pattern" from "data"
+ size_t const pattern_max_size = 20;
+ string pattern;
while (!isEndOfData(buffer)) {
- if (pattern_index > 20)
+ if (pattern.size() > pattern_max_size)
return false;
- pattern[pattern_index] = nextToken(buffer);
- if (pattern[pattern_index] == 'E')
+ char const c = nextToken(buffer);
+ if (c == 'E')
return false;
- ++pattern_index;
+ pattern.push_back(c);
}
- pattern[pattern_index] = '\0';
// search "pattern" in "table"
- table_index = 0;
- while (compare(pattern, table[table_index].pattern)) {
+ size_t table_index = 0;
+ while (pattern != table[table_index].pattern) {
++table_index;
if (!*table[table_index].pattern)
return false;
pattern[pattern_index] = '\0';
// only the most basic pattern is accepted here
- if (compare(pattern, "nu") != 0)
+ if (strcmp(pattern, "nu") != 0)
return false;
// It _was_ a correct length string.
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;
: "\\vspace{" + len_.asLatexString() + '}';
default:
- BOOST_ASSERT(false);
+ LASSERT(false, /**/);
return string();
}
}
}
+string VSpace::asHTMLLength() const
+{
+ string result;
+ switch (kind_) {
+ case DEFSKIP: result = "2ex"; break;
+ case SMALLSKIP: result = "1ex"; break;
+ case MEDSKIP: result = "3ex"; break;
+ case BIGSKIP: result = "5ex"; break;
+ case LENGTH: {
+ Length tmp = len_.len();
+ if (tmp.value() > 0)
+ result = tmp.asHTMLString();
+ }
+ case VFILL: break;
+ }
+ return result;
+}
+
int VSpace::inPixels(BufferView const & bv) const
{
// Height of a normal line in pixels (zoom factor considered)
return len_.len().inPixels(bv.workWidth());
default:
- BOOST_ASSERT(false);
+ LASSERT(false, /**/);
return 0;
}
}