]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.h
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / tabular.h
index e3966812c9566555e6732160faffd210424cde9d..6b5a9449e58f0be96cf27c6dd82c5b3b324b73b2 100644 (file)
@@ -6,6 +6,8 @@
  *      
  *           Copyright 2000 The LyX Team.
  *
+ *           @author: Jürgen Vigna
+ *
  * ====================================================== */
 #ifndef TABULAR_H
 #define TABULAR_H
@@ -31,7 +33,7 @@ class Buffer;
 class LyXTabular  {
 public:
     ///
-    enum {
+    enum Feature {
        ///
        APPEND_ROW = 0,
        ///
@@ -81,8 +83,6 @@ public:
        ///
        M_VALIGN_CENTER,
        ///
-       DELETE_TABULAR,
-       ///
        MULTICOLUMN,
        ///
        SET_ALL_LINES,
@@ -143,6 +143,15 @@ public:
        LYX_VALIGN_CENTER = 2
     };
 
+    enum BoxType {
+       ///
+       BOX_NONE = 0,
+       ///
+       BOX_PARBOX = 1,
+       ///
+       BOX_MINIPAGE = 2
+    };
+
     /* konstruktor */
     ///
     LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
@@ -152,20 +161,18 @@ public:
     explicit
     LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
     ///
-    ~LyXTabular();
-    ///
     LyXTabular & operator=(LyXTabular const &);
     ///
     LyXTabular * Clone(InsetTabular *);
     
     /// Returns true if there is a topline, returns false if not
-    bool TopLine(int cell, bool onlycolumn=false) const;
+    bool TopLine(int cell, bool onlycolumn = false) const;
     /// Returns true if there is a topline, returns false if not
-    bool BottomLine(int cell, bool onlycolumn=false) const;
+    bool BottomLine(int cell, bool onlycolumn = false) const;
     /// Returns true if there is a topline, returns false if not
-    bool LeftLine(int cell, bool onlycolumn=false) const;
+    bool LeftLine(int cell, bool onlycolumn = false) const;
     /// Returns true if there is a topline, returns false if not
-    bool RightLine(int cell, bool onlycolumn=false) const;
+    bool RightLine(int cell, bool onlycolumn = false) const;
     
     ///
     bool TopAlreadyDrawed(int cell) const;
@@ -207,27 +214,27 @@ public:
     /// 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, char align, bool onlycolumn = false);
+    bool SetAlignment(int cell, LyXAlignment align, bool onlycolumn = false);
     /// Returns true if a complete update is necessary, otherwise false
-    bool SetVAlignment(int cell, char align, bool onlycolumn = false);
+    bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false);
     ///
     bool SetColumnPWidth(int cell, string const & width);
     ///
     bool SetMColumnPWidth(int cell, string const & width);
     ///
-    bool SetAlignSpecial(int cell, string const & special, int what);
+    bool SetAlignSpecial(int cell, string const & special, Feature what);
     ///
-    char GetAlignment(int cell, bool onlycolumn = false) const;
+    LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
     ///
-    char GetVAlignment(int cell, bool onlycolumn = false) const;
+    VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
     ///
-    string GetPWidth(int cell) const;
+    string const GetPWidth(int cell) const;
     ///
-    string GetColumnPWidth(int cell) const;
+    string const GetColumnPWidth(int cell) const;
     ///
-    string GetMColumnPWidth(int cell) const;
+    string const GetMColumnPWidth(int cell) const;
     ///
-    string GetAlignSpecial(int cell, int what) const;
+    string const GetAlignSpecial(int cell, int what) const;
     ///
     int GetWidthOfCell(int cell) const;
     ///
@@ -235,11 +242,11 @@ public:
     ///
     void AppendRow(int cell);
     ///
-    void DeleteRow(int cell);
+    void DeleteRow(int row);
     ///
     void AppendColumn(int cell);
     ///
-    void DeleteColumn(int cell);
+    void DeleteColumn(int column);
     ///
     bool IsFirstCellInRow(int cell) const;
     ///
@@ -271,13 +278,28 @@ public:
     ///
     int Latex(Buffer const *, std::ostream &, bool, bool) const;
     ///
+    int DocBook(Buffer const * buf, std::ostream & os) const;
+    ///
+    // helper function for Latex returns number of newlines
+    ///
+    int AsciiTopHLine(std::ostream &, int row,
+                     std::vector<unsigned int> const &) const;
+    ///
+    int AsciiBottomHLine(std::ostream &, int row,
+                        std::vector<unsigned int> const &) const;
+    ///
+    int AsciiPrintCell(Buffer const *, std::ostream &, int cell, int row,
+                      int column, std::vector<unsigned int> const &) const;
+    ///
+    int Ascii(Buffer const *, std::ostream &) const;
+    ///
     int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
 #if 0
     ///
     int RoffEndOfCell(std::ostream &, int cell);
 #endif
     ///
-    char const * GetDocBookAlign(int cell, bool isColumn = false) const;
+    string const  GetDocBookAlign(int cell, bool isColumn = false) const;
 
     ///
     bool IsMultiColumn(int cell, bool real = false) const;
@@ -294,15 +316,15 @@ public:
     ///
     int right_column_of_cell(int cell) const;
     ///
-    void SetLongTabular(int what);
+    void SetLongTabular(bool);
     ///
     bool IsLongTabular() const;
     ///
-    void SetRotateTabular(int what);
+    void SetRotateTabular(bool);
     ///
     bool GetRotateTabular() const;
     ///
-    void SetRotateCell(int cell, int what);
+    void SetRotateCell(int cell, bool);
     ///
     bool GetRotateCell(int cell) const;
     ///
@@ -320,9 +342,9 @@ public:
     ///
     int GetCellNumber(int row, int column) const;
     ///
-    void SetUsebox(int cell, int what);
+    void SetUsebox(int cell, BoxType);
     ///
-    int GetUsebox(int cell) const;
+    BoxType GetUsebox(int cell) const;
     //
     // Long Tabular Options
     ///
@@ -343,6 +365,7 @@ public:
     bool GetLTNewPage(int cell) const;
     ///
     InsetText * GetCellInset(int cell) const;
+    InsetText * GetCellInset(int row, int column) const;
     ///
     int rows() const { return rows_; }
     ///
@@ -357,14 +380,6 @@ private: //////////////////////////////////////////////////////////////////
     struct cellstruct {
        ///
         cellstruct();
-#ifdef INSET_POINTER
-       ///
-       ~cellstruct();
-       //
-        cellstruct(cellstruct const &);
-       ///
-       cellstruct & operator=(cellstruct const &);
-#endif
        ///
        int cellno;
        ///
@@ -372,9 +387,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
        int multicolumn;
        ///
-       int alignment;
+       LyXAlignment alignment;
        ///
-       int valignment;
+       VAlignment valignment;
        ///
        bool top_line;
        ///
@@ -383,15 +398,10 @@ private: //////////////////////////////////////////////////////////////////
        bool left_line;
        ///
        bool right_line;
-       /**
-          0 ... don't use a box
-          1 ... use a parbox
-          2 ... use a minipage
-          This should be made into an enum (Lgb)
-       */
-       int usebox;
        ///
-       int rotate;
+       BoxType usebox;
+       ///
+       bool rotate;
        ///
        string align_special;
        ///
@@ -408,10 +418,6 @@ private: //////////////////////////////////////////////////////////////////
     struct rowstruct {
        ///
         rowstruct();
-       //
-           //~rowstruct();
-       //
-           // rowstruct & operator=(rowstruct const &);
        ///
        bool top_line;
        ///
@@ -430,14 +436,10 @@ private: //////////////////////////////////////////////////////////////////
     struct columnstruct {
        ///
         columnstruct();
-       //
-           //~columnstruct();
-       //
-           //columnstruct & operator=(columnstruct const &);
        ///
-       int alignment;
+       LyXAlignment alignment;
        ///
-       int valignment;
+       VAlignment valignment;
        ///
        bool left_line;
        ///
@@ -459,9 +461,9 @@ private: //////////////////////////////////////////////////////////////////
     ///
     int numberofcells;
     ///
-    int * rowofcell;
+    std::vector<int> rowofcell;
     ///
-    int * columnofcell;
+    std::vector<int> columnofcell;
     ///
     row_vector row_info;
     ///
@@ -471,11 +473,11 @@ private: //////////////////////////////////////////////////////////////////
     ///
     int width_of_tabular;
     ///
-    int rotate;
+    bool rotate;
     //
     // for long tabulars
     ///
-    int is_long_tabular;
+    bool is_long_tabular;
     /// row of endhead
     int endhead;
     /// row of endfirsthead
@@ -492,9 +494,10 @@ private: //////////////////////////////////////////////////////////////////
     ///
     void Reinit();
     ///
-    void set_row_column_number_info();
+    void set_row_column_number_info(bool oldformat = false);
     /// Returns true if a complete update is necessary, otherwise false
     bool SetWidthOfMulticolCell(int cell, int new_width);
+    ///
     void recalculateMulticolCells(int cell, int new_width);
     /// Returns true if change
     bool calculate_width_of_column(int column);
@@ -509,7 +512,7 @@ private: //////////////////////////////////////////////////////////////////
     ///
     int cells_in_multicolumn(int cell) const;
     ///
-    bool UseParbox(int cell) const;
+    BoxType UseParbox(int cell) const;
 };
 
 #endif