diff --git a/src/ChangeLog b/src/ChangeLog index 6e8cfdd7f0..6f1eedf0e7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-04-01 Lars Gullik Bjønnes + + * text2.C (redoParagraphs): rewrite (with help from Alfredo) for + RowList::iterator. + + * lyxtext.h (rows): drop one version and leve a const variant that + returns a RowList::iterator. + 2003-03-31 Angus Leeming * text.C (fill): ensure that the signature is the same as that in the diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6da95bf9e9..28a3517dc3 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-04-01 Lars Gullik Bjønnes + + * insetminipage.C (localDispatch): adjust + + * insetert.C (localDispatch): adjust + 2003-03-31 John Levon * insetgraphics.C: diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 6499ea54b1..37fc79acc6 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -455,7 +455,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) * taken by the text). */ LyXText * t = inset.getLyXText(cmd.view()); - t->need_break_row = &*t->rows().begin(); + t->need_break_row = t->rows().begin(); t->fullRebreak(); t->setCursorIntern(t->cursor.par(), t->cursor.pos()); inset.update(cmd.view(), true); diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index bc0ffda2d1..892473647d 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -120,7 +120,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) /* FIXME: I refuse to believe we have to live * with ugliness like this ... */ LyXText * t = inset.getLyXText(cmd.view()); - t->need_break_row = &*t->rows().begin(); + t->need_break_row = t->rows().begin(); t->fullRebreak(); inset.update(cmd.view(), true); t->setCursorIntern(t->cursor.par(), t->cursor.pos()); diff --git a/src/lyxtext.h b/src/lyxtext.h index 8b3f2c0111..44ce1d749e 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -247,10 +247,7 @@ public: RowList::iterator getRow(Paragraph * par, lyx::pos_type pos, int & y) const; - RowList & rows() { - return rowlist_; - } - RowList const & rows() const { + RowList & rows() const { return rowlist_; } diff --git a/src/text2.C b/src/text2.C index d0b793b866..938da8bab0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -679,83 +679,72 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur) void LyXText::redoParagraphs(LyXCursor const & cur, Paragraph const * endpar) { - Row * tmprow = cur.row(); + RowList::iterator tmprit = cur.row(); - int y = cur.y() - tmprow->baseline(); + int y = cur.y() - tmprit->baseline(); Paragraph * first_phys_par = 0; - if (!tmprow->previous()) { + if (tmprit == rows().begin()) { // a trick/hack for UNDO // This is needed because in an UNDO/REDO we could have changed // the ownerParagrah() so the paragraph inside the row is NOT // my really first par anymore. Got it Lars ;) (Jug 20011206) first_phys_par = ownerParagraph(); } else { - first_phys_par = tmprow->par(); - - // Find first row of this paragraph. - while (tmprow->previous() - && tmprow->previous()->par() == first_phys_par) + first_phys_par = tmprit->par(); + while (tmprit != rows().begin() + && boost::prior(tmprit)->par() == first_phys_par) { - tmprow = tmprow->previous(); - y -= tmprow->height(); + --tmprit; + y -= tmprit->height(); } } - Row * prevrow = tmprow->previous(); + RowList::iterator prevrit; + if (tmprit != rows().begin()) { + prevrit = boost::prior(tmprit); + } else { + prevrit = tmprit; + y = prevrit ->height(); + } - // Remove all the rows until we reach endpar + // remove it Paragraph * tmppar = 0; - if (tmprow->next()) - tmppar = tmprow->next()->par(); - while (tmprow->next() && tmppar != endpar) { - removeRow(tmprow->next()); - if (tmprow->next()) { - tmppar = tmprow->next()->par(); + if (boost::next(tmprit) != rows().end()) + tmppar = boost::next(tmprit)->par(); + while (boost::next(tmprit) != rows().end() && tmppar != endpar) { + removeRow(boost::next(tmprit)); + if (boost::next(tmprit) != rows().end()) { + tmppar = boost::next(tmprit)->par(); } else { tmppar = 0; } } - // Remove the first of the paragraphs rows. - // This is because tmprow->previous() can be 0 - Row * tmprow2 = tmprow; - tmprow = tmprow->previous(); - removeRow(tmprow2); + // remove the first one + RowList::iterator tmprit2 = tmprit; /* this is because tmprow->previous() + can be 0 */ + ++tmprit; + removeRow(tmprit2); // Reinsert the paragraphs. tmppar = first_phys_par; do { if (tmppar) { - if (!tmprow) { - insertParagraph(tmppar, rowlist_.begin()); - } else { - insertParagraph(tmppar, tmprow->next()); - } - - - if (!tmprow) { - tmprow = &*rows().begin(); - } - while (tmprow->next() - && tmprow->next()->par() == tmppar) { - tmprow = tmprow->next(); + insertParagraph(tmppar, tmprit); + while (tmprit != rows().end() + && tmprit->par() == tmppar) { + ++tmprit; } tmppar = tmppar->next(); } } while (tmppar && tmppar != endpar); - // this is because of layout changes - if (prevrow) { - setHeightOfRow(prevrow); - const_cast(this)->postPaint(y - prevrow->height()); - } else { - setHeightOfRow(rows().begin()); - const_cast(this)->postPaint(0); - } + setHeightOfRow(prevrit); + const_cast(this)->postPaint(y - prevrit->height()); - if (tmprow && tmprow->next()) - setHeightOfRow(tmprow->next()); + if (tmprit != rows().end() && boost::next(tmprit) != rows().end()) + setHeightOfRow(boost::next(tmprit)); updateCounters(); } @@ -1230,7 +1219,6 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) textclass.counters().step(fl.type()); // Doesn't work... yet. -#warning use boost.format #if USE_BOOST_FORMAT s = boost::io::str(boost::format(_("%1$s #:")) % fl.name()); // s << boost::format(_("%1$s %1$d:") @@ -1877,8 +1865,7 @@ void LyXText::setCurrentFont() // returns the column near the specified x-coordinate of the row // x is set to the real beginning of this column pos_type -LyXText::getColumnNearX(RowList::iterator rit, int & x, - bool & boundary) const +LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const { float tmpx = 0.0; float fill_separator;