]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.h
Rename ascii to plaintext and LatexRunParams to OutputParams.
[lyx.git] / src / tabular.h
index 5d1ec5b74f2ec588e5f0cccdefb75882c2d2b800..ad2818fc890180f5b12e894d999276b9cb4b65d1 100644 (file)
@@ -1,32 +1,28 @@
 // -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file tabular.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ * \author André Pönitz
+ * \author Jürgen Vigna
  *
- *           Copyright 2000-2001 The LyX Team.
- *
- *           @author: Jürgen Vigna
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
+
 #ifndef TABULAR_H
 #define TABULAR_H
 
-#include "layout.h"
-#include "LString.h"
 #include "lyxlength.h"
-
 #include "insets/insettext.h"
 
 #include <iosfwd>
 #include <vector>
 
 class InsetTabular;
-class BufferParams;
-class LaTeXFeatures;
-class LatexRunParams;
-class Buffer;
-class LyXLex;
+class OutputParams;
 
 /* The features the text class offers for tables */
 
@@ -64,7 +60,7 @@ public:
                ///
                VALIGN_BOTTOM,
                ///
-               VALIGN_CENTER,
+               VALIGN_MIDDLE,
                ///
                M_TOGGLE_LINE_TOP,
                ///
@@ -84,7 +80,7 @@ public:
                ///
                M_VALIGN_BOTTOM,
                ///
-               M_VALIGN_CENTER,
+               M_VALIGN_MIDDLE,
                ///
                MULTICOLUMN,
                ///
@@ -147,7 +143,7 @@ public:
                ///
                LYX_VALIGN_BOTTOM = 1,
                ///
-               LYX_VALIGN_CENTER = 2
+               LYX_VALIGN_MIDDLE = 2
        };
 
        enum BoxType {
@@ -175,16 +171,9 @@ public:
        };
 
        /// constructor
-       LyXTabular(BufferParams const &,
-                  InsetTabular *, int columns_arg, int rows_arg);
-       /// sort of copy constructor
-       LyXTabular(BufferParams const &,
-                  InsetTabular *, LyXTabular const &);
+       LyXTabular(BufferParams const &, int columns_arg, int rows_arg);
        ///
-       explicit
-       LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
-       ///
-       LyXTabular * clone(BufferParams const &, InsetTabular *);
+       void setOwner(InsetTabular * inset);
 
        /// Returns true if there is a topline, returns false if not
        bool topLine(int cell, bool onlycolumn = false) const;
@@ -219,33 +208,33 @@ public:
        ///
        int getHeightOfTabular() const;
        /// Returns true if a complete update is necessary, otherwise false
-       bool setAscentOfRow(int row, int height);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setDescentOfRow(int row, int height);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setWidthOfCell(int cell, int new_width);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setAllLines(int cell, bool line);
+       void setAscentOfRow(int row, int height);
        /// Returns true if a complete update is necessary, otherwise false
-       bool setTopLine(int cell, bool line, bool onlycolumn = false);
+       void setDescentOfRow(int row, int height);
        /// Returns true if a complete update is necessary, otherwise false
-       bool setBottomLine(int cell, bool line, bool onlycolumn = false);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setLeftLine(int cell, bool line, bool onlycolumn = false);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setRightLine(int cell, bool line, bool onlycolumn = false);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setAlignment(int cell, LyXAlignment align,
+       void setWidthOfCell(int cell, int new_width);
+       ///
+       void setAllLines(int cell, bool line);
+       ///
+       void setTopLine(int cell, bool line, bool onlycolumn = false);
+       ///
+       void setBottomLine(int cell, bool line, bool onlycolumn = false);
+       ///
+       void setLeftLine(int cell, bool line, bool onlycolumn = false);
+       ///
+       void setRightLine(int cell, bool line, bool onlycolumn = false);
+       ///
+       void setAlignment(int cell, LyXAlignment align,
                          bool onlycolumn = false);
-       /// Returns true if a complete update is necessary, otherwise false
-       bool setVAlignment(int cell, VAlignment align,
+       ///
+       void setVAlignment(int cell, VAlignment align,
                           bool onlycolumn = false);
        ///
-       bool setColumnPWidth(int cell, LyXLength const & width);
+       void setColumnPWidth(int cell, LyXLength const & width);
        ///
        bool setMColumnPWidth(int cell, LyXLength const & width);
        ///
-       bool setAlignSpecial(int cell, string const & special, Feature what);
+       void setAlignSpecial(int cell, std::string const & special, Feature what);
        ///
        LyXAlignment getAlignment(int cell, bool onlycolumn = false) const;
        ///
@@ -257,7 +246,7 @@ public:
        ///
        LyXLength const getMColumnPWidth(int cell) const;
        ///
-       string const getAlignSpecial(int cell, int what) const;
+       std::string const getAlignSpecial(int cell, int what) const;
        ///
        int getWidthOfCell(int cell) const;
        ///
@@ -283,19 +272,27 @@ public:
        ///
        int numberOfCellsInRow(int cell) const;
        ///
-       void write(Buffer const *, std::ostream &) const;
+       void write(Buffer const &, std::ostream &) const;
        ///
-       void read(Buffer const *, LyXLex &);
+       void read(Buffer const &, LyXLex &);
        ///
-       int latex(Buffer const *, std::ostream &,
-                 LatexRunParams const &) const;
+       int latex(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
+       //
+       int linuxdoc(Buffer const & buf, std::ostream & os,
+                    OutputParams const &) const;
        ///
-       int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
+       int docbook(Buffer const & buf, std::ostream & os,
+                   OutputParams const &) const;
        ///
-       int ascii(Buffer const *, std::ostream &, int const depth,
+       int plaintext(Buffer const &, std::ostream &,
+                 OutputParams const & runparams,
+                 int const depth,
                  bool onlydata, unsigned char delim) const;
        ///
-       bool isMultiColumn(int cell, bool real = false) const;
+       bool isMultiColumn(int cell) const;
+       ///
+       bool isMultiColumnReal(int cell) const;
        ///
        void setMultiColumn(Buffer *, int cell, int number);
        ///
@@ -369,27 +366,22 @@ public:
        ///
        // end longtable support
        ///
-       InsetText * getCellInset(int cell) const;
+       InsetText & getCellInset(int cell) const;
        ///
-       InsetText * getCellInset(int row, int column) 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 getCellFromInset(InsetOld const * inset) const;
        ///
        int rows() const { return rows_; }
        ///
        int columns() const { return columns_;}
        ///
        void validate(LaTeXFeatures &) const;
-       ///
-       void getLabelList(std::vector<string> &) const;
-       ///
-       /// recalculate the widths/heights only!
-       void reinit();
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &, std::vector<std::string> & list) const;
        ///
 //private:
-       ///
-       mutable int cur_cell;
        ///
        struct cellstruct {
                ///
@@ -417,13 +409,13 @@ public:
                ///
                bool rotate;
                ///
-               string align_special;
+               std::string align_special;
                ///
                LyXLength p_width; // this is only set for multicolumn!!!
                ///
                InsetText inset;
        };
-       cellstruct * cellinfo_of_cell(int cell) const;
+       cellstruct & cellinfo_of_cell(int cell) const;
        ///
        typedef std::vector<cellstruct> cell_vector;
        ///
@@ -473,7 +465,7 @@ public:
                ///
                LyXLength p_width;
                ///
-               string align_special;
+               std::string align_special;
        };
        ///
        typedef std::vector<columnstruct> column_vector;
@@ -510,25 +502,17 @@ public:
        ltType endfoot;
        /// endlastfoot data
        ltType endlastfoot;
-       //
-       ///
-       InsetTabular * owner_;
 
        ///
-       void init(BufferParams const &,
-                 int columns_arg, int rows_arg, LyXTabular const * lt = 0);
+       void init(BufferParams const &, int rows_arg, int columns_arg);
        ///
-       void Reinit(bool reset_widths = true);
-       ///
-       LyXTabular & operator=(LyXTabular const &);
-       ///
-       void set_row_column_number_info(bool oldformat = false);
+       void set_row_column_number_info();
        /// Returns true if a complete update is necessary, otherwise false
        bool setWidthOfMulticolCell(int cell, int new_width);
        ///
        void recalculateMulticolumnsOfColumn(int column);
        /// Returns true if change
-       bool calculate_width_of_column(int column);
+       void calculate_width_of_column(int column);
        ///
        bool calculate_width_of_column_NMC(int column); // no multi cells
        ///
@@ -552,13 +536,13 @@ public:
        ///
        int TeXCellPostamble(std::ostream &, int cell) const;
        ///
-       int TeXLongtableHeaderFooter(std::ostream &, Buffer const * buf,
-                                    LatexRunParams const &) const;
+       int TeXLongtableHeaderFooter(std::ostream &, Buffer const & buf,
+                                    OutputParams const &) const;
        ///
        bool isValidRow(int const row) const;
        ///
-       int TeXRow(std::ostream &, int const row, Buffer const * buf,
-                  LatexRunParams const &) const;
+       int TeXRow(std::ostream &, int const row, Buffer const & buf,
+                  OutputParams const &) const;
        ///
        // helper function for ASCII returns number of newlines
        ///
@@ -568,12 +552,18 @@ public:
        int asciiBottomHLine(std::ostream &, int row,
                             std::vector<unsigned int> const &) const;
        ///
-       int asciiPrintCell(Buffer const *, std::ostream &,
+       int asciiPrintCell(Buffer const &, std::ostream &,
+                          OutputParams const &,
                           int cell, int row, int column,
                           std::vector<unsigned int> const &,
                                           bool onlydata) const;
        /// auxiliary function for docbook
-       int docbookRow(Buffer const * buf, std::ostream & os, int row) const;
+       int docbookRow(Buffer const & buf, std::ostream & os, int,
+                      OutputParams const &) const;
+
+private:
+       /// renumber cells after structural changes
+       void fixCellNums();
 };
 
 #endif