]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
Fix logic error that led to bug #8777. I have no idea what I was
[lyx.git] / src / insets / InsetTabular.h
index 6b34e6caf37be6a4910f5b6961b2aba86bd0a45c..1fed9bea174b96c1701d91c4085decfa146e2276 100644 (file)
@@ -10,6 +10,7 @@
  * \author Jürgen Vigna
  * \author Edwin Leuven
  * \author Uwe Stöhr
+ * \author Scott Kostyshak
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -29,6 +30,7 @@
 
 #include "support/shared_ptr.h"
 
+#include <climits>
 #include <iosfwd>
 #include <vector>
 
@@ -55,7 +57,7 @@ public:
        ///
        InsetCode lyxCode() const { return CELL_CODE; }
        ///
-       Inset * clone() { return new InsetTableCell(*this); }
+       Inset * clone() const { return new InsetTableCell(*this); }
        ///
        bool getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & status) const;
@@ -136,6 +138,14 @@ public:
                ///
                COPY_COLUMN,
                ///
+               MOVE_COLUMN_RIGHT,
+               ///
+               MOVE_COLUMN_LEFT,
+               ///
+               MOVE_ROW_DOWN,
+               ///
+               MOVE_ROW_UP,
+               ///
                SET_LINE_TOP,
                ///
                SET_LINE_BOTTOM,
@@ -233,6 +243,7 @@ public:
                UNSET_LTLASTFOOT,
                ///
                SET_LTNEWPAGE,
+               UNSET_LTNEWPAGE,
                ///
                TOGGLE_LTCAPTION,
                ///
@@ -270,6 +281,8 @@ public:
                ///
                SET_DECIMAL_POINT,
                ///
+               SET_TABULAR_WIDTH,
+               ///
                LAST_ACTION
        };
        ///
@@ -315,6 +328,29 @@ public:
                BOX_MINIPAGE = 2
        };
 
+       enum CaptionType {
+               ///
+               CAPTION_FIRSTHEAD,
+               ///
+               CAPTION_HEAD,
+               ///
+               CAPTION_FOOT,
+               ///
+               CAPTION_LASTFOOT,
+               ///
+               CAPTION_ANY
+       };
+
+       enum RowDirection {
+               UP,
+               DOWN
+       };
+
+       enum ColDirection {
+               RIGHT,
+               LEFT
+       };
+
        class ltType {
        public:
                // constructor
@@ -402,6 +438,10 @@ 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 &);
@@ -425,17 +465,25 @@ public:
        ///
        int textVOffset(idx_type cell) const;
        ///
-       void appendRow(idx_type cell);
+       void appendRow(row_type row);
        ///
        void deleteRow(row_type row);
        ///
-       void copyRow(row_type);
+       void copyRow(row_type row);
+       ///  
+       void insertRow(row_type row, bool copy);
        ///
-       void appendColumn(idx_type cell);
+       void moveColumn(col_type col, ColDirection direction);
+       ///
+       void moveRow(row_type row, RowDirection direction);
+       ///
+       void appendColumn(col_type column);
        ///
        void deleteColumn(col_type column);
        ///
-       void copyColumn(col_type);
+       void copyColumn(col_type column);
+       ///
+       void insertColumn(col_type column, bool copy);
        ///
        idx_type getFirstCellInRow(row_type row) const;
        ///
@@ -447,19 +495,22 @@ public:
        ///
        void read(Lexer &);
        ///
-       int latex(odocstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int docbook(odocstream & os, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream & os, OutputParams const &) const;
        ///
-       void plaintext(odocstream &,
+       void plaintext(odocstringstream &,
                       OutputParams const & runparams, int const depth,
-                      bool onlydata, char_type delim) const;
+                      bool onlydata, char_type delim, size_t max_length = INT_MAX) const;
        ///
        bool isMultiColumn(idx_type cell) const;
        ///
-       idx_type setMultiColumn(idx_type cell, idx_type number);
+       bool hasMultiColumn(col_type cell) const;
+       ///
+       idx_type setMultiColumn(idx_type cell, idx_type number,
+                            bool const right_border);
        ///
        void unsetMultiColumn(idx_type cell);
        ///
@@ -469,7 +520,10 @@ public:
        ///
        bool isMultiRow(idx_type cell) const;
        ///
-       idx_type setMultiRow(idx_type cell, idx_type number);
+       bool hasMultiRow(row_type r) const;
+       ///
+       idx_type setMultiRow(idx_type cell, idx_type number,
+                            bool const bottom_border);
        ///
        void unsetMultiRow(idx_type cell);
        ///
@@ -477,9 +531,9 @@ public:
        ///
        col_type cellColumn(idx_type cell) const;
        ///
-       void setRotateCell(idx_type cell, bool);
+       void setRotateCell(idx_type cell, int);
        ///
-       bool getRotateCell(idx_type cell) const;
+       int getRotateCell(idx_type cell) const;
        ///
        bool needRotating() const;
        ///
@@ -497,8 +551,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;
@@ -519,15 +571,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
        ///
@@ -589,7 +641,7 @@ public:
                ///
                BoxType usebox;
                ///
-               bool rotate;
+               int rotate;
                ///
                docstring align_special;
                ///
@@ -675,9 +727,11 @@ public:
        ///
        mutable cell_vvector cell_info;
        ///
+       Length tabular_width;
+       ///
        bool use_booktabs;
        ///
-       bool rotate;
+       int rotate;
        ///
        VAlignment tabular_valignment;
        //
@@ -711,40 +765,41 @@ 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
        ///
-       bool plaintextTopHLine(odocstream &, row_type row,
+       bool plaintextTopHLine(odocstringstream &, row_type row,
                               std::vector<unsigned int> const &) const;
        ///
-       bool plaintextBottomHLine(odocstream &, row_type row,
+       bool plaintextBottomHLine(odocstringstream &, row_type row,
                                  std::vector<unsigned int> const &) const;
        ///
-       void plaintextPrintCell(odocstream &,
+       void plaintextPrintCell(odocstringstream &,
                                OutputParams const &,
                                idx_type cell, row_type row, col_type column,
                                std::vector<unsigned int> const &,
-                               bool onlydata) const;
+                               bool onlydata, size_t max_length) const;
        /// 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);
@@ -794,16 +849,19 @@ 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; }
+       ///
+       bool allowsCaptionVariation(std::string const &) const;
        ///
        DisplayType display() const;
        ///
-       int latex(odocstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
-       int plaintext(odocstream &, OutputParams const &) const;
+       int plaintext(odocstringstream & ods, OutputParams const & op,
+                     size_t max_length = INT_MAX) const;
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
@@ -813,7 +871,9 @@ public:
        ///
        InsetCode lyxCode() const { return TABULAR_CODE; }
        ///
-       docstring contextMenuName() 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;
@@ -861,7 +921,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 & di, bool output_active) const;
 
        ///
        bool completionSupported(Cursor const &) const;
@@ -909,8 +969,6 @@ private:
        ///
        bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
        ///
-       int scroll() const { return scx_; }
-       ///
        Inset * clone() const { return new InsetTabular(*this); }
 
        ///