]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Fix crash when running lyx -dbg insets -e ...
[lyx.git] / src / tabular.C
index 99e7816168bc011a4d64bf3c845fd3b14a4161a6..2202e3367bf818c2ec9959cfb7b9440345ff9c4e 100644 (file)
@@ -1504,6 +1504,10 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                        || token == "\\end_float"
                        || token == "\\end_deeper") {
                        lex.pushToken(token);
+                       // Here we need to insert the inset_ert_contents into the last
+                       // cell of the tabular.
+                       owner_->bufferOwner()->insertErtContents(par, pos, font);
+                       
                        break;
                }
                if (owner_->bufferOwner()->parseSingleLyXformat2Token(lex, par,
@@ -1530,7 +1534,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
        for (int i = 0; i < par->size(); ++i) {
                if (par->isNewline(i)) {
                        ++cell;
-                       if (cell > GetNumberOfCells()) {
+                       if (cell > numberofcells) {
                                lyxerr << "Some error in reading old table format occured!" <<
                                        endl << "Terminating when reading cell[" << cell << "]!" <<
                                        endl;
@@ -1556,7 +1560,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                        }
                }
                par->copyIntoMinibuffer(*owner_->bufferOwner(), i);
-               inset->par->insertFromMinibuffer(inset->par->size());
+               inset->paragraph()->insertFromMinibuffer(inset->paragraph()->size());
        }
        delete par;
        Reinit();
@@ -1682,7 +1686,7 @@ bool LyXTabular::NeedRotating() const
 
 bool LyXTabular::IsLastCell(int cell) const
 {
-       if ((cell + 1) < GetNumberOfCells())
+       if ((cell + 1) < numberofcells)
                return false;
        return true;
 }
@@ -1726,6 +1730,7 @@ int LyXTabular::GetLastCellBelow(int cell) const
 
 int LyXTabular::GetCellNumber(int row, int column) const
 {
+#if 0
        if (column >= columns_)
                column = columns_ - 1;
        else if (column < 0)
@@ -1734,7 +1739,9 @@ int LyXTabular::GetCellNumber(int row, int column) const
                row = rows_ - 1;
        else if (row < 0)
                row = 0;
-       
+#else
+       lyx::Assert(column >= 0 || column < columns_ || row >= 0 || row < rows_);
+#endif
        return cell_info[row][column].cellno;
 }
 
@@ -2163,8 +2170,8 @@ int LyXTabular::Latex(Buffer const * buf,
                        ret += TeXCellPreamble(os, cell);
                        InsetText * inset = GetCellInset(cell);
 
-                       bool rtl = inset->par->isRightToLeftPar(buf->params) &&
-                                       inset->par->size() > 0 && GetPWidth(cell).empty();
+                       bool rtl = inset->paragraph()->isRightToLeftPar(buf->params) &&
+                                       inset->paragraph()->size() > 0 && GetPWidth(cell).empty();
 
                        if (rtl)
                                os << "\\R{";
@@ -2530,11 +2537,6 @@ InsetText * LyXTabular::GetCellInset(int cell) const
 
 InsetText * LyXTabular::GetCellInset(int row, int column) const
 {
-#ifdef WITH_WARNINGS
-#warning Juergen, should we check whether the row/column values are correct?
-// If we do not need to do that, the tests in GetCellNumber should be
-// changed to asserts.
-#endif
        cur_cell = GetCellNumber(row, column);
        return & cell_info[row][column].inset;
 }
@@ -2570,7 +2572,7 @@ std::vector<string> const LyXTabular::getLabelList() const
                        
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
-       Paragraph * par = GetCellInset(cell)->par;
+       Paragraph * par = GetCellInset(cell)->paragraph();
 
        for (; par; par = par->next()) {
                for (int i = 0; i < par->size(); ++i) {