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);
74 LyXTabular(LyXTabular const &, Buffer *buf);
77 LyXTabular(LyXLex & lex, Buffer *buf);
81 LyXTabular & operator=(LyXTabular const &);
83 LyXTabular * Clone(Buffer * buf);
85 /// Returns true if there is a topline, returns false if not
86 bool TopLine(int cell) const;
87 /// Returns true if there is a topline, returns false if not
88 bool BottomLine(int cell) const;
89 /// Returns true if there is a topline, returns false if not
90 bool LeftLine(int cell) const;
91 /// Returns true if there is a topline, returns false if not
92 bool RightLine(int cell) const;
95 bool TopAlreadyDrawed(int cell) const;
97 bool LeftAlreadyDrawed(int cell) const;
99 bool IsLastRow(int cell) const;
102 int GetAdditionalHeight(int cell) const;
104 int GetAdditionalWidth(int cell) const;
106 /* returns the maximum over all rows */
108 int GetWidthOfColumn(int cell) const;
110 int GetWidthOfTabular() const;
112 int GetAscentOfRow(int row) const;
114 int GetDescentOfRow(int row) const;
116 int GetHeightOfTabular() const;
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) const; // add approp. signedness
142 string GetPWidth(int cell) const;
144 string GetAlignSpecial(int cell, int what) const;
146 int GetWidthOfCell(int cell) const;
148 int GetBeginningOfTextInCell(int cell) const;
150 void AppendRow(int cell);
152 void DeleteRow(int cell);
154 void AppendColumn(int cell);
156 void DeleteColumn(int cell);
158 bool IsFirstCellInRow(int cell) const;
160 bool IsLastCellInRow(int cell) const;
162 int GetNumberOfCells() const;
164 int AppendCellAfterCell(int append_cell, int question_cell);
166 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
168 int NumberOfCellsInRow(int cell) const;
172 void Init(int columns_arg, int rows_arg);
174 void Write(std::ostream &) const;
178 void OldFormatRead(std::istream &, string);
180 int Latex(std::ostream &) const;
182 // cell <0 will tex the preamble
183 // returns the number of printed newlines
185 int TexEndOfCell(std::ostream &, int cell) const;
187 int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
190 int RoffEndOfCell(std::ostream &, int cell);
193 char const * GetDocBookAlign(int cell, bool isColumn = false) const;
196 bool IsMultiColumn(int cell) const;
198 void SetMultiColumn(int cell, int number);
200 int UnsetMultiColumn(int cell); // returns number of new cells
202 bool IsPartOfMultiColumn(int row, int column) const;
204 int row_of_cell(int cell) const;
206 int column_of_cell(int cell) const;
208 void SetLongTabular(int what);
210 bool IsLongTabular() const;
212 void SetRotateTabular(int what);
214 bool GetRotateTabular() const;
216 void SetRotateCell(int cell, int what);
218 bool GetRotateCell(int cell) const;
220 bool NeedRotating() const;
222 bool IsLastCell(int cell) const;
224 int GetCellAbove(int cell) const;
226 int GetCellNumber(int column, int row) const;
228 void SetLinebreaks(int cell, bool what);
230 bool GetLinebreaks(int cell) const;
232 /// Long Tabular Options
234 void SetLTHead(int cell, bool first);
236 bool GetRowOfLTHead(int cell) const;
238 bool GetRowOfLTFirstHead(int cell) const;
240 void SetLTFoot(int cell, bool last);
242 bool GetRowOfLTFoot(int cell) const;
244 bool GetRowOfLTLastFoot(int cell) const;
246 void SetLTNewPage(int cell, bool what);
248 bool GetLTNewPage(int cell) const;
250 InsetText * GetCellInset(int cell) const;
252 int rows() const { return rows_; }
254 int columns() const { return columns_;}
256 private: //////////////////////////////////////////////////////////////////
260 cellstruct(Buffer * buf);
264 cellstruct & operator=(cellstruct const &);
270 int multicolumn; // add approp. signedness
272 int alignment; // add approp. signedness
282 string align_special;
284 string p_width; // this is only set for multicolumn!!!
295 rowstruct & operator=(rowstruct const &);
301 /// This are for longtabulars only
305 struct columnstruct {
311 columnstruct & operator=(columnstruct const &);
313 int alignment; // add approp. signedness
318 string align_special;
331 rowstruct * row_info;
333 columnstruct * column_info;
335 cellstruct ** cell_info;
337 int width_of_tabular;
339 /// for long tabulars
341 int endhead; // row of endhead
342 int endfirsthead; // row of endfirsthead
343 int endfoot; // row of endfoot
344 int endlastfoot; // row of endlastfoot
349 void set_row_column_number_info();
350 /// Returns true if a complete update is necessary, otherwise false
351 bool SetWidthOfMulticolCell(int cell, int new_width);
352 void recalculateMulticolCells(int cell, int new_width);
353 /// Returns true if change
354 bool calculate_width_of_column(int column);
355 bool calculate_width_of_column_NMC(int column); // no multi cells
357 void calculate_width_of_tabular();
360 int right_column_of_cell(int cell) const;
363 cellstruct * cellinfo_of_cell(int cell) const;
366 void delete_column(int column);
369 int cells_in_multicolumn(int cell) const;