X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftabular-old.C;h=796f47b650412b96b13e88aac336cf29d090d764;hb=51b7adb110be8eea7388b17dfebfc5ba614ce1de;hp=eb6219ea2e569333a96dcd9d4579b57c2fd49140;hpb=07ea5f51f03223a1cce9bb5b8260f5a5e9dba9de;p=lyx.git diff --git a/src/tabular-old.C b/src/tabular-old.C index eb6219ea2e..796f47b650 100644 --- a/src/tabular-old.C +++ b/src/tabular-old.C @@ -1,21 +1,25 @@ /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 2000-2001 The LyX Team. * * @author: Jürgen Vigna * - * ====================================================== + * ====================================================== */ #include #include "tabular.h" +#include "buffer.h" #include "debug.h" + #include "support/lstrings.h" +#include "support/textutils.h" +using std::abs; using std::istream; using std::getline; using std::endl; @@ -26,7 +30,7 @@ using std::strlen; 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 = strlen(token); string::size_type pos = str.find(token); @@ -41,14 +45,14 @@ 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 + strlen(token)]; @@ -59,12 +63,12 @@ bool getTokenValue(string const & str, const char * token, int & num) 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); @@ -72,7 +76,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); @@ -81,7 +85,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; @@ -91,7 +95,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; @@ -101,7 +105,7 @@ 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 + strlen(token)]; @@ -112,12 +116,12 @@ bool getTokenValue(string const & str, const char * token, bool & flag) 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); @@ -125,14 +129,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); } @@ -149,7 +162,7 @@ void LyXTabular::ReadOld(Buffer const * buf, istream & is, return; if (!getTokenValue(line, "columns", columns_arg)) return; - Init(rows_arg, columns_arg); + Init(buf->params, rows_arg, columns_arg); l_getline(is, line); if (!prefixIs(line, " got" << @@ -157,10 +170,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); @@ -206,7 +225,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 != "") {