]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Alfredo's second patch
[lyx.git] / src / tabular.C
index 2d167988453549bfe19703049c70c83d2449c1b7..6ae8ab1c518f5fcc62f470ea466ba4485af17184 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;
@@ -133,7 +129,7 @@ LyXTabular::LyXTabular(BufferParams const & bp,
                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.paragraph(),true);
+                               cell_info[i][j].inset.setParagraphData(lt.cell_info[i][j].inset.paragraphs, true);
                        }
                }
        }
@@ -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) {
@@ -751,8 +750,9 @@ bool LyXTabular::SetColumnPWidth(int cell, LyXLength const & width)
        int const j = column_of_cell(cell);
 
        column_info[j].p_width = width;
-       if (flag) // do this only if there is a width
-               SetAlignment(cell, LYX_ALIGN_LEFT);
+       // This should not ne necessary anymore
+       //      if (flag) // do this only if there is a width
+       //      SetAlignment(cell, LYX_ALIGN_LEFT);
        for (int i = 0; i < rows_; ++i) {
                int c = GetCellNumber(i, j);
                flag = !GetPWidth(c).zero(); // because of multicolumns!
@@ -1102,17 +1102,15 @@ void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
        l_getline(is, line);
        if (!prefixIs(line, "<lyxtabular ")
                && !prefixIs(line, "<LyXTabular ")) {
-               OldFormatRead(buf->params, lex, line);
+               lyx::Assert(false);
                return;
        }
 
        int version;
        if (!getTokenValue(line, "version", version))
                return;
-       if (version == 1)
-               ReadOld(buf, is, lex, line);
-       else if (version >= 2)
-               ReadNew(buf, is, lex, line, version);
+       lyx::Assert(version >= 2);
+       read(buf, is, lex, line, version);
 }
 
 void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
@@ -1192,8 +1190,8 @@ void LyXTabular::setHeaderFooterRows(int hr, int fhr, int fr, int lfr)
        }
 }
 
-void LyXTabular::ReadNew(Buffer const * buf, istream & is,
-                        LyXLex & lex, string const & l, int const version)
+void LyXTabular::read(Buffer const * buf, istream & is,
+                      LyXLex & lex, string const & l, int const version)
 {
        string line(l);
        int rows_arg;
@@ -1205,8 +1203,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
        Init(buf->params, rows_arg, columns_arg);
        l_getline(is, line);
        if (!prefixIs(line, "<features")) {
-               lyxerr << "Wrong tabular format (expected <features ...> got" <<
-                       line << ")" << endl;
+               lyxerr << "Wrong tabular format (expected <features ...> got"
+                      << line << ')' << endl;
                return;
        }
        getTokenValue(line, "rotate", rotate);
@@ -1245,8 +1243,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
        for (int j = 0; j < columns_; ++j) {
                l_getline(is,line);
                if (!prefixIs(line,"<column")) {
-                       lyxerr << "Wrong tabular format (expected <column ...> got" <<
-                               line << ")" << endl;
+                       lyxerr << "Wrong tabular format (expected <column ...> got"
+                              << line << ')' << endl;
                        return;
                }
                getTokenValue(line, "alignment", column_info[j].alignment);
@@ -1260,8 +1258,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
        for (int i = 0; i < rows_; ++i) {
                l_getline(is, line);
                if (!prefixIs(line, "<row")) {
-                       lyxerr << "Wrong tabular format (expected <row ...> got" <<
-                               line << ")" << endl;
+                       lyxerr << "Wrong tabular format (expected <row ...> got"
+                              << line << ')' << endl;
                        return;
                }
                getTokenValue(line, "topline", row_info[i].top_line);
@@ -1274,8 +1272,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
                for (int j = 0; j < columns_; ++j) {
                        l_getline(is, line);
                        if (!prefixIs(line, "<cell")) {
-                               lyxerr << "Wrong tabular format (expected <cell ...> got" <<
-                                       line << ")" << endl;
+                               lyxerr << "Wrong tabular format (expected <cell ...> got"
+                                      << line << ')' << endl;
                                return;
                        }
                        getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
@@ -1295,15 +1293,15 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
                                l_getline(is, line);
                        }
                        if (!prefixIs(line, "</cell>")) {
-                               lyxerr << "Wrong tabular format (expected </cell> got" <<
-                                       line << ")" << endl;
+                               lyxerr << "Wrong tabular format (expected </cell> got"
+                                      << line << ')' << endl;
                                return;
                        }
                }
                l_getline(is, line);
                if (!prefixIs(line, "</row>")) {
-                       lyxerr << "Wrong tabular format (expected </row> got" <<
-                               line << ")" << endl;
+                       lyxerr << "Wrong tabular format (expected </row> got"
+                              << line << ')' << endl;
                        return;
                }
        }
@@ -1314,230 +1312,6 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
 }
 
 
-void LyXTabular::OldFormatRead(BufferParams const & bp,
-                              LyXLex & lex, string const & fl)
-{
-       int version;
-       int i;
-       int j;
-       int rows_arg = 0;
-       int columns_arg = 0;
-       int is_long_tabular_arg = false;
-       int rotate_arg = false;
-       int a = -1;
-       int b = -1;
-       int c = -1;
-       int d = -1;
-       int e = 0;
-       int f = 0;
-       int g = 0;
-
-       istream & is = lex.getStream();
-       string s(fl);
-       if (s.length() > 8)
-               version = lyx::atoi(s.substr(8, string::npos));
-       else
-               version = 1;
-
-       vector<int> cont_row_info;
-
-       if (version < 5) {
-               lyxerr << "Tabular format < 5 is not supported anymore\n"
-                       "Get an older version of LyX (< 1.1.x) for conversion!"
-                          << endl;
-               Alert::alert(_("Warning:"),
-                                  _("Tabular format < 5 is not supported anymore\n"),
-                                  _("Get an older version of LyX (< 1.1.x) for conversion!"));
-               if (version > 2) {
-                       is >> rows_arg >> columns_arg >> is_long_tabular_arg
-                          >> rotate_arg >> a >> b >> c >> d;
-               } else
-                       is >> rows_arg >> columns_arg;
-               Init(bp, rows_arg, columns_arg);
-               cont_row_info = vector<int>(rows_arg);
-               SetLongTabular(is_long_tabular_arg);
-               SetRotateTabular(rotate_arg);
-               string tmp;
-               for (i = 0; i < rows_; ++i) {
-                       getline(is, tmp);
-                       cont_row_info[i] = false;
-               }
-               for (i = 0; i < columns_; ++i) {
-                       getline(is, tmp);
-               }
-               for (i = 0; i < rows_; ++i) {
-                       for (j = 0; j < columns_; ++j) {
-                               getline(is, tmp);
-                       }
-               }
-       } else {
-               is >> rows_arg >> columns_arg >> is_long_tabular_arg
-                  >> rotate_arg >> a >> b >> c >> d;
-               Init(bp, rows_arg, columns_arg);
-               cont_row_info = vector<int>(rows_arg);
-               SetLongTabular(is_long_tabular_arg);
-               SetRotateTabular(rotate_arg);
-               setHeaderFooterRows(a+1, b+1 , c+1, d+1);
-               for (i = 0; i < rows_; ++i) {
-                       a = b = c = d = e = f = g = 0;
-                       is >> a >> b >> c >> d;
-                       row_info[i].top_line = a;
-                       row_info[i].bottom_line = b;
-                       cont_row_info[i] = c;
-                       row_info[i].newpage = d;
-               }
-               for (i = 0; i < columns_; ++i) {
-                       string s1;
-                       string s2;
-                       is >> a >> b >> c;
-#if 1
-                       char ch; // skip '"'
-                       is >> ch;
-#else
-                       // ignore is buggy but we will use it later (Lgb)
-                       is.ignore(); // skip '"'
-#endif
-                       getline(is, s1, '"');
-#if 1
-                       is >> ch; // skip '"'
-#else
-                       // ignore is buggy but we will use it later (Lgb)
-                       is.ignore(); // skip '"'
-#endif
-                       getline(is, s2, '"');
-                       column_info[i].alignment = static_cast<LyXAlignment>(a);
-                       column_info[i].left_line = b;
-                       column_info[i].right_line = c;
-                       column_info[i].p_width = LyXLength(s1);
-                       column_info[i].align_special = s2;
-               }
-               for (i = 0; i < rows_; ++i) {
-                       for (j = 0; j < columns_; ++j) {
-                               string s1;
-                               string s2;
-                               is >> a >> b >> c >> d >> e >> f >> g;
-#if 1
-                               char ch;
-                               is >> ch; // skip '"'
-#else
-                               // ignore is buggy but we will use it later (Lgb)
-                               is.ignore(); // skip '"'
-#endif
-                               getline(is, s1, '"');
-#if 1
-                               is >> ch; // skip '"'
-#else
-                               // ignore is buggy but we will use it later (Lgb)
-                               is.ignore(); // skip '"'
-#endif
-                               getline(is, s2, '"');
-                               cell_info[i][j].multicolumn = static_cast<char>(a);
-                               cell_info[i][j].alignment = static_cast<LyXAlignment>(b);
-                               cell_info[i][j].top_line = static_cast<char>(c);
-                               cell_info[i][j].bottom_line = static_cast<char>(d);
-                               cell_info[i][j].left_line = column_info[j].left_line;
-                               cell_info[i][j].right_line = column_info[j].right_line;
-                               cell_info[i][j].rotate = static_cast<bool>(f);
-                               cell_info[i][j].usebox = static_cast<BoxType>(g);
-                               cell_info[i][j].align_special = s1;
-                               cell_info[i][j].p_width = LyXLength(s2);
-                       }
-               }
-       }
-       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());
-
-       while (lex.isOK()) {
-               lex.nextToken();
-               string const token = lex.getString();
-               if (token.empty())
-                       continue;
-               if (token == "\\layout"
-                       || token == "\\end_float" // this should not exist anymore
-                       || token == "\\end_inset" // as it is substituted by this
-                       || token == "\\end_deeper")
-               {
-                       lex.pushToken(token);
-#ifndef NO_COMPABILITY
-                       // Here we need to insert the inset_ert_contents into the last
-                       // cell of the tabular.
-                       owner_->bufferOwner()->insertErtContents(par, pos);
-#endif
-                       break;
-               }
-#ifndef NO_COMPABILITY
-               if (token == "\\newline")
-                       // Here we need to insert the inset_ert_contents into the last
-                       // cell of the tabular.
-                       owner_->bufferOwner()->insertErtContents(par, pos, false);
-#endif
-               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!");
-                       lex.pushToken(token);
-                       delete par;
-                       par = return_par;
-                       break;
-               }
-       }
-       // now we have the par we should fill the insets with this!
-       int cell = 0;
-       InsetText * inset = GetCellInset(cell);
-       int row;
-
-       for (int i = 0; i < par->size(); ++i) {
-               if (par->isNewline(i)) {
-                       ++cell;
-                       if (cell > numberofcells) {
-                               lyxerr << "Some error in reading old table format occured!" <<
-                                       endl << "Terminating when reading cell[" << cell << "]!" <<
-                                       endl;
-                               delete par;
-                               return;
-                       }
-                       row = row_of_cell(cell);
-                       if (cont_row_info[row]) {
-                               DeleteRow(row);
-                               cont_row_info.erase(cont_row_info.begin() + row); //&cont_row_info[row]);
-                               while (!IsFirstCellInRow(--cell));
-                       } else {
-                               inset = GetCellInset(cell);
-                               continue;
-                       }
-                       inset = GetCellInset(cell);
-                       row = row_of_cell(cell);
-                       if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].usebox)
-                       {
-                               // insert a space instead
-                               par->erase(i);
-                               par->insertChar(i, ' ');
-                       }
-               }
-               par->copyIntoMinibuffer(*owner_->bufferOwner(), i);
-               inset->paragraph()->insertFromMinibuffer(inset->paragraph()->size());
-       }
-       delete par;
-       Reinit();
-}
-
-
 bool LyXTabular::IsMultiColumn(int cell, bool real) const
 {
        return ((!real || (column_of_cell(cell) != right_column_of_cell(cell))) &&
@@ -1553,7 +1327,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;
@@ -1563,9 +1337,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+i)->inset.paragraph());
-               cellinfo_of_cell(cell+i)->inset.clear();
+               cellinfo_of_cell(cell)->inset.appendParagraphs(buffer,
+                       cellinfo_of_cell(cell+i)->inset.paragraphs);
+               cellinfo_of_cell(cell+i)->inset.clear(false);
        }
 #else
        for (number--; number > 0; --number) {
@@ -2007,16 +1781,18 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
                        if (!GetPWidth(cell).zero()) {
                                switch (GetVAlignment(cell)) {
                                case LYX_VALIGN_TOP:
-                                       os << "p";
+                                       os << 'p';
                                        break;
                                case LYX_VALIGN_CENTER:
-                                       os << "m";
+                                       os << 'm';
                                        break;
                                case LYX_VALIGN_BOTTOM:
-                                       os << "b";
+                                       os << 'b';
                                        break;
                                }
-                               os << "{" << GetPWidth(cell).asLatexString() << '}';
+                               os << '{'
+                                  << GetPWidth(cell).asLatexString()
+                                  << '}';
                        } else {
                                switch (GetAlignment(cell)) {
                                case LYX_ALIGN_LEFT:
@@ -2042,13 +1818,13 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
                os << "\\parbox[";
                switch (GetVAlignment(cell)) {
                case LYX_VALIGN_TOP:
-                       os << "t";
+                       os << 't';
                        break;
                case LYX_VALIGN_CENTER:
-                       os << "c";
+                       os << 'c';
                        break;
                case LYX_VALIGN_BOTTOM:
-                       os << "b";
+                       os << 'b';
                        break;
                }
                os << "]{" << GetPWidth(cell).asLatexString() << "}{";
@@ -2056,13 +1832,13 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
                os << "\\begin{minipage}[";
                switch (GetVAlignment(cell)) {
                case LYX_VALIGN_TOP:
-                       os << "t";
+                       os << 't';
                        break;
                case LYX_VALIGN_CENTER:
-                       os << "m";
+                       os << 'm';
                        break;
                case LYX_VALIGN_BOTTOM:
-                       os << "b";
+                       os << 'b';
                        break;
                }
                os << "]{" << GetPWidth(cell).asLatexString() << "}\n";
@@ -2078,7 +1854,7 @@ int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
 
        // usual cells
        if (GetUsebox(cell) == BOX_PARBOX)
-               os << "}";
+               os << '}';
        else if (GetUsebox(cell) == BOX_MINIPAGE) {
                os << "%\n\\end{minipage}";
                ret += 2;
@@ -2207,14 +1983,14 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
                ret += TeXCellPreamble(os, cell);
                InsetText * inset = GetCellInset(cell);
 
-               bool rtl = inset->paragraph()->isRightToLeftPar(buf->params) &&
-                       !inset->paragraph()->empty() && GetPWidth(cell).zero();
+               bool rtl = inset->paragraphs.begin()->isRightToLeftPar(buf->params) &&
+                       !inset->paragraphs.begin()->empty() && GetPWidth(cell).zero();
 
                if (rtl)
                        os << "\\R{";
                ret += inset->latex(buf, os, fragile, fp);
                if (rtl)
-                       os << "}";
+                       os << '}';
 
                ret += TeXCellPostamble(os, cell);
                if (!IsLastCellInRow(cell)) { // not last cell in row
@@ -2223,7 +1999,7 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
                }
                ++cell;
        }
-       os << "\\\\\n";
+       os << "\\tabularnewline\n";
        ++ret;
        ret += TeXBottomHLine(os, i);
        return ret;
@@ -2254,18 +2030,35 @@ int LyXTabular::latex(Buffer const * buf,
                        if (column_info[i].left_line)
                                os << '|';
                        if (!column_info[i].p_width.zero()) {
+                               switch (column_info[i].alignment) {
+                               case LYX_ALIGN_LEFT:
+                                       os << ">{\\raggedright}";
+                                       break;
+                               case LYX_ALIGN_RIGHT:
+                                       os << ">{\\raggedleft}";
+                                       break;
+                               case LYX_ALIGN_CENTER:
+                                       os << ">{\\centering}";
+                                       break;
+                               case LYX_ALIGN_NONE:
+                               case LYX_ALIGN_BLOCK:
+                               case LYX_ALIGN_LAYOUT:
+                               case LYX_ALIGN_SPECIAL:
+                                       break;
+                               }
+
                                switch (column_info[i].valignment) {
                                case LYX_VALIGN_TOP:
-                                       os << "p";
+                                       os << 'p';
                                        break;
                                case LYX_VALIGN_CENTER:
-                                       os << "m";
+                                       os << 'm';
                                        break;
                                case LYX_VALIGN_BOTTOM:
-                                       os << "b";
+                                       os << 'b';
                                        break;
                        }
-                               os << "{"
+                               os << '{'
                                   << column_info[i].p_width.asLatexString()
                                   << '}';
                        } else {
@@ -2274,8 +2067,8 @@ int LyXTabular::latex(Buffer const * buf,
                                        os << 'l';
                                        break;
                                case LYX_ALIGN_RIGHT:
-                               os << 'r';
-                               break;
+                                       os << 'r';
+                                       break;
                                default:
                                        os << 'c';
                                        break;
@@ -2355,14 +2148,14 @@ int LyXTabular::docbookRow(Buffer const * buf, ostream & os, int row) const
                case LYX_VALIGN_CENTER:
                        os << "middle";
                }
-               os << "\"";
+               os << '"';
 
                if (IsMultiColumn(cell)) {
                        os << " namest=\"col" << j << "\" ";
-                       os << "nameend=\"col" << j + cells_in_multicolumn(cell) - 1<< "\"";
+                       os << "nameend=\"col" << j + cells_in_multicolumn(cell) - 1<< '"';
                }
 
-               os << ">";
+               os << '>';
                ret += GetCellInset(cell)->docbook(buf, os, true);
                os << "</entry>\n";
                ++cell;
@@ -2589,11 +2382,9 @@ int LyXTabular::asciiPrintCell(Buffer const * buf, ostream & os,
                break;
        }
 
-       for (unsigned int i = 0; i < len1; ++i)
-               os << " ";
-       os << sstr.str();
-       for (unsigned int i = 0; i < len2; ++i)
-               os << " ";
+       os << string(len1, ' ')
+          << sstr.str()
+          << string(len2, ' ');
        if (RightLine(cell))
                os << " |";
        else
@@ -2733,12 +2524,15 @@ int LyXTabular::GetCellFromInset(Inset const * inset, int maybe_cell) const
 
 void LyXTabular::Validate(LaTeXFeatures & features) const
 {
+       features.require("NeedTabularnewline");
        if (IsLongTabular())
                features.require("longtable");
        if (NeedRotating())
                features.require("rotating");
        for (int cell = 0; cell < numberofcells; ++cell) {
-               if (GetVAlignment(cell) != LYX_VALIGN_TOP)
+               if ( (GetVAlignment(cell) != LYX_VALIGN_TOP) ||
+                    ( !(GetPWidth(cell).zero())&&!(IsMultiColumn(cell)) )
+                  )
                        features.require("array");
                GetCellInset(cell)->validate(features);
        }
@@ -2761,11 +2555,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;
                }
        }