]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Make lyx2lyx output the new external inset format.
[lyx.git] / src / tabular.C
index f982b67b9ea29bfcab8f87358c345b285203abd6..023f5406cb98e3d4f65de007759403990facf4f7 100644 (file)
@@ -30,6 +30,7 @@
 #include "support/LAssert.h"
 #include "frontends/Alert.h"
 #include "gettext.h"
+#include "Lsstream.h"
 #include "tabular_funcs.h"
 #include "lyxlex.h"
 
@@ -116,23 +117,11 @@ LyXTabular::LyXTabular(BufferParams const & bp,
 
 
 LyXTabular::LyXTabular(BufferParams const & bp,
-                      InsetTabular * inset, LyXTabular const & lt,
-                      bool same_id)
+                      InsetTabular * inset, LyXTabular const & lt)
 {
        owner_ = inset;
        cur_cell = -1;
        Init(bp, lt.rows_, lt.columns_, &lt);
-       // we really should change again to have InsetText as a pointer
-       // and allocate it then we would not have to do this stuff all
-       // double!
-       if (same_id) {
-               for (int i = 0; i < rows_; ++i) {
-                       for (int j = 0; j < columns_; ++j) {
-                               cell_info[i][j].inset.id(lt.cell_info[i][j].inset.id());
-                               cell_info[i][j].inset.setParagraphData(&*lt.cell_info[i][j].inset.paragraphs.begin(), true);
-                       }
-               }
-       }
 #if 0
 #ifdef WITH_WARNINGS
 #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
@@ -176,9 +165,9 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 
 
 LyXTabular * LyXTabular::clone(BufferParams const & bp,
-                              InsetTabular * inset, bool same_id)
+                              InsetTabular * inset)
 {
-       LyXTabular * result = new LyXTabular(bp, inset, *this, same_id);
+       LyXTabular * result = new LyXTabular(bp, inset, *this);
 #if 0
        // don't know if this is good but I need to Clone also
        // the text-insets here, this is for the Undo-facility!
@@ -1336,14 +1325,14 @@ void LyXTabular::SetMultiColumn(Buffer * buffer, int cell, int number)
        cellinfo_of_cell(cell)->right_line = column_info[column_of_cell(cell+number-1)].right_line;
 #if 1
        for (int i = 1; i < number; ++i) {
-               cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
+               cellinfo_of_cell(cell + i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
                cellinfo_of_cell(cell)->inset.appendParagraphs(buffer,
-                       &*cellinfo_of_cell(cell+i)->inset.paragraphs.begin());
-               cellinfo_of_cell(cell+i)->inset.clear(false);
+                       cellinfo_of_cell(cell+i)->inset.paragraphs);
+               cellinfo_of_cell(cell + i)->inset.clear(false);
        }
 #else
        for (number--; number > 0; --number) {
-               cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
+               cellinfo_of_cell(cell + number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
        }
 #endif
        set_row_column_number_info();
@@ -1871,7 +1860,7 @@ int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
 
 
 int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
-                                        bool fragile, bool fp) const
+                                        LatexRunParams const & runparams) const
 {
        if (!is_long_tabular)
                return 0;
@@ -1885,7 +1874,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
                }
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endhead) {
-                               ret += TeXRow(os, i, buf, fragile, fp);
+                               ret += TeXRow(os, i, buf, runparams);
                        }
                }
                if (endhead.bottomDL) {
@@ -1907,7 +1896,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
                }
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endfirsthead) {
-                               ret += TeXRow(os, i, buf, fragile, fp);
+                               ret += TeXRow(os, i, buf, runparams);
                        }
                }
                if (endfirsthead.bottomDL) {
@@ -1925,7 +1914,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
                }
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endfoot) {
-                               ret += TeXRow(os, i, buf, fragile, fp);
+                               ret += TeXRow(os, i, buf, runparams);
                        }
                }
                if (endfoot.bottomDL) {
@@ -1947,7 +1936,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
                }
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endlastfoot) {
-                               ret += TeXRow(os, i, buf, fragile, fp);
+                               ret += TeXRow(os, i, buf, runparams);
                        }
                }
                if (endlastfoot.bottomDL) {
@@ -1971,7 +1960,7 @@ bool LyXTabular::isValidRow(int const row) const
 
 
 int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
-                      bool fragile, bool fp) const
+                      LatexRunParams const & runparams) const
 {
        int ret = 0;
        int cell = GetCellNumber(i, 0);
@@ -1988,7 +1977,7 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
 
                if (rtl)
                        os << "\\R{";
-               ret += inset->latex(buf, os, fragile, fp);
+               ret += inset->latex(buf, os, runparams);
                if (rtl)
                        os << '}';
 
@@ -2006,8 +1995,8 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
 }
 
 
-int LyXTabular::latex(Buffer const * buf,
-                                         ostream & os, bool fragile, bool fp) const
+int LyXTabular::latex(Buffer const * buf, ostream & os,
+                     LatexRunParams const & runparams) const
 {
        int ret = 0;
 
@@ -2081,7 +2070,7 @@ int LyXTabular::latex(Buffer const * buf,
        os << "}\n";
        ++ret;
 
-       ret += TeXLongtableHeaderFooter(os, buf, fragile, fp);
+       ret += TeXLongtableHeaderFooter(os, buf, runparams);
 
        //+---------------------------------------------------------------------
        //+                      the single row and columns (cells)            +
@@ -2089,7 +2078,7 @@ int LyXTabular::latex(Buffer const * buf,
 
        for (int i = 0; i < rows_; ++i) {
                if (isValidRow(i)) {
-                       ret += TeXRow(os, i, buf, fragile, fp);
+                       ret += TeXRow(os, i, buf, runparams);
                        if (is_long_tabular && row_info[i].newpage) {
                                os << "\\newpage\n";
                                ++ret;
@@ -2556,8 +2545,8 @@ vector<string> const LyXTabular::getLabelList() const
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
        ParagraphList const & parlist = GetCellInset(cell)->paragraphs;
-       ParagraphList::iterator cit = parlist.begin();
-       ParagraphList::iterator end = parlist.end();
+       ParagraphList::const_iterator cit = parlist.begin();
+       ParagraphList::const_iterator end = parlist.end();
 
        for (; cit != end; ++cit) {
                for (int i = 0; i < cit->size(); ++i) {