]> git.lyx.org Git - lyx.git/blobdiff - src/tabular-old.C
More fixes to the autocollapsing of paragraphs.
[lyx.git] / src / tabular-old.C
index feb698e2199c14915f7bf447aa6bb8356a8a5024..9c7c0cac7f80892abe8c4d2c30fdc386140f1bb2 100644 (file)
@@ -20,16 +20,19 @@ 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 = strlen(token);
     string::size_type pos = str.find(token);
 
-    if (pos == string::npos || pos+token_length+1 >= str.length()
-       || str[pos+token_length] != '=')
+    if (pos == string::npos || pos + token_length + 1 >= str.length()
+       || str[pos + token_length] != '=')
        return false;
     ret.erase();
     pos += token_length + 1;
@@ -38,14 +41,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)];
@@ -61,7 +64,7 @@ bool getTokenValue(string const & str, const char * token, int & num)
        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 +72,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 +81,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 +91,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,7 +101,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)];
@@ -114,7 +117,7 @@ bool getTokenValue(string const & str, const char * token, bool & flag)
        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 +125,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 +166,10 @@ 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);
+    getTokenValue(line, "endhead", endhead.row);
+    getTokenValue(line, "endfirsthead", endfirsthead.row);
+    getTokenValue(line, "endfoot", endfoot.row);
+    getTokenValue(line, "endlastfoot", endlastfoot.row);
 
     for (int i = 0; i < rows_; ++i) {
        l_getline(is, line);
@@ -203,7 +215,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 != "</Cell>") {