2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
22 #include "insets/insettext.h"
28 /* The features the text class offers for tables */
102 UNSET_ROTATE_TABULAR,
131 CELL_BEGIN_OF_MULTICOLUMN,
133 CELL_PART_OF_MULTICOLUMN
141 LYX_VALIGN_BOTTOM = 1,
143 LYX_VALIGN_CENTER = 2
148 LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
150 LyXTabular(InsetTabular *, LyXTabular const &);
153 LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
157 LyXTabular & operator=(LyXTabular const &);
159 LyXTabular * Clone(InsetTabular *);
161 /// Returns true if there is a topline, returns false if not
162 bool TopLine(int cell, bool onlycolumn=false) const;
163 /// Returns true if there is a topline, returns false if not
164 bool BottomLine(int cell, bool onlycolumn=false) const;
165 /// Returns true if there is a topline, returns false if not
166 bool LeftLine(int cell, bool onlycolumn=false) const;
167 /// Returns true if there is a topline, returns false if not
168 bool RightLine(int cell, bool onlycolumn=false) const;
171 bool TopAlreadyDrawed(int cell) const;
173 bool LeftAlreadyDrawed(int cell) const;
175 bool IsLastRow(int cell) const;
178 int GetAdditionalHeight(int cell) const;
180 int GetAdditionalWidth(int cell) const;
182 /* returns the maximum over all rows */
184 int GetWidthOfColumn(int cell) const;
186 int GetWidthOfTabular() const;
188 int GetAscentOfRow(int row) const;
190 int GetDescentOfRow(int row) const;
192 int GetHeightOfTabular() const;
193 /// Returns true if a complete update is necessary, otherwise false
194 bool SetAscentOfRow(int row, int height);
195 /// Returns true if a complete update is necessary, otherwise false
196 bool SetDescentOfRow(int row, int height);
197 /// Returns true if a complete update is necessary, otherwise false
198 bool SetWidthOfCell(int cell, int new_width);
199 /// Returns true if a complete update is necessary, otherwise false
200 bool SetAllLines(int cell, bool line);
201 /// Returns true if a complete update is necessary, otherwise false
202 bool SetTopLine(int cell, bool line, bool onlycolumn=false);
203 /// Returns true if a complete update is necessary, otherwise false
204 bool SetBottomLine(int cell, bool line, bool onlycolumn=false);
205 /// Returns true if a complete update is necessary, otherwise false
206 bool SetLeftLine(int cell, bool line, bool onlycolumn=false);
207 /// Returns true if a complete update is necessary, otherwise false
208 bool SetRightLine(int cell, bool line, bool onlycolumn=false);
209 /// Returns true if a complete update is necessary, otherwise false
210 bool SetAlignment(int cell, char align, bool onlycolumn = false);
211 /// Returns true if a complete update is necessary, otherwise false
212 bool SetVAlignment(int cell, char align, bool onlycolumn = false);
214 bool SetColumnPWidth(int cell, string const & width);
216 bool SetMColumnPWidth(int cell, string const & width);
218 bool SetAlignSpecial(int cell, string const & special, int what);
220 char GetAlignment(int cell, bool onlycolumn = false) const;
222 char GetVAlignment(int cell, bool onlycolumn = false) const;
224 string GetPWidth(int cell) const;
226 string GetColumnPWidth(int cell) const;
228 string GetMColumnPWidth(int cell) const;
230 string GetAlignSpecial(int cell, int what) const;
232 int GetWidthOfCell(int cell) const;
234 int GetBeginningOfTextInCell(int cell) const;
236 void AppendRow(int cell);
238 void DeleteRow(int cell);
240 void AppendColumn(int cell);
242 void DeleteColumn(int cell);
244 bool IsFirstCellInRow(int cell) const;
246 int GetFirstCellInRow(int row) const;
248 bool IsLastCellInRow(int cell) const;
250 int GetLastCellInRow(int row) const;
252 int GetNumberOfCells() const;
254 int NumberOfCellsInRow(int cell) const;
256 void Write(Buffer const *, std::ostream &) const;
258 void Read(Buffer const *, LyXLex &);
260 void OldFormatRead(LyXLex &, string const &);
262 // helper function for Latex returns number of newlines
264 int TeXTopHLine(std::ostream &, int row) const;
266 int TeXBottomHLine(std::ostream &, int row) const;
268 int TeXCellPreamble(std::ostream &, int cell) const;
270 int TeXCellPostamble(std::ostream &, int cell) const;
272 int Latex(Buffer const *, std::ostream &, bool, bool) const;
274 int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
277 int RoffEndOfCell(std::ostream &, int cell);
280 char const * GetDocBookAlign(int cell, bool isColumn = false) const;
283 bool IsMultiColumn(int cell, bool real = false) const;
285 void SetMultiColumn(int cell, int number);
287 int UnsetMultiColumn(int cell); // returns number of new cells
289 bool IsPartOfMultiColumn(int row, int column) const;
291 int row_of_cell(int cell) const;
293 int column_of_cell(int cell) const;
295 int right_column_of_cell(int cell) const;
297 void SetLongTabular(int what);
299 bool IsLongTabular() const;
301 void SetRotateTabular(int what);
303 bool GetRotateTabular() const;
305 void SetRotateCell(int cell, int what);
307 bool GetRotateCell(int cell) const;
309 bool NeedRotating() const;
311 bool IsLastCell(int cell) const;
313 int GetCellAbove(int cell) const;
315 int GetCellBelow(int cell) const;
317 int GetLastCellAbove(int cell) const;
319 int GetLastCellBelow(int cell) const;
321 int GetCellNumber(int row, int column) const;
323 void SetUsebox(int cell, int what);
325 int GetUsebox(int cell) const;
327 // Long Tabular Options
329 void SetLTHead(int cell, bool first);
331 bool GetRowOfLTHead(int cell, int & row) const;
333 bool GetRowOfLTFirstHead(int cell, int & row) const;
335 void SetLTFoot(int cell, bool last);
337 bool GetRowOfLTFoot(int cell, int & row) const;
339 bool GetRowOfLTLastFoot(int cell, int & row) const;
341 void SetLTNewPage(int cell, bool what);
343 bool GetLTNewPage(int cell) const;
345 InsetText * GetCellInset(int cell) const;
347 int rows() const { return rows_; }
349 int columns() const { return columns_;}
351 InsetTabular * owner() const { return owner_; }
353 void Validate(LaTeXFeatures &) const;
355 private: //////////////////////////////////////////////////////////////////
364 cellstruct(cellstruct const &);
366 cellstruct & operator=(cellstruct const &);
387 0 ... don't use a box
390 This should be made into an enum (Lgb)
396 string align_special;
398 string p_width; // this is only set for multicolumn!!!
403 typedef std::vector<cellstruct> cell_vector;
405 typedef std::vector<cell_vector> cell_vvector;
414 // rowstruct & operator=(rowstruct const &);
423 /// This are for longtabulars only
427 typedef std::vector<rowstruct> row_vector;
430 struct columnstruct {
436 //columnstruct & operator=(columnstruct const &);
450 string align_special;
453 typedef std::vector<columnstruct> column_vector;
468 column_vector column_info;
470 mutable cell_vvector cell_info;
472 int width_of_tabular;
481 /// row of endfirsthead
485 /// row of endlastfoot
488 InsetTabular * owner_;
491 void Init(int columns_arg, int rows_arg);
495 void set_row_column_number_info();
496 /// Returns true if a complete update is necessary, otherwise false
497 bool SetWidthOfMulticolCell(int cell, int new_width);
498 void recalculateMulticolCells(int cell, int new_width);
499 /// Returns true if change
500 bool calculate_width_of_column(int column);
502 bool calculate_width_of_column_NMC(int column); // no multi cells
504 void calculate_width_of_tabular();
506 cellstruct * cellinfo_of_cell(int cell) const;
508 void delete_column(int column);
510 int cells_in_multicolumn(int cell) const;
512 bool UseParbox(int cell) const;