// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 2000 The LyX Team.
+/**
+ * \file tabular.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * @author: Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ * \author André Pönitz
+ * \author Jürgen Vigna
*
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
+
#ifndef TABULAR_H
#define TABULAR_H
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "lyxlength.h"
+#include "insets/insettext.h"
+
+#include <boost/shared_ptr.hpp>
#include <iosfwd>
#include <vector>
-#include "lyxlex.h"
-#include "LString.h"
-#include "insets/insettext.h"
+
+namespace lyx {
class InsetTabular;
-class LaTeXFeatures;
-class Buffer;
+class LCursor;
+class OutputParams;
-/* The features the text class offers for tables */
+/* The features the text class offers for tables */
///
class LyXTabular {
public:
- ///
- enum Feature {
///
- APPEND_ROW = 0,
+ enum Feature {
+ ///
+ APPEND_ROW = 0,
+ ///
+ APPEND_COLUMN,
+ ///
+ DELETE_ROW,
+ ///
+ DELETE_COLUMN,
+ ///
+ COPY_ROW,
+ ///
+ COPY_COLUMN,
+ ///
+ TOGGLE_LINE_TOP,
+ ///
+ TOGGLE_LINE_BOTTOM,
+ ///
+ TOGGLE_LINE_LEFT,
+ ///
+ TOGGLE_LINE_RIGHT,
+ ///
+ ALIGN_LEFT,
+ ///
+ ALIGN_RIGHT,
+ ///
+ ALIGN_CENTER,
+ ///
+ ALIGN_BLOCK,
+ ///
+ VALIGN_TOP,
+ ///
+ VALIGN_BOTTOM,
+ ///
+ VALIGN_MIDDLE,
+ ///
+ M_TOGGLE_LINE_TOP,
+ ///
+ M_TOGGLE_LINE_BOTTOM,
+ ///
+ M_TOGGLE_LINE_LEFT,
+ ///
+ M_TOGGLE_LINE_RIGHT,
+ ///
+ M_ALIGN_LEFT,
+ ///
+ M_ALIGN_RIGHT,
+ ///
+ M_ALIGN_CENTER,
+ ///
+ M_VALIGN_TOP,
+ ///
+ M_VALIGN_BOTTOM,
+ ///
+ M_VALIGN_MIDDLE,
+ ///
+ MULTICOLUMN,
+ ///
+ SET_ALL_LINES,
+ ///
+ UNSET_ALL_LINES,
+ ///
+ SET_LONGTABULAR,
+ ///
+ UNSET_LONGTABULAR,
+ ///
+ SET_PWIDTH,
+ ///
+ SET_MPWIDTH,
+ ///
+ SET_ROTATE_TABULAR,
+ ///
+ UNSET_ROTATE_TABULAR,
+ ///
+ SET_ROTATE_CELL,
+ ///
+ UNSET_ROTATE_CELL,
+ ///
+ SET_USEBOX,
+ ///
+ SET_LTHEAD,
+ UNSET_LTHEAD,
+ ///
+ SET_LTFIRSTHEAD,
+ UNSET_LTFIRSTHEAD,
+ ///
+ SET_LTFOOT,
+ UNSET_LTFOOT,
+ ///
+ SET_LTLASTFOOT,
+ UNSET_LTLASTFOOT,
+ ///
+ SET_LTNEWPAGE,
+ ///
+ SET_SPECIAL_COLUMN,
+ ///
+ SET_SPECIAL_MULTI,
+ ///
+ SET_BOOKTABS,
+ ///
+ UNSET_BOOKTABS,
+ ///
+ SET_TOP_SPACE,
+ ///
+ SET_BOTTOM_SPACE,
+ ///
+ SET_INTERLINE_SPACE,
+ ///
+ LAST_ACTION
+ };
+ ///
+ enum {
+ ///
+ CELL_NORMAL = 0,
+ ///
+ CELL_BEGIN_OF_MULTICOLUMN,
+ ///
+ CELL_PART_OF_MULTICOLUMN
+ };
+
///
- APPEND_COLUMN,
+ enum VAlignment {
+ ///
+ LYX_VALIGN_TOP = 0,
+ ///
+ LYX_VALIGN_BOTTOM = 1,
+ ///
+ LYX_VALIGN_MIDDLE = 2
+ };
+
+ enum BoxType {
+ ///
+ BOX_NONE = 0,
+ ///
+ BOX_PARBOX = 1,
+ ///
+ BOX_MINIPAGE = 2
+ };
+
+ class ltType {
+ public:
+ // constructor
+ ltType();
+ // we have this header type (is set in the getLT... functions)
+ bool set;
+ // double borders on top
+ bool topDL;
+ // double borders on bottom
+ bool bottomDL;
+ // used for FirstHeader & LastFooter and if this is true
+ // all the rows marked as FirstHeader or LastFooter are
+ // ignored in the output and it is set to be empty!
+ bool empty;
+ };
+
+ /// type for row numbers
+ typedef size_t row_type;
+ /// type for column numbers
+ typedef size_t col_type;
+ /// type for cell indices
+ typedef size_t idx_type;
+ /// index indicating an invalid position
+ static const idx_type npos = static_cast<idx_type>(-1);
+
+ /// constructor
+ LyXTabular(BufferParams const &, col_type columns_arg,
+ row_type rows_arg);
+
+ /// Returns true if there is a topline, returns false if not
+ bool topLine(idx_type cell, bool wholerow = false) const;
+ /// Returns true if there is a topline, returns false if not
+ bool bottomLine(idx_type cell, bool wholerow = false) const;
+ /// Returns true if there is a topline, returns false if not
+ bool leftLine(idx_type cell, bool wholecolumn = false) const;
+ /// Returns true if there is a topline, returns false if not
+ bool rightLine(idx_type cell, bool wholecolumn = false) const;
+
///
- DELETE_ROW,
+ bool topAlreadyDrawn(idx_type cell) const;
///
- DELETE_COLUMN,
+ bool leftAlreadyDrawn(idx_type cell) const;
///
- TOGGLE_LINE_TOP,
+ bool isLastRow(idx_type cell) const;
+
+ /// return space occupied by the second horizontal line and
+ /// interline space above row \p row in pixels
+ int getAdditionalHeight(row_type row) const;
///
- TOGGLE_LINE_BOTTOM,
+ int getAdditionalWidth(idx_type cell) const;
+
+ /* returns the maximum over all rows */
///
- TOGGLE_LINE_LEFT,
+ int getWidthOfColumn(idx_type cell) const;
///
- TOGGLE_LINE_RIGHT,
+ int getWidthOfTabular() const;
///
- ALIGN_LEFT,
+ int getAscentOfRow(row_type row) const;
///
- ALIGN_RIGHT,
+ int getDescentOfRow(row_type row) const;
///
- ALIGN_CENTER,
+ int getHeightOfTabular() const;
///
- VALIGN_TOP,
+ void setAscentOfRow(row_type row, int height);
///
- VALIGN_BOTTOM,
+ void setDescentOfRow(row_type row, int height);
///
- VALIGN_CENTER,
+ void setWidthOfCell(idx_type cell, int new_width);
///
- M_TOGGLE_LINE_TOP,
+ void setAllLines(idx_type cell, bool line);
///
- M_TOGGLE_LINE_BOTTOM,
+ void setTopLine(idx_type cell, bool line, bool wholerow = false);
///
- M_TOGGLE_LINE_LEFT,
+ void setBottomLine(idx_type cell, bool line, bool wholerow = false);
///
- M_TOGGLE_LINE_RIGHT,
+ void setLeftLine(idx_type cell, bool line, bool wholecolumn = false);
///
- M_ALIGN_LEFT,
+ void setRightLine(idx_type cell, bool line, bool wholecolumn = false);
///
- M_ALIGN_RIGHT,
+ void setAlignment(idx_type cell, LyXAlignment align,
+ bool onlycolumn = false);
///
- M_ALIGN_CENTER,
+ void setVAlignment(idx_type cell, VAlignment align,
+ bool onlycolumn = false);
///
- M_VALIGN_TOP,
+ void setColumnPWidth(LCursor &, idx_type, LyXLength const &);
///
- M_VALIGN_BOTTOM,
+ bool setMColumnPWidth(LCursor &, idx_type, LyXLength const &);
///
- M_VALIGN_CENTER,
+ void setAlignSpecial(idx_type cell, docstring const & special,
+ Feature what);
///
- MULTICOLUMN,
+ LyXAlignment getAlignment(idx_type cell,
+ bool onlycolumn = false) const;
///
- SET_ALL_LINES,
+ VAlignment getVAlignment(idx_type cell,
+ bool onlycolumn = false) const;
///
- UNSET_ALL_LINES,
+ LyXLength const getPWidth(idx_type cell) const;
///
- SET_LONGTABULAR,
+ LyXLength const getColumnPWidth(idx_type cell) const;
///
- UNSET_LONGTABULAR,
+ LyXLength const getMColumnPWidth(idx_type cell) const;
///
- SET_PWIDTH,
+ docstring const getAlignSpecial(idx_type cell, int what) const;
///
- SET_MPWIDTH,
+ int getWidthOfCell(idx_type cell) const;
///
- SET_ROTATE_TABULAR,
+ int getBeginningOfTextInCell(idx_type cell) const;
///
- UNSET_ROTATE_TABULAR,
+ void appendRow(BufferParams const &, idx_type cell);
///
- SET_ROTATE_CELL,
+ void deleteRow(row_type row);
///
- UNSET_ROTATE_CELL,
+ void copyRow(BufferParams const &, row_type);
///
- SET_USEBOX,
+ void appendColumn(BufferParams const &, idx_type cell);
///
- SET_LTHEAD,
+ void deleteColumn(col_type column);
///
- SET_LTFIRSTHEAD,
+ void copyColumn(BufferParams const &, col_type);
///
- SET_LTFOOT,
+ bool isFirstCellInRow(idx_type cell) const;
///
- SET_LTLASTFOOT,
+ idx_type getFirstCellInRow(row_type row) const;
///
- SET_LTNEWPAGE,
+ bool isLastCellInRow(idx_type cell) const;
///
- SET_SPECIAL_COLUMN,
+ idx_type getLastCellInRow(row_type row) const;
///
- SET_SPECIAL_MULTI,
+ idx_type getNumberOfCells() const;
///
- LAST_ACTION
- };
- ///
- enum {
+ idx_type numberOfCellsInRow(idx_type cell) const;
///
- CELL_NORMAL = 0,
+ void write(Buffer const &, std::ostream &) const;
///
- CELL_BEGIN_OF_MULTICOLUMN,
+ void read(Buffer const &, LyXLex &);
///
- CELL_PART_OF_MULTICOLUMN
- };
-
- ///
- enum VAlignment {
+ int latex(Buffer const &, odocstream &, OutputParams const &) const;
+ //
+ int docbook(Buffer const & buf, odocstream & os, OutputParams const &) const;
///
- LYX_VALIGN_TOP = 0,
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const & runparams,
+ int const depth,
+ bool onlydata, unsigned char delim) const;
///
- LYX_VALIGN_BOTTOM = 1,
+ bool isMultiColumn(idx_type cell) const;
///
- LYX_VALIGN_CENTER = 2
- };
-
- enum BoxType {
+ bool isMultiColumnReal(idx_type cell) const;
///
- BOX_NONE = 0,
+ void setMultiColumn(Buffer *, idx_type cell, idx_type number);
///
- BOX_PARBOX = 1,
+ idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
///
- BOX_MINIPAGE = 2
- };
-
- /* konstruktor */
- ///
- LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
- ///
- LyXTabular(InsetTabular *, LyXTabular const &);
- ///
- explicit
- LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
- ///
- LyXTabular & operator=(LyXTabular const &);
- ///
- LyXTabular * Clone(InsetTabular *);
-
- /// Returns true if there is a topline, returns false if not
- bool TopLine(int cell, bool onlycolumn = false) const;
- /// Returns true if there is a topline, returns false if not
- bool BottomLine(int cell, bool onlycolumn = false) const;
- /// Returns true if there is a topline, returns false if not
- bool LeftLine(int cell, bool onlycolumn = false) const;
- /// Returns true if there is a topline, returns false if not
- bool RightLine(int cell, bool onlycolumn = false) const;
-
- ///
- bool TopAlreadyDrawed(int cell) const;
- ///
- bool LeftAlreadyDrawed(int cell) const;
- ///
- bool IsLastRow(int cell) const;
-
- ///
- int GetAdditionalHeight(int cell) const;
- ///
- int GetAdditionalWidth(int cell) const;
-
- /* returns the maximum over all rows */
- ///
- int GetWidthOfColumn(int cell) const;
- ///
- int GetWidthOfTabular() const;
- ///
- int GetAscentOfRow(int row) const;
- ///
- int GetDescentOfRow(int row) const;
- ///
- int GetHeightOfTabular() const;
- /// Returns true if a complete update is necessary, otherwise false
- bool SetAscentOfRow(int row, int height);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetDescentOfRow(int row, int height);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetWidthOfCell(int cell, int new_width);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetAllLines(int cell, bool line);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetTopLine(int cell, bool line, bool onlycolumn=false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetBottomLine(int cell, bool line, bool onlycolumn=false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetLeftLine(int cell, bool line, bool onlycolumn=false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetRightLine(int cell, bool line, bool onlycolumn=false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetAlignment(int cell, LyXAlignment align, bool onlycolumn = false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false);
- ///
- bool SetColumnPWidth(int cell, string const & width);
- ///
- bool SetMColumnPWidth(int cell, string const & width);
- ///
- bool SetAlignSpecial(int cell, string const & special, Feature what);
- ///
- LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
- ///
- VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
- ///
- string const GetPWidth(int cell) const;
- ///
- string const GetColumnPWidth(int cell) const;
- ///
- string const GetMColumnPWidth(int cell) const;
- ///
- string const GetAlignSpecial(int cell, int what) const;
- ///
- int GetWidthOfCell(int cell) const;
- ///
- int GetBeginningOfTextInCell(int cell) const;
- ///
- void AppendRow(int cell);
- ///
- void DeleteRow(int row);
- ///
- void AppendColumn(int cell);
- ///
- void DeleteColumn(int column);
- ///
- bool IsFirstCellInRow(int cell) const;
- ///
- int GetFirstCellInRow(int row) const;
- ///
- bool IsLastCellInRow(int cell) const;
- ///
- int GetLastCellInRow(int row) const;
- ///
- int GetNumberOfCells() const;
- ///
- int NumberOfCellsInRow(int cell) const;
- ///
- void Write(Buffer const *, std::ostream &) const;
- ///
- void Read(Buffer const *, LyXLex &);
- ///
- void OldFormatRead(LyXLex &, string const &);
- //
- // helper function for Latex returns number of newlines
- ///
- int TeXTopHLine(std::ostream &, int row) const;
- ///
- int TeXBottomHLine(std::ostream &, int row) const;
- ///
- int TeXCellPreamble(std::ostream &, int cell) const;
- ///
- int TeXCellPostamble(std::ostream &, int cell) const;
- ///
- int Latex(Buffer const *, std::ostream &, bool, bool) const;
- ///
- int DocBook(Buffer const * buf, std::ostream & os) const;
- ///
- // helper function for Latex returns number of newlines
- ///
- int AsciiTopHLine(std::ostream &, int row,
- std::vector<unsigned int> const &) const;
- ///
- int AsciiBottomHLine(std::ostream &, int row,
- std::vector<unsigned int> const &) const;
- ///
- int AsciiPrintCell(Buffer const *, std::ostream &, int cell, int row,
- int column, std::vector<unsigned int> const &) const;
- ///
- int Ascii(Buffer const *, std::ostream &) const;
- ///
- int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
-#if 0
- ///
- int RoffEndOfCell(std::ostream &, int cell);
-#endif
- ///
- string const GetDocBookAlign(int cell, bool isColumn = false) const;
+ bool isPartOfMultiColumn(row_type row, col_type column) const;
+ ///
+ row_type row_of_cell(idx_type cell) const;
+ ///
+ col_type column_of_cell(idx_type cell) const;
+ ///
+ col_type right_column_of_cell(idx_type cell) const;
+ ///
+ void setBookTabs(bool);
+ ///
+ bool useBookTabs() const;
+ ///
+ void setLongTabular(bool);
+ ///
+ bool isLongTabular() const;
+ ///
+ void setRotateTabular(bool);
+ ///
+ bool getRotateTabular() const;
+ ///
+ void setRotateCell(idx_type cell, bool);
+ ///
+ bool getRotateCell(idx_type cell) const;
+ ///
+ bool needRotating() const;
+ ///
+ bool isLastCell(idx_type cell) const;
+ ///
+ idx_type getCellAbove(idx_type cell) const;
+ ///
+ idx_type getCellBelow(idx_type cell) const;
+ ///
+ idx_type getLastCellAbove(idx_type cell) const;
+ ///
+ idx_type getLastCellBelow(idx_type cell) const;
+ ///
+ idx_type getCellNumber(row_type row, col_type column) const;
+ ///
+ void setUsebox(idx_type cell, BoxType);
+ ///
+ BoxType getUsebox(idx_type cell) const;
+ //
+ // Long Tabular Options support functions
+ ///
+ bool checkLTType(row_type row, ltType const &) const;
+ ///
+ void setLTHead(row_type row, bool flag, ltType const &, bool first);
+ ///
+ bool getRowOfLTHead(row_type row, ltType &) const;
+ ///
+ bool getRowOfLTFirstHead(row_type row, ltType &) const;
+ ///
+ void setLTFoot(row_type row, bool flag, ltType const &, bool last);
+ ///
+ bool getRowOfLTFoot(row_type row, ltType &) const;
+ ///
+ bool getRowOfLTLastFoot(row_type row, ltType &) const;
+ ///
+ void setLTNewPage(row_type row, bool what);
+ ///
+ bool getLTNewPage(row_type row) const;
+ ///
+ bool haveLTHead() const;
+ ///
+ bool haveLTFirstHead() const;
+ ///
+ bool haveLTFoot() const;
+ ///
+ bool haveLTLastFoot() const;
+ ///
+ // end longtable support
+ ///
+ boost::shared_ptr<InsetText> getCellInset(idx_type cell) const;
+ ///
+ boost::shared_ptr<InsetText> getCellInset(row_type row,
+ col_type column) const;
+ ///
+ void setCellInset(row_type row, col_type column,
+ boost::shared_ptr<InsetText>) const;
+ /// Search for \param inset in the tabular, with the
+ ///
+ idx_type getCellFromInset(InsetBase const * inset) const;
+ ///
+ row_type rows() const { return rows_; }
+ ///
+ col_type columns() const { return columns_;}
+ ///
+ void validate(LaTeXFeatures &) const;
+ ///
+//private:
+ ///
+ class cellstruct {
+ public:
+ ///
+ cellstruct(BufferParams const &);
+ ///
+ cellstruct(cellstruct const &);
+ ///
+ cellstruct & operator=(cellstruct);
+ ///
+ void swap(cellstruct & rhs);
+ ///
+ idx_type cellno;
+ ///
+ int width_of_cell;
+ ///
+ int multicolumn;
+ ///
+ LyXAlignment alignment;
+ ///
+ VAlignment valignment;
+ ///
+ bool top_line;
+ ///
+ bool bottom_line;
+ ///
+ bool left_line;
+ ///
+ bool right_line;
+ ///
+ BoxType usebox;
+ ///
+ bool rotate;
+ ///
+ docstring align_special;
+ ///
+ LyXLength p_width; // this is only set for multicolumn!!!
+ ///
+ boost::shared_ptr<InsetText> inset;
+ };
+ cellstruct & cellinfo_of_cell(idx_type cell) const;
+ ///
+ typedef std::vector<cellstruct> cell_vector;
+ ///
+ typedef std::vector<cell_vector> cell_vvector;
- ///
- bool IsMultiColumn(int cell, bool real = false) const;
- ///
- void SetMultiColumn(int cell, int number);
- ///
- int UnsetMultiColumn(int cell); // returns number of new cells
- ///
- bool IsPartOfMultiColumn(int row, int column) const;
- ///
- int row_of_cell(int cell) const;
- ///
- int column_of_cell(int cell) const;
- ///
- int right_column_of_cell(int cell) const;
- ///
- void SetLongTabular(bool);
- ///
- bool IsLongTabular() const;
- ///
- void SetRotateTabular(bool);
- ///
- bool GetRotateTabular() const;
- ///
- void SetRotateCell(int cell, bool);
- ///
- bool GetRotateCell(int cell) const;
- ///
- bool NeedRotating() const;
- ///
- bool IsLastCell(int cell) const;
- ///
- int GetCellAbove(int cell) const;
- ///
- int GetCellBelow(int cell) const;
- ///
- int GetLastCellAbove(int cell) const;
- ///
- int GetLastCellBelow(int cell) const;
- ///
- int GetCellNumber(int row, int column) const;
- ///
- void SetUsebox(int cell, BoxType);
- ///
- BoxType GetUsebox(int cell) const;
- //
- // Long Tabular Options
- ///
- void SetLTHead(int cell, bool first);
- ///
- bool GetRowOfLTHead(int cell, int & row) const;
- ///
- bool GetRowOfLTFirstHead(int cell, int & row) const;
- ///
- void SetLTFoot(int cell, bool last);
- ///
- bool GetRowOfLTFoot(int cell, int & row) const;
- ///
- bool GetRowOfLTLastFoot(int cell, int & row) const;
- ///
- void SetLTNewPage(int cell, bool what);
- ///
- bool GetLTNewPage(int cell) const;
- ///
- InsetText * GetCellInset(int cell) const;
- InsetText * GetCellInset(int row, int column) const;
- ///
- int rows() const { return rows_; }
- ///
- int columns() const { return columns_;}
- ///
- InsetTabular * owner() const { return owner_; }
- ///
- void Validate(LaTeXFeatures &) const;
+ ///
+ class rowstruct {
+ public:
+ ///
+ rowstruct();
+ ///
+ int ascent_of_row;
+ ///
+ int descent_of_row;
+ ///
+ bool top_line;
+ ///
+ bool bottom_line;
+ /// Extra space between the top line and this row
+ LyXLength top_space;
+ /// Ignore top_space if true and use the default top space
+ bool top_space_default;
+ /// Extra space between this row and the bottom line
+ LyXLength bottom_space;
+ /// Ignore bottom_space if true and use the default bottom space
+ bool bottom_space_default;
+ /// Extra space between the bottom line and the next top line
+ LyXLength interline_space;
+ /// Ignore interline_space if true and use the default interline space
+ bool interline_space_default;
+ /// This are for longtabulars only
+ /// a row of endhead
+ bool endhead;
+ /// a row of endfirsthead
+ bool endfirsthead;
+ /// a row of endfoot
+ bool endfoot;
+ /// row of endlastfoot
+ bool endlastfoot;
+ /// row for a pagebreak
+ bool newpage;
+ };
+ ///
+ typedef std::vector<rowstruct> row_vector;
-private: //////////////////////////////////////////////////////////////////
- ///
- struct cellstruct {
///
- cellstruct();
+ class columnstruct {
+ public:
+ ///
+ columnstruct();
+ ///
+ LyXAlignment alignment;
+ ///
+ VAlignment valignment;
+ ///
+ bool left_line;
+ ///
+ bool right_line;
+ ///
+ int width_of_column;
+ ///
+ LyXLength p_width;
+ ///
+ docstring align_special;
+ };
+ ///
+ typedef std::vector<columnstruct> column_vector;
+
///
- int cellno;
+ row_type rows_;
///
- int width_of_cell;
+ col_type columns_;
///
- int multicolumn;
+ idx_type numberofcells;
///
- LyXAlignment alignment;
+ std::vector<row_type> rowofcell;
///
- VAlignment valignment;
+ std::vector<col_type> columnofcell;
///
- bool top_line;
+ row_vector row_info;
///
- bool bottom_line;
+ column_vector column_info;
///
- bool left_line;
+ mutable cell_vvector cell_info;
///
- bool right_line;
+ int width_of_tabular;
///
- BoxType usebox;
+ bool use_booktabs;
///
bool rotate;
+ //
+ // for long tabulars
+ //
+ bool is_long_tabular;
+ /// endhead data
+ ltType endhead;
+ /// endfirsthead data
+ ltType endfirsthead;
+ /// endfoot data
+ ltType endfoot;
+ /// endlastfoot data
+ ltType endlastfoot;
+
///
- string align_special;
+ void init(BufferParams const &, row_type rows_arg,
+ col_type columns_arg);
///
- string p_width; // this is only set for multicolumn!!!
+ void set_row_column_number_info();
+ /// Returns true if a complete update is necessary, otherwise false
+ bool setWidthOfMulticolCell(idx_type cell, int new_width);
///
- InsetText inset;
- };
- ///
- typedef std::vector<cellstruct> cell_vector;
- ///
- typedef std::vector<cell_vector> cell_vvector;
-
- ///
- struct rowstruct {
+ void recalculateMulticolumnsOfColumn(col_type column);
+ /// Returns true if change
+ void calculate_width_of_column(col_type column);
///
- rowstruct();
+ bool calculate_width_of_column_NMC(col_type column); // no multi cells
///
- bool top_line;
+ void calculate_width_of_tabular();
///
- bool bottom_line;
+ void delete_column(col_type column);
///
- int ascent_of_row;
+ idx_type cells_in_multicolumn(idx_type cell) const;
///
- int descent_of_row;
- /// This are for longtabulars only
- bool newpage;
- };
- ///
- typedef std::vector<rowstruct> row_vector;
-
- ///
- struct columnstruct {
+ BoxType useParbox(idx_type cell) const;
+ ///
+ // helper function for Latex returns number of newlines
+ ///
+ int TeXTopHLine(odocstream &, row_type row) const;
///
- columnstruct();
+ int TeXBottomHLine(odocstream &, row_type row) const;
///
- LyXAlignment alignment;
+ int TeXCellPreamble(odocstream &, idx_type cell) const;
///
- VAlignment valignment;
+ int TeXCellPostamble(odocstream &, idx_type cell) const;
///
- bool left_line;
+ int TeXLongtableHeaderFooter(odocstream &, Buffer const & buf,
+ OutputParams const &) const;
///
- bool right_line;
+ bool isValidRow(row_type const row) const;
///
- int width_of_column;
+ int TeXRow(odocstream &, row_type const row, Buffer const & buf,
+ OutputParams const &) const;
///
- string p_width;
+ // helper function for ASCII returns number of newlines
///
- string align_special;
- };
- ///
- typedef std::vector<columnstruct> column_vector;
+ int asciiTopHLine(odocstream &, row_type row,
+ std::vector<unsigned int> const &) const;
+ ///
+ int asciiBottomHLine(odocstream &, row_type row,
+ std::vector<unsigned int> const &) const;
+ ///
+ int asciiPrintCell(Buffer const &, odocstream &,
+ OutputParams const &,
+ idx_type cell, row_type row, col_type column,
+ std::vector<unsigned int> const &,
+ bool onlydata) const;
+ /// auxiliary function for docbook
+ int docbookRow(Buffer const & buf, odocstream & os, row_type,
+ OutputParams const &) const;
- ///
- void ReadNew(Buffer const * buf, istream & is,
- LyXLex & lex, string const & l);
- ///
- void ReadOld(Buffer const * buf, istream & is,
- LyXLex & lex, string const & l);
- ///
- int rows_;
- ///
- int columns_;
- ///
- int numberofcells;
- ///
- std::vector<int> rowofcell;
- ///
- std::vector<int> columnofcell;
- ///
- row_vector row_info;
- ///
- column_vector column_info;
- ///
- mutable cell_vvector cell_info;
- ///
- int width_of_tabular;
- ///
- bool rotate;
- //
- // for long tabulars
- ///
- bool is_long_tabular;
- /// row of endhead
- int endhead;
- /// row of endfirsthead
- int endfirsthead;
- /// row of endfoot
- int endfoot;
- /// row of endlastfoot
- int endlastfoot;
- ///
- InsetTabular * owner_;
-
- ///
- void Init(int columns_arg, int rows_arg);
- ///
- void Reinit();
- ///
- void set_row_column_number_info(bool oldformat = false);
- /// Returns true if a complete update is necessary, otherwise false
- bool SetWidthOfMulticolCell(int cell, int new_width);
- ///
- void recalculateMulticolCells(int cell, int new_width);
- /// Returns true if change
- bool calculate_width_of_column(int column);
- ///
- bool calculate_width_of_column_NMC(int column); // no multi cells
- ///
- void calculate_width_of_tabular();
- ///
- cellstruct * cellinfo_of_cell(int cell) const;
- ///
- void delete_column(int column);
- ///
- int cells_in_multicolumn(int cell) const;
- ///
- BoxType UseParbox(int cell) const;
+private:
+ /// renumber cells after structural changes
+ void fixCellNums();
};
+
+} // namespace lyx
+
#endif