This patch basically rewrites redoParagraphs to use the
RowList::iterators instead of Row*.

This is a very important function and quite complex too, so strange
things might arise here.

Would be nice if people could test this a bit.

Index: po/POTFILES.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v
retrieving revision 1.324
diff -u -p -r1.324 POTFILES.in
--- po/POTFILES.in	26 Mar 2003 15:55:51 -0000	1.324
+++ po/POTFILES.in	31 Mar 2003 18:01:14 -0000
@@ -29,9 +29,10 @@ src/frontends/controllers/helper_funcs.C
 src/frontends/gnome/GLog.C
 src/frontends/LyXView.C
 src/frontends/qt2/Alert_pimpl.C
+src/frontends/qt2/BulletsModule.C
 src/frontends/qt2/Dialogs.C
 src/frontends/qt2/FileDialog.C
-src/frontends/qt2/lengthcombo.C
+src/frontends/qt2/floatplacement.C
 src/frontends/qt2/QAbout.C
 src/frontends/qt2/QBibitem.C
 src/frontends/qt2/QBibtex.C
@@ -123,7 +124,6 @@ src/frontends/xforms/FormToc.C
 src/frontends/xforms/FormUrl.C
 src/frontends/xforms/FormVCLog.C
 src/frontends/xforms/FormWrap.C
-src/frontends/xforms/input_validators.C
 src/frontends/xforms/Menubar_pimpl.C
 src/frontends/xforms/xformsBC.h
 src/frontends/xforms/xforms_helpers.C
@@ -169,7 +169,6 @@ src/lyxfont.C
 src/lyxfunc.C
 src/lyx_main.C
 src/lyxrc.C
-src/lyxtextclasslist.C
 src/lyxvc.C
 src/mathed/formulabase.C
 src/mathed/formulamacro.C
@@ -181,8 +180,6 @@ src/paragraph.C
 src/paragraph_funcs.C
 src/ParagraphParameters.C
 src/rowpainter.C
-src/support/filetools.C
-src/tabular.C
 src/text2.C
 src/text3.C
 src/text.C
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.334
diff -u -p -r1.334 text.C
--- src/text.C	31 Mar 2003 16:57:44 -0000	1.334
+++ src/text.C	31 Mar 2003 18:01:18 -0000
@@ -907,7 +907,7 @@ LyXText::rowBreakPoint(Row const & row) 
 
 
 // returns the minimum space a row needs on the screen in pixel
-int LyXText::fill(Row & row, int paper_width)
+int LyXText::fill(Row & row, int paper_width) const
 {
 	if (paper_width < 0)
 		return 0;
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.313
diff -u -p -r1.313 text2.C
--- src/text2.C	31 Mar 2003 16:57:45 -0000	1.313
+++ src/text2.C	31 Mar 2003 18:01:19 -0000
@@ -679,83 +679,78 @@ void LyXText::redoDrawingOfParagraph(LyX
 void LyXText::redoParagraphs(LyXCursor const & cur,
 			     Paragraph const * endpar)
 {
-	Row * tmprow = cur.row();
+	Paragraph * tmppar = 0;
+	Paragraph * first_phys_par = 0;
 
-	int y = cur.y() - tmprow->baseline();
+	RowList::iterator tmprit = cur.row();
 
-	Paragraph * first_phys_par = 0;
-	if (!tmprow->previous()) {
+	int y = cur.y() - tmprit->baseline();
+
+	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 = boost::prior(tmprit);
 
-	// Remove all the rows until we reach endpar
-	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();
+	// remove it
+	if (boost::next(tmprit) != rows().end())
+		tmppar = boost::next(tmprit)->par();
+	else
+		tmppar = 0;
+	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();
+			insertParagraph(tmppar, tmprit);
+			if (tmprit == rows().end()) {
+				tmprit = rows().begin();
 			}
-			while (tmprow->next()
-			       && tmprow->next()->par() == tmppar) {
-				tmprow = tmprow->next();
+			while (boost::next(tmprit) != rows().end()
+			       && boost::next(tmprit)->par() == tmppar) {
+				++tmprit;
 			}
 			tmppar = tmppar->next();
 		}
 	} while (tmppar && tmppar != endpar);
 
 	// this is because of layout changes
-	if (prevrow) {
-		setHeightOfRow(prevrow);
-		const_cast<LyXText *>(this)->postPaint(y - prevrow->height());
+	if (prevrit != rows().begin()) {
+		setHeightOfRow(prevrit);
+		const_cast<LyXText *>(this)->postPaint(y - prevrit->height());
 	} else {
 		setHeightOfRow(rows().begin());
 		const_cast<LyXText *>(this)->postPaint(0);
 	}
 
-	if (tmprow && tmprow->next())
-		setHeightOfRow(tmprow->next());
+	if (tmprit != rows().end() && boost::next(tmprit) != rows().end())
+		setHeightOfRow(boost::next(tmprit));
 	updateCounters();
 }
 
@@ -1230,7 +1225,6 @@ void LyXText::setCounter(Buffer const * 
 				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 +1871,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;
-- 
        Lgb

Reply via email to