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 NumberOfCellsInRow(int cell) const;
172 void Write(std::ostream &) const;
176 void OldFormatRead(LyXLex &, string const &);
178 /// helper function for Latex returns number of newlines
180 int TeXTopHLine(std::ostream &, int row) const;
181 int TeXBottomHLine(std::ostream &, int row) const;
182 int TeXCellPreamble(std::ostream &, int cell) const;
183 int TeXCellPostamble(std::ostream &, int cell) const;
185 int Latex(std::ostream &, bool, bool) 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 int right_column_of_cell(int cell) const;
210 void SetLongTabular(int what);
212 bool IsLongTabular() const;
214 void SetRotateTabular(int what);
216 bool GetRotateTabular() const;
218 void SetRotateCell(int cell, int what);
220 bool GetRotateCell(int cell) const;
222 bool NeedRotating() const;
224 bool IsLastCell(int cell) const;
226 int GetCellAbove(int cell) const;
228 int GetCellBelow(int cell) const;
230 int GetLastCellAbove(int cell) const;
232 int GetLastCellBelow(int cell) const;
234 int GetCellNumber(int row, int column) const;
236 void SetLinebreaks(int cell, bool what);
238 bool GetLinebreaks(int cell) const;
240 /// Long Tabular Options
242 void SetLTHead(int cell, bool first);
244 bool GetRowOfLTHead(int cell) const;
246 bool GetRowOfLTFirstHead(int cell) const;
248 void SetLTFoot(int cell, bool last);
250 bool GetRowOfLTFoot(int cell) const;
252 bool GetRowOfLTLastFoot(int cell) const;
254 void SetLTNewPage(int cell, bool what);
256 bool GetLTNewPage(int cell) const;
258 InsetText * GetCellInset(int cell) const;
260 int rows() const { return rows_; }
262 int columns() const { return columns_;}
264 InsetTabular * owner() const { return owner_; }
266 void Validate(LaTeXFeatures &) const;
268 private: //////////////////////////////////////////////////////////////////
276 cellstruct(cellstruct const &);
278 cellstruct & operator=(cellstruct const &);
284 int multicolumn; // add approp. signedness
286 int alignment; // add approp. signedness
296 string align_special;
298 string p_width; // this is only set for multicolumn!!!
302 typedef std::vector<cellstruct> cell_vector;
303 typedef std::vector<cell_vector> cell_vvector;
312 // rowstruct & operator=(rowstruct const &);
318 /// This are for longtabulars only
321 typedef std::vector<rowstruct> row_vector;
324 struct columnstruct {
330 //columnstruct & operator=(columnstruct const &);
332 int alignment; // add approp. signedness
337 string align_special;
339 typedef std::vector<columnstruct> column_vector;
354 column_vector column_info;
356 mutable cell_vvector cell_info;
358 int width_of_tabular;
360 /// for long tabulars
362 int endhead; // row of endhead
363 int endfirsthead; // row of endfirsthead
364 int endfoot; // row of endfoot
365 int endlastfoot; // row of endlastfoot
367 InsetTabular * owner_;
370 void Init(int columns_arg, int rows_arg);
374 void set_row_column_number_info();
375 /// Returns true if a complete update is necessary, otherwise false
376 bool SetWidthOfMulticolCell(int cell, int new_width);
377 void recalculateMulticolCells(int cell, int new_width);
378 /// Returns true if change
379 bool calculate_width_of_column(int column);
380 bool calculate_width_of_column_NMC(int column); // no multi cells
382 void calculate_width_of_tabular();
385 cellstruct * cellinfo_of_cell(int cell) const;
388 void delete_column(int column);
391 int cells_in_multicolumn(int cell) const;