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);
128 bool getTokenValue(string const & str, const char * token, LyXLength & len)
131 if (!getTokenValue(str, token, tmp))
133 return isValidLength(tmp, &len);
138 void l_getline(istream & is, string & str)
141 //#warning old l_getline
151 void LyXTabular::ReadOld(Buffer const * buf, istream & is,
152 LyXLex & lex, string const & l)
157 if (!getTokenValue(line, "rows", rows_arg))
159 if (!getTokenValue(line, "columns", columns_arg))
161 Init(rows_arg, columns_arg);
163 if (!prefixIs(line, "<Features ")) {
164 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
168 getTokenValue(line, "islongtable", is_long_tabular);
169 getTokenValue(line, "endhead", endhead.row);
170 getTokenValue(line, "endfirsthead", endfirsthead.row);
171 getTokenValue(line, "endfoot", endfoot.row);
172 getTokenValue(line, "endlastfoot", endlastfoot.row);
174 for (int i = 0; i < rows_; ++i) {
176 if (!prefixIs(line, "<Row ")) {
177 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
181 getTokenValue(line, "topline", row_info[i].top_line);
182 getTokenValue(line, "bottomline", row_info[i].bottom_line);
183 getTokenValue(line, "newpage", row_info[i].newpage);
184 for (int j = 0; j < columns_; ++j) {
186 if (!prefixIs(line,"<Column")) {
187 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
192 getTokenValue(line, "alignment", column_info[j].alignment);
193 getTokenValue(line, "valignment", column_info[j].valignment);
194 getTokenValue(line, "leftline", column_info[j].left_line);
195 getTokenValue(line, "rightline", column_info[j].right_line);
196 getTokenValue(line, "width", column_info[j].p_width);
197 getTokenValue(line, "special", column_info[j].align_special);
200 if (!prefixIs(line, "<Cell")) {
201 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
205 getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
206 getTokenValue(line, "alignment", cell_info[i][j].alignment);
207 getTokenValue(line, "valignment", cell_info[i][j].valignment);
208 getTokenValue(line, "topline", cell_info[i][j].top_line);
209 getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
210 getTokenValue(line, "leftline", cell_info[i][j].left_line);
211 getTokenValue(line, "rightline", cell_info[i][j].right_line);
212 getTokenValue(line, "rotate", cell_info[i][j].rotate);
213 getTokenValue(line, "usebox", cell_info[i][j].usebox);
214 getTokenValue(line, "width", cell_info[i][j].p_width);
215 getTokenValue(line, "special", cell_info[i][j].align_special);
217 if (prefixIs(line, "\\begin_inset")) {
218 cell_info[i][j].inset.read(buf, lex);
221 if (line != "</Cell>") {
222 lyxerr << "Wrong tabular format (expected </Cell> got" <<
227 if (line != "</Column>") {
228 lyxerr << "Wrong tabular format (expected </Column> got" <<
234 if (line != "</Row>") {
235 lyxerr << "Wrong tabular format (expected </Row> got" <<
240 while (line != "</LyXTabular>") {
243 set_row_column_number_info();