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 * ====================================================== */
26 /* The features the text class offers for tables */
31 // Are the values of these enums important? (Lgb)
38 TOGGLE_LINE_BOTTOM = 5,
40 TOGGLE_LINE_RIGHT = 7,
41 ALIGN_LEFT = 8, // what are these alignment enums used for?
52 SET_ROTATE_TABLE = 19,
53 UNSET_ROTATE_TABLE = 20,
55 UNSET_ROTATE_CELL = 22,
62 SET_SPECIAL_COLUMN = 29,
63 SET_SPECIAL_MULTI = 30
68 CELL_BEGIN_OF_MULTICOLUMN = 1,
69 CELL_PART_OF_MULTICOLUMN = 2
73 LyXTable(int columns_arg, int rows_arg, Buffer *buf = 0);
76 LyXTable(LyXTable const &, Buffer *buf = 0);
79 LyXTable(LyXLex & lex, Buffer *buf = 0);
83 LyXTable & operator=(LyXTable const &);
87 /// Returns true if there is a topline, returns false if not
88 bool TopLine(int cell);
89 /// Returns true if there is a topline, returns false if not
90 bool BottomLine(int cell);
91 /// Returns true if there is a topline, returns false if not
92 bool LeftLine(int cell);
93 /// Returns true if there is a topline, returns false if not
94 bool RightLine(int cell);
97 bool TopAlreadyDrawed(int cell);
99 bool VeryLastRow(int cell);
102 int AdditionalHeight(int cell);
104 int AdditionalWidth(int cell);
106 /* returns the maximum over all rows */
108 int WidthOfColumn(int cell);
112 int AscentOfRow(int row);
114 int DescentOfRow(int row);
118 void SetAscentOfRow(int row, int height);
120 void SetDescentOfRow(int row, int height);
121 /// Returns true if a complete update is necessary, otherwise false
122 bool SetWidthOfCell(int cell, int new_width);
123 /// Returns true if a complete update is necessary, otherwise false
124 bool SetAllLines(int cell, bool line);
125 /// Returns true if a complete update is necessary, otherwise false
126 bool SetTopLine(int cell, bool line);
127 /// Returns true if a complete update is necessary, otherwise false
128 bool SetBottomLine(int cell, bool line);
129 /// Returns true if a complete update is necessary, otherwise false
130 bool SetLeftLine(int cell, bool line);
131 /// Returns true if a complete update is necessary, otherwise false
132 bool SetRightLine(int cell, bool line);
133 /// Returns true if a complete update is necessary, otherwise false
134 bool SetAlignment(int cell, char align);
136 bool SetPWidth(int cell, string width);
138 bool SetAlignSpecial(int cell, string special, int what);
140 char GetAlignment(int cell); // add approp. signedness
142 string GetPWidth(int cell);
144 string GetAlignSpecial(int cell, int what);
147 int GetWidthOfCell(int cell);
149 int GetBeginningOfTextInCell(int cell);
152 void AppendRow(int cell);
154 void DeleteRow(int cell);
157 void AppendColumn(int cell);
159 void DeleteColumn(int cell);
162 bool IsFirstCell(int cell);
164 bool IsLastCell(int cell);
167 int GetNumberOfCells();
169 int AppendCellAfterCell(int append_cell, int question_cell);
171 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
173 int NumberOfCellsInRow(int cell);
178 void Init(int columns_arg, int rows_arg);
181 void Write(std::ostream &, bool old_format=true);
183 void Read(std::istream &);
185 int Latex(std::ostream &);
187 // cell <0 will tex the preamble
188 // returns the number of printed newlines
190 int TexEndOfCell(std::ostream &, int cell);
192 int DocBookEndOfCell(std::ostream &, int cell, int & depth);
195 int RoffEndOfCell(std::ostream &, int cell);
198 char const * getDocBookAlign(int cell, bool isColumn = false);
201 bool IsMultiColumn(int cell);
203 void SetMultiColumn(int cell, int number);
205 int UnsetMultiColumn(int cell); // returns number of new cells
207 bool IsPartOfMultiColumn(int row, int column);
209 int row_of_cell(int cell) const;
211 int column_of_cell(int cell) const;
217 void SetLongTable(int what);
221 void SetRotateTable(int what);
225 void SetRotateCell(int cell, int what);
227 bool RotateCell(int cell);
231 void AppendContRow(int cell);
233 bool IsContRow(int cell);
234 /// returns the number of the cell which continues
235 /// or -1 if no ContRow
236 int CellHasContRow(int cell);
238 bool RowHasContRow(int cell);
240 int FirstVirtualCell(int cell);
242 int NextVirtualCell(int cell);
244 bool ShouldBeVeryLastCell(int cell);
246 bool ShouldBeVeryLastRow(int cell);
248 int GetCellAbove(int cell);
250 int GetCellNumber(int column, int row);
252 void SetLinebreaks(int cell, bool what);
254 bool Linebreaks(int cell);
256 /// Long Table Options
258 void SetLTHead(int cell, bool first);
260 bool RowOfLTHead(int cell);
262 bool RowOfLTFirstHead(int cell);
264 void SetLTFoot(int cell, bool last);
266 bool RowOfLTFoot(int cell);
268 bool RowOfLTLastFoot(int cell);
270 void SetLTNewPage(int cell, bool what);
272 bool LTNewPage(int cell);
274 InsetText * GetCellInset(int cell) const;
277 private: //////////////////////////////////////////////////////////////////
281 cellstruct(Buffer * buf = 0);
285 cellstruct & operator=(cellstruct const &);
291 int multicolumn; // add approp. signedness
293 int alignment; // add approp. signedness
305 string align_special;
307 string p_width; // this is only set for multicolumn!!!
318 rowstruct & operator=(rowstruct const &);
325 /// This are for longtables only
329 struct columnstruct {
335 columnstruct & operator=(columnstruct const &);
337 int alignment; // add approp. signedness
342 string align_special;
351 rowstruct * row_info;
353 columnstruct * column_info;
355 cellstruct ** cell_info;
361 int endhead; // row of endhead
362 int endfirsthead; // row of endfirsthead
363 int endfoot; // row of endfoot
364 int endlastfoot; // row of endlastfoot
369 void set_row_column_number_info();
370 /// Returns true if a complete update is necessary, otherwise false
371 bool SetWidthOfMulticolCell(int cell, int new_width);
372 void recalculateMulticolCells(int cell, int new_width);
373 /// Returns true if change
374 bool calculate_width_of_column(int column);
375 bool calculate_width_of_column_NMC(int column); // no multi cells
377 void calculate_width_of_table();
380 int right_column_of_cell(int cell);
383 cellstruct * cellinfo_of_cell(int cell);
386 void delete_column(int column);
389 int cells_in_multicolumn(int cell);