]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetTabular.h
InsetIndex: revamp IndexEntry to handle both legacy and modern index insets; simplify...
[features.git] / src / insets / InsetTabular.h
index 33d4974107355415263af672ec773d40e2f69d10..08b626ff8fe21cee717f7801e6c00a7ebd7f278c 100644 (file)
 #ifndef INSET_TABULAR_H
 #define INSET_TABULAR_H
 
+#include "BufferParams.h"
+#include "Changes.h"
 #include "InsetText.h"
 
 #include "support/Length.h"
+#include "support/types.h"
 
 #include <climits>
 #include <iosfwd>
@@ -44,7 +47,6 @@ class CursorSlice;
 class FuncStatus;
 class Lexer;
 class OutputParams;
-class Paragraph;
 class XMLStream;
 
 
@@ -55,9 +57,8 @@ public:
        ///
        explicit InsetTableCell(Buffer * buf);
        /// We need this since generation of the default is deprecated
-       /// (since we declare the assignment constucture below).
-       /// Please make sure to adjust it if you add members!
-       InsetTableCell(InsetTableCell const &);
+       /// (since we declare the assignment constuctor below).
+       InsetTableCell(InsetTableCell const & in) = default;
        ///
        InsetCode lyxCode() const override { return CELL_CODE; }
        ///
@@ -68,11 +69,13 @@ public:
        ///
        void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
        ///
+       void toggleVarWidth(bool vw) { isVarwidth = vw; }
+       ///
        void toggleMultiCol(bool m) { isMultiColumn = m; }
        ///
        void toggleMultiRow(bool m) { isMultiRow = m; }
        ///
-       void setContentAlignment(LyXAlignment al) {contentAlign = al; }
+       void setContentAlignment(LyXAlignment al) { contentAlign = al; }
        /// writes the contents of the cell as a string, optionally
        /// descending into insets
        docstring asString(bool intoInsets = true);
@@ -89,11 +92,15 @@ public:
        bool inheritFont() const override { return false; }
        /// Can the cell contain several paragraphs?
        bool allowMultiPar() const override { return !isMultiRow && (!isMultiColumn || isFixedWidth); }
+       ///
+       bool canPaintChange(BufferView const &) const override { return false; }
+       /// This assures we never output \maketitle in table cells
+       bool isInTitle() const override { return true; }
 private:
-       /// unimplemented
-       InsetTableCell();
-       /// unimplemented
-       void operator=(InsetTableCell const &);
+       ///
+       InsetTableCell() = delete;
+       ///
+       void operator=(InsetTableCell const &) = delete;
        // FIXME
        // These booleans are supposed to track whether the cell has had its
        // width explicitly set and whether it is part of a multicolumn, respectively.
@@ -118,12 +125,11 @@ private:
        // be quite slow.
        // So, well, if someone can do better, please do!
        // --rkh
-       //
-       // NOTE: Make sure to adapt the construcors (especially the copy
-       // constructor) if you add members!
        ///
        bool isFixedWidth;
        ///
+       bool isVarwidth;
+       ///
        bool isMultiColumn;
        ///
        bool isMultiRow;
@@ -137,8 +143,6 @@ private:
        ///
        bool usePlainLayout() const override { return true; }
        ///
-       bool forcePlainLayout(idx_type = 0) const override;
-       ///
        bool allowParagraphCustomization(idx_type = 0) const override;
        ///
        bool forceLocalFontSwitch() const override;
@@ -338,6 +342,12 @@ public:
                ///
                SET_INNER_LINES,
                ///
+               TOGGLE_INNER_LINES,
+               ///
+               TOGGLE_BORDER_LINES,
+               ///
+               TOGGLE_ALL_LINES,
+               ///
                LAST_ACTION
        };
        ///
@@ -424,12 +434,6 @@ public:
                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);
 
@@ -448,6 +452,18 @@ public:
        /// If \p ignore_bt is true, we return the state as if booktabs was
        /// not used
        bool rightLine(idx_type cell, bool const ignore_bt = false) const;
+       /// Returns true if there is an outside border around the selection
+       bool outsideBorders(row_type sel_row_start, row_type sel_row_end,
+                                               col_type sel_col_start, col_type sel_col_end) const;
+       /// Returns true if there are inside lines in the selection
+       bool innerBorders(row_type sel_row_start, row_type sel_row_end,
+                                         col_type sel_col_start, col_type sel_col_end) const;
+       /// Sets the grid lines in the selection
+       /// if \p setLinesInnerOnly is true, outside borders are excluded
+       /// if \p setLines is true the lines are set otherwise they are unset
+       void setLines(row_type const sel_row_start, row_type const sel_row_end,
+                                 col_type const sel_col_start, col_type const sel_col_end,
+                                 bool setLinesInnerOnly, bool setLines);
        /// Returns whether the top line is trimmed left and/or right
        std::pair<bool, bool> topLineTrim(idx_type const cell) const;
        /// Returns whether the bottom line is trimmed left and/or right
@@ -555,9 +571,11 @@ public:
        ///
        void insertRow(row_type row, bool copy);
        ///
-       void moveColumn(col_type col, ColDirection direction);
+       void moveColumn(col_type col_start, col_type col_end,
+                       ColDirection direction);
        ///
-       void moveRow(row_type row, RowDirection direction);
+       void moveRow(row_type row_start, row_type row_end,
+                    RowDirection direction);
        ///
        void appendColumn(col_type column);
        ///
@@ -832,6 +850,24 @@ public:
        ///
        typedef std::vector<ColumnData> column_vector;
 
+private:
+       // Determines the style of borders, per row.
+       class XmlRowWiseBorders {
+       public:
+               // Whether to draw double bottom line.
+               bool completeBorder = true;
+
+               // Whether to draw booktabs' thicker lines.
+               bool completeBorderAbove = true;
+               bool completeBorderBelow = true;
+
+               // Size of the borders.
+               double borderBottomWidth = 1.0;
+               double borderBottomWidthComplete = 3.0;
+               double borderTopWidth = 1.0;
+       };
+
+public:
        ///
        idx_type numberofcells;
        ///
@@ -917,17 +953,20 @@ public:
                                idx_type cell, row_type row, col_type column,
                                std::vector<unsigned int> const &,
                                bool onlydata, size_t max_length) const;
-       /// auxiliary function for DocBook
-       void docbookRow(XMLStream &, row_type, OutputParams const &,
-                                       bool header = false) const;
-       /// auxiliary function for DocBook: export this row as HTML
-       void docbookRowAsHTML(XMLStream &, row_type, OutputParams const &,
-                                       bool header) const;
-       /// auxiliary function for DocBook: export this row as CALS
-       void docbookRowAsCALS(XMLStream &, row_type, OutputParams const &) const;
-       ///
-       docstring xhtmlRow(XMLStream & xs, row_type, OutputParams const &,
-                          bool header = false) const;
+       ///
+       docstring xmlRow(XMLStream & xs, row_type row, OutputParams const &,
+                        bool header = false, bool is_xhtml = true,
+                                        BufferParams::TableOutput docbook_table_output = BufferParams::TableOutput::HTMLTable) const;
+       void xmlHeader(XMLStream & xs, OutputParams const &) const;
+       void xmlFooter(XMLStream & xs, OutputParams const &) const;
+       void xmlBody(XMLStream & xs, OutputParams const &) const;
+       XmlRowWiseBorders computeXmlBorders(row_type row) const;
+       std::vector<std::string> computeCssStylePerCell(row_type row, col_type col, idx_type cell) const;
+
+       /// Transforms the vertical alignment of the given cell as a prebaked XML attribute (for HTML and CALS).
+       std::string getHAlignAsXmlAttribute(idx_type cell, bool is_xhtml = true) const;
+       /// Transforms the vertical alignment of the given cell as a prebaked XML attribute (for HTML and CALS).
+       std::string getVAlignAsXmlAttribute(idx_type cell) const;
 
        /// change associated Buffer
        void setBuffer(Buffer & buffer);
@@ -981,9 +1020,7 @@ public:
        bool canTrackChanges() const override { return true; }
        ///
        bool canPaintChange(BufferView const &) const override { return true; }
-       /** returns false if, when outputting LaTeX, font changes should
-           be closed before generating this inset. This is needed for
-           insets that may contain several paragraphs */
+       ///
        bool inheritFont() const override { return false; }
        ///
        bool allowMultiPar() const override;
@@ -992,7 +1029,7 @@ public:
        //
        bool isTable() const override { return true; }
        ///
-       RowFlags rowFlags() const override;
+       int rowFlags() const override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
@@ -1041,8 +1078,6 @@ public:
        /// should all paragraphs be output with "Standard" layout?
        bool allowParagraphCustomization(idx_type cell = 0) const override;
        ///
-       bool forcePlainLayout(idx_type cell = 0) const override;
-       ///
        void addPreview(DocIterator const & inset_pos,
                graphics::PreviewLoader &) const override;