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 * ====================================================== */
20 #include "support/LOstream.h"
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);
72 LyXTable(LyXLex & lex);
78 /// Returns true if there is a topline, returns false if not
79 bool TopLine(int cell);
80 /// Returns true if there is a topline, returns false if not
81 bool BottomLine(int cell);
82 /// Returns true if there is a topline, returns false if not
83 bool LeftLine(int cell);
84 /// Returns true if there is a topline, returns false if not
85 bool RightLine(int cell);
88 bool TopAlreadyDrawed(int cell);
90 bool VeryLastRow(int cell);
93 int AdditionalHeight(int cell);
95 int AdditionalWidth(int cell);
97 /* returns the maximum over all rows */
99 int WidthOfColumn(int cell);
103 /// Returns true if a complete update is necessary, otherwise false
104 bool SetWidthOfCell(int cell, int new_width);
105 /// Returns true if a complete update is necessary, otherwise false
106 bool SetAllLines(int cell, bool line);
107 /// Returns true if a complete update is necessary, otherwise false
108 bool SetTopLine(int cell, bool line);
109 /// Returns true if a complete update is necessary, otherwise false
110 bool SetBottomLine(int cell, bool line);
111 /// Returns true if a complete update is necessary, otherwise false
112 bool SetLeftLine(int cell, bool line);
113 /// Returns true if a complete update is necessary, otherwise false
114 bool SetRightLine(int cell, bool line);
115 /// Returns true if a complete update is necessary, otherwise false
116 bool SetAlignment(int cell, char align);
118 bool SetPWidth(int cell, string width);
120 bool SetAlignSpecial(int cell, string special, int what);
122 char GetAlignment(int cell); // add approp. signedness
124 string GetPWidth(int cell);
126 string GetAlignSpecial(int cell, int what);
129 int GetWidthOfCell(int cell);
131 int GetBeginningOfTextInCell(int cell);
134 void AppendRow(int cell);
136 void DeleteRow(int cell);
139 void AppendColumn(int cell);
141 void DeleteColumn(int cell);
144 bool IsFirstCell(int cell);
146 bool IsLastCell(int cell);
149 int GetNumberOfCells();
151 int AppendCellAfterCell(int append_cell, int question_cell);
153 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
155 int NumberOfCellsInRow(int cell);
160 void Init(int columns_arg, int rows_arg);
163 void Write(ostream &);
165 void Read(istream &);
167 // cell <0 will tex the preamble
168 // returns the number of printed newlines
170 int TexEndOfCell(ostream &, int cell);
172 int DocBookEndOfCell(ostream &, int cell, int & depth);
175 int RoffEndOfCell(ostream &, int cell);
178 char const * getDocBookAlign(int cell, bool isColumn = false);
181 bool IsMultiColumn(int cell);
183 void SetMultiColumn(int cell, int number);
185 int UnsetMultiColumn(int cell); // returns number of new cells
187 int row_of_cell(int cell);
189 int column_of_cell(int cell);
195 void SetLongTable(int what);
199 void SetRotateTable(int what);
203 void SetRotateCell(int cell, int what);
205 bool RotateCell(int cell);
209 void AppendContRow(int cell);
211 bool IsContRow(int cell);
212 /// returns the number of the cell which continues
213 /// or -1 if no ContRow
214 int CellHasContRow(int cell);
216 bool RowHasContRow(int cell);
218 int FirstVirtualCell(int cell);
220 int NextVirtualCell(int cell);
222 bool ShouldBeVeryLastCell(int cell);
224 bool ShouldBeVeryLastRow(int cell);
226 int GetCellAbove(int cell);
228 int GetCellNumber(int column, int row);
230 void SetLinebreaks(int cell, bool what);
232 bool Linebreaks(int cell);
234 /// Long Table Options
236 void SetLTHead(int cell, bool first);
238 bool RowOfLTHead(int cell);
240 bool RowOfLTFirstHead(int cell);
242 void SetLTFoot(int cell, bool last);
244 bool RowOfLTFoot(int cell);
246 bool RowOfLTLastFoot(int cell);
248 void SetLTNewPage(int cell, bool what);
250 bool LTNewPage(int cell);
259 int multicolumn; // add approp. signedness
261 int alignment; // add approp. signedness
273 string align_special;
275 string p_width; // this is only set for multicolumn!!!
282 /// This are for longtables only
286 struct columnstruct {
287 int alignment; // add approp. signedness
292 string align_special;
301 void set_row_column_number_info();
304 rowstruct * row_info;
306 columnstruct * column_info;
308 cellstruct ** cell_info;
314 int endhead; // row of endhead
315 int endfirsthead; // row of endfirsthead
316 int endfoot; // row of endfoot
317 int endlastfoot; // row of endlastfoot
319 /// Returns true if a complete update is necessary, otherwise false
320 bool SetWidthOfMulticolCell(int cell, int new_width);
321 void recalculateMulticolCells(int cell, int new_width);
322 /// Returns true if change
323 bool calculate_width_of_column(int column);
324 bool calculate_width_of_column_NMC(int column); // no multi cells
326 void calculate_width_of_table();
329 int right_column_of_cell(int cell);
332 cellstruct * cellinfo_of_cell(int cell);
335 void delete_column(int column);
338 int cells_in_multicolumn(int cell);