2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
25 /* The features the text class offers for tables */
30 // Are the values of these enums important? (Lgb)
40 ALIGN_LEFT, // what are these alignment enums used for?
66 CELL_BEGIN_OF_MULTICOLUMN,
67 CELL_PART_OF_MULTICOLUMN
71 LyXTabular(int columns_arg, int rows_arg, Buffer *buf = 0);
74 LyXTabular(LyXTabular const &, Buffer *buf = 0);
77 LyXTabular(LyXLex & lex, Buffer *buf = 0);
81 LyXTabular & operator=(LyXTabular const &);
85 /// Returns true if there is a topline, returns false if not
86 bool TopLine(int cell);
87 /// Returns true if there is a topline, returns false if not
88 bool BottomLine(int cell);
89 /// Returns true if there is a topline, returns false if not
90 bool LeftLine(int cell);
91 /// Returns true if there is a topline, returns false if not
92 bool RightLine(int cell);
95 bool TopAlreadyDrawed(int cell);
97 bool VeryLastRow(int cell);
100 int AdditionalHeight(int cell);
102 int AdditionalWidth(int cell);
104 /* returns the maximum over all rows */
106 int WidthOfColumn(int cell);
108 int WidthOfTabular();
110 int AscentOfRow(int row);
112 int DescentOfRow(int row);
114 int HeightOfTabular();
116 void SetAscentOfRow(int row, int height);
118 void SetDescentOfRow(int row, int height);
119 /// Returns true if a complete update is necessary, otherwise false
120 bool SetWidthOfCell(int cell, int new_width);
121 /// Returns true if a complete update is necessary, otherwise false
122 bool SetAllLines(int cell, bool line);
123 /// Returns true if a complete update is necessary, otherwise false
124 bool SetTopLine(int cell, bool line);
125 /// Returns true if a complete update is necessary, otherwise false
126 bool SetBottomLine(int cell, bool line);
127 /// Returns true if a complete update is necessary, otherwise false
128 bool SetLeftLine(int cell, bool line);
129 /// Returns true if a complete update is necessary, otherwise false
130 bool SetRightLine(int cell, bool line);
131 /// Returns true if a complete update is necessary, otherwise false
132 bool SetAlignment(int cell, char align);
134 bool SetPWidth(int cell, string width);
136 bool SetAlignSpecial(int cell, string special, int what);
138 char GetAlignment(int cell); // add approp. signedness
140 string GetPWidth(int cell);
142 string GetAlignSpecial(int cell, int what);
144 int GetWidthOfCell(int cell);
146 int GetBeginningOfTextInCell(int cell);
148 void AppendRow(int cell);
150 void DeleteRow(int cell);
152 void AppendColumn(int cell);
154 void DeleteColumn(int cell);
156 bool IsFirstCellInRow(int cell);
158 bool IsLastCellInRow(int cell);
160 int GetNumberOfCells();
162 int AppendCellAfterCell(int append_cell, int question_cell);
164 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
166 int NumberOfCellsInRow(int cell);
170 void Init(int columns_arg, int rows_arg);
172 void Write(std::ostream &, bool old_format=true);
174 void Read(std::istream &);
176 int Latex(std::ostream &);
178 // cell <0 will tex the preamble
179 // returns the number of printed newlines
181 int TexEndOfCell(std::ostream &, int cell);
183 int DocBookEndOfCell(std::ostream &, int cell, int & depth);
186 int RoffEndOfCell(std::ostream &, int cell);
189 char const * getDocBookAlign(int cell, bool isColumn = false);
192 bool IsMultiColumn(int cell);
194 void SetMultiColumn(int cell, int number);
196 int UnsetMultiColumn(int cell); // returns number of new cells
198 bool IsPartOfMultiColumn(int row, int column);
200 int row_of_cell(int cell) const;
202 int column_of_cell(int cell) const;
204 void SetLongTabular(int what);
206 bool IsLongTabular();
208 void SetRotateTabular(int what);
210 bool RotateTabular();
212 void SetRotateCell(int cell, int what);
214 bool RotateCell(int cell);
218 bool ShouldBeVeryLastCell(int cell);
220 bool IsLastRow(int cell);
222 int GetCellAbove(int cell);
224 int GetCellNumber(int column, int row);
226 void SetLinebreaks(int cell, bool what);
228 bool Linebreaks(int cell);
230 /// Long Tabular Options
232 void SetLTHead(int cell, bool first);
234 bool RowOfLTHead(int cell);
236 bool RowOfLTFirstHead(int cell);
238 void SetLTFoot(int cell, bool last);
240 bool RowOfLTFoot(int cell);
242 bool RowOfLTLastFoot(int cell);
244 void SetLTNewPage(int cell, bool what);
246 bool LTNewPage(int cell);
248 InsetText * GetCellInset(int cell) const;
250 int rows() const { return rows_; }
252 int columns() const { return columns_;}
254 private: //////////////////////////////////////////////////////////////////
258 cellstruct(Buffer * buf = 0);
262 cellstruct & operator=(cellstruct const &);
268 int multicolumn; // add approp. signedness
270 int alignment; // add approp. signedness
280 string align_special;
282 string p_width; // this is only set for multicolumn!!!
293 rowstruct & operator=(rowstruct const &);
299 /// This are for longtabulars only
303 struct columnstruct {
309 columnstruct & operator=(columnstruct const &);
311 int alignment; // add approp. signedness
316 string align_special;
329 rowstruct * row_info;
331 columnstruct * column_info;
333 cellstruct ** cell_info;
335 int width_of_tabular;
337 /// for long tabulars
339 int endhead; // row of endhead
340 int endfirsthead; // row of endfirsthead
341 int endfoot; // row of endfoot
342 int endlastfoot; // row of endlastfoot
347 void set_row_column_number_info();
348 /// Returns true if a complete update is necessary, otherwise false
349 bool SetWidthOfMulticolCell(int cell, int new_width);
350 void recalculateMulticolCells(int cell, int new_width);
351 /// Returns true if change
352 bool calculate_width_of_column(int column);
353 bool calculate_width_of_column_NMC(int column); // no multi cells
355 void calculate_width_of_tabular();
358 int right_column_of_cell(int cell);
361 cellstruct * cellinfo_of_cell(int cell);
364 void delete_column(int column);
367 int cells_in_multicolumn(int cell);