]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
More sensible longtable caption handling (needed for bug #7412)
[lyx.git] / src / insets / InsetTabular.h
index c989c3464865750cafc34456af4af0334064e5ae..8546858ea9dc8142ca210c15c84923a8d2440ba6 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "Inset.h"
 #include "InsetText.h"
-#include "Layout.h"
 #include "Length.h"
 
 #include "support/shared_ptr.h"
@@ -193,6 +192,8 @@ public:
                ///
                UNSET_MULTIROW,
                ///
+               SET_MROFFSET,
+               ///
                SET_ALL_LINES,
                ///
                UNSET_ALL_LINES,
@@ -243,8 +244,6 @@ public:
                ///
                SET_SPECIAL_MULTICOLUMN,
                ///
-               SET_SPECIAL_MULTIROW,
-               ///
                SET_BOOKTABS,
                ///
                UNSET_BOOKTABS,
@@ -271,6 +270,8 @@ public:
                ///
                SET_DECIMAL_POINT,
                ///
+               SET_TABULAR_WIDTH,
+               ///
                LAST_ACTION
        };
        ///
@@ -316,6 +317,19 @@ public:
                BOX_MINIPAGE = 2
        };
 
+       enum CaptionType {
+               ///
+               CAPTION_FIRSTHEAD,
+               ///
+               CAPTION_HEAD,
+               ///
+               CAPTION_FOOT,
+               ///
+               CAPTION_LASTFOOT,
+               ///
+               CAPTION_ANY
+       };
+
        class ltType {
        public:
                // constructor
@@ -403,10 +417,16 @@ public:
        void setVAlignment(idx_type cell, VAlignment align,
                           bool onlycolumn = false);
        ///
+       void setTabularWidth(Length const & l) { tabular_width = l; }
+       ///
+       Length tabularWidth() const { return tabular_width; }
+       ///
        void setColumnPWidth(Cursor &, idx_type, Length const &);
        ///
        bool setMColumnPWidth(Cursor &, idx_type, Length const &);
        ///
+       bool setMROffset(Cursor &, idx_type, Length const &);
+       ///
        void setAlignSpecial(idx_type cell, docstring const & special,
                             Feature what);
        ///
@@ -418,6 +438,8 @@ public:
        ///
        Length const getPWidth(idx_type cell) const;
        ///
+       Length const getMROffset(idx_type cell) const;
+       ///
        int textHOffset(idx_type cell) const;
        ///
        int textVOffset(idx_type cell) const;
@@ -444,7 +466,7 @@ public:
        ///
        void read(Lexer &);
        ///
-       int latex(odocstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int docbook(odocstream & os, OutputParams const &) const;
        ///
@@ -456,7 +478,8 @@ public:
        ///
        bool isMultiColumn(idx_type cell) const;
        ///
-       idx_type setMultiColumn(idx_type cell, idx_type number);
+       idx_type setMultiColumn(idx_type cell, idx_type number,
+                            bool const right_border);
        ///
        void unsetMultiColumn(idx_type cell);
        ///
@@ -466,7 +489,8 @@ public:
        ///
        bool isMultiRow(idx_type cell) const;
        ///
-       idx_type setMultiRow(idx_type cell, idx_type number);
+       idx_type setMultiRow(idx_type cell, idx_type number,
+                            bool const bottom_border);
        ///
        void unsetMultiRow(idx_type cell);
        ///
@@ -494,8 +518,6 @@ public:
        //
        // 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;
@@ -516,15 +538,15 @@ public:
        ///
        bool ltCaption(row_type row) const;
        ///
-       bool haveLTHead() const;
+       bool haveLTHead(bool withcaptions = true) const;
        ///
-       bool haveLTFirstHead() const;
+       bool haveLTFirstHead(bool withcaptions = true) const;
        ///
-       bool haveLTFoot() const;
+       bool haveLTFoot(bool withcaptions = true) const;
        ///
-       bool haveLTLastFoot() const;
+       bool haveLTLastFoot(bool withcaptions = true) const;
        ///
-       bool haveLTCaption() const;
+       bool haveLTCaption(CaptionType captiontype = CAPTION_ANY) const;
        ///
        // end longtable support
        ///
@@ -564,6 +586,8 @@ public:
                ///
                int multirow;
                ///
+               Length mroffset;
+               ///
                LyXAlignment alignment;
                ///
                VAlignment valignment;
@@ -670,6 +694,8 @@ public:
        ///
        mutable cell_vvector cell_info;
        ///
+       Length tabular_width;
+       ///
        bool use_booktabs;
        ///
        bool rotate;
@@ -706,22 +732,22 @@ public:
        ///
        BoxType useParbox(idx_type cell) const;
        ///
-       // helper function for Latex returns number of newlines
+       // helper function for Latex
        ///
-       int TeXTopHLine(odocstream &, row_type row, std::string const lang) const;
+       void TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
        ///
-       int TeXBottomHLine(odocstream &, row_type row, std::string const lang) const;
+       void TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
        ///
-       int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
+       void TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
        ///
-       int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
+       void TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
        ///
-       int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
+       void TeXLongtableHeaderFooter(otexstream &, OutputParams const &) const;
        ///
        bool isValidRow(row_type const row) const;
        ///
-       int TeXRow(odocstream &, row_type const row,
-                  OutputParams const &) const;
+       void TeXRow(otexstream &, row_type const row,
+                   OutputParams const &) const;
        ///
        // helper functions for plain text
        ///
@@ -739,7 +765,8 @@ public:
        /// auxiliary function for docbook
        int docbookRow(odocstream & os, row_type, OutputParams const &) const;
        ///
-       docstring xhtmlRow(XHTMLStream & xs, row_type, OutputParams const &) const;
+       docstring xhtmlRow(XHTMLStream & xs, row_type, OutputParams const &,
+                          bool header = false) const;
 
        /// change associated Buffer
        void setBuffer(Buffer & buffer);
@@ -778,6 +805,8 @@ public:
        ///
        void drawSelection(PainterInfo & pi, int x, int y) const;
        ///
+       void drawBackground(PainterInfo & pi, int x, int y) const;
+       ///
        bool editable() const { return true; }
        ///
        bool hasSettings() const { return true; }
@@ -787,14 +816,14 @@ public:
        bool allowSpellCheck() const { return true; }
        ///
        bool canTrackChanges() const { return true; }
-       /** returns true if, when outputing LaTeX, font changes should
+       /** returns false if, when outputing LaTeX, font changes should
            be closed before generating this inset. This is needed for
            insets that may contain several paragraphs */
-       bool noFontChange() const { return true; }
+       bool inheritFont() const { return false; }
        ///
        DisplayType display() const;
        ///
-       int latex(odocstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
@@ -806,7 +835,9 @@ public:
        ///
        InsetCode lyxCode() const { return TABULAR_CODE; }
        ///
-       docstring contextMenu(BufferView const & bv, int x, int y) const;
+       std::string contextMenu(BufferView const &, int, int) const;
+       ///
+       std::string contextMenuName() const;
        /// get offset of this cursor slice relative to our upper left corner
        void cursorPos(BufferView const & bv, CursorSlice const & sl,
                bool boundary, int & x, int & y) const;
@@ -854,7 +885,7 @@ public:
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
-       void addToToc(DocIterator const &);
+       void addToToc(DocIterator const &) const;
 
        ///
        bool completionSupported(Cursor const &) const;
@@ -902,8 +933,6 @@ private:
        ///
        bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
        ///
-       int scroll() const { return scx_; }
-       ///
        Inset * clone() const { return new InsetTabular(*this); }
 
        ///
@@ -921,6 +950,8 @@ private:
        ///
        int cellXPos(idx_type cell) const;
        ///
+       int cellYPos(idx_type cell) const;
+       ///
        void resetPos(Cursor & cur) const;
        ///
        bool copySelection(Cursor & cur);
@@ -947,6 +978,9 @@ private:
        mutable idx_type first_visible_cell;
        ///
        mutable int scx_;
+       /// The vertical offset of the table due to the vertical
+       /// alignment with respect to the baseline.
+       mutable int offset_valign_;
        /// true when selecting rows with the mouse
        bool rowselect_;
        /// true when selecting columns with the mouse