2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
22 #include "insets/insettext.h"
28 /* The features the text class offers for tables */
33 // Are the values of these enums important? (Lgb)
43 ALIGN_LEFT, // what are these alignment enums used for?
69 CELL_BEGIN_OF_MULTICOLUMN,
70 CELL_PART_OF_MULTICOLUMN
74 LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
77 LyXTabular(InsetTabular *, LyXTabular const &);
80 LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
84 LyXTabular & operator=(LyXTabular const &);
86 LyXTabular * Clone(InsetTabular *);
88 /// Returns true if there is a topline, returns false if not
89 bool TopLine(int cell) const;
90 /// Returns true if there is a topline, returns false if not
91 bool BottomLine(int cell) const;
92 /// Returns true if there is a topline, returns false if not
93 bool LeftLine(int cell) const;
94 /// Returns true if there is a topline, returns false if not
95 bool RightLine(int cell) const;
98 bool TopAlreadyDrawed(int cell) const;
100 bool LeftAlreadyDrawed(int cell) const;
102 bool IsLastRow(int cell) const;
105 int GetAdditionalHeight(int cell) const;
107 int GetAdditionalWidth(int cell) const;
109 /* returns the maximum over all rows */
111 int GetWidthOfColumn(int cell) const;
113 int GetWidthOfTabular() const;
115 int GetAscentOfRow(int row) const;
117 int GetDescentOfRow(int row) const;
119 int GetHeightOfTabular() const;
121 void SetAscentOfRow(int row, int height);
123 void SetDescentOfRow(int row, int height);
124 /// Returns true if a complete update is necessary, otherwise false
125 bool SetWidthOfCell(int cell, int new_width);
126 /// Returns true if a complete update is necessary, otherwise false
127 bool SetAllLines(int cell, bool line);
128 /// Returns true if a complete update is necessary, otherwise false
129 bool SetTopLine(int cell, bool line);
130 /// Returns true if a complete update is necessary, otherwise false
131 bool SetBottomLine(int cell, bool line);
132 /// Returns true if a complete update is necessary, otherwise false
133 bool SetLeftLine(int cell, bool line);
134 /// Returns true if a complete update is necessary, otherwise false
135 bool SetRightLine(int cell, bool line);
136 /// Returns true if a complete update is necessary, otherwise false
137 bool SetAlignment(int cell, char align);
139 bool SetPWidth(int cell, string const & width);
141 bool SetAlignSpecial(int cell, string const & special, int what);
143 char GetAlignment(int cell) const; // add approp. signedness
145 string GetPWidth(int cell) const;
147 string GetAlignSpecial(int cell, int what) const;
149 int GetWidthOfCell(int cell) const;
151 int GetBeginningOfTextInCell(int cell) const;
153 void AppendRow(int cell);
155 void DeleteRow(int cell);
157 void AppendColumn(int cell);
159 void DeleteColumn(int cell);
161 bool IsFirstCellInRow(int cell) const;
163 int GetFirstCellInRow(int row) const;
165 bool IsLastCellInRow(int cell) const;
167 int GetLastCellInRow(int row) const;
169 int GetNumberOfCells() const;
171 int NumberOfCellsInRow(int cell) const;
173 void Write(Buffer const *, std::ostream &) const;
175 void Read(Buffer const *, LyXLex &);
177 void OldFormatRead(LyXLex &, string const &);
179 /// helper function for Latex returns number of newlines
181 int TeXTopHLine(std::ostream &, int row) const;
182 int TeXBottomHLine(std::ostream &, int row) const;
183 int TeXCellPreamble(std::ostream &, int cell) const;
184 int TeXCellPostamble(std::ostream &, int cell) const;
186 int Latex(Buffer const *, std::ostream &, bool, bool) 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 int right_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 GetCellBelow(int cell) const;
231 int GetLastCellAbove(int cell) const;
233 int GetLastCellBelow(int cell) const;
235 int GetCellNumber(int row, int column) const;
237 void SetLinebreaks(int cell, bool what);
239 bool GetLinebreaks(int cell) const;
241 /// Long Tabular Options
243 void SetLTHead(int cell, bool first);
245 bool GetRowOfLTHead(int cell) const;
247 bool GetRowOfLTFirstHead(int cell) const;
249 void SetLTFoot(int cell, bool last);
251 bool GetRowOfLTFoot(int cell) const;
253 bool GetRowOfLTLastFoot(int cell) const;
255 void SetLTNewPage(int cell, bool what);
257 bool GetLTNewPage(int cell) const;
259 InsetText * GetCellInset(int cell) const;
261 int rows() const { return rows_; }
263 int columns() const { return columns_;}
265 InsetTabular * owner() const { return owner_; }
267 void Validate(LaTeXFeatures &) const;
269 private: //////////////////////////////////////////////////////////////////
278 cellstruct(cellstruct const &);
280 cellstruct & operator=(cellstruct const &);
287 int multicolumn; // add approp. signedness
289 int alignment; // add approp. signedness
299 string align_special;
301 string p_width; // this is only set for multicolumn!!!
305 typedef std::vector<cellstruct> cell_vector;
306 typedef std::vector<cell_vector> cell_vvector;
315 // rowstruct & operator=(rowstruct const &);
321 /// This are for longtabulars only
324 typedef std::vector<rowstruct> row_vector;
327 struct columnstruct {
333 //columnstruct & operator=(columnstruct const &);
335 int alignment; // add approp. signedness
340 string align_special;
342 typedef std::vector<columnstruct> column_vector;
357 column_vector column_info;
359 mutable cell_vvector cell_info;
361 int width_of_tabular;
363 /// for long tabulars
365 int endhead; // row of endhead
366 int endfirsthead; // row of endfirsthead
367 int endfoot; // row of endfoot
368 int endlastfoot; // row of endlastfoot
370 InsetTabular * owner_;
373 void Init(int columns_arg, int rows_arg);
377 void set_row_column_number_info();
378 /// Returns true if a complete update is necessary, otherwise false
379 bool SetWidthOfMulticolCell(int cell, int new_width);
380 void recalculateMulticolCells(int cell, int new_width);
381 /// Returns true if change
382 bool calculate_width_of_column(int column);
383 bool calculate_width_of_column_NMC(int column); // no multi cells
385 void calculate_width_of_tabular();
388 cellstruct * cellinfo_of_cell(int cell) const;
391 void delete_column(int column);
394 int cells_in_multicolumn(int cell) const;