]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
Remove TextClassPtr without losing the type safety it provided.
[lyx.git] / src / insets / InsetTabular.h
index 32e1aa56e55080c9c31b6057387e21b74d1d93a7..78727b0f5cb12d32793dd0ce6d870a72d8edbb3c 100644 (file)
 #define INSETTABULAR_H
 
 #include "Inset.h"
-#include "MailInset.h"
-#include "Length.h"
 #include "InsetText.h"
-
+#include "Layout.h"
+#include "Length.h"
+#include "MailInset.h"
 
 #include <boost/shared_ptr.hpp>
 
@@ -67,7 +67,7 @@ class OutputParams;
 //
 // A helper struct for tables
 //
-class Tabular  {
+class Tabular {
 public:
        ///
        enum Feature {
@@ -239,8 +239,9 @@ public:
        static const idx_type npos = static_cast<idx_type>(-1);
 
        /// constructor
-       Tabular(BufferParams const &, col_type columns_arg,
-                  row_type rows_arg);
+       Tabular();
+       /// constructor
+       Tabular(Buffer 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;
@@ -266,21 +267,21 @@ public:
 
        /* returns the maximum over all rows */
        ///
-       int getWidthOfColumn(idx_type cell) const;
+       int columnWidth(idx_type cell) const;
        ///
-       int getWidthOfTabular() const;
+       int width() const;
        ///
-       int getAscentOfRow(row_type row) const;
+       int height() const;
        ///
-       int getDescentOfRow(row_type row) const;
+       int rowAscent(row_type row) const;
        ///
-       int getHeightOfTabular() const;
+       int rowDescent(row_type row) const;
        ///
-       void setAscentOfRow(row_type row, int height);
+       void setRowAscent(row_type row, int height);
        ///
-       void setDescentOfRow(row_type row, int height);
+       void setRowDescent(row_type row, int height);
        ///
-       void setWidthOfCell(idx_type cell, int new_width);
+       void setCellWidth(idx_type cell, int new_width);
        ///
        void setAllLines(idx_type cell, bool line);
        ///
@@ -319,21 +320,21 @@ public:
        ///
        docstring const getAlignSpecial(idx_type cell, int what) const;
        ///
-       int getWidthOfCell(idx_type cell) const;
+       int cellWidth(idx_type cell) const;
        ///
        int getBeginningOfTextInCell(idx_type cell) const;
        ///
-       void appendRow(BufferParams const &, idx_type cell);
+       void appendRow(idx_type cell);
        ///
        void deleteRow(row_type row);
        ///
-       void copyRow(BufferParams const &, row_type);
+       void copyRow(row_type);
        ///
-       void appendColumn(BufferParams const &, idx_type cell);
+       void appendColumn(idx_type cell);
        ///
        void deleteColumn(col_type column);
        ///
-       void copyColumn(BufferParams const &, col_type);
+       void copyColumn(col_type);
        ///
        bool isFirstCellInRow(idx_type cell) const;
        ///
@@ -343,37 +344,37 @@ public:
        ///
        idx_type getLastCellInRow(row_type row) const;
        ///
-       idx_type getNumberOfCells() const;
+       idx_type cellCount() const;
        ///
        idx_type numberOfCellsInRow(idx_type cell) const;
        ///
-       void write(Buffer const &, std::ostream &) const;
+       void write(std::ostream &) const;
        ///
-       void read(Buffer const &, Lexer &);
+       void read(Lexer &);
        ///
-       int latex(Buffer const &, odocstream &, OutputParams const &) const;
+       int latex(odocstream &, OutputParams const &) const;
        //
-       int docbook(Buffer const & buf, odocstream & os, OutputParams const &) const;
+       int docbook(odocstream & os, OutputParams const &) const;
        ///
-       void plaintext(Buffer const &, odocstream &,
+       void plaintext(odocstream &,
                       OutputParams const & runparams, int const depth,
-                      bool onlydata, unsigned char delim) const;
+                      bool onlydata, char_type delim) const;
        ///
        bool isMultiColumn(idx_type cell) const;
        ///
        bool isMultiColumnReal(idx_type cell) const;
        ///
-       void setMultiColumn(Buffer *, idx_type cell, idx_type number);
+       void setMultiColumn(idx_type cell, idx_type number);
        ///
        idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
        ///
        bool isPartOfMultiColumn(row_type row, col_type column) const;
        ///
-       row_type row_of_cell(idx_type cell) const;
+       row_type cellRow(idx_type cell) const;
        ///
-       col_type column_of_cell(idx_type cell) const;
+       col_type cellColumn(idx_type cell) const;
        ///
-       col_type right_column_of_cell(idx_type cell) const;
+       col_type cellRightColumn(idx_type cell) const;
        ///
        void setBookTabs(bool);
        ///
@@ -403,7 +404,7 @@ public:
        ///
        idx_type getLastCellBelow(idx_type cell) const;
        ///
-       idx_type getCellNumber(row_type row, col_type column) const;
+       idx_type cellIndex(row_type row, col_type column) const;
        ///
        void setUsebox(idx_type cell, BoxType);
        ///
@@ -450,28 +451,28 @@ public:
        ///
        idx_type getCellFromInset(Inset const * inset) const;
        ///
-       row_type rows() const { return rows_; }
+       row_type rowCount() const { return row_info.size(); }
        ///
-       col_type columns() const { return columns_;}
+       col_type columnCount() const { return column_info.size();}
        ///
        void validate(LaTeXFeatures &) const;
        ///
 //private:
        ///
-       class cellstruct {
+       class CellData {
        public:
                ///
-               cellstruct(BufferParams const &);
+               CellData(Buffer const &);
                ///
-               cellstruct(cellstruct const &);
+               CellData(CellData const &);
                ///
-               cellstruct & operator=(cellstruct);
+               CellData & operator=(CellData);
                ///
-               void swap(cellstruct & rhs);
+               void swap(CellData & rhs);
                ///
                idx_type cellno;
                ///
-               int width_of_cell;
+               int width;
                ///
                int multicolumn;
                ///
@@ -497,21 +498,21 @@ public:
                ///
                boost::shared_ptr<InsetText> inset;
        };
-       cellstruct & cellinfo_of_cell(idx_type cell) const;
+       CellData & cellinfo_of_cell(idx_type cell) const;
        ///
-       typedef std::vector<cellstruct> cell_vector;
+       typedef std::vector<CellData> cell_vector;
        ///
        typedef std::vector<cell_vector> cell_vvector;
 
        ///
-       class rowstruct {
+       class RowData {
        public:
                ///
-               rowstruct();
+               RowData();
                ///
-               int ascent_of_row;
+               int ascent;
                ///
-               int descent_of_row;
+               int descent;
                ///
                bool top_line;
                ///
@@ -537,17 +538,17 @@ public:
                bool endfoot;
                /// row of endlastfoot
                bool endlastfoot;
-               /// row for a pagebreak
+               /// row for a newpage
                bool newpage;
        };
        ///
-       typedef std::vector<rowstruct> row_vector;
+       typedef std::vector<RowData> row_vector;
 
        ///
-       class columnstruct {
+       class ColumnData {
                public:
                ///
-               columnstruct();
+               ColumnData();
                ///
                LyXAlignment alignment;
                ///
@@ -557,19 +558,15 @@ public:
                ///
                bool right_line;
                ///
-               int  width_of_column;
+               int width;
                ///
                Length p_width;
                ///
                docstring align_special;
        };
        ///
-       typedef std::vector<columnstruct> column_vector;
+       typedef std::vector<ColumnData> column_vector;
 
-       ///
-       row_type rows_;
-       ///
-       col_type columns_;
        ///
        idx_type numberofcells;
        ///
@@ -583,8 +580,6 @@ public:
        ///
        mutable cell_vvector cell_info;
        ///
-       int width_of_tabular;
-       ///
        bool use_booktabs;
        ///
        bool rotate;
@@ -602,10 +597,10 @@ public:
        ltType endlastfoot;
 
        ///
-       void init(BufferParams const &, row_type rows_arg,
+       void init(Buffer const &, row_type rows_arg,
                  col_type columns_arg);
        ///
-       void set_row_column_number_info();
+       void updateIndexes();
        /// Returns true if a complete update is necessary, otherwise false
        bool setWidthOfMulticolCell(idx_type cell, int new_width);
        ///
@@ -615,10 +610,6 @@ public:
        ///
        bool calculate_width_of_column_NMC(col_type column); // no multi cells
        ///
-       void calculate_width_of_tabular();
-       ///
-       void delete_column(col_type column);
-       ///
        idx_type cells_in_multicolumn(idx_type cell) const;
        ///
        BoxType useParbox(idx_type cell) const;
@@ -633,12 +624,11 @@ public:
        ///
        int TeXCellPostamble(odocstream &, idx_type cell) const;
        ///
-       int TeXLongtableHeaderFooter(odocstream &, Buffer const & buf,
-                                    OutputParams const &) const;
+       int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
        ///
        bool isValidRow(row_type const row) const;
        ///
-       int TeXRow(odocstream &, row_type const row, Buffer const & buf,
+       int TeXRow(odocstream &, row_type const row,
                   OutputParams const &) const;
        ///
        // helper functions for plain text
@@ -649,16 +639,22 @@ public:
        bool plaintextBottomHLine(odocstream &, row_type row,
                                  std::vector<unsigned int> const &) const;
        ///
-       void plaintextPrintCell(Buffer const &, odocstream &,
+       void plaintextPrintCell(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;
+       int docbookRow(odocstream & os, row_type, OutputParams const &) const;
+
+       /// change associated Buffer
+       void setBuffer(Buffer const & buffer) { buffer_ = &buffer; }
+       /// retrieve associated Buffer
+       Buffer const & buffer() const { return *buffer_; }
 
 private:
+       Buffer const * buffer_;
+
        /// renumber cells after structural changes
        void fixCellNums();
 };
@@ -673,21 +669,21 @@ public:
        ///
        ~InsetTabular();
        ///
-       void read(Buffer const &, Lexer &);
+       void read(Lexer &);
        ///
-       void write(Buffer const &, std::ostream &) const;
+       void write(std::ostream &) const;
        ///
-       bool metrics(MetricsInfo &, Dimension &) const;
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
        void drawSelection(PainterInfo & pi, int x, int y) const;
        ///
-       virtual docstring const editMessage() const;
+       docstring editMessage() const;
        ///
        EDITABLE editable() const { return HIGHLY_EDITABLE; }
        ///
-       bool insetAllowed(Inset::Code) const { return true; }
+       bool insetAllowed(InsetCode code) const;
        ///
        bool allowSpellCheck() const { return true; }
        ///
@@ -699,18 +695,15 @@ public:
        ///
        DisplayType display() const { return tabular.isLongTabular() ? AlignCenter : Inline; }
        ///
-       int latex(Buffer const &, odocstream &,
-                 OutputParams const &) const;
+       int latex(odocstream &, OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, odocstream &,
-                     OutputParams const &) const;
+       int plaintext(odocstream &, OutputParams const &) const;
        ///
-       int docbook(Buffer const &, odocstream &,
-                   OutputParams const &) const;
+       int docbook(odocstream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
-       Code lyxCode() const { return Inset::TABULAR_CODE; }
+       InsetCode lyxCode() const { return TABULAR_CODE; }
        /// 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;
@@ -724,7 +717,7 @@ public:
        ///
        bool showInsetDialog(BufferView *) const;
        /// number of cells
-       size_t nargs() const { return tabular.getNumberOfCells(); }
+       size_t nargs() const { return tabular.cellCount(); }
        ///
        boost::shared_ptr<InsetText const> cell(idx_type) const;
        ///
@@ -742,22 +735,20 @@ public:
        // this should return true if we have a "normal" cell, otherwise false.
        // "normal" means without width set!
        /// should all paragraphs be output with "Standard" layout?
-       bool forceDefaultParagraphs(idx_type cell = 0) const;
-
+       virtual bool allowParagraphCustomization(idx_type cell = 0) const;
        ///
-       void addPreview(graphics::PreviewLoader &) const;
-
+       virtual bool forceEmptyLayout() { return true; }
        ///
-       Buffer const & buffer() const;
+       void addPreview(graphics::PreviewLoader &) const;
 
-       /// set the owning buffer
-       void buffer(Buffer const * buf);
        /// lock cell with given index
-       void edit(Cursor & cur, bool left);
+       void edit(Cursor & cur, bool front, EntryDirection entry_from);
        ///
        Inset * editXY(Cursor & cur, int x, int y);
        /// can we go further down on mouse click?
        bool descendable() const { return true; }
+       // Update the counters of this inset and of its contents
+       void updateLabels(ParIterator const &);
 
        //
        // Public structures and variables
@@ -775,7 +766,7 @@ protected:
        int scroll() const { return scx_; }
 
 private:
-       virtual std::auto_ptr<Inset> doClone() const;
+       Inset * clone() const;
 
        ///
        void drawCellLines(frontend::Painter &, int x, int y, row_type row,
@@ -819,8 +810,6 @@ private:
                                row_type row_start, row_type row_end,
                                col_type col_start, col_type col_end) const;
        ///
-       Buffer const * buffer_;
-       ///
        mutable idx_type first_visible_cell;
        ///
        mutable int scx_;