2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
27 /* The features the text class offers for tables */
32 // Are the values of these enums important? (Lgb)
42 ALIGN_LEFT, // what are these alignment enums used for?
68 CELL_BEGIN_OF_MULTICOLUMN,
69 CELL_PART_OF_MULTICOLUMN
73 LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
76 LyXTabular(InsetTabular *, LyXTabular const &);
79 LyXTabular(InsetTabular *, LyXLex & lex);
83 LyXTabular & operator=(LyXTabular const &);
85 LyXTabular * Clone(InsetTabular *);
87 /// Returns true if there is a topline, returns false if not
88 bool TopLine(int cell) const;
89 /// Returns true if there is a topline, returns false if not
90 bool BottomLine(int cell) const;
91 /// Returns true if there is a topline, returns false if not
92 bool LeftLine(int cell) const;
93 /// Returns true if there is a topline, returns false if not
94 bool RightLine(int cell) const;
97 bool TopAlreadyDrawed(int cell) const;
99 bool LeftAlreadyDrawed(int cell) const;
101 bool IsLastRow(int cell) const;
104 int GetAdditionalHeight(int cell) const;
106 int GetAdditionalWidth(int cell) const;
108 /* returns the maximum over all rows */
110 int GetWidthOfColumn(int cell) const;
112 int GetWidthOfTabular() const;
114 int GetAscentOfRow(int row) const;
116 int GetDescentOfRow(int row) const;
118 int GetHeightOfTabular() const;
120 void SetAscentOfRow(int row, int height);
122 void SetDescentOfRow(int row, int height);
123 /// Returns true if a complete update is necessary, otherwise false
124 bool SetWidthOfCell(int cell, int new_width);
125 /// Returns true if a complete update is necessary, otherwise false
126 bool SetAllLines(int cell, bool line);
127 /// Returns true if a complete update is necessary, otherwise false
128 bool SetTopLine(int cell, bool line);
129 /// Returns true if a complete update is necessary, otherwise false
130 bool SetBottomLine(int cell, bool line);
131 /// Returns true if a complete update is necessary, otherwise false
132 bool SetLeftLine(int cell, bool line);
133 /// Returns true if a complete update is necessary, otherwise false
134 bool SetRightLine(int cell, bool line);
135 /// Returns true if a complete update is necessary, otherwise false
136 bool SetAlignment(int cell, char align);
138 bool SetPWidth(int cell, string const & width);
140 bool SetAlignSpecial(int cell, string const & special, int what);
142 char GetAlignment(int cell) const; // add approp. signedness
144 string GetPWidth(int cell) const;
146 string GetAlignSpecial(int cell, int what) const;
148 int GetWidthOfCell(int cell) const;
150 int GetBeginningOfTextInCell(int cell) const;
152 void AppendRow(int cell);
154 void DeleteRow(int cell);
156 void AppendColumn(int cell);
158 void DeleteColumn(int cell);
160 bool IsFirstCellInRow(int cell) const;
162 int GetFirstCellInRow(int row) const;
164 bool IsLastCellInRow(int cell) const;
166 int GetLastCellInRow(int row) const;
168 int GetNumberOfCells() const;
170 int AppendCellAfterCell(int append_cell, int question_cell);
172 int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
174 int NumberOfCellsInRow(int cell) const;
176 void Write(std::ostream &) const;
180 void OldFormatRead(LyXLex &, string const &);
182 /// helper function for Latex returns number of newlines
184 int TeXTopHLine(std::ostream &, int row) const;
185 int TeXBottomHLine(std::ostream &, int row) const;
186 int TeXCellPreamble(std::ostream &, int cell) const;
187 int TeXCellPostamble(std::ostream &, int cell) const;
189 int Latex(std::ostream &, bool, bool) const;
191 int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
194 int RoffEndOfCell(std::ostream &, int cell);
197 char const * GetDocBookAlign(int cell, bool isColumn = false) const;
200 bool IsMultiColumn(int cell) const;
202 void SetMultiColumn(int cell, int number);
204 int UnsetMultiColumn(int cell); // returns number of new cells
206 bool IsPartOfMultiColumn(int row, int column) const;
208 int row_of_cell(int cell) const;
210 int column_of_cell(int cell) const;
212 void SetLongTabular(int what);
214 bool IsLongTabular() const;
216 void SetRotateTabular(int what);
218 bool GetRotateTabular() const;
220 void SetRotateCell(int cell, int what);
222 bool GetRotateCell(int cell) const;
224 bool NeedRotating() const;
226 bool IsLastCell(int cell) const;
228 int GetCellAbove(int cell) const;
230 int GetCellNumber(int row, int column) const;
232 void SetLinebreaks(int cell, bool what);
234 bool GetLinebreaks(int cell) const;
236 /// Long Tabular Options
238 void SetLTHead(int cell, bool first);
240 bool GetRowOfLTHead(int cell) const;
242 bool GetRowOfLTFirstHead(int cell) const;
244 void SetLTFoot(int cell, bool last);
246 bool GetRowOfLTFoot(int cell) const;
248 bool GetRowOfLTLastFoot(int cell) const;
250 void SetLTNewPage(int cell, bool what);
252 bool GetLTNewPage(int cell) const;
254 InsetText * GetCellInset(int cell) const;
256 int rows() const { return rows_; }
258 int columns() const { return columns_;}
260 InsetTabular * owner() const { return owner_; }
262 void Validate(LaTeXFeatures &) const;
264 private: //////////////////////////////////////////////////////////////////
272 cellstruct(cellstruct const &);
274 cellstruct & operator=(cellstruct const &);
280 int multicolumn; // add approp. signedness
282 int alignment; // add approp. signedness
292 string align_special;
294 string p_width; // this is only set for multicolumn!!!
305 // rowstruct & operator=(rowstruct const &);
311 /// This are for longtabulars only
315 struct columnstruct {
321 //columnstruct & operator=(columnstruct const &);
323 int alignment; // add approp. signedness
328 string align_special;
341 std::vector<rowstruct> row_info;
343 std::vector<columnstruct> column_info;
345 mutable std::vector< std::vector<cellstruct> > cell_info;
347 int width_of_tabular;
349 /// for long tabulars
351 int endhead; // row of endhead
352 int endfirsthead; // row of endfirsthead
353 int endfoot; // row of endfoot
354 int endlastfoot; // row of endlastfoot
356 InsetTabular * owner_;
359 void Init(int columns_arg, int rows_arg);
363 void set_row_column_number_info();
364 /// Returns true if a complete update is necessary, otherwise false
365 bool SetWidthOfMulticolCell(int cell, int new_width);
366 void recalculateMulticolCells(int cell, int new_width);
367 /// Returns true if change
368 bool calculate_width_of_column(int column);
369 bool calculate_width_of_column_NMC(int column); // no multi cells
371 void calculate_width_of_tabular();
374 int right_column_of_cell(int cell) const;
377 cellstruct * cellinfo_of_cell(int cell) const;
380 void delete_column(int column);
383 int cells_in_multicolumn(int cell) const;