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);
192 int RoffEndOfCell(std::ostream &, int cell);
195 char const * getDocBookAlign(int cell, bool isColumn = false);
198 bool IsMultiColumn(int cell);
200 void SetMultiColumn(int cell, int number);
202 int UnsetMultiColumn(int cell); // returns number of new cells
204 bool IsPartOfMultiColumn(int row, int column);
206 int row_of_cell(int cell) const;
208 int column_of_cell(int cell) const;
214 void SetLongTable(int what);
218 void SetRotateTable(int what);
222 void SetRotateCell(int cell, int what);
224 bool RotateCell(int cell);
228 void AppendContRow(int cell);
230 bool IsContRow(int cell);
231 /// returns the number of the cell which continues
232 /// or -1 if no ContRow
233 int CellHasContRow(int cell);
235 bool RowHasContRow(int cell);
237 int FirstVirtualCell(int cell);
239 int NextVirtualCell(int cell);
241 bool ShouldBeVeryLastCell(int cell);
243 bool ShouldBeVeryLastRow(int cell);
245 int GetCellAbove(int cell);
247 int GetCellNumber(int column, int row);
249 void SetLinebreaks(int cell, bool what);
251 bool Linebreaks(int cell);
253 /// Long Table Options
255 void SetLTHead(int cell, bool first);
257 bool RowOfLTHead(int cell);
259 bool RowOfLTFirstHead(int cell);
261 void SetLTFoot(int cell, bool last);
263 bool RowOfLTFoot(int cell);
265 bool RowOfLTLastFoot(int cell);
267 void SetLTNewPage(int cell, bool what);
269 bool LTNewPage(int cell);
272 private: //////////////////////////////////////////////////////////////////
280 cellstruct & operator=(cellstruct const &);
286 int multicolumn; // add approp. signedness
288 int alignment; // add approp. signedness
300 string align_special;
302 string p_width; // this is only set for multicolumn!!!
311 rowstruct & operator=(rowstruct const &);
318 /// This are for longtables only
322 struct columnstruct {
328 columnstruct & operator=(columnstruct const &);
330 int alignment; // add approp. signedness
335 string align_special;
344 rowstruct * row_info;
346 columnstruct * column_info;
348 cellstruct ** cell_info;
354 int endhead; // row of endhead
355 int endfirsthead; // row of endfirsthead
356 int endfoot; // row of endfoot
357 int endlastfoot; // row of endlastfoot
360 void set_row_column_number_info();
361 /// Returns true if a complete update is necessary, otherwise false
362 bool SetWidthOfMulticolCell(int cell, int new_width);
363 void recalculateMulticolCells(int cell, int new_width);
364 /// Returns true if change
365 bool calculate_width_of_column(int column);
366 bool calculate_width_of_column_NMC(int column); // no multi cells
368 void calculate_width_of_table();
371 int right_column_of_cell(int cell);
374 cellstruct * cellinfo_of_cell(int cell);
377 void delete_column(int column);
380 int cells_in_multicolumn(int cell);