2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
26 /* The features the text class offers for tables */
31 // Are the values of these enums important? (Lgb)
41 ALIGN_LEFT, // what are these alignment enums used for?
67 CELL_BEGIN_OF_MULTICOLUMN,
68 CELL_PART_OF_MULTICOLUMN
72 LyXTabular(int columns_arg, int rows_arg, Buffer *buf);
75 LyXTabular(LyXTabular const &, Buffer *buf);
78 LyXTabular(LyXLex & lex, Buffer *buf);
82 LyXTabular & operator=(LyXTabular const &);
84 LyXTabular * Clone(Buffer * buf);
86 /// Returns true if there is a topline, returns false if not
87 bool TopLine(int cell) const;
88 /// Returns true if there is a topline, returns false if not
89 bool BottomLine(int cell) const;
90 /// Returns true if there is a topline, returns false if not
91 bool LeftLine(int cell) const;
92 /// Returns true if there is a topline, returns false if not
93 bool RightLine(int cell) const;
96 bool TopAlreadyDrawed(int cell) const;
98 bool LeftAlreadyDrawed(int cell) const;
100 bool IsLastRow(int cell) const;
103 int GetAdditionalHeight(int cell) const;
105 int GetAdditionalWidth(int cell) const;
107 /* returns the maximum over all rows */
109 int GetWidthOfColumn(int cell) const;
111 int GetWidthOfTabular() const;
113 int GetAscentOfRow(int row) const;
115 int GetDescentOfRow(int row) const;
117 int GetHeightOfTabular() const;
119 void SetAscentOfRow(int row, int height);
121 void SetDescentOfRow(int row, int height);
122 /// Returns true if a complete update is necessary, otherwise false
123 bool SetWidthOfCell(int cell, int new_width);
124 /// Returns true if a complete update is necessary, otherwise false
125 bool SetAllLines(int cell, bool line);
126 /// Returns true if a complete update is necessary, otherwise false
127 bool SetTopLine(int cell, bool line);
128 /// Returns true if a complete update is necessary, otherwise false
129 bool SetBottomLine(int cell, bool line);
130 /// Returns true if a complete update is necessary, otherwise false
131 bool SetLeftLine(int cell, bool line);
132 /// Returns true if a complete update is necessary, otherwise false
133 bool SetRightLine(int cell, bool line);
134 /// Returns true if a complete update is necessary, otherwise false
135 bool SetAlignment(int cell, char align);
137 bool SetPWidth(int cell, string width);
139 bool SetAlignSpecial(int cell, string special, int what);
141 char GetAlignment(int cell) const; // add approp. signedness
143 string GetPWidth(int cell) const;
145 string GetAlignSpecial(int cell, int what) const;
147 int GetWidthOfCell(int cell) const;
149 int GetBeginningOfTextInCell(int cell) const;
151 void AppendRow(int cell);
153 void DeleteRow(int cell);
155 void AppendColumn(int cell);
157 void DeleteColumn(int cell);
159 bool IsFirstCellInRow(int cell) const;
161 bool IsLastCellInRow(int cell) const;
163 int GetNumberOfCells() const;
165 int AppendCellAfterCell(int append_cell, int question_cell);
167 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
169 int NumberOfCellsInRow(int cell) const;
173 void Init(Buffer * buf, int columns_arg, int rows_arg);
175 void Write(std::ostream &) const;
179 void OldFormatRead(std::istream &, string);
181 int Latex(std::ostream &) const;
183 // cell <0 will tex the preamble
184 // returns the number of printed newlines
186 int TexEndOfCell(std::ostream &, int cell) const;
188 int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
191 int RoffEndOfCell(std::ostream &, int cell);
194 char const * GetDocBookAlign(int cell, bool isColumn = false) const;
197 bool IsMultiColumn(int cell) const;
199 void SetMultiColumn(int cell, int number);
201 int UnsetMultiColumn(int cell); // returns number of new cells
203 bool IsPartOfMultiColumn(int row, int column) const;
205 int row_of_cell(int cell) const;
207 int column_of_cell(int cell) const;
209 void SetLongTabular(int what);
211 bool IsLongTabular() const;
213 void SetRotateTabular(int what);
215 bool GetRotateTabular() const;
217 void SetRotateCell(int cell, int what);
219 bool GetRotateCell(int cell) const;
221 bool NeedRotating() const;
223 bool IsLastCell(int cell) const;
225 int GetCellAbove(int cell) const;
227 int GetCellNumber(int column, int row) const;
229 void SetLinebreaks(int cell, bool what);
231 bool GetLinebreaks(int cell) const;
233 /// Long Tabular Options
235 void SetLTHead(int cell, bool first);
237 bool GetRowOfLTHead(int cell) const;
239 bool GetRowOfLTFirstHead(int cell) const;
241 void SetLTFoot(int cell, bool last);
243 bool GetRowOfLTFoot(int cell) const;
245 bool GetRowOfLTLastFoot(int cell) const;
247 void SetLTNewPage(int cell, bool what);
249 bool GetLTNewPage(int cell) const;
251 InsetText * GetCellInset(int cell) const;
253 int rows() const { return rows_; }
255 int columns() const { return columns_;}
257 private: //////////////////////////////////////////////////////////////////
265 cellstruct & operator=(cellstruct const &);
271 int multicolumn; // add approp. signedness
273 int alignment; // add approp. signedness
283 string align_special;
285 string p_width; // this is only set for multicolumn!!!
296 rowstruct & operator=(rowstruct const &);
302 /// This are for longtabulars only
306 struct columnstruct {
312 columnstruct & operator=(columnstruct const &);
314 int alignment; // add approp. signedness
319 string align_special;
332 std::vector<rowstruct> row_info;
334 std::vector<columnstruct> column_info;
336 mutable std::vector< std::vector<cellstruct> > cell_info;
338 int width_of_tabular;
340 /// for long tabulars
342 int endhead; // row of endhead
343 int endfirsthead; // row of endfirsthead
344 int endfoot; // row of endfoot
345 int endlastfoot; // row of endlastfoot
350 void set_row_column_number_info();
351 /// Returns true if a complete update is necessary, otherwise false
352 bool SetWidthOfMulticolCell(int cell, int new_width);
353 void recalculateMulticolCells(int cell, int new_width);
354 /// Returns true if change
355 bool calculate_width_of_column(int column);
356 bool calculate_width_of_column_NMC(int column); // no multi cells
358 void calculate_width_of_tabular();
361 int right_column_of_cell(int cell) const;
364 cellstruct * cellinfo_of_cell(int cell) const;
367 void delete_column(int column);
370 int cells_in_multicolumn(int cell) const;