X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftabular-old.C;h=1ab944317f1bb06b43bec7bffbe08f3978431311;hb=8d1c58af82d1fc356f470dff97878ab7c3e8a2fe;hp=b769acc2296cb0103ab58a7764b710c802a76664;hpb=f1d829a18584fe8c787c7ea428f10cc7a82d6083;p=lyx.git diff --git a/src/tabular-old.C b/src/tabular-old.C index b769acc229..1ab944317f 100644 --- a/src/tabular-old.C +++ b/src/tabular-old.C @@ -15,17 +15,21 @@ #include "tabular.h" #include "debug.h" #include "support/lstrings.h" +#include "support/textutils.h" using std::istream; using std::getline; using std::endl; +#ifndef CXX_GLOBAL_CSTD +using std::strlen; +#endif namespace { -bool getTokenValue(string const & str, const char * token, string & ret) +bool getTokenValue(string const & str, char const * token, string & ret) { - size_t token_length = std::strlen(token); + size_t token_length = strlen(token); string::size_type pos = str.find(token); if (pos == string::npos || pos + token_length + 1 >= str.length() @@ -38,30 +42,30 @@ bool getTokenValue(string const & str, const char * token, string & ret) ret += ch; ch = ' '; } - while((pos < str.length() - 1) && (str[++pos] != ch)) + while ((pos < str.length() - 1) && (str[++pos] != ch)) ret += str[pos]; return true; } -bool getTokenValue(string const & str, const char * token, int & num) +bool getTokenValue(string const & str, char const * token, int & num) { string::size_type pos = str.find(token); - char ch = str[pos + std::strlen(token)]; + char ch = str[pos + strlen(token)]; if ((pos == string::npos) || (ch != '=')) return false; string ret; - pos += std::strlen(token) + 1; + pos += strlen(token) + 1; ch = str[pos]; if ((ch != '"') && (ch != '\'')) { // only read till next space - if (!isdigit(ch)) + if (!IsDigit(ch)) return false; ret += ch; } ++pos; - while((pos < str.length() - 1) && isdigit(str[pos])) + while ((pos < str.length() - 1) && IsDigit(str[pos])) ret += str[pos++]; num = strToInt(ret); @@ -69,7 +73,7 @@ bool getTokenValue(string const & str, const char * token, int & num) } -bool getTokenValue(string const & str, const char * token, LyXAlignment & num) +bool getTokenValue(string const & str, char const * token, LyXAlignment & num) { int tmp; bool const ret = getTokenValue(str, token, tmp); @@ -78,7 +82,7 @@ bool getTokenValue(string const & str, const char * token, LyXAlignment & num) } -bool getTokenValue(string const & str, const char * token, +bool getTokenValue(string const & str, char const * token, LyXTabular::VAlignment & num) { int tmp; @@ -88,7 +92,7 @@ bool getTokenValue(string const & str, const char * token, } -bool getTokenValue(string const & str, const char * token, +bool getTokenValue(string const & str, char const * token, LyXTabular::BoxType & num) { int tmp; @@ -98,23 +102,23 @@ bool getTokenValue(string const & str, const char * token, } -bool getTokenValue(string const & str, const char * token, bool & flag) +bool getTokenValue(string const & str, char const * token, bool & flag) { string::size_type pos = str.find(token); - char ch = str[pos + std::strlen(token)]; + char ch = str[pos + strlen(token)]; if ((pos == string::npos) || (ch != '=')) return false; string ret; - pos += std::strlen(token) + 1; + pos += strlen(token) + 1; ch = str[pos]; if ((ch != '"') && (ch != '\'')) { // only read till next space - if (!isdigit(ch)) + if (!IsDigit(ch)) return false; ret += ch; } ++pos; - while((pos < str.length() - 1) && isdigit(str[pos])) + while ((pos < str.length() - 1) && IsDigit(str[pos])) ret += str[pos++]; flag = strToInt(ret); @@ -122,14 +126,23 @@ bool getTokenValue(string const & str, const char * token, bool & flag) } +bool getTokenValue(string const & str, const char * token, LyXLength & len) +{ + string tmp; + if (!getTokenValue(str, token, tmp)) + return false; + return isValidLength(tmp, &len); +} + + inline void l_getline(istream & is, string & str) { #ifdef WITH_WARNINGS -#warning old l_getline +//#warning old l_getline #endif getline(is, str); - while(str.empty()) + while (str.empty()) getline(is, str); } @@ -154,10 +167,16 @@ void LyXTabular::ReadOld(Buffer const * buf, istream & is, return; } getTokenValue(line, "islongtable", is_long_tabular); - getTokenValue(line, "endhead", endhead); - getTokenValue(line, "endfirsthead", endfirsthead); - getTokenValue(line, "endfoot", endfoot); - getTokenValue(line, "endlastfoot", endlastfoot); + int hrow; + int fhrow; + int frow; + int lfrow; + + getTokenValue(line, "endhead", hrow); + getTokenValue(line, "endfirsthead", fhrow); + getTokenValue(line, "endfoot", frow); + getTokenValue(line, "endlastfoot", lfrow); + setHeaderFooterRows(abs(hrow), abs(fhrow), abs(frow), abs(lfrow)); for (int i = 0; i < rows_; ++i) { l_getline(is, line); @@ -203,7 +222,7 @@ void LyXTabular::ReadOld(Buffer const * buf, istream & is, getTokenValue(line, "special", cell_info[i][j].align_special); l_getline(is, line); if (prefixIs(line, "\\begin_inset")) { - cell_info[i][j].inset.Read(buf, lex); + cell_info[i][j].inset.read(buf, lex); l_getline(is, line); } if (line != "") {