/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
*
* @author: Jürgen Vigna
*
- * ======================================================
+ * ======================================================
*/
#include <config.h>
#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;
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);
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);
}
+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)
{
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, "<Features ")) {
- lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected <Feture ...> got"
+ << line << ')' << endl;
return;
}
getTokenValue(line, "islongtable", is_long_tabular);
- getTokenValue(line, "endhead", endhead.row);
- getTokenValue(line, "endfirsthead", endfirsthead.row);
- getTokenValue(line, "endfoot", endfoot.row);
- getTokenValue(line, "endlastfoot", endlastfoot.row);
+ 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);
if (!prefixIs(line, "<Row ")) {
- lyxerr << "Wrong tabular format (expected <Row ...> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected <Row ...> got"
+ << line << ')' << endl;
return;
}
getTokenValue(line, "topline", row_info[i].top_line);
for (int j = 0; j < columns_; ++j) {
l_getline(is,line);
if (!prefixIs(line,"<Column")) {
- lyxerr << "Wrong tabular format (expected <Column ...> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected <Column ...> got"
+ << line << ')' << endl;
return;
}
if (!i) {
}
l_getline(is, line);
if (!prefixIs(line, "<Cell")) {
- lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected <Cell ...> got"
+ << line << ')' << endl;
return;
}
getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
l_getline(is, line);
}
if (line != "</Cell>") {
- lyxerr << "Wrong tabular format (expected </Cell> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected </Cell> got"
+ << line << ')' << endl;
return;
}
l_getline(is, line);
if (line != "</Column>") {
- lyxerr << "Wrong tabular format (expected </Column> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected </Column> got"
+ << line << ')' << endl;
return;
}
}
l_getline(is, line);
if (line != "</Row>") {
- lyxerr << "Wrong tabular format (expected </Row> got" <<
- line << ")" << endl;
+ lyxerr << "Wrong tabular format (expected </Row> got"
+ << line << ')' << endl;
return;
}
}