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(InsetTabular *, int columns_arg, int rows_arg);
75 LyXTabular(InsetTabular *, LyXTabular const &);
78 LyXTabular(InsetTabular *, LyXLex & lex);
82 LyXTabular & operator=(LyXTabular const &);
84 LyXTabular * Clone(InsetTabular *);
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 int GetFirstCellInRow(int row) const;
163 bool IsLastCellInRow(int cell) const;
165 int GetLastCellInRow(int row) const;
167 int GetNumberOfCells() const;
169 int AppendCellAfterCell(int append_cell, int question_cell);
171 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
173 int NumberOfCellsInRow(int cell) const;
175 void Write(std::ostream &) const;
179 void OldFormatRead(std::istream &, string);
181 /// helper function for Latex returns number of newlines
183 int TeXTopHLine(std::ostream &, int row) const;
184 int TeXBottomHLine(std::ostream &, int row) const;
185 int TeXCellPreamble(std::ostream &, int cell) const;
186 int TeXCellPostamble(std::ostream &, int cell) const;
188 int Latex(std::ostream &, bool, bool) const;
190 int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
193 int RoffEndOfCell(std::ostream &, int cell);
196 char const * GetDocBookAlign(int cell, bool isColumn = false) const;
199 bool IsMultiColumn(int cell) const;
201 void SetMultiColumn(int cell, int number);
203 int UnsetMultiColumn(int cell); // returns number of new cells
205 bool IsPartOfMultiColumn(int row, int column) const;
207 int row_of_cell(int cell) const;
209 int column_of_cell(int cell) const;
211 void SetLongTabular(int what);
213 bool IsLongTabular() const;
215 void SetRotateTabular(int what);
217 bool GetRotateTabular() const;
219 void SetRotateCell(int cell, int what);
221 bool GetRotateCell(int cell) const;
223 bool NeedRotating() const;
225 bool IsLastCell(int cell) const;
227 int GetCellAbove(int cell) const;
229 int GetCellNumber(int row, int column) const;
231 void SetLinebreaks(int cell, bool what);
233 bool GetLinebreaks(int cell) const;
235 /// Long Tabular Options
237 void SetLTHead(int cell, bool first);
239 bool GetRowOfLTHead(int cell) const;
241 bool GetRowOfLTFirstHead(int cell) const;
243 void SetLTFoot(int cell, bool last);
245 bool GetRowOfLTFoot(int cell) const;
247 bool GetRowOfLTLastFoot(int cell) const;
249 void SetLTNewPage(int cell, bool what);
251 bool GetLTNewPage(int cell) const;
253 InsetText * GetCellInset(int cell) const;
255 int rows() const { return rows_; }
257 int columns() const { return columns_;}
259 InsetTabular * owner() const { return owner_; }
261 private: //////////////////////////////////////////////////////////////////
269 cellstruct(cellstruct const &);
271 cellstruct & operator=(cellstruct const &);
277 int multicolumn; // add approp. signedness
279 int alignment; // add approp. signedness
289 string align_special;
291 string p_width; // this is only set for multicolumn!!!
302 // rowstruct & operator=(rowstruct const &);
308 /// This are for longtabulars only
312 struct columnstruct {
318 //columnstruct & operator=(columnstruct const &);
320 int alignment; // add approp. signedness
325 string align_special;
338 std::vector<rowstruct> row_info;
340 std::vector<columnstruct> column_info;
342 mutable std::vector< std::vector<cellstruct> > cell_info;
344 int width_of_tabular;
346 /// for long tabulars
348 int endhead; // row of endhead
349 int endfirsthead; // row of endfirsthead
350 int endfoot; // row of endfoot
351 int endlastfoot; // row of endlastfoot
353 InsetTabular * owner_;
356 void Init(int columns_arg, int rows_arg);
360 void set_row_column_number_info();
361 /// Returns true if a complete update is necessary, otherwise false
362 bool SetWidthOfMulticolCell(int cell, int new_width);
363 void recalculateMulticolCells(int cell, int new_width);
364 /// Returns true if change
365 bool calculate_width_of_column(int column);
366 bool calculate_width_of_column_NMC(int column); // no multi cells
368 void calculate_width_of_tabular();
371 int right_column_of_cell(int cell) const;
374 cellstruct * cellinfo_of_cell(int cell) const;
377 void delete_column(int column);
380 int cells_in_multicolumn(int cell) const;