]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
the spellcheck cleanup
[lyx.git] / src / tabular.C
index b1c0407efc923f82afc75b51ea26c3b615636528..e140abd6348d29fd7b544e55a4ef03e102562d0c 100644 (file)
@@ -23,6 +23,7 @@
 #include "bufferparams.h"
 #include "debug.h"
 #include "LaTeXFeatures.h"
+#include "latexrunparams.h"
 #include "lyxlex.h"
 #include "paragraph.h"
 
@@ -383,9 +384,6 @@ void LyXTabular::init(BufferParams const & bp, int rows_arg, int columns_arg)
 
 void LyXTabular::fixCellNums()
 {
-       BOOST_ASSERT(rows_ == row_info.size());
-       BOOST_ASSERT(columns_ == column_info.size());
-       BOOST_ASSERT(rows_ == cell_info.size());
        int cellno = 0;
        for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j < columns_; ++j) {
@@ -396,26 +394,20 @@ void LyXTabular::fixCellNums()
        }
 
        set_row_column_number_info();
-       BOOST_ASSERT(rows_ == row_info.size());
-       BOOST_ASSERT(columns_ == column_info.size());
-       BOOST_ASSERT(rows_  == cell_info.size());
 }
 
 
 void LyXTabular::setOwner(InsetTabular * inset)
 {
-       for (int i = 0; i < rows_; ++i)
+       for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j < columns_; ++j) {
                        cell_info[i][j].inset.setOwner(inset);
                        cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
                }
+       }
 }
 
 
-#warning for some strange reason, cellstruct does not seem to have copy-semantics
-
-// work around using 'swap' only...
-
 void LyXTabular::appendRow(BufferParams const & bp, int cell)
 {
        ++rows_;
@@ -463,8 +455,6 @@ void LyXTabular::appendColumn(BufferParams const & bp, int cell)
 {
        ++columns_;
 
-       cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
-                                                             cellstruct(bp)));
        int const column = column_of_cell(cell);
        column_vector::iterator cit = column_info.begin() + column + 1;
        column_info.insert(cit, columnstruct());
@@ -472,21 +462,16 @@ void LyXTabular::appendColumn(BufferParams const & bp, int cell)
        column_info[column + 1] = column_info[column];
 
        for (int i = 0; i < rows_; ++i) {
-               for (int j = 0; j <= column; ++j)
-                       c_info[i][j] = cell_info[i][j];
-
-               for (int j = column + 1; j < columns_; ++j)
-                       c_info[i][j] = cell_info[i][j - 1];
+               cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp));
 
                // care about multicolumns
-               if (c_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
-                       c_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
+               if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
+                       cell_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
 
                if (column + 2 >= columns_
-                   || c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
-                       c_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
+                   || cell_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
+                       cell_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
        }
-       cell_info = c_info;
        //++column;
        for (int i = 0; i < rows_; ++i) {
                cell_info[i][column + 1].inset.clear(false);
@@ -2164,7 +2149,8 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::linuxdoc(Buffer const & buf, ostream & os) const
+int LyXTabular::linuxdoc(Buffer const & buf, ostream & os,
+                        const LatexRunParams & runparams) const
 {
        os << "<tabular ca=\"";
        for (int i = 0; i < columns_; ++i) {
@@ -2189,7 +2175,7 @@ int LyXTabular::linuxdoc(Buffer const & buf, ostream & os) const
                                continue;
                        InsetText & inset = getCellInset(cell);
 
-                       ret += inset.linuxdoc(buf, os);
+                       ret += inset.linuxdoc(buf, os, runparams);
 
                        if (isLastCellInRow(cell)) {
                                os << "@\n";
@@ -2205,7 +2191,8 @@ int LyXTabular::linuxdoc(Buffer const & buf, ostream & os) const
 }
 
 
-int LyXTabular::docbookRow(Buffer const & buf, ostream & os, int row) const
+int LyXTabular::docbookRow(Buffer const & buf, ostream & os, int row,
+                          LatexRunParams const & runparams) const
 {
        int ret = 0;
        int cell = getFirstCellInRow(row);
@@ -2247,7 +2234,9 @@ int LyXTabular::docbookRow(Buffer const & buf, ostream & os, int row) const
                }
 
                os << '>';
-               ret += getCellInset(cell).docbook(buf, os, true);
+               LatexRunParams runp = runparams;
+               runp.mixed_content = true;
+               ret += getCellInset(cell).docbook(buf, os, runp);
                os << "</entry>\n";
                ++cell;
        }
@@ -2257,7 +2246,7 @@ int LyXTabular::docbookRow(Buffer const & buf, ostream & os, int row) const
 
 
 int LyXTabular::docbook(Buffer const & buf, ostream & os,
-                       bool /*mixcont*/) const
+                       LatexRunParams const & runparams) const
 {
        int ret = 0;
 
@@ -2295,7 +2284,7 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
                ++ret;
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endhead || row_info[i].endfirsthead) {
-                               ret += docbookRow(buf, os, i);
+                               ret += docbookRow(buf, os, i, runparams);
                        }
                }
                os << "</thead>\n";
@@ -2307,7 +2296,7 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
                ++ret;
                for (int i = 0; i < rows_; ++i) {
                        if (row_info[i].endfoot || row_info[i].endlastfoot) {
-                               ret += docbookRow(buf, os, i);
+                               ret += docbookRow(buf, os, i, runparams);
                        }
                }
                os << "</tfoot>\n";
@@ -2322,7 +2311,7 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
        ++ret;
        for (int i = 0; i < rows_; ++i) {
                if (isValidRow(i)) {
-                       ret += docbookRow(buf, os, i);
+                       ret += docbookRow(buf, os, i, runparams);
                }
        }
        os << "</tbody>\n";
@@ -2433,12 +2422,13 @@ int LyXTabular::asciiBottomHLine(ostream & os, int row,
 
 
 int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
+                              LatexRunParams const & runparams,
                               int cell, int row, int column,
                               vector<unsigned int> const & clen,
                               bool onlydata) const
 {
        ostringstream sstr;
-       int ret = getCellInset(cell).ascii(buf, sstr, 0);
+       int ret = getCellInset(cell).ascii(buf, sstr, runparams);
 
        if (onlydata) {
                os << sstr.str();
@@ -2482,8 +2472,10 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::ascii(Buffer const & buf, ostream & os, int const depth,
-                                         bool onlydata, unsigned char delim) const
+int LyXTabular::ascii(Buffer const & buf, ostream & os,
+                     LatexRunParams const & runparams,
+                     int const depth,
+                     bool onlydata, unsigned char delim) const
 {
        int ret = 0;
 
@@ -2499,7 +2491,7 @@ int LyXTabular::ascii(Buffer const & buf, ostream & os, int const depth,
                                if (isMultiColumnReal(cell))
                                        continue;
                                ostringstream sstr;
-                               getCellInset(cell).ascii(buf, sstr, 0);
+                               getCellInset(cell).ascii(buf, sstr, runparams);
                                if (clen[j] < sstr.str().length())
                                        clen[j] = sstr.str().length();
                        }
@@ -2511,7 +2503,7 @@ int LyXTabular::ascii(Buffer const & buf, ostream & os, int const depth,
                                if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j))
                                        continue;
                                ostringstream sstr;
-                               getCellInset(cell).ascii(buf, sstr, 0);
+                               getCellInset(cell).ascii(buf, sstr, runparams);
                                int len = int(sstr.str().length());
                                int const n = cells_in_multicolumn(cell);
                                for (int k = j; len > 0 && k < j + n - 1; ++k)
@@ -2531,7 +2523,8 @@ int LyXTabular::ascii(Buffer const & buf, ostream & os, int const depth,
                                continue;
                        if (onlydata && j > 0)
                                os << delim;
-                       ret += asciiPrintCell(buf, os, cell, i, j, clen, onlydata);
+                       ret += asciiPrintCell(buf, os, runparams,
+                                             cell, i, j, clen, onlydata);
                        ++cell;
                }
                os << endl;