1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000-2001 The LyX Team.
8 * @author: Jürgen Vigna
10 * ======================================================
17 #include "support/lstrings.h"
23 #ifndef CXX_GLOBAL_CSTD
29 bool getTokenValue(string const & str, char const * token, string & ret)
31 size_t token_length = strlen(token);
32 string::size_type pos = str.find(token);
34 if (pos == string::npos || pos + token_length + 1 >= str.length()
35 || str[pos + token_length] != '=')
38 pos += token_length + 1;
40 if ((ch != '"') && (ch != '\'')) { // only read till next space
44 while((pos < str.length() - 1) && (str[++pos] != ch))
51 bool getTokenValue(string const & str, char const * token, int & num)
53 string::size_type pos = str.find(token);
54 char ch = str[pos + strlen(token)];
56 if ((pos == string::npos) || (ch != '='))
59 pos += strlen(token) + 1;
61 if ((ch != '"') && (ch != '\'')) { // only read till next space
67 while((pos < str.length() - 1) && isdigit(str[pos]))
75 bool getTokenValue(string const & str, char const * token, LyXAlignment & num)
78 bool const ret = getTokenValue(str, token, tmp);
79 num = static_cast<LyXAlignment>(tmp);
84 bool getTokenValue(string const & str, char const * token,
85 LyXTabular::VAlignment & num)
88 bool const ret = getTokenValue(str, token, tmp);
89 num = static_cast<LyXTabular::VAlignment>(tmp);
94 bool getTokenValue(string const & str, char const * token,
95 LyXTabular::BoxType & num)
98 bool ret = getTokenValue(str, token, tmp);
99 num = static_cast<LyXTabular::BoxType>(tmp);
104 bool getTokenValue(string const & str, char const * token, bool & flag)
106 string::size_type pos = str.find(token);
107 char ch = str[pos + strlen(token)];
109 if ((pos == string::npos) || (ch != '='))
112 pos += strlen(token) + 1;
114 if ((ch != '"') && (ch != '\'')) { // only read till next space
120 while((pos < str.length() - 1) && isdigit(str[pos]))
123 flag = strToInt(ret);
129 void l_getline(istream & is, string & str)
132 #warning old l_getline
142 void LyXTabular::ReadOld(Buffer const * buf, istream & is,
143 LyXLex & lex, string const & l)
148 if (!getTokenValue(line, "rows", rows_arg))
150 if (!getTokenValue(line, "columns", columns_arg))
152 Init(rows_arg, columns_arg);
154 if (!prefixIs(line, "<Features ")) {
155 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
159 getTokenValue(line, "islongtable", is_long_tabular);
160 getTokenValue(line, "endhead", endhead);
161 getTokenValue(line, "endfirsthead", endfirsthead);
162 getTokenValue(line, "endfoot", endfoot);
163 getTokenValue(line, "endlastfoot", endlastfoot);
165 for (int i = 0; i < rows_; ++i) {
167 if (!prefixIs(line, "<Row ")) {
168 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
172 getTokenValue(line, "topline", row_info[i].top_line);
173 getTokenValue(line, "bottomline", row_info[i].bottom_line);
174 getTokenValue(line, "newpage", row_info[i].newpage);
175 for (int j = 0; j < columns_; ++j) {
177 if (!prefixIs(line,"<Column")) {
178 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
183 getTokenValue(line, "alignment", column_info[j].alignment);
184 getTokenValue(line, "valignment", column_info[j].valignment);
185 getTokenValue(line, "leftline", column_info[j].left_line);
186 getTokenValue(line, "rightline", column_info[j].right_line);
187 getTokenValue(line, "width", column_info[j].p_width);
188 getTokenValue(line, "special", column_info[j].align_special);
191 if (!prefixIs(line, "<Cell")) {
192 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
196 getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
197 getTokenValue(line, "alignment", cell_info[i][j].alignment);
198 getTokenValue(line, "valignment", cell_info[i][j].valignment);
199 getTokenValue(line, "topline", cell_info[i][j].top_line);
200 getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
201 getTokenValue(line, "leftline", cell_info[i][j].left_line);
202 getTokenValue(line, "rightline", cell_info[i][j].right_line);
203 getTokenValue(line, "rotate", cell_info[i][j].rotate);
204 getTokenValue(line, "usebox", cell_info[i][j].usebox);
205 getTokenValue(line, "width", cell_info[i][j].p_width);
206 getTokenValue(line, "special", cell_info[i][j].align_special);
208 if (prefixIs(line, "\\begin_inset")) {
209 cell_info[i][j].inset.read(buf, lex);
212 if (line != "</Cell>") {
213 lyxerr << "Wrong tabular format (expected </Cell> got" <<
218 if (line != "</Column>") {
219 lyxerr << "Wrong tabular format (expected </Column> got" <<
225 if (line != "</Row>") {
226 lyxerr << "Wrong tabular format (expected </Row> got" <<
231 while (line != "</LyXTabular>") {
234 set_row_column_number_info();