]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
fix some C++ parsing bugs
[lyx.git] / src / tabular.C
index c3255f0cea6e84ae581734dedca58498884fac5e..bc38b967facee396db09906995d1a103c51e83e0 100644 (file)
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 // temporary until verified (08/08/2001 Jug)
 #define SPECIAL_COLUM_HANDLING 1
 
@@ -101,7 +97,7 @@ LyXTabular::columnstruct::columnstruct()
 }
 
 
-LyXTabular::lttype::lttype()
+LyXTabular::ltType::ltType()
 {
        topDL = false;
        bottomDL = false;
@@ -157,7 +153,7 @@ LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 {
 #if 0
-#warning This while method should look like this: (Lgb)
+#warning This whole method should look like this: (Lgb)
 
                LyXTabular tmp(lt);
                tmp.swap(*this);
@@ -270,7 +266,9 @@ void LyXTabular::AppendRow(BufferParams const & bp, int cell)
        cell_info = c_info;
        ++row;
        for (int j = 0; j < columns_; ++j) {
-               cell_info[row][j].inset.clear();
+               cell_info[row][j].inset.clear(false);
+               if (bp.tracking_changes)
+                       cell_info[row][j].inset.markNew(true);
        }
 #endif
        Reinit();
@@ -321,8 +319,9 @@ void LyXTabular::AppendColumn(BufferParams const & bp, int cell)
        cell_info = c_info;
        //++column;
        for (int i = 0; i < rows_; ++i) {
-               //cell_info[i][column].inset.clear();
-               cell_info[i][column + 1].inset.clear();
+               cell_info[i][column + 1].inset.clear(false);
+               if (bp.tracking_changes)
+                       cell_info[i][column + 1].inset.markNew(true);
        }
        Reinit();
 }
@@ -510,7 +509,7 @@ bool LyXTabular::RightLine(int cell, bool onlycolumn) const
 }
 
 
-bool LyXTabular::TopAlreadyDrawed(int cell) const
+bool LyXTabular::topAlreadyDrawn(int cell) const
 {
        int row = row_of_cell(cell);
        if ((row > 0) && !GetAdditionalHeight(row)) {
@@ -529,7 +528,7 @@ bool LyXTabular::TopAlreadyDrawed(int cell) const
 }
 
 
-bool LyXTabular::LeftAlreadyDrawed(int cell) const
+bool LyXTabular::leftAlreadyDrawn(int cell) const
 {
        int column = column_of_cell(cell);
        if (column > 0) {
@@ -1447,17 +1446,12 @@ void LyXTabular::OldFormatRead(BufferParams const & bp,
        }
        set_row_column_number_info(true);
 
-       Paragraph * par = new Paragraph;
-       Paragraph * return_par = 0;
-
-       par->layout(bp.getLyXTextClass().defaultLayout());
-
        string tmptok;
-       int pos = 0;
        Paragraph::depth_type depth = 0;
-       LyXFont font(LyXFont::ALL_INHERIT);
-       font.setLanguage(owner_->bufferOwner()->getLanguage());
 
+       ParagraphList parlist;
+       ParagraphList::iterator pit = parlist.begin();
+       
        while (lex.isOK()) {
                lex.nextToken();
                string const token = lex.getString();
@@ -1471,22 +1465,17 @@ void LyXTabular::OldFormatRead(BufferParams const & bp,
                        lex.pushToken(token);
                        break;
                }
-               if (owner_->bufferOwner()->parseSingleLyXformat2Token(lex, par,
-                                                                                                                         return_par,
-                                                                                                                         token, pos,
-                                                                                                                         depth, font)) {
-                       // the_end read
-                       lex.pushToken(token);
-                       break;
-               }
-               if (return_par) {
-                       lex.printError("New Paragraph allocated! This should not happen!");
+
+               if (token == "\\the_end") {
                        lex.pushToken(token);
-                       delete par;
-                       par = return_par;
                        break;
                }
+
+               owner_->bufferOwner()->readParagraph(lex, token, parlist, pit, depth);
        }
+
+       Paragraph * par = &(*parlist.begin());
+
        // now we have the par we should fill the insets with this!
        int cell = 0;
        InsetText * inset = GetCellInset(cell);
@@ -1543,7 +1532,7 @@ LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
 }
 
 
-void LyXTabular::SetMultiColumn(Buffer const * buffer, int cell, int number)
+void LyXTabular::SetMultiColumn(Buffer * buffer, int cell, int number)
 {
        cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
        cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
@@ -1553,9 +1542,9 @@ void LyXTabular::SetMultiColumn(Buffer const * buffer, int cell, int number)
 #if 1
        for (int i = 1; i < number; ++i) {
                cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
-               cellinfo_of_cell(cell)->inset.appendParagraphs(buffer->params,
+               cellinfo_of_cell(cell)->inset.appendParagraphs(buffer,
                        cellinfo_of_cell(cell+i)->inset.paragraph());
-               cellinfo_of_cell(cell+i)->inset.clear();
+               cellinfo_of_cell(cell+i)->inset.clear(false);
        }
 #else
        for (number--; number > 0; --number) {
@@ -2771,11 +2760,13 @@ vector<string> const LyXTabular::getLabelList() const
 
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
-       Paragraph * par = GetCellInset(cell)->paragraph();
+       ParagraphList const & parlist = GetCellInset(cell)->paragraphs;
+       ParagraphList::iterator cit = parlist.begin();
+       ParagraphList::iterator end = parlist.end();
 
-       for (; par; par = par->next()) {
-               for (int i = 0; i < par->size(); ++i) {
-                       if (par->getChar(i) == Paragraph::META_NEWLINE)
+       for (; cit != end; ++cit) {
+               for (int i = 0; i < cit->size(); ++i) {
+                       if (cit->isNewline(i))
                                return BOX_PARBOX;
                }
        }