X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftabular.h;h=75f9feacf0b7c5e5d7ff00fbad5df07bd983923d;hb=acb4e0a1d39ad697fdfcc7f2d66be2bc6b82e2d1;hp=810037f9853463ca52404082cadbc2aa62b7fb96;hpb=85a5ea7bfc80e179a61a99f2955455e84d3384cc;p=lyx.git diff --git a/src/tabular.h b/src/tabular.h index 810037f985..75f9feacf0 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -1,9 +1,9 @@ // -*- C++ -*- /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 2000-2001 The LyX Team. * * @author: Jürgen Vigna @@ -16,18 +16,21 @@ #pragma interface #endif -#include -#include - #include "lyxlex.h" +#include "layout.h" #include "LString.h" +#include "lyxlength.h" + #include "insets/insettext.h" +#include +#include + class InsetTabular; class LaTeXFeatures; class Buffer; -/* The features the text class offers for tables */ +/* The features the text class offers for tables */ /// class LyXTabular { @@ -108,12 +111,16 @@ public: SET_USEBOX, /// SET_LTHEAD, + UNSET_LTHEAD, /// SET_LTFIRSTHEAD, + UNSET_LTFIRSTHEAD, /// SET_LTFOOT, + UNSET_LTFOOT, /// SET_LTLASTFOOT, + UNSET_LTLASTFOOT, /// SET_LTNEWPAGE, /// @@ -152,19 +159,39 @@ public: BOX_MINIPAGE = 2 }; + struct lttype { + // 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; + }; + /// + typedef struct lttype ltType; + /* konstruktor */ /// - LyXTabular(InsetTabular *, int columns_arg, int rows_arg); + LyXTabular(BufferParams const &, + InsetTabular *, int columns_arg, int rows_arg); /// - LyXTabular(InsetTabular *, LyXTabular const &); + LyXTabular(BufferParams const &, + InsetTabular *, LyXTabular const &, bool same_id = false); /// explicit LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex); /// LyXTabular & operator=(LyXTabular const &); /// - LyXTabular * clone(InsetTabular *); - + LyXTabular * clone(BufferParams const &, + InsetTabular *, bool same_id = false); + /// 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 @@ -173,7 +200,7 @@ public: 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; /// @@ -185,7 +212,7 @@ public: int GetAdditionalHeight(int row) const; /// int GetAdditionalWidth(int cell) const; - + /* returns the maximum over all rows */ /// int GetWidthOfColumn(int cell) const; @@ -220,9 +247,9 @@ public: bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false); /// - bool SetColumnPWidth(int cell, string const & width); + bool SetColumnPWidth(int cell, LyXLength const & width); /// - bool SetMColumnPWidth(int cell, string const & width); + bool SetMColumnPWidth(int cell, LyXLength const & width); /// bool SetAlignSpecial(int cell, string const & special, Feature what); /// @@ -230,11 +257,11 @@ public: /// VAlignment GetVAlignment(int cell, bool onlycolumn = false) const; /// - string const GetPWidth(int cell) const; + LyXLength const GetPWidth(int cell) const; /// - string const GetColumnPWidth(int cell) const; + LyXLength const GetColumnPWidth(int cell) const; /// - string const GetMColumnPWidth(int cell) const; + LyXLength const GetMColumnPWidth(int cell) const; /// string const GetAlignSpecial(int cell, int what) const; /// @@ -242,11 +269,11 @@ public: /// int GetBeginningOfTextInCell(int cell) const; /// - void AppendRow(int cell); + void AppendRow(BufferParams const &, int cell); /// void DeleteRow(int row); /// - void AppendColumn(int cell); + void AppendColumn(BufferParams const &, int cell); /// void DeleteColumn(int column); /// @@ -266,39 +293,18 @@ public: /// void Read(Buffer const *, LyXLex &); /// - void OldFormatRead(LyXLex &, string const &); - // - // helper function for Latex returns number of newlines + void OldFormatRead(BufferParams const &, LyXLex &, string const &); /// - int TeXTopHLine(std::ostream &, int row) const; + int latex(Buffer const *, std::ostream &, bool, bool) const; /// - int TeXBottomHLine(std::ostream &, int row) const; + int docbook(Buffer const * buf, std::ostream & os, bool mixcont) 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 const &) const; - /// - int AsciiBottomHLine(std::ostream &, int row, - std::vector const &) const; - /// - int AsciiPrintCell(Buffer const *, std::ostream &, - int cell, int row, int column, - std::vector const &) const; - /// - int Ascii(Buffer const *, std::ostream &) const; + int ascii(Buffer const *, std::ostream &, int const depth, + bool onlydata, unsigned char delim) const; /// bool IsMultiColumn(int cell, bool real = false) const; /// - void SetMultiColumn(int cell, int number); + void SetMultiColumn(Buffer const *, int cell, int number); /// int UnsetMultiColumn(int cell); // returns number of new cells /// @@ -340,27 +346,42 @@ public: /// BoxType GetUsebox(int cell) const; // - // Long Tabular Options + // Long Tabular Options support functions + /// + bool checkLTType(int row, ltType const &) const; + /// + void SetLTHead(int row, bool flag, ltType const &, bool first); + /// + bool GetRowOfLTHead(int row, ltType &) const; + /// + bool GetRowOfLTFirstHead(int row, ltType &) const; /// - void SetLTHead(int cell, bool first); + void SetLTFoot(int row, bool flag, ltType const &, bool last); /// - bool GetRowOfLTHead(int cell, int & row) const; + bool GetRowOfLTFoot(int row, ltType &) const; /// - bool GetRowOfLTFirstHead(int cell, int & row) const; + bool GetRowOfLTLastFoot(int row, ltType &) const; /// - void SetLTFoot(int cell, bool last); + void SetLTNewPage(int row, bool what); /// - bool GetRowOfLTFoot(int cell, int & row) const; + bool GetLTNewPage(int row) const; /// - bool GetRowOfLTLastFoot(int cell, int & row) const; + bool haveLTHead() const; /// - void SetLTNewPage(int cell, bool what); + bool haveLTFirstHead() const; /// - bool GetLTNewPage(int cell) const; + bool haveLTFoot() const; + /// + bool haveLTLastFoot() const; + /// + // end longtable support /// InsetText * GetCellInset(int cell) const; /// InsetText * GetCellInset(int row, int column) const; + /// Search for \param inset in the tabular, with the + /// additional hint that it could be at \param maybe_cell + int GetCellFromInset(Inset const * inset, int maybe_cell = -1) const; /// int rows() const { return rows_; } /// @@ -372,12 +393,15 @@ public: /// std::vector const getLabelList() const; /// + /// recalculate the widths/heights only! + void reinit(); + /// mutable int cur_cell; private: /// struct cellstruct { /// - cellstruct(); + cellstruct(BufferParams const &); /// int cellno; /// @@ -403,7 +427,7 @@ private: /// string align_special; /// - string p_width; // this is only set for multicolumn!!! + LyXLength p_width; // this is only set for multicolumn!!! /// InsetText inset; }; @@ -417,14 +441,23 @@ private: /// rowstruct(); /// - bool top_line; - /// - bool bottom_line; - /// int ascent_of_row; /// int descent_of_row; + /// + bool top_line; + /// + bool bottom_line; /// 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; }; /// @@ -445,7 +478,7 @@ private: /// int width_of_column; /// - string p_width; + LyXLength p_width; /// string align_special; }; @@ -454,7 +487,7 @@ private: /// void ReadNew(Buffer const * buf, std::istream & is, - LyXLex & lex, string const & l); + LyXLex & lex, string const & l, int const version); /// void ReadOld(Buffer const * buf, std::istream & is, LyXLex & lex, string const & l); @@ -480,29 +513,31 @@ private: 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; + /// endhead data + ltType endhead; + /// endfirsthead data + ltType endfirsthead; + /// endfoot data + ltType endfoot; + /// endlastfoot data + ltType endlastfoot; + // /// InsetTabular * owner_; /// - void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0); + void Init(BufferParams const &, + int columns_arg, int rows_arg, LyXTabular const * lt = 0); /// - void Reinit(); + void Reinit(bool reset_widths = true); /// 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); + void recalculateMulticolumnsOfColumn(int column); /// Returns true if change bool calculate_width_of_column(int column); /// @@ -517,6 +552,41 @@ private: int cells_in_multicolumn(int cell) const; /// BoxType UseParbox(int cell) const; + /// + void setHeaderFooterRows(int header, int fheader, int footer, int lfooter); + /// + // 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 TeXLongtableHeaderFooter(std::ostream &, Buffer const * buf, + bool fragile, bool fp) const; + /// + bool isValidRow(int const row) const; + /// + int TeXRow(std::ostream &, int const row, Buffer const * buf, + bool fragile, bool fp) const; + /// + // helper function for ASCII returns number of newlines + /// + int asciiTopHLine(std::ostream &, int row, + std::vector const &) const; + /// + int asciiBottomHLine(std::ostream &, int row, + std::vector const &) const; + /// + int asciiPrintCell(Buffer const *, std::ostream &, + int cell, int row, int column, + std::vector const &, + bool onlydata) const; + /// auxiliary function for docbook + int docbookRow(Buffer const * buf, std::ostream & os, int row) const; }; #endif