2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * ====================================================== */
23 /* The features the text class offers for tables */
28 // Are the values of these enums important? (Lgb)
35 TOGGLE_LINE_BOTTOM = 5,
37 TOGGLE_LINE_RIGHT = 7,
38 ALIGN_LEFT = 8, // what are these alignment enums used for?
49 SET_ROTATE_TABLE = 19,
50 UNSET_ROTATE_TABLE = 20,
52 UNSET_ROTATE_CELL = 22,
59 SET_SPECIAL_COLUMN = 29,
60 SET_SPECIAL_MULTI = 30
65 CELL_BEGIN_OF_MULTICOLUMN = 1,
66 CELL_PART_OF_MULTICOLUMN = 2
70 LyXTable(int columns_arg, int rows_arg);
73 LyXTable(LyXTable const &);
76 LyXTable(LyXLex & lex);
80 LyXTable & operator=(LyXTable const &);
84 /// Returns true if there is a topline, returns false if not
85 bool TopLine(int cell);
86 /// Returns true if there is a topline, returns false if not
87 bool BottomLine(int cell);
88 /// Returns true if there is a topline, returns false if not
89 bool LeftLine(int cell);
90 /// Returns true if there is a topline, returns false if not
91 bool RightLine(int cell);
94 bool TopAlreadyDrawed(int cell);
96 bool VeryLastRow(int cell);
99 int AdditionalHeight(int cell);
101 int AdditionalWidth(int cell);
103 /* returns the maximum over all rows */
105 int WidthOfColumn(int cell);
109 int AscentOfRow(int row);
111 int DescentOfRow(int row);
115 void SetAscentOfRow(int row, int height);
117 void SetDescentOfRow(int row, int height);
118 /// Returns true if a complete update is necessary, otherwise false
119 bool SetWidthOfCell(int cell, int new_width);
120 /// Returns true if a complete update is necessary, otherwise false
121 bool SetAllLines(int cell, bool line);
122 /// Returns true if a complete update is necessary, otherwise false
123 bool SetTopLine(int cell, bool line);
124 /// Returns true if a complete update is necessary, otherwise false
125 bool SetBottomLine(int cell, bool line);
126 /// Returns true if a complete update is necessary, otherwise false
127 bool SetLeftLine(int cell, bool line);
128 /// Returns true if a complete update is necessary, otherwise false
129 bool SetRightLine(int cell, bool line);
130 /// Returns true if a complete update is necessary, otherwise false
131 bool SetAlignment(int cell, char align);
133 bool SetPWidth(int cell, string width);
135 bool SetAlignSpecial(int cell, string special, int what);
137 char GetAlignment(int cell); // add approp. signedness
139 string GetPWidth(int cell);
141 string GetAlignSpecial(int cell, int what);
144 int GetWidthOfCell(int cell);
146 int GetBeginningOfTextInCell(int cell);
149 void AppendRow(int cell);
151 void DeleteRow(int cell);
154 void AppendColumn(int cell);
156 void DeleteColumn(int cell);
159 bool IsFirstCell(int cell);
161 bool IsLastCell(int cell);
164 int GetNumberOfCells();
166 int AppendCellAfterCell(int append_cell, int question_cell);
168 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
170 int NumberOfCellsInRow(int cell);
175 void Init(int columns_arg, int rows_arg);
178 void Write(std::ostream &, bool old_format=true);
180 void Read(std::istream &);
182 int Latex(std::ostream &);
184 // cell <0 will tex the preamble
185 // returns the number of printed newlines
187 int TexEndOfCell(std::ostream &, int cell);
189 int DocBookEndOfCell(std::ostream &, int cell, int & depth);
193 int RoffEndOfCell(std::ostream &, int cell);
197 char const * getDocBookAlign(int cell, bool isColumn = false);
200 bool IsMultiColumn(int cell);
202 void SetMultiColumn(int cell, int number);
204 int UnsetMultiColumn(int cell); // returns number of new cells
206 bool IsPartOfMultiColumn(int row, int column);
208 int row_of_cell(int cell) const;
210 int column_of_cell(int cell) const;
216 void SetLongTable(int what);
220 void SetRotateTable(int what);
224 void SetRotateCell(int cell, int what);
226 bool RotateCell(int cell);
230 void AppendContRow(int cell);
232 bool IsContRow(int cell);
233 /// returns the number of the cell which continues
234 /// or -1 if no ContRow
235 int CellHasContRow(int cell);
237 bool RowHasContRow(int cell);
239 int FirstVirtualCell(int cell);
241 int NextVirtualCell(int cell);
243 bool ShouldBeVeryLastCell(int cell);
245 bool ShouldBeVeryLastRow(int cell);
247 int GetCellAbove(int cell);
249 int GetCellNumber(int column, int row);
251 void SetLinebreaks(int cell, bool what);
253 bool Linebreaks(int cell);
255 /// Long Table Options
257 void SetLTHead(int cell, bool first);
259 bool RowOfLTHead(int cell);
261 bool RowOfLTFirstHead(int cell);
263 void SetLTFoot(int cell, bool last);
265 bool RowOfLTFoot(int cell);
267 bool RowOfLTLastFoot(int cell);
269 void SetLTNewPage(int cell, bool what);
271 bool LTNewPage(int cell);
274 private: //////////////////////////////////////////////////////////////////
282 cellstruct & operator=(cellstruct const &);
288 int multicolumn; // add approp. signedness
290 int alignment; // add approp. signedness
302 string align_special;
304 string p_width; // this is only set for multicolumn!!!
313 rowstruct & operator=(rowstruct const &);
320 /// This are for longtables only
324 struct columnstruct {
330 columnstruct & operator=(columnstruct const &);
332 int alignment; // add approp. signedness
337 string align_special;
346 rowstruct * row_info;
348 columnstruct * column_info;
350 cellstruct ** cell_info;
356 int endhead; // row of endhead
357 int endfirsthead; // row of endfirsthead
358 int endfoot; // row of endfoot
359 int endlastfoot; // row of endlastfoot
362 void set_row_column_number_info();
363 /// Returns true if a complete update is necessary, otherwise false
364 bool SetWidthOfMulticolCell(int cell, int new_width);
365 void recalculateMulticolCells(int cell, int new_width);
366 /// Returns true if change
367 bool calculate_width_of_column(int column);
368 bool calculate_width_of_column_NMC(int column); // no multi cells
370 void calculate_width_of_table();
373 int right_column_of_cell(int cell);
376 cellstruct * cellinfo_of_cell(int cell);
379 void delete_column(int column);
382 int cells_in_multicolumn(int cell);