diff --git a/src/ChangeLog b/src/ChangeLog index 80536e5349..63594586d6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2003-03-29 Lars Gullik Bjønnes + + * text2.C (init): use rowlist_.end() and not 0. + (insertRow): change to take a RowList::iterator as arg, adjust + for this. + (insertParagraph): change to take a RowList::iterator as arg, + adjust for this. + (redoParagraphs): remove some debug msgs. + + * text.C (appendParagraph): change to take a RowList::iterator + arg, adjust for this. + (breakAgain): add an assert + (breakAgainOneRow): ditto + 2003-03-29 John Levon * text2.C: do not clear selection after inc/decDepth @@ -64,7 +78,7 @@ * lyxfunc.C: remove a couple of silly questions, use Alert::prompt - + 2003-03-28 John Levon * text2.C: fix bug 974 (End on empty par) @@ -74,7 +88,7 @@ * BufferView_pimpl.C: * LyXAction.C: * lfuns.h: remove do-nothing math greek lfuns - + 2003-03-27 Lars Gullik Bjønnes * lyxgluelength.h (isValidGlueLength): add default arg on diff --git a/src/lyxtext.h b/src/lyxtext.h index 5a4f8efc51..beddb960e5 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -510,8 +510,9 @@ private: /** inserts a new row behind the specified row, increments the touched counters */ - void insertRow(Row * row, Paragraph * par, lyx::pos_type pos); - + RowList::iterator + insertRow(RowList::iterator rowit, + Paragraph * par, lyx::pos_type pos); /// removes the row and reset the touched counters void removeRow(Row * row); @@ -519,11 +520,11 @@ private: void removeParagraph(Row * row); /// insert the specified paragraph behind the specified row - void insertParagraph(Paragraph * par, Row * row); + void insertParagraph(Paragraph * par, RowList::iterator rowit); /** appends the implizit specified paragraph behind the specified row, * start at the implizit given position */ - void appendParagraph(Row * row); + void appendParagraph(RowList::iterator rowit); /// void breakAgain(Row * row); diff --git a/src/text.C b/src/text.C index 396ca0e08c..d615e7e5ad 100644 --- a/src/text.C +++ b/src/text.C @@ -1312,20 +1312,21 @@ void LyXText::setHeightOfRow(Row * row) // Appends the implicit specified paragraph before the specified row, // start at the implicit given position -void LyXText::appendParagraph(Row * row) +void LyXText::appendParagraph(RowList::iterator rowit) { - pos_type const last = row->par()->size(); + lyx::Assert(rowit != rowlist_.end()); + + pos_type const last = rowit->par()->size(); bool done = false; do { - pos_type z = rowBreakPoint(*row); + pos_type z = rowBreakPoint(*rowit); - Row * tmprow = row; + RowList::iterator tmprow = rowit; if (z < last) { ++z; - insertRow(row, row->par(), z); - row = row->next(); + rowit = insertRow(rowit, rowit->par(), z); } else { done = true; } @@ -1334,7 +1335,7 @@ void LyXText::appendParagraph(Row * row) // fixed fill setting now by calling inset->update() in // SingleWidth when needed! tmprow->fill(fill(*tmprow, workWidth())); - setHeightOfRow(tmprow); + setHeightOfRow(&*tmprow); } while (!done); } @@ -1342,6 +1343,8 @@ void LyXText::appendParagraph(Row * row) void LyXText::breakAgain(Row * row) { + lyx::Assert(row); + bool not_ready = true; do { @@ -1387,6 +1390,8 @@ void LyXText::breakAgain(Row * row) // this is just a little changed version of break again void LyXText::breakAgainOneRow(Row * row) { + lyx::Assert(row); + pos_type z = rowBreakPoint(*row); Row * tmprow = row; diff --git a/src/text2.C b/src/text2.C index 9774dce7a3..bb9dba2a67 100644 --- a/src/text2.C +++ b/src/text2.C @@ -88,7 +88,7 @@ void LyXText::init(BufferView * bview, bool reinit) while (par) { if (rowlist_.empty()) - insertParagraph(par, 0); + insertParagraph(par, rowlist_.end()); else insertParagraph(par, lastRow()); par = par->next(); @@ -263,18 +263,18 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par, // inserts a new row before the specified row, increments // the touched counters -void LyXText::insertRow(Row * row, Paragraph * par, - pos_type pos) +RowList::iterator + LyXText::insertRow(RowList::iterator rowit, Paragraph * par, + pos_type pos) { Row * tmprow = new Row; tmprow->par(par); tmprow->pos(pos); - if (!row) { - rowlist_.insert(rowlist_.begin(), tmprow); - } else { - rowlist_.insert(row->next(), tmprow); - } + if (rowit == rowlist_.end()) + return rowlist_.insert(rowlist_.begin(), tmprow); + else + return rowlist_.insert(boost::next(rowit), tmprow); } @@ -326,17 +326,13 @@ void LyXText::removeParagraph(Row * row) } -void LyXText::insertParagraph(Paragraph * par, Row * row) +void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit) { // insert a new row, starting at position 0 - insertRow(row, par, 0); + RowList::iterator rit = insertRow(rowit, par, 0); // and now append the whole paragraph before the new row - if (!row) { - appendParagraph(firstRow()); - } else { - appendParagraph(row->next()); - } + appendParagraph(rit); } @@ -715,11 +711,8 @@ void LyXText::redoParagraphs(LyXCursor const & cur, // the ownerParagrah() so the paragraph inside the row is NOT // my really first par anymore. Got it Lars ;) (Jug 20011206) first_phys_par = ownerParagraph(); - lyxerr << "ownerParagraph" << endl; - } else { first_phys_par = tmprow->par(); - lyxerr << "tmprow->par()" << endl; // Find first row of this paragraph. while (tmprow->previous() @@ -756,6 +749,7 @@ void LyXText::redoParagraphs(LyXCursor const & cur, do { if (tmppar) { insertParagraph(tmppar, tmprow); + if (!tmprow) { tmprow = firstRow(); }