diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/bufferview_funcs.C lyx-rowlist10/src/bufferview_funcs.C
--- lyx-rowlist9/src/bufferview_funcs.C	2003-03-22 04:21:51.000000000 +0100
+++ lyx-rowlist10/src/bufferview_funcs.C	2003-03-22 13:30:37.000000000 +0100
@@ -403,7 +403,7 @@
 	if (font.language() != ignore_language ||
 	    font.number() != LyXFont::IGNORE) {
 		LyXCursor & cursor = text->cursor;
-		text->computeBidiTables(bv->buffer(), *cursor.row());
+		text->computeBidiTables(bv->buffer(), cursor.row());
 		if (cursor.boundary() !=
 		    text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(),
 				     text->real_current_font))
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/frontends/screen.C lyx-rowlist10/src/frontends/screen.C
--- lyx-rowlist9/src/frontends/screen.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/frontends/screen.C	2003-03-22 20:55:42.000000000 +0100
@@ -265,7 +265,7 @@
 	case LyXText::NEED_VERY_LITTLE_REFRESH:
 	{
 		// ok I will update the current cursor row
-		drawOneRow(text, &bv, &*text->refresh_row, text->refresh_y,
+		drawOneRow(text, &bv, text->refresh_row, text->refresh_y,
 			   yo, xo);
 		// this because if we had a major update the refresh_row could
 		// have been set to 0!
@@ -423,8 +423,9 @@
 	int y = y_text - text->top_y();
 	// y1 is now the real beginning of row on the screen
 
+
 	while (row != end && y < y2) {
-		RowPainter rp(*bv, *text, *row);
+		RowPainter rp(*bv, *text, row);
 		rp.paint(y + yo, xo, y + text->top_y());
 		y += row->height();
 		++row;
@@ -439,7 +440,8 @@
 }
 
 
-void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
+void LyXScreen::drawOneRow(LyXText * text, BufferView * bv,
+			   RowList::iterator row,
 	int y_text, int yo, int xo)
 {
 	int const y = y_text - text->top_y() + yo;
@@ -450,6 +452,6 @@
 	if (y - row->height() > workarea().workHeight())
 		return;
 
-	RowPainter rp(*bv, *text, *row);
+	RowPainter rp(*bv, *text, row);
 	rp.paint(y, xo, y + text->top_y());
 }
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/frontends/screen.h lyx-rowlist10/src/frontends/screen.h
--- lyx-rowlist9/src/frontends/screen.h	2003-03-22 19:13:15.000000000 +0100
+++ lyx-rowlist10/src/frontends/screen.h	2003-03-22 20:52:39.000000000 +0100
@@ -13,12 +13,12 @@
 #ifndef SCREEN_H
 #define SCREEN_H
 
+#include "RowList.h"
 
 class LyXText;
 class LyXCursor;
 class WorkArea;
 class BufferView;
-struct Row;
 
 /**
  * LyXScreen - document rendering management
@@ -150,8 +150,9 @@
 	                int y_offset = 0, int x_offset = 0);
 
 	/// y is a coordinate of the text
-	void drawOneRow(LyXText *, BufferView *, Row * row,
-	                int y_text, int y_offset = 0, int x_offset = 0);
+	void drawOneRow(LyXText *, BufferView *,
+			RowList::iterator row,
+			int y_text, int y_offset = 0, int x_offset = 0);
 
 	/// is the blinking cursor currently drawn
 	bool cursor_visible_;
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/insets/insetert.C lyx-rowlist10/src/insets/insetert.C
--- lyx-rowlist9/src/insets/insetert.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/insets/insetert.C	2003-03-22 20:52:39.000000000 +0100
@@ -453,7 +453,7 @@
 		 * 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 -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/insets/insetminipage.C lyx-rowlist10/src/insets/insetminipage.C
--- lyx-rowlist9/src/insets/insetminipage.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/insets/insetminipage.C	2003-03-22 20:52:39.000000000 +0100
@@ -120,7 +120,7 @@
 		/* 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 -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/insets/insettext.C lyx-rowlist10/src/insets/insettext.C
--- lyx-rowlist9/src/insets/insettext.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/insets/insettext.C	2003-03-22 20:55:42.000000000 +0100
@@ -425,7 +425,7 @@
 	int yf = y_offset + first;
 	y = 0;
 	while ((rowit != end) && (yf < ph)) {
-		RowPainter rp(*bv, *lt, *rowit);
+		RowPainter rp(*bv, *lt, rowit);
 		rp.paint(y + y_offset + first, int(x), y + lt->top_y());
 		y += rowit->height();
 		yf += rowit->height();
@@ -1256,7 +1256,7 @@
 		updwhat = CURSOR;
 		break;
 	case LFUN_PRIOR:
-		if (!crow(bv)->previous())
+		if (crow(bv) == lt->rows().begin())
 			result = FINISHED_UP;
 		else {
 			lt->cursorPrevious();
@@ -1265,7 +1265,7 @@
 		updwhat = CURSOR;
 		break;
 	case LFUN_NEXT:
-		if (!crow(bv)->next())
+		if (boost::next(crow(bv)) == lt->rows().end())
 			result = FINISHED_DOWN;
 		else {
 			lt->cursorNext();
@@ -1823,7 +1823,7 @@
 
 Inset::RESULT InsetText::moveUp(BufferView * bv)
 {
-	if (!crow(bv)->previous())
+	if (crow(bv) == getLyXText(bv)->rows().begin())
 		return FINISHED_UP;
 	getLyXText(bv)->cursorUp(bv);
 	return DISPATCHED_NOUPDATE;
@@ -1832,7 +1832,7 @@
 
 Inset::RESULT InsetText::moveDown(BufferView * bv)
 {
-	if (!crow(bv)->next())
+	if (boost::next(crow(bv)) == getLyXText(bv)->rows().end())
 		return FINISHED_DOWN;
 	getLyXText(bv)->cursorDown(bv);
 	return DISPATCHED_NOUPDATE;
Binary files lyx-rowlist9/src/lyx and lyx-rowlist10/src/lyx differ
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxfunc.C lyx-rowlist10/src/lyxfunc.C
--- lyx-rowlist9/src/lyxfunc.C	2003-03-22 00:00:25.000000000 +0100
+++ lyx-rowlist10/src/lyxfunc.C	2003-03-22 12:58:18.000000000 +0100
@@ -821,7 +821,7 @@
 				owner->view_state_changed();
 				goto exit_with_message;
 			} else if (result == FINISHED_UP) {
-				if (TEXT()->cursor.irow()->previous()) {
+				if (TEXT()->cursor.irow() != TEXT()->rows().begin()) {
 #if 1
 					TEXT()->setCursorFromCoordinates(
 						TEXT()->cursor.ix() + inset_x,
@@ -838,7 +838,7 @@
 				}
 				goto exit_with_message;
 			} else if (result == FINISHED_DOWN) {
-				if (TEXT()->cursor.irow()->next()) {
+				if (boost::next(TEXT()->cursor.irow()) != TEXT()->rows().end()) {
 #if 1
 					TEXT()->setCursorFromCoordinates(
 						TEXT()->cursor.ix() + inset_x,
@@ -882,7 +882,7 @@
 					}
 					goto exit_with_message;
 				case LFUN_DOWN:
-					if (TEXT()->cursor.row()->next())
+					if (boost::next(TEXT()->cursor.row()) != TEXT()->rows().end())
 						TEXT()->cursorDown(view());
 					else
 						TEXT()->cursorRight(view());
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxrow.C lyx-rowlist10/src/lyxrow.C
--- lyx-rowlist9/src/lyxrow.C	2003-03-22 01:03:48.000000000 +0100
+++ lyx-rowlist10/src/lyxrow.C	2003-03-22 14:15:07.000000000 +0100
@@ -3,7 +3,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author unknown
+ * \author Matthias Ettrich
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS
  *
@@ -19,18 +20,15 @@
 
 using lyx::pos_type;
 
-using std::max;
-using std::min;
-
 Row::Row()
 	: par_(0), pos_(0), fill_(0), height_(0), width_(0),
-	  ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
+	  ascent_of_text_(0), baseline_(0)
 {}
 
 
 Row::Row(Paragraph * pa, pos_type po)
 	: par_(pa), pos_(po), fill_(0), height_(0), width_(0),
-	  ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
+	  ascent_of_text_(0), baseline_(0)
 {}
 
 
@@ -52,12 +50,6 @@
 }
 
 
-Row * Row::next() const
-{
-	return next_;
-}
-
-
 void Row::par(Paragraph * p)
 {
 	par_ = p;
@@ -142,179 +134,7 @@
 }
 
 
-void Row::next(Row * r)
-{
-	next_ = r;
-}
-
-
-void Row::previous(Row * r)
-{
-	previous_ = r;
-}
-
-
-Row * Row::previous() const
-{
-	return previous_;
-}
-
-
 bool Row::isParStart() const
 {
 	return !pos();
 }
-
-
-bool Row::isParEnd() const
-{
-	return !next() || next()->par() != par();
-}
-
-
-pos_type Row::lastPos() const
-{
-	if (!par()->size())
-		return 0;
-
-	if (isParEnd()) {
-		return par()->size() - 1;
-	} else {
-		return next()->pos() - 1;
-	}
-}
-
-
-namespace {
-
-bool nextRowIsAllInset(Row const & row, pos_type last)
-{
-	if (last + 1 >= row.par()->size())
-		return false;
-
-	if (!row.par()->isInset(last + 1))
-		return false;
-
-	Inset * i = row.par()->getInset(last + 1);
-	return i->needFullRow() || i->display();
-}
-
-};
-
-
-pos_type Row::lastPrintablePos() const
-{
-	pos_type const last = lastPos();
-
-	// if this row is an end of par, just act like lastPos()
-	if (isParEnd())
-		return last;
-
-	bool const nextrownotinset = !nextRowIsAllInset(*this, last);
-
-	if (nextrownotinset && par()->isSeparator(last))
-		return last - 1;
-
-	return last;
-}
-
-
-int Row::numberOfSeparators() const
-{
-	pos_type const last = lastPrintablePos();
-	pos_type p = max(pos(), par()->beginningOfBody());
-
-	int n = 0;
-	for (; p < last; ++p) {
-		if (par()->isSeparator(p)) {
-			++n;
-		}
-	}
-	return n;
-}
-
-
-int Row::numberOfHfills() const
-{
-	pos_type const last = lastPos();
-	pos_type first = pos();
-
-	// hfill *DO* count at the beginning of paragraphs!
-	if (first) {
-		while (first < last && par()->isHfill(first)) {
-			++first;
-		}
-	}
-
-	first = max(first, par()->beginningOfBody());
-
-	int n = 0;
-
-	// last, because the end is ignored!
-	for (pos_type p = first; p < last; ++p) {
-		if (par()->isHfill(p))
-			++n;
-	}
-	return n;
-}
-
-
-int Row::numberOfLabelHfills() const
-{
-	pos_type last = lastPos();
-	pos_type first = pos();
-
-	// hfill *DO* count at the beginning of paragraphs!
-	if (first) {
-		while (first < last && par()->isHfill(first))
-			++first;
-	}
-
-	last = min(last, par()->beginningOfBody());
-	int n = 0;
-
-	// last, because the end is ignored!
-	for (pos_type p = first; p < last; ++p) {
-		if (par()->isHfill(p))
-			++n;
-	}
-	return n;
-}
-
-
-bool Row::hfillExpansion(pos_type pos) const
-{
-	if (!par()->isHfill(pos))
-		return false;
-
-	// at the end of a row it does not count
-	// unless another hfill exists on the line
-	if (pos >= lastPos()) {
-		pos_type i = this->pos();
-		while (i < pos && !par()->isHfill(i)) {
-			++i;
-		}
-		if (i == pos) {
-			return false;
-		}
-	}
-
-	// at the beginning of a row it does not count, if it is not
-	// the first row of a paragaph
-	if (isParStart())
-		return true;
-
-	// in some labels it does not count
-	if (par()->layout()->margintype != MARGIN_MANUAL
-	    && pos < par()->beginningOfBody())
-		return false;
-
-	// if there is anything between the first char of the row and
-	// the specified position that is not a newline and not a hfill,
-	// the hfill will count, otherwise not
-	pos_type i = this->pos();
-	while (i < pos && (par()->isNewline(i) || par()->isHfill(i)))
-		++i;
-
-	return i != pos;
-}
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxrow_funcs.C lyx-rowlist10/src/lyxrow_funcs.C
--- lyx-rowlist9/src/lyxrow_funcs.C	1970-01-01 01:00:00.000000000 +0100
+++ lyx-rowlist10/src/lyxrow_funcs.C	2003-03-22 14:05:38.000000000 +0100
@@ -0,0 +1,159 @@
+#include <config.h>
+
+#include "lyxrow_funcs.h"
+#include "lyxtext.h"
+#include "paragraph.h"
+#include "lyxlayout.h"
+
+#include <boost/next_prior.hpp>
+#include <algorithm>
+
+using lyx::pos_type;
+using std::max;
+using std::min;
+
+
+bool isParEnd(LyXText * lt, RowList::iterator rit)
+{
+	return boost::next(rit) == lt->rows().end() ||
+		boost::next(rit)->par() != rit->par();
+}
+
+
+// It seems that this is only used in LyXText, it
+// perhaps this function should be moved into LyXText. (Lgb)
+pos_type lastPos(LyXText * lt, RowList::iterator rit)
+{
+	if (!rit->par()->size())
+		return 0;
+
+	if (isParEnd(lt, rit)) {
+		return rit->par()->size() - 1;
+	} else {
+		return boost::next(rit)->pos() - 1;
+	}
+}
+
+
+namespace {
+
+bool nextRowIsAllInset(Row const & row, pos_type last)
+{
+	if (last + 1 >= row.par()->size())
+		return false;
+
+	if (!row.par()->isInset(last + 1))
+		return false;
+
+	Inset * i = row.par()->getInset(last + 1);
+	return i->needFullRow() || i->display();
+}
+
+} // anon namespace
+
+
+pos_type lastPrintablePos(LyXText * lt, RowList::iterator rit)
+{
+	pos_type const last = lastPos(lt, rit);
+
+	// if this row is an end of par, just act like lastPos()
+	if (isParEnd(lt, rit))
+		return last;
+
+	bool const nextrownotinset = !nextRowIsAllInset(*rit, last);
+
+	if (nextrownotinset && rit->par()->isSeparator(last))
+		return last - 1;
+
+	return last;
+}
+
+
+// This is called _once_ from LyXText and should at least be moved into
+// an anonymous namespace there. (Lgb)
+int numberOfHfills(LyXText * lt, RowList::iterator rit)
+{
+	pos_type const last = lastPos(lt, rit);
+	pos_type first = rit->pos();
+
+	// hfill *DO* count at the beginning of paragraphs!
+	if (first) {
+		while (first < last && rit->par()->isHfill(first)) {
+			++first;
+		}
+	}
+
+	first = max(first, rit->par()->beginningOfBody());
+
+	int n = 0;
+
+	// last, because the end is ignored!
+	for (pos_type p = first; p < last; ++p) {
+		if (rit->par()->isHfill(p))
+			++n;
+	}
+	return n;
+}
+
+
+// This is called _once_ from LyXText and should at least be moved into
+// an anonymous namespace there. (Lgb)
+int numberOfLabelHfills(LyXText * lt, RowList::iterator rit)
+{
+	pos_type last = lastPos(lt, rit);
+	pos_type first = rit->pos();
+
+	// hfill *DO* count at the beginning of paragraphs!
+	if (first) {
+		while (first < last && rit->par()->isHfill(first))
+			++first;
+	}
+
+	last = min(last, rit->par()->beginningOfBody());
+	int n = 0;
+
+	// last, because the end is ignored!
+	for (pos_type p = first; p < last; ++p) {
+		if (rit->par()->isHfill(p))
+			++n;
+	}
+	return n;
+}
+
+
+bool hfillExpansion(LyXText * lt, RowList::iterator rit, pos_type pos)
+{
+	if (!rit->par()->isHfill(pos))
+		return false;
+
+	// at the end of a row it does not count
+	// unless another hfill exists on the line
+	if (pos >= lastPos(lt, rit)) {
+		pos_type i = rit->pos();
+		while (i < pos && !rit->par()->isHfill(i)) {
+			++i;
+		}
+		if (i == pos) {
+			return false;
+		}
+	}
+
+	// at the beginning of a row it does not count, if it is not
+	// the first row of a paragaph
+	if (rit->isParStart())
+		return true;
+
+	// in some labels it does not count
+	if (rit->par()->layout()->margintype != MARGIN_MANUAL
+	    && pos < rit->par()->beginningOfBody())
+		return false;
+
+	// if there is anything between the first char of the row and
+	// the specified position that is not a newline and not a hfill,
+	// the hfill will count, otherwise not
+	pos_type i = rit->pos();
+	while (i < pos && (rit->par()->isNewline(i) || rit->par()->isHfill(i)))
+		++i;
+
+	return i != pos;
+}
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxrow_funcs.h lyx-rowlist10/src/lyxrow_funcs.h
--- lyx-rowlist9/src/lyxrow_funcs.h	1970-01-01 01:00:00.000000000 +0100
+++ lyx-rowlist10/src/lyxrow_funcs.h	2003-03-22 14:17:20.000000000 +0100
@@ -0,0 +1,23 @@
+// -*- C++ -*-
+
+#ifndef LYXROW_FUNCS_H
+#define LYXROW_FUNCS_H
+
+#include "RowList.h"
+#include "support/types.h"
+
+class LyXText;
+
+bool isParEnd(LyXText * lt, RowList::iterator rit);
+
+lyx::pos_type lastPos(LyXText * lt, RowList::iterator rit);
+
+lyx::pos_type lastPrintablePos(LyXText * lt, RowList::iterator rit);
+
+int numberOfHfills(LyXText * lt, RowList::iterator rit);
+
+int numberOfLabelHfills(LyXText * lt, RowList::iterator rit);
+
+bool hfillExpansion(LyXText * lt, RowList::iterator rit, lyx::pos_type pos);
+
+#endif
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxrow.h lyx-rowlist10/src/lyxrow.h
--- lyx-rowlist9/src/lyxrow.h	2003-03-22 01:03:02.000000000 +0100
+++ lyx-rowlist10/src/lyxrow.h	2003-03-22 14:13:07.000000000 +0100
@@ -4,7 +4,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author unknown
+ * \author Matthias Ettrich
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS
  *
@@ -59,48 +60,8 @@
 	void baseline(unsigned int b);
 	///
 	unsigned int baseline() const;
-	///
-	void next(Row * r);
-	///
-	Row * next() const;
-	///
-	void previous(Row * r);
-	///
-	Row * previous() const;
-
 	/// return true if this row is the start of a paragraph
 	bool isParStart() const;
-
-	/// return true if this  row is the end of a paragraph
-	bool isParEnd() const;
-
-	/// return the position of the last character in this row
-	lyx::pos_type lastPos() const;
-	/// return the position of the last normal, printable character in this row
-	lyx::pos_type lastPrintablePos() const;
-
-	/**
-	 * Returns the number of separators.
-	 * The separator on the very last column doesnt count.
-	 */
-	int numberOfSeparators() const;
-
-	/**
-	 * Returns the number of hfills. It works like a LaTeX \hfill:
-	 * the hfills at the beginning and at the end are ignored.
-	 * This is much more useful than not to ignore!
-	 */
-	int numberOfHfills() const;
-
-	/// Returns the number of hfills in the manual label. See numberOfHfills().
-	int numberOfLabelHfills() const;
-
-	/**
-	 * Returns true if a expansion is needed at the given position.
-	 * Rules are given by LaTeX
-	 */
-	bool hfillExpansion(lyx::pos_type pos) const;
-
 private:
 	///
 	Paragraph * par_;
@@ -119,10 +80,6 @@
 	unsigned int top_of_text_;
 	///
 	unsigned int baseline_;
-	///
-	Row * next_;
-	///
-	Row * previous_;
 };
 
 #endif
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/lyxtext.h lyx-rowlist10/src/lyxtext.h
--- lyx-rowlist9/src/lyxtext.h	2003-03-22 20:10:57.000000000 +0100
+++ lyx-rowlist10/src/lyxtext.h	2003-03-22 20:11:15.000000000 +0100
@@ -480,7 +480,7 @@
 	int workWidth(Inset * inset);
 
 	///
-	void computeBidiTables(Buffer const *, Row const & row) const;
+	void computeBidiTables(Buffer const *, RowList::iterator row) const;
 	/// Maps positions in the visual string to positions in logical string.
 	lyx::pos_type log2vis(lyx::pos_type pos) const;
 	/// Maps positions in the logical string to positions in visual string.
@@ -572,13 +572,13 @@
 	 * in LaTeX the beginning of the text fits in some cases
 	 * (for example sections) exactly the label-width.
 	 */
-	int leftMargin(RowList::iterator rit);
+	int leftMargin(Row const & row);
 	///
 	int rightMargin(Buffer const &, Row const & row) const;
 
 	/** this calculates the specified parameters. needed when setting
 	 * the cursor and when creating a visible row */
-	void prepareToPrint(RowList::iterator rit, float & x,
+	void prepareToPrint(RowList::iterator row, float & x,
 			    float & fill_separator,
 			    float & fill_hfill,
 			    float & fill_label_hfill,
@@ -604,8 +604,8 @@
 	lyx::pos_type rowBreakPoint(Row const & row);
 
 	/// returns the minimum space a row needs on the screen in pixel
-	int fill(Row & row, int workwidth);
+	int fill(RowList::iterator row, int workwidth);
 
 	/**
 	 * returns the minimum space a manual label needs on the
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/Makefile.am lyx-rowlist10/src/Makefile.am
--- lyx-rowlist9/src/Makefile.am	2003-03-21 19:18:57.000000000 +0100
+++ lyx-rowlist10/src/Makefile.am	2003-03-22 14:58:00.000000000 +0100
@@ -77,7 +77,6 @@
 	ParagraphParameters.h \
 	ParameterStruct.h \
 	PrinterParams.h \
-	RowList.C \
 	RowList.h \
 	ShareContainer.h \
 	Spacing.C \
@@ -172,7 +171,9 @@
 	lyxrc.h \
 	lyxrow.C \
 	lyxrow.h \
+	lyxrow_funcs.C \
+	lyxrow_funcs.h \
 	lyxserver.C \
 	lyxserver.h \
 	lyxtext.h \
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/RowList.C lyx-rowlist10/src/RowList.C
--- lyx-rowlist9/src/RowList.C	2003-03-22 04:47:55.000000000 +0100
+++ lyx-rowlist10/src/RowList.C	1970-01-01 01:00:00.000000000 +0100
@@ -1,296 +0,0 @@
-#include <config.h>
-
-#include "RowList.h"
-
-#include "lyxrow.h"
-
-////////// The RowList::iterator
-
-RowList::iterator::iterator()
-	: ptr(0)
-{}
-
-
-RowList::iterator::iterator(Row * p)
-	: ptr(p)
-{}
-
-
-RowList::iterator::reference
-RowList::iterator::operator*()
-{
-	return *ptr;
-}
-
-
-RowList::iterator::pointer
-RowList::iterator::operator->()
-{
-	return ptr;
-}
-
-
-RowList::iterator &
-RowList::iterator::operator++()
-{
-	ptr = ptr->next();
-	return *this;
-}
-
-
-RowList::iterator
-RowList::iterator::operator++(int)
-{
-	iterator tmp = *this;
-	++*this;
-	return tmp;
-}
-
-
-RowList::iterator &
-RowList::iterator::operator--()
-{
-	ptr = ptr->previous();
-	return *this;
-}
-
-
-RowList::iterator
-RowList::iterator::operator--(int)
-{
-	iterator tmp = *this;
-	--*this;
-	return tmp;
-}
-
-
-bool operator==(RowList::iterator const & i1,
-		RowList::iterator const & i2)
-{
-	return &(*const_cast<RowList::iterator&>(i1))
-	    == &(*const_cast<RowList::iterator&>(i2));
-}
-
-
-bool operator!=(RowList::iterator const & i1,
-		RowList::iterator const & i2)
-{
-	return !(i1 == i2);
-}
-
-
-////////// The RowList::const_iterator
-
-RowList::const_iterator::const_iterator()
-	: ptr(0)
-{}
-
-
-RowList::const_iterator::const_iterator(Row * p)
-	: ptr(p)
-{}
-
-
-RowList::const_iterator::const_reference
-RowList::const_iterator::operator*()
-{
-	return *ptr;
-}
-
-
-RowList::const_iterator::const_pointer
-RowList::const_iterator::operator->()
-{
-	return ptr;
-}
-
-
-RowList::const_iterator &
-RowList::const_iterator::operator++()
-{
-	ptr = ptr->next();
-	return *this;
-}
-
-
-RowList::const_iterator
-RowList::const_iterator::operator++(int)
-{
-	const_iterator tmp = *this;
-	++*this;
-	return tmp;
-}
-
-
-RowList::const_iterator &
-RowList::const_iterator::operator--()
-{
-	ptr = ptr->previous();
-	return *this;
-}
-
-
-RowList::const_iterator
-RowList::const_iterator::operator--(int)
-{
-	const_iterator tmp = *this;
-	--*this;
-	return tmp;
-}
-
-
-bool operator==(RowList::const_iterator const & i1,
-		RowList::const_iterator const & i2)
-{
-	return &(*const_cast<RowList::const_iterator&>(i1))
-	    == &(*const_cast<RowList::const_iterator&>(i2));
-}
-
-
-bool operator!=(RowList::const_iterator const & i1,
-		RowList::const_iterator const & i2)
-{
-	return !(i1 == i2);
-}
-
-
-////////// The RowList proper
-RowList::RowList()
-	: rowlist(0)
-{}
-
-
-RowList::iterator
-RowList::insert(RowList::iterator it, Row * row)
-{
-	if (it != end()) {
-		Row * prev = it->previous();
-		row->next(&*it);
-		row->previous(prev);
-		prev->next(row);
-		it->previous(row);
-	} else if (rowlist == 0) {
-		rowlist = row;
-	} else {
-		// Find last par.
-		Row * last = rowlist;
-		while (last->next())
-			last = last->next();
-		last->next(row);
-		row->previous(last);
-	}
-	return iterator(row);
-}
-
-
-void RowList::clear()
-{
-	while (rowlist) {
-		Row * tmp = rowlist->next();
-		delete rowlist;
-		rowlist = tmp;
-	}
-}
-
-
-void RowList::erase(RowList::iterator it)
-{
-	Row * prev = it->previous();
-	Row * next = it->next();
-
-	if (prev)
-		prev->next(next);
-	if (next)
-		next->previous(prev);
-
-	delete &*it;
-}
-
-
-RowList::iterator RowList::begin()
-{
-	return iterator(rowlist);
-}
-
-
-RowList::const_iterator RowList::begin() const
-{
-	return const_iterator(rowlist);
-}
-
-
-RowList::iterator RowList::end()
-{
-	return iterator();
-}
-
-
-RowList::const_iterator RowList::end() const
-{
-	return const_iterator();
-}
-
-
-Row const & RowList::front() const
-{
-	return *rowlist;
-}
-
-
-Row & RowList::front()
-{
-	return *rowlist;
-}
-
-
-Row const & RowList::back() const
-{
-	Row * tmp = rowlist;
-	while (tmp->next())
-		tmp = tmp->next();
-	return *tmp;
-}
-
-
-Row & RowList::back()
-{
-	Row * tmp = rowlist;
-	while (tmp->next())
-		tmp = tmp->next();
-	return *tmp;
-}
-
-
-void RowList::push_back(Row * p)
-{
-	if (!rowlist) {
-		rowlist = p;
-		return;
-	}
-
-	Row * pos = rowlist;
-	while (pos->next())
-		pos = pos->next();
-	pos->next(p);
-	p->previous(pos);
-}
-
-
-int RowList::size() const
-{
-	// When we switch to a std::container this will be O(1)
-	// instead of O(n). (Lgb)
-	Row * tmp = rowlist;
-	int c = 0;
-	while (tmp) {
-		++c;
-		tmp = tmp->next();
-	}
-	return c;
-}
-
-
-bool RowList::empty() const
-{
-	return rowlist == 0;
-}
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/RowList.h lyx-rowlist10/src/RowList.h
--- lyx-rowlist9/src/RowList.h	2003-03-22 04:47:54.000000000 +0100
+++ lyx-rowlist10/src/RowList.h	2003-03-22 14:57:45.000000000 +0100
@@ -3,126 +3,10 @@
 #ifndef ROW_LIST_H
 #define ROW_LIST_H
 
-#include <iterator>
+#include "lyxrow.h"
 
-class Row;
+#include <list>
 
-///
-class RowList {
-public:
-	///
-	class iterator {
-	public:
-		///
-		typedef std::bidirectional_iterator_tag iterator_category;
-		///
-		typedef Row * value_type;
-		///
-		typedef ptrdiff_t difference_type;
-		///
-		typedef Row * pointer;
-		///
-		typedef Row & reference;
-		///
-		iterator();
-		///
-		iterator(value_type);
-		///
-		reference operator*();
-		///
-		pointer operator->();
-		///
-		iterator & operator++();
-		///
-		iterator operator++(int);
-		///
-		iterator & operator--();
-		///
-		iterator operator--(int);
-	private:
-		///
-		Row * ptr;
-	};
-	///
-	class const_iterator {
-	public:
-		///
-		typedef std::bidirectional_iterator_tag iterator_category;
-		///
-		typedef Row * value_type;
-		///
-		typedef ptrdiff_t difference_type;
-		///
-		typedef Row const * const_pointer;
-		///
-		typedef Row const & const_reference;
-		///
-		const_iterator();
-		///
-		const_iterator(value_type);
-		///
-		const_reference operator*();
-		///
-		const_pointer operator->();
-		///
-		const_iterator & operator++();
-		///
-		const_iterator operator++(int);
-		///
-		const_iterator & operator--();
-		///
-		const_iterator operator--(int);
-	private:
-		///
-		Row * ptr;
-	};
-	///
-	RowList();
-	///
-	iterator insert(iterator it, Row * row);
-	///
-	void clear();
-	///
-	void erase(iterator it);
-	///
-	iterator begin();
-	///
-	const_iterator begin() const;
-	///
-	iterator end();
-	///
-	const_iterator end() const;
-	///
-	void push_back(Row *);
-	///
-	Row const & front() const;
-	///
-	Row & front();
-	///
-	Row const & back() const;
-	///
-	Row & back();
-	///
-	int size() const;
-	///
-	bool empty() const;
-private:
-	///
-	Row * rowlist;
-};
-
-///
-bool operator==(RowList::iterator const & i1,
-		RowList::iterator const & i2);
-///
-bool operator!=(RowList::iterator const & i1,
-		RowList::iterator const & i2);
-
-///
-bool operator==(RowList::const_iterator const & i1,
-		RowList::const_iterator const & i2);
-///
-bool operator!=(RowList::const_iterator const & i1,
-		RowList::const_iterator const & i2);
+typedef std::list<Row> RowList;
 
 #endif
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/rowpainter.C lyx-rowlist10/src/rowpainter.C
--- lyx-rowlist9/src/rowpainter.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/rowpainter.C	2003-03-22 20:56:37.000000000 +0100
@@ -31,7 +31,7 @@
 #include "lyxrow.h"
 #include "rowpainter.h"
 #include "lyxrc.h"
-
+#include "lyxrow_funcs.h"
 
 using std::max;
 using lyx::pos_type;
@@ -53,8 +53,9 @@
 } // namespace anon
 
 
-RowPainter::RowPainter(BufferView const & bv, LyXText const & text, Row const & row)
-	: bv_(bv), pain_(bv_.painter()), text_(text), row_(row), par_(*row.par())
+RowPainter::RowPainter(BufferView const & bv,
+		       LyXText const & text, RowList::iterator rit)
+	: bv_(bv), pain_(bv_.painter()), text_(text), row_(rit), par_(*rit->par())
 {
 }
 
@@ -97,8 +98,7 @@
 
 int RowPainter::leftMargin() const
 {
-	Row * row(const_cast<Row *>(&row_));
-	return const_cast<LyXText&>(text_).leftMargin(row);
+	return const_cast<LyXText&>(text_).leftMargin(*row_);
 }
 
 
@@ -113,7 +113,7 @@
 #warning inset->update FIXME
 	inset->update(perv(bv_), false);
 
-	inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_);
+	inset->draw(perv(bv_), font, yo_ + row_->baseline(), x_);
 }
 
 
@@ -148,7 +148,7 @@
 	}
 
 	// Draw nikud
-	pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
+	pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
 }
 
 
@@ -179,14 +179,14 @@
 		}
 	}
 	// Draw nikud
-	pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
+	pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
 }
 
 
 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
 {
 	pos_type pos = text_.vis2log(vpos);
-	pos_type const last = row_.lastPrintablePos();
+	pos_type const last = lastPrintablePos(const_cast<LyXText*>(&text_), row_);
 	LyXFont orig_font(getFont(pos));
 
 	// first character
@@ -236,7 +236,7 @@
 	}
 
 	// Draw text and set the new x position
-	pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
+	pain_.text(int(x_), yo_ + row_->baseline(), str, orig_font);
 	x_ += font_metrics::width(str, orig_font);
 }
 
@@ -250,7 +250,7 @@
 	if (orig_font.language() == bv_.buffer()->params.language)
 		return;
 
-	int const y = yo_ + row_.baseline() + 1;
+	int const y = yo_ + row_->baseline() + 1;
 	pain_.line(int(orig_x), y, int(x_), y, LColor::language);
 }
 
@@ -302,7 +302,7 @@
 {
 	int const x = xo_;
 	int const y = yo_ < 0 ? 0 : yo_;
-	int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
+	int const h = yo_ < 0 ? row_->height() + yo_ : row_->height();
 	pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
 }
 
@@ -323,10 +323,9 @@
 		int x;
 		int y = yo_;
 		int w;
-		int h = row_.height();
+		int h = row_->height();
 
-		if (&*startrow == &row_ &&
-		    &*endrow == &row_) {
+		if (startrow == row_ && endrow == row_) {
 			if (startx < endx) {
 				x = xo_ + startx;
 				w = endx - startx;
@@ -336,11 +335,11 @@
 				w = startx - endx;
 				pain_.fillRectangle(x, y, w, h, LColor::selection);
 			}
-		} else if (&*startrow == &row_) {
+		} else if (startrow == row_) {
 			int const x = (is_rtl) ? xo_ : (xo_ + startx);
 			int const w = (is_rtl) ? startx : (width_ - startx);
 			pain_.fillRectangle(x, y, w, h, LColor::selection);
-		} else if (&*endrow == &row_) {
+		} else if (endrow == row_) {
 			int const x = (is_rtl) ? (xo_ + endx) : xo_;
 			int const w = (is_rtl) ? (width_ - endx) : endx;
 			pain_.fillRectangle(x, y, w, h, LColor::selection);
@@ -348,23 +347,23 @@
 			pain_.fillRectangle(xo_, y, width_, h, LColor::selection);
 		}
 		return;
-	} else if (&*startrow != &row_ && &*endrow != &row_) {
+	} else if (startrow != row_ && endrow != row_) {
 		if (y_ > starty && y_ < endy) {
 			int w = width_;
-			int h = row_.height();
+			int h = row_->height();
 			pain_.fillRectangle(xo_, yo_, w, h, LColor::selection);
 		}
 		return;
 	}
 
-	if ((&*startrow != &row_ && !is_rtl) || (&*endrow != &row_ && is_rtl))
-		pain_.fillRectangle(xo_, yo_, int(x_), row_.height(), LColor::selection);
+	if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
+		pain_.fillRectangle(xo_, yo_, int(x_), row_->height(), LColor::selection);
 
 	pos_type const body_pos = par_.beginningOfBody();
-	pos_type const last = row_.lastPrintablePos();
+	pos_type const last = lastPrintablePos(const_cast<LyXText*>(&text_), row_);
 	float tmpx = x_;
 
-	for (pos_type vpos = row_.pos(); vpos <= last; ++vpos)  {
+	for (pos_type vpos = row_->pos(); vpos <= last; ++vpos)  {
 		pos_type pos = text_.vis2log(vpos);
 		float const old_tmpx = tmpx;
 		if (body_pos > 0 && pos == body_pos - 1) {
@@ -377,7 +376,7 @@
 				tmpx -= singleWidth(body_pos - 1);
 		}
 
-		if (row_.hfillExpansion(pos)) {
+		if (hfillExpansion(const_cast<LyXText*>(&text_), row_, pos)) {
 			tmpx += singleWidth(pos);
 			if (pos >= body_pos)
 				tmpx += hfill_;
@@ -393,34 +392,34 @@
 			tmpx += singleWidth(pos);
 		}
 
-		if ((&*startrow != &row_ || text_.selection.start.pos() <= pos) &&
-			(&*endrow != &row_ || pos < text_.selection.end.pos())) {
+		if ((startrow != row_ || text_.selection.start.pos() <= pos) &&
+			(endrow != row_ || pos < text_.selection.end.pos())) {
 			// Here we do not use x_ as xo_ was added to x_.
 			pain_.fillRectangle(int(old_tmpx), yo_,
 				int(tmpx - old_tmpx + 1),
-				row_.height(), LColor::selection);
+				row_->height(), LColor::selection);
 		}
 	}
 
-	if ((&*startrow != &row_ && is_rtl) || (&*endrow != &row_ && !is_rtl)) {
+	if ((startrow != row_ && is_rtl) || (endrow != row_ && !is_rtl)) {
 		pain_.fillRectangle(xo_ + int(tmpx),
 				      yo_, int(bv_.workWidth() - tmpx),
-				      row_.height(), LColor::selection);
+				      row_->height(), LColor::selection);
 	}
 }
 
 
 void RowPainter::paintChangeBar()
 {
-	pos_type const start = row_.pos();
-	pos_type const end = row_.lastPrintablePos();
+	pos_type const start = row_->pos();
+	pos_type const end = lastPrintablePos(const_cast<LyXText*>(&text_), row_);
 
 	if (!par_.isChanged(start, end))
 		return;
 
-	int const height = (row_.next()
-		? row_.height() + row_.next()->top_of_text()
-		: row_.baseline());
+	int const height = (boost::next(row_) != text_.rows().end()
+		? row_->height() + boost::next(row_)->top_of_text()
+		: row_->baseline());
 
 	pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
 }
@@ -439,8 +438,8 @@
 	if (par_.params().startOfAppendix())
 		y += 2 * defaultRowHeight();
 
-	pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
-	pain_.line(ww - 2, y, ww - 2, yo_ + row_.height(), LColor::appendix);
+	pain_.line(1, y, 1, yo_ + row_->height(), LColor::appendix);
+	pain_.line(ww - 2, y, ww - 2, yo_ + row_->height(), LColor::appendix);
 }
 
 
@@ -452,18 +451,18 @@
 		return;
 
 	Paragraph::depth_type prev_depth = 0;
-	if (row_.previous())
-		prev_depth = row_.previous()->par()->getDepth();
+	if (row_ != text_.rows().begin())
+		prev_depth = boost::prior(row_)->par()->getDepth();
 	Paragraph::depth_type next_depth = 0;
-	if (row_.next())
-		next_depth = row_.next()->par()->getDepth();
+	if (boost::next(row_) != text_.rows().end())
+		next_depth = boost::next(row_)->par()->getDepth();
 
 	for (Paragraph::depth_type i = 1; i <= depth; ++i) {
 		int x = (PAPER_MARGIN / 5) * i + xo_;
 		// only consider the changebar space if we're drawing outer left
 		if (!xo_)
 			x += CHANGEBAR_MARGIN;
-		int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
+		int const h = yo_ + row_->height() - 1 - (i - next_depth - 1) * 3;
 
 		pain_.line(x, yo_, x, h, LColor::depthbar);
 
@@ -622,7 +621,7 @@
 	}
 
 	// the top margin
-	if (!row_.previous() && !text_.isInInset())
+	if (row_ == text_.rows().begin() && !text_.isInInset())
 		y_top += PAPER_MARGIN;
 
 	// draw a top pagebreak
@@ -709,8 +708,8 @@
 					}
 
 					pain_.text(int(x),
-						yo_ + row_.baseline() -
-						row_.ascent_of_text() - maxdesc,
+						yo_ + row_->baseline() -
+						row_->ascent_of_text() - maxdesc,
 						str, font);
 				}
 			} else {
@@ -722,7 +721,7 @@
 						- font_metrics::width(str, font);
 				}
 
-				pain_.text(int(x), yo_ + row_.baseline(), str, font);
+				pain_.text(int(x), yo_ + row_->baseline(), str, font);
 			}
 		}
 
@@ -749,14 +748,14 @@
 			float x = x_;
 			if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
 				x = ((is_rtl ? leftMargin() : x_)
-					 + ww - text_.rightMargin(*bv_.buffer(), row_)) / 2;
+					 + ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
 				x -= font_metrics::width(str, font) / 2;
 			} else if (is_rtl) {
 				x = ww - leftMargin() -
 					font_metrics::width(str, font);
 			}
-			pain_.text(int(x), yo_ + row_.baseline()
-				  - row_.ascent_of_text() - maxdesc,
+			pain_.text(int(x), yo_ + row_->baseline()
+				  - row_->ascent_of_text() - maxdesc,
 				  str, font);
 		}
 	}
@@ -766,10 +765,10 @@
 void RowPainter::paintLast()
 {
 	ParagraphParameters const & parparams = par_.params();
-	int y_bottom = row_.height() - 1;
+	int y_bottom = row_->height() - 1;
 
 	// the bottom margin
-	if (!row_.next() && !text_.isInInset())
+	if (boost::next(row_) == text_.rows().end() && !text_.isInInset())
 		y_bottom -= PAPER_MARGIN;
 
 	int const ww = bv_.workWidth();
@@ -812,11 +811,11 @@
 	{
 		LyXFont const font = getLabelFont();
 		int const size = int(0.75 * font_metrics::maxAscent(font));
-		int const y = (yo_ + row_.baseline()) - size;
+		int const y = (yo_ + row_->baseline()) - size;
 		int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
 
-		if (row_.fill() <= size)
-			x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
+		if (row_->fill() <= size)
+			x += (size - row_->fill() + 1) * (is_rtl ? -1 : 1);
 
 		if (endlabel == END_LABEL_BOX) {
 			pain_.rectangle(x, y, size, size, LColor::eolmarker);
@@ -836,8 +835,8 @@
 		string const & str = par_.layout()->endlabelstring();
 		int const x = is_rtl ?
 			int(x_) - font_metrics::width(str, font)
-			: ww - text_.rightMargin(*bv_.buffer(), row_) - row_.fill();
-		pain_.text(x, yo_ + row_.baseline(), str, font);
+			: ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
+		pain_.text(x, yo_ + row_->baseline(), str, font);
 		break;
 	}
 	case END_LABEL_NO_LABEL:
@@ -848,7 +847,7 @@
 
 void RowPainter::paintText()
 {
-	pos_type const last = row_.lastPrintablePos();
+	pos_type const last = lastPrintablePos(const_cast<LyXText*>(&text_), row_);
 	pos_type body_pos = par_.beginningOfBody();
 	if (body_pos > 0 &&
 		(body_pos - 1 > last ||
@@ -862,7 +861,7 @@
 	bool is_struckout = false;
 	float last_strikeout_x = 0.0;
 
-	pos_type vpos = row_.pos();
+	pos_type vpos = row_->pos();
 	while (vpos <= last) {
 		if (x_ > bv_.workWidth())
 			break;
@@ -892,8 +891,8 @@
 		// if we reach the end of a struck out range, paint it
 		// we also don't paint across things like tables
 		if (running_strikeout && (highly_editable_inset || !is_struckout)) {
-			int const middle = yo_ + row_.top_of_text()
-				+ ((row_.baseline() - row_.top_of_text()) / 2);
+			int const middle = yo_ + row_->top_of_text()
+				+ ((row_->baseline() - row_->top_of_text()) / 2);
 			pain_.line(int(last_strikeout_x), middle, int(x_), middle,
 				LColor::strikeout, Painter::line_solid, Painter::line_thin);
 			running_strikeout = false;
@@ -910,13 +909,13 @@
 		if (par_.isHfill(pos)) {
 			x_ += 1;
 
-			int const y0 = yo_ + row_.baseline();
+			int const y0 = yo_ + row_->baseline();
 			int const y1 = y0 - defaultRowHeight() / 2;
 
 			pain_.line(int(x_), y1, int(x_), y0,
 				     LColor::added_space);
 
-			if (row_.hfillExpansion(pos)) {
+			if (hfillExpansion(const_cast<LyXText*>(&text_), row_, pos)) {
 				int const y2 = (y0 + y1) / 2;
 
 				if (pos >= body_pos) {
@@ -950,8 +949,8 @@
 
 	// if we reach the end of a struck out range, paint it
 	if (running_strikeout) {
-		int const middle = yo_ + row_.top_of_text()
-			+ ((row_.baseline() - row_.top_of_text()) / 2);
+		int const middle = yo_ + row_->top_of_text()
+			+ ((row_->baseline() - row_->top_of_text()) / 2);
 		pain_.line(int(last_strikeout_x), middle, int(x_), middle,
 			LColor::strikeout, Painter::line_solid, Painter::line_thin);
 		running_strikeout = false;
@@ -970,8 +969,7 @@
 
 	// FIXME: must be a cleaner way here. Aren't these calculations
 	// belonging to row metrics ?
-	Row * row(const_cast<Row *>(&row_));
-	const_cast<LyXText&>(text_).prepareToPrint(row, x_, separator_, hfill_, label_hfill_);
+	const_cast<LyXText&>(text_).prepareToPrint(row_, x_, separator_, hfill_, label_hfill_);
 
 	// FIXME: what is this fixing ?
 	if (text_.isInInset() && (x_ < 0))
@@ -997,11 +995,11 @@
 	// changebar
 	paintChangeBar();
 
-	if (row_.isParStart()) {
+	if (row_->isParStart()) {
 		paintFirst();
 	}
 
-	if (row_.isParEnd()) {
+	if (isParEnd(const_cast<LyXText*>(&text_), row_)) {
 		paintLast();
 	}
 
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/rowpainter.h lyx-rowlist10/src/rowpainter.h
--- lyx-rowlist9/src/rowpainter.h	2003-03-22 19:13:09.000000000 +0100
+++ lyx-rowlist10/src/rowpainter.h	2003-03-22 19:15:10.000000000 +0100
@@ -1,3 +1,4 @@
+// -** C++ -*-
 /**
  * \file rowpainter.h
  * This file is part of LyX, the document processor.
@@ -14,6 +15,7 @@
 
 #include <config.h>
 
+#include "RowList.h"
 #include "LString.h"
 #include "support/types.h"
 
@@ -31,7 +33,7 @@
 class RowPainter {
 public:
 	/// initialise painter
-	RowPainter(BufferView const & bv, LyXText const & text, Row const & row);
+	RowPainter(BufferView const & bv, LyXText const & text, RowList::iterator rit);
 
 	/// paint the row.
 	void paint(int y_offset, int x_offset, int y);
@@ -81,7 +83,7 @@
 	LyXText const & text_;
 
 	/// The row to paint
-	Row const & row_;
+	RowList::iterator row_;
 
 	/// Row's paragraph
 	Paragraph const & par_;
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/text2.C lyx-rowlist10/src/text2.C
--- lyx-rowlist9/src/text2.C	2003-03-22 19:13:12.000000000 +0100
+++ lyx-rowlist10/src/text2.C	2003-03-22 19:15:13.000000000 +0100
@@ -29,6 +29,7 @@
 #include "language.h"
 #include "ParagraphParameters.h"
 #include "counters.h"
+#include "lyxrow_funcs.h"
 
 #include "insets/inseterror.h"
 #include "insets/insetbibitem.h"
@@ -52,19 +53,23 @@
 
 
 LyXText::LyXText(BufferView * bv)
-	: height(0), width(0), anchor_row_(0), anchor_row_offset_(0),
-	  inset_owner(0), the_locking_inset(0), need_break_row(0),
-	  bv_owner(bv)
+	: height(0), width(0), anchor_row_offset_(0),
+	  inset_owner(0), the_locking_inset(0), bv_owner(bv)
 {
+	anchor_row_ = rows().end();
+	need_break_row = rows().end();
+
 	clearPaint();
 }
 
 
 LyXText::LyXText(BufferView * bv, InsetText * inset)
-	: height(0), width(0), anchor_row_(0), anchor_row_offset_(0),
-	  inset_owner(inset), the_locking_inset(0), need_break_row(0),
-	  bv_owner(bv)
+	: height(0), width(0), anchor_row_offset_(0),
+	  inset_owner(inset), the_locking_inset(0), bv_owner(bv)
 {
+	anchor_row_ = rows().end();
+	need_break_row = rows().end();
+
 	clearPaint();
 }
 
@@ -73,7 +78,7 @@
 {
 	if (reinit) {
 		rowlist_.clear();
-		need_break_row = 0;
+		need_break_row = rows().end();
 		width = height = 0;
 		copylayouttype.erase();
 		top_y(0);
@@ -303,7 +308,8 @@
 void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit)
 {
 	// insert a new row, starting at position 0
-	RowList::iterator rit = rowlist_.insert(rowit, new Row(par, 0));
+	Row newrow(par, 0);
+	RowList::iterator rit = rowlist_.insert(rowit, newrow);
 
 	// and now append the whole paragraph before the new row
 	rit->height(0);
@@ -762,7 +768,7 @@
 	}
 	if (need_break_row != rows().end()) {
 		breakAgain(need_break_row);
-		need_break_row = 0;
+		need_break_row = rows().end();
 		return;
 	}
 }
@@ -888,17 +894,17 @@
 
 void LyXText::cursorEnd()
 {
-	if (!cursor.row()->next()
-	    || cursor.row()->next()->par() != cursor.row()->par()) {
-		setCursor(cursor.par(), cursor.row()->lastPos() + 1);
+	if (boost::next(cursor.row()) == rows().end()
+	    || boost::next(cursor.row())->par() != cursor.row()->par()) {
+		setCursor(cursor.par(), lastPos(this, cursor.row()) + 1);
 	} else {
 		if (!cursor.par()->empty() &&
-		    (cursor.par()->getChar(cursor.row()->lastPos()) == ' '
-		     || cursor.par()->isNewline(cursor.row()->lastPos()))) {
-			setCursor(cursor.par(), cursor.row()->lastPos());
+		    (cursor.par()->getChar(lastPos(this, cursor.row())) == ' '
+		     || cursor.par()->isNewline(lastPos(this, cursor.row())))) {
+			setCursor(cursor.par(), lastPos(this, cursor.row()));
 		} else {
 			setCursor(cursor.par(),
-				  cursor.row()->lastPos() + 1);
+				  lastPos(this, cursor.row()) + 1);
 		}
 	}
 }
@@ -1558,7 +1564,7 @@
 	RowList::iterator beg = rows().begin();
 
 	// is there a break one row above
-	if (boost::prior(row) != beg
+	if (row != beg
 	    && boost::prior(row)->par() == row->par()) {
 		z = rowBreakPoint(*boost::prior(row));
 		if (z >= row->pos()) {
@@ -1578,10 +1584,10 @@
 	}
 
 	int const tmpheight = row->height();
-	pos_type const tmplast = row->lastPos();
+	pos_type const tmplast = lastPos(this, row);
 
 	breakAgain(row);
-	if (row->height() == tmpheight && row->lastPos() == tmplast) {
+	if (row->height() == tmpheight && lastPos(this, row) == tmplast) {
 		postRowPaint(row, y);
 	} else {
 		postPaint(y);
@@ -1682,7 +1688,7 @@
 	// the end of the previous row
 	cur.iy(y + row->baseline());
 	Inset * ins;
-	if (boost::prior(row) != beg && pos &&
+	if (row != beg && pos &&
 		boost::prior(row)->par() == row->par() &&
 	    pos < par->size() &&
 		par->getChar(pos) == Paragraph::META_INSET &&
@@ -1698,7 +1704,7 @@
 	// y is now the cursor baseline
 	cur.y(y);
 
-	pos_type last = old_row->lastPrintablePos();
+	pos_type last = lastPrintablePos(this, old_row);
 
 	// None of these should happen, but we're scaredy-cats
 	if (pos > par->size()) {
@@ -1776,7 +1782,7 @@
 			if (rit->par()->isLineSeparator(body_pos - 1))
 				x -= singleWidth(rit->par(), body_pos - 1);
 		}
-		if (rit->hfillExpansion(pos)) {
+		if (hfillExpansion(this, rit, pos)) {
 			x += singleWidth(rit->par(), pos);
 			if (pos >= body_pos)
 				x += fill_hfill;
@@ -1880,7 +1886,7 @@
 		       fill_hfill, fill_label_hfill);
 
 	pos_type vc = rit->pos();
-	pos_type last = rit->lastPrintablePos();
+	pos_type last = lastPrintablePos(this, rit);
 	pos_type c = 0;
 
 	LyXLayout_ptr const & layout = rit->par()->layout();
@@ -1912,7 +1918,7 @@
 				tmpx -= singleWidth(rit->par(), body_pos - 1);
 		}
 
-		if (rit->hfillExpansion(c)) {
+		if (hfillExpansion(this, rit, c)) {
 			tmpx += singleWidth(rit->par(), c);
 			if (c >= body_pos)
 				tmpx += fill_hfill;
@@ -1995,10 +2001,11 @@
 	 * and the next row is filled by an inset that spans an entire
 	 * row.
 	 */
-	bool beforeFullRowInset(Row & row, LyXCursor & cur) {
-		if (!row.next())
+	bool beforeFullRowInset(LyXText & lt, RowList::iterator row,
+				LyXCursor & cur) {
+		if (boost::next(row) == lt.rows().end())
 			return false;
-		Row const & next = *row.next();
+		Row const & next = *boost::next(row);
 
 		if (next.pos() != cur.pos() || next.par() != cur.par())
 			return false;
@@ -2025,12 +2032,12 @@
 	cur.y(y + row->baseline());
 	cur.row(row);
 
-	if (beforeFullRowInset(*row, cur)) {
-		pos_type last = row->lastPrintablePos();
-		float x = getCursorX(row->next(), cur.pos(), last, bound);
+	if (beforeFullRowInset(*this, row, cur)) {
+		pos_type last = lastPrintablePos(this, row);
+		float x = getCursorX(boost::next(row), cur.pos(), last, bound);
 		cur.ix(int(x));
-		cur.iy(y + row->height() + row->next()->baseline());
-		cur.irow(row->next());
+		cur.iy(y + row->height() + boost::next(row)->baseline());
+		cur.irow(boost::next(row));
 	} else {
 		cur.iy(cur.y());
 		cur.ix(cur.x());
@@ -2256,9 +2263,9 @@
 
 		deleted = true;
 
-		if (old_cursor.row()->previous()) {
+		if (old_cursor.row() != rows().begin()) {
 			const_cast<LyXText *>(this)->postPaint(old_cursor.y() - old_cursor.row()->baseline()
-				  - old_cursor.row()->previous()->height());
+				  - boost::prior(old_cursor.row())->height());
 			tmpcursor = cursor;
 			cursor = old_cursor; // that undo can restore the right cursor position
 			Paragraph * endpar = old_cursor.par()->next();
@@ -2282,13 +2289,13 @@
 			 * the parindent that can occur or dissappear.
 			 * The next row can change its height, if
 			 * there is another layout before */
-			if (refresh_row->next()) {
-				breakAgain(refresh_row->next());
+			if (boost::next(refresh_row) != rows().end()) {
+				breakAgain(boost::next(refresh_row));
 				updateCounters();
 			}
 			setHeightOfRow(refresh_row);
 		} else {
-			Row * nextrow = old_cursor.row()->next();
+			RowList::iterator nextrow = boost::next(old_cursor.row());
 			const_cast<LyXText *>(this)->postPaint(
 				old_cursor.y() - old_cursor.row()->baseline());
 
@@ -2316,7 +2323,7 @@
 			   the parindent that can occur or dissappear.
 			   The next row can change its height, if
 			   there is another layout before */
-			if (nextrow) {
+			if (nextrow != rows().end()) {
 				breakAgain(nextrow);
 				updateCounters();
 			}
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/text3.C lyx-rowlist10/src/text3.C
--- lyx-rowlist9/src/text3.C	2003-03-22 05:51:13.000000000 +0100
+++ lyx-rowlist10/src/text3.C	2003-03-22 12:45:33.000000000 +0100
@@ -240,7 +240,7 @@
 {
 	int y = top_y();
 
-	if (!cursor.row()->previous()) {
+	if (cursor.row() == rows().begin()) {
 		if (y > 0) {
 			int new_y = bv()->text->top_y() - bv()->workHeight();
 			bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
@@ -279,10 +279,10 @@
 		}
 	}
 	bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
-	if (cursor.row()->previous()) {
+	if (cursor.row() != rows().begin()) {
 		LyXCursor cur;
-		setCursor(cur, cursor.row()->previous()->par(),
-			  cursor.row()->previous()->pos(), false);
+		setCursor(cur, boost::prior(cursor.row())->par(),
+			  boost::prior(cursor.row())->pos(), false);
 		if (cur.y() > top_y()) {
 			cursorUp(true);
 		}
@@ -295,7 +295,7 @@
 {
 	int topy = top_y();
 
-	if (!cursor.row()->next()) {
+	if (boost::next(cursor.row()) == rows().end()) {
 		int y = cursor.y() - cursor.row()->baseline() +
 			cursor.row()->height();
 		if (y > topy + bv()->workHeight()) {
@@ -340,10 +340,10 @@
 		}
 	}
 	bv()->screen().draw(bv()->text, bv(), new_y);
-	if (cursor.row()->next()) {
+	if (boost::next(cursor.row()) != rows().end()) {
 		LyXCursor cur;
-		setCursor(cur, cursor.row()->next()->par(),
-						cursor.row()->next()->pos(), false);
+		setCursor(cur, boost::next(cursor.row())->par(),
+			  boost::next(cursor.row())->pos(), false);
 		if (cur.y() < top_y() + bv()->workHeight()) {
 			cursorDown(true);
 		}
diff -ruN --exclude=CVS -x '*.o' -x '*.libs*' -x '*~' -x '*.#*' -x '*.deps*' lyx-rowlist9/src/text.C lyx-rowlist10/src/text.C
--- lyx-rowlist9/src/text.C	2003-03-22 20:43:41.000000000 +0100
+++ lyx-rowlist10/src/text.C	2003-03-22 20:55:42.000000000 +0100
@@ -33,6 +33,7 @@
 #include "WordLangTuple.h"
 #include "paragraph_funcs.h"
 #include "rowpainter.h"
+#include "lyxrow_funcs.h"
 
 #include "insets/insettext.h"
 
@@ -150,21 +151,21 @@
 		Row dummyrow;
 		dummyrow.par(par);
 		dummyrow.pos(pos);
-		return workWidth() - leftMargin(&dummyrow);
+		return workWidth() - leftMargin(dummyrow);
 	} else {
 		int dummy_y;
 		RowList::iterator row = getRow(par, pos, dummy_y);
 		RowList::iterator frow = row;
 		RowList::iterator beg = rows().begin();
 
-		while (boost::prior(frow) != beg
+		while (frow != beg
 		       && frow->par() == boost::prior(frow)->par())
 			--frow;
 
 		// FIXME: I don't understand this code - jbl
 
 		unsigned int maxw = 0;
-		while (!frow->isParEnd()) {
+		while (!isParEnd(this, frow)) {
 			if ((frow != row) && (maxw < frow->width()))
 				maxw = frow->width();
 			++frow;
@@ -341,7 +342,7 @@
 
 
 void LyXText::computeBidiTables(Buffer const * buf,
-				Row const & row) const
+				RowList::iterator row) const
 {
 	bidi_same_direction = true;
 	if (!lyxrc.rtl_support) {
@@ -349,15 +350,15 @@
 		return;
 	}
 
-	Inset * inset = row.par()->inInset();
+	Inset * inset = row->par()->inInset();
 	if (inset && inset->owner() &&
 	    inset->owner()->lyxCode() == Inset::ERT_CODE) {
 		bidi_start = -1;
 		return;
 	}
 
-	bidi_start = row.pos();
-	bidi_end = row.lastPrintablePos();
+	bidi_start = row->pos();
+	bidi_end = lastPrintablePos(const_cast<LyXText*>(this), row);
 
 	if (bidi_start > bidi_end) {
 		bidi_start = -1;
@@ -379,25 +380,25 @@
 
 	pos_type stack[2];
 	bool const rtl_par =
-		row.par()->isRightToLeftPar(buf->params);
+		row->par()->isRightToLeftPar(buf->params);
 	int level = 0;
 	bool rtl = false;
 	bool rtl0 = false;
-	pos_type const body_pos = row.par()->beginningOfBody();
+	pos_type const body_pos = row->par()->beginningOfBody();
 
 	for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
-		bool is_space = row.par()->isLineSeparator(lpos);
+		bool is_space = row->par()->isLineSeparator(lpos);
 		pos_type const pos =
 			(is_space && lpos + 1 <= bidi_end &&
-			 !row.par()->isLineSeparator(lpos + 1) &&
-			 !row.par()->isNewline(lpos + 1))
+			 !row->par()->isLineSeparator(lpos + 1) &&
+			 !row->par()->isNewline(lpos + 1))
 			? lpos + 1 : lpos;
-		LyXFont font = row.par()->getFontSettings(buf->params, pos);
+		LyXFont font = row->par()->getFontSettings(buf->params, pos);
 		if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
 		    font.number() == LyXFont::ON &&
-		    row.par()->getFontSettings(buf->params, lpos - 1).number()
+		    row->par()->getFontSettings(buf->params, lpos - 1).number()
 		    == LyXFont::ON) {
-			font = row.par()->getFontSettings(buf->params, lpos);
+			font = row->par()->getFontSettings(buf->params, lpos);
 			is_space = false;
 		}
 
@@ -407,7 +408,7 @@
 		int new_level;
 
 		if (lpos == body_pos - 1
-		    && row.pos() < body_pos - 1
+		    && row->pos() < body_pos - 1
 		    && is_space) {
 			new_level = (rtl_par) ? 1 : 0;
 			new_rtl = new_rtl0 = rtl_par;
@@ -502,19 +503,19 @@
 }
 
 
-int LyXText::leftMargin(RowList::iterator rit)
+int LyXText::leftMargin(Row const & row)
 {
 	Inset * ins;
 
-	if (rit->pos() < rit->par()->size())
-		if ((rit->par()->getChar(rit->pos()) == Paragraph::META_INSET) &&
-		    (ins = rit->par()->getInset(rit->pos())) &&
+	if (row.pos() < row.par()->size())
+		if ((row.par()->getChar(row.pos()) == Paragraph::META_INSET) &&
+		    (ins = row.par()->getInset(row.pos())) &&
 		    (ins->needFullRow() || ins->display()))
 			return LEFT_MARGIN;
 
 	LyXTextClass const & tclass =
 		bv()->buffer()->params.getLyXTextClass();
-	LyXLayout_ptr const & layout = rit->par()->layout();
+	LyXLayout_ptr const & layout = row.par()->layout();
 
 	string parindent = layout->parindent;
 
@@ -525,12 +526,12 @@
 	// this is the way, LyX handles the LaTeX-Environments.
 	// I have had this idea very late, so it seems to be a
 	// later added hack and this is true
-	if (!rit->par()->getDepth()) {
-		if (rit->par()->layout() == tclass.defaultLayout()) {
+	if (!row.par()->getDepth()) {
+		if (row.par()->layout() == tclass.defaultLayout()) {
 			// find the previous same level paragraph
-			if (rit->par()->previous()) {
-				Paragraph * newpar = rit->par()
-					->depthHook(rit->par()->getDepth());
+			if (row.par()->previous()) {
+				Paragraph * newpar = row.par()
+					->depthHook(row.par()->getDepth());
 				if (newpar &&
 				    newpar->layout()->nextnoindent)
 					parindent.erase();
@@ -539,7 +540,7 @@
 	} else {
 		// find the next level paragraph
 
-		Paragraph * newpar = rit->par()->outerHook();
+		Paragraph * newpar = row.par()->outerHook();
 
 		// make a corresponding row. Needed to call LeftMargin()
 
@@ -548,16 +549,16 @@
 			Row dummyrow;
 			dummyrow.par(newpar);
 			dummyrow.pos(newpar->size());
-			x = leftMargin(&dummyrow);
+			x = leftMargin(dummyrow);
 		} else {
 			// this is no longer an error, because this function
 			// is used to clear impossible depths after changing
 			// a layout. Since there is always a redo,
 			// LeftMargin() is always called
-			rit->par()->params().depth(0);
+			row.par()->params().depth(0);
 		}
 
-		if (newpar && rit->par()->layout() == tclass.defaultLayout()) {
+		if (newpar && row.par()->layout() == tclass.defaultLayout()) {
 			if (newpar->params().noindent())
 				parindent.erase();
 			else {
@@ -567,17 +568,17 @@
 		}
 	}
 
-	LyXFont const labelfont = getLabelFont(bv()->buffer(), rit->par());
+	LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par());
 	switch (layout->margintype) {
 	case MARGIN_DYNAMIC:
 		if (!layout->leftmargin.empty()) {
 			x += font_metrics::signedWidth(layout->leftmargin,
 						  tclass.defaultfont());
 		}
-		if (!rit->par()->getLabelstring().empty()) {
+		if (!row.par()->getLabelstring().empty()) {
 			x += font_metrics::signedWidth(layout->labelindent,
 						  labelfont);
-			x += font_metrics::width(rit->par()->getLabelstring(),
+			x += font_metrics::width(row.par()->getLabelstring(),
 					    labelfont);
 			x += font_metrics::width(layout->labelsep, labelfont);
 		}
@@ -585,9 +586,9 @@
 	case MARGIN_MANUAL:
 		x += font_metrics::signedWidth(layout->labelindent, labelfont);
 		// The width of an empty par, even with manual label, should be 0
-		if (!rit->par()->empty() && rit->pos() >= rit->par()->beginningOfBody()) {
-			if (!rit->par()->getLabelWidthString().empty()) {
-				x += font_metrics::width(rit->par()->getLabelWidthString(),
+		if (!row.par()->empty() && row.pos() >= row.par()->beginningOfBody()) {
+			if (!row.par()->getLabelWidthString().empty()) {
+				x += font_metrics::width(row.par()->getLabelWidthString(),
 					       labelfont);
 				x += font_metrics::width(layout->labelsep, labelfont);
 			}
@@ -595,23 +596,23 @@
 		break;
 	case MARGIN_STATIC:
 		x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
-			/ (rit->par()->getDepth() + 4);
+			/ (row.par()->getDepth() + 4);
 		break;
 	case MARGIN_FIRST_DYNAMIC:
 		if (layout->labeltype == LABEL_MANUAL) {
-			if (rit->pos() >= rit->par()->beginningOfBody()) {
+			if (row.pos() >= row.par()->beginningOfBody()) {
 				x += font_metrics::signedWidth(layout->leftmargin,
 							  labelfont);
 			} else {
 				x += font_metrics::signedWidth(layout->labelindent,
 							  labelfont);
 			}
-		} else if (rit->pos()
+		} else if (row.pos()
 			   // Special case to fix problems with
 			   // theorems (JMarc)
 			   || (layout->labeltype == LABEL_STATIC
 			       && layout->latextype == LATEX_ENVIRONMENT
-			       && ! rit->par()->isFirstInSequence())) {
+			       && ! row.par()->isFirstInSequence())) {
 			x += font_metrics::signedWidth(layout->leftmargin,
 						  labelfont);
 		} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
@@ -621,7 +622,7 @@
 			x += font_metrics::signedWidth(layout->labelindent,
 						  labelfont);
 			x += font_metrics::width(layout->labelsep, labelfont);
-			x += font_metrics::width(rit->par()->getLabelstring(),
+			x += font_metrics::width(row.par()->getLabelstring(),
 					    labelfont);
 		}
 		break;
@@ -633,14 +634,14 @@
 		// are *NOT* allowed in the LaTeX realisation of this layout.
 
 		// find the first row of this paragraph
-		RowList::iterator tmprit = rit;
-		while (tmprit != rows().begin()
-		       && boost::prior(tmprit)->par() == rit->par())
-			--tmprit;
+		RowList::iterator tmprit = rows().begin();
+		while (tmprit != rows().end()
+		       && tmprit->par() != row.par())
+			++tmprit;
 
 		int minfill = tmprit->fill();
 		while (boost::next(tmprit) != rows().end() &&
-		       boost::next(tmprit)->par() == rit->par()) {
+		       boost::next(tmprit)->par() == row.par()) {
 			++tmprit;
 			if (tmprit->fill() < minfill)
 				minfill = tmprit->fill();
@@ -654,9 +655,9 @@
 	}
 
 	if ((workWidth() > 0) &&
-		!rit->par()->params().leftIndent().zero())
+		!row.par()->params().leftIndent().zero())
 	{
-		LyXLength const len = rit->par()->params().leftIndent();
+		LyXLength const len = row.par()->params().leftIndent();
 		int const tw = inset_owner ?
 			inset_owner->latexTextWidth(bv()) : workWidth();
 		x += len.inPixels(tw);
@@ -664,26 +665,26 @@
 
 	LyXAlignment align; // wrong type
 
-	if (rit->par()->params().align() == LYX_ALIGN_LAYOUT)
+	if (row.par()->params().align() == LYX_ALIGN_LAYOUT)
 		align = layout->align;
 	else
-		align = rit->par()->params().align();
+		align = row.par()->params().align();
 
 	// set the correct parindent
-	if (rit->pos() == 0) {
+	if (row.pos() == 0) {
 		if ((layout->labeltype == LABEL_NO_LABEL
 		     || layout->labeltype == LABEL_TOP_ENVIRONMENT
 		     || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
 		     || (layout->labeltype == LABEL_STATIC
 			 && layout->latextype == LATEX_ENVIRONMENT
-			 && ! rit->par()->isFirstInSequence()))
+			 && ! row.par()->isFirstInSequence()))
 		    && align == LYX_ALIGN_BLOCK
-		    && !rit->par()->params().noindent()
+		    && !row.par()->params().noindent()
 			// in tabulars and ert paragraphs are never indented!
-			&& (!rit->par()->inInset() || !rit->par()->inInset()->owner() ||
-				(rit->par()->inInset()->owner()->lyxCode() != Inset::TABULAR_CODE &&
-				 rit->par()->inInset()->owner()->lyxCode() != Inset::ERT_CODE))
-		    && (rit->par()->layout() != tclass.defaultLayout() ||
+			&& (!row.par()->inInset() || !row.par()->inInset()->owner() ||
+				(row.par()->inInset()->owner()->lyxCode() != Inset::TABULAR_CODE &&
+				 row.par()->inInset()->owner()->lyxCode() != Inset::ERT_CODE))
+		    && (row.par()->layout() != tclass.defaultLayout() ||
 			bv()->buffer()->params.paragraph_separation ==
 			BufferParams::PARSEP_INDENT)) {
 			x += font_metrics::signedWidth(parindent,
@@ -759,7 +760,7 @@
 		Row tmprow = row;
 		tmprow.pos(row.par()->size());
 		// return the beginning of the body
-		return leftMargin(&tmprow);
+		return leftMargin(tmprow);
 	}
 
 	// LabelEnd is only needed if the layout
@@ -814,7 +815,7 @@
 	// or the end of the par, then choose the possible break
 	// nearest that.
 
-	int const left = leftMargin(const_cast<Row*>(&row));
+	int const left = leftMargin(const_cast<Row&>(row));
 	int x = left;
 
 	// pixel width since last breakpoint
@@ -909,36 +910,36 @@
 
 
 // returns the minimum space a row needs on the screen in pixel
-int LyXText::fill(Row & row, int paper_width)
+int LyXText::fill(RowList::iterator row, int paper_width)
 {
 	if (paper_width < 0)
 		return 0;
 
 	int w;
 	// get the pure distance
-	pos_type const last = row.lastPrintablePos();
+	pos_type const last = lastPrintablePos(this, row);
 
 	// special handling of the right address boxes
-	if (row.par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
-		int const tmpfill = row.fill();
-		row.fill(0); // the minfill in MarginLeft()
-		w = leftMargin(&row);
-		row.fill(tmpfill);
+	if (row->par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+		int const tmpfill = row->fill();
+		row->fill(0); // the minfill in MarginLeft()
+		w = leftMargin(*row);
+		row->fill(tmpfill);
 	} else
-		w = leftMargin(&row);
+		w = leftMargin(*row);
 
-	Paragraph * par = row.par();
+	Paragraph * par = row->par();
 	LyXLayout_ptr const & layout = par->layout();
 
 	pos_type const body_pos = par->beginningOfBody();
-	pos_type i = row.pos();
+	pos_type i = row->pos();
 
 	while (i <= last) {
 		if (body_pos > 0 && i == body_pos) {
 			w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par));
 			if (par->isLineSeparator(i - 1))
 				w -= singleWidth(par, i - 1);
-			int left_margin = labelEnd(row);
+			int left_margin = labelEnd(*row);
 			if (w < left_margin)
 				w = left_margin;
 		}
@@ -949,12 +950,12 @@
 		w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par));
 		if (last >= 0 && par->isLineSeparator(last))
 			w -= singleWidth(par, last);
-		int const left_margin = labelEnd(row);
+		int const left_margin = labelEnd(*row);
 		if (w < left_margin)
 			w = left_margin;
 	}
 
-	int const fill = paper_width - w - rightMargin(*bv()->buffer(), row);
+	int const fill = paper_width - w - rightMargin(*bv()->buffer(), *row);
 	return fill;
 }
 
@@ -1051,7 +1052,7 @@
 			  layout->spacing.getValue() *
 			  spacing_val);
 
-	pos_type const pos_end = rit->lastPos();
+	pos_type const pos_end = lastPos(this, rit);
 	int labeladdon = 0;
 	int maxwidth = 0;
 
@@ -1334,8 +1335,9 @@
 
 		if (z < last) {
 			++z;
-			rowit = rowlist_.insert(rowit->next(),
-						new Row(rowit->par(), z));
+			Row newrow(rowit->par(), z);
+
+			rowit = rowlist_.insert(boost::next(rowit), newrow);
 			rowit->height(0);
 		} else {
 			done = true;
@@ -1344,7 +1346,7 @@
 		// Set the dimensions of the row
 		// fixed fill setting now by calling inset->update() in
 		// SingleWidth when needed!
-		tmprow->fill(fill(*tmprow, workWidth()));
+		tmprow->fill(fill(tmprow, workWidth()));
 		setHeightOfRow(tmprow);
 
 	} while (!done);
@@ -1366,7 +1368,8 @@
 			     boost::next(rit)->par() != rit->par())) {
 				// insert a new row
 				++z;
-				rowlist_.insert(rit, new Row(rit->par(), z));
+				Row newrow(rit->par(), z);
+				rowlist_.insert(rit, newrow);
 				++rit;
 				rit->height(0);
 			} else  {
@@ -1393,7 +1396,7 @@
 		}
 
 		// set the dimensions of the row
-		tmprit->fill(fill(*tmprit, workWidth()));
+		tmprit->fill(fill(tmprit, workWidth()));
 		setHeightOfRow(tmprit);
 	} while (not_ready);
 }
@@ -1410,7 +1413,8 @@
 		    || (boost::next(rit) != rows().end() && boost::next(rit)->par() != rit->par())) {
 			// insert a new row
 			++z;
-			rowlist_.insert(rit, new Row(rit->par(), z));
+			Row newrow(rit->par(), z);
+			rowlist_.insert(rit, newrow);
 			++rit;
 			rit->height(0);
 		} else  {
@@ -1434,7 +1438,7 @@
 	}
 
 	// set the dimensions of the row
-	tmprit->fill(fill(*tmprit, workWidth()));
+	tmprit->fill(fill(tmprit, workWidth()));
 	setHeightOfRow(tmprit);
 }
 
@@ -1517,7 +1521,7 @@
 	removeParagraph(cursor.row());
 
 	// set the dimensions of the cursor row
-	cursor.row()->fill(fill(*cursor.row(), workWidth()));
+	cursor.row()->fill(fill(cursor.row(), workWidth()));
 
 	setHeightOfRow(cursor.row());
 
@@ -1529,7 +1533,7 @@
 	  && cursor.par()->next()->isNewline(0))
 	   cursor.par()->next()->erase(0);
 
-	insertParagraph(cursor.par()->next(), cursor.row()->next());
+	insertParagraph(cursor.par()->next(), boost::next(cursor.row()));
 	updateCounters();
 
 	// This check is necessary. Otherwise the new empty paragraph will
@@ -1539,10 +1543,10 @@
 	else
 		setCursor(cursor.par(), 0);
 
-	if (cursor.row()->next())
-		breakAgain(cursor.row()->next());
+	if (boost::next(cursor.row()) != rows().end())
+		breakAgain(boost::next(cursor.row()));
 
-	need_break_row = 0;
+	need_break_row = rows().end();
 }
 
 
@@ -1688,26 +1692,27 @@
 	}
 
 	// Is there a break one row above
-	if (row->previous() && row->previous()->par() == row->par()
+	if (row != rows().begin() &&
+	    boost::prior(row)->par() == row->par()
 	    && (cursor.par()->isLineSeparator(cursor.pos())
 		|| cursor.par()->isNewline(cursor.pos())
 		|| ((cursor.pos() + 1 < cursor.par()->size()) &&
 		    cursor.par()->isInset(cursor.pos() + 1))
 		|| cursor.row()->fill() == -1))
 	{
-		pos_type z = rowBreakPoint(*row->previous());
+		pos_type z = rowBreakPoint(*boost::prior(row));
 
 		if (z >= row->pos()) {
 			row->pos(z + 1);
 
 			// set the dimensions of the row above
-			row->previous()->fill(fill(
-						   *row->previous(),
+			boost::prior(row)->fill(fill(
+						   boost::prior(row),
 						   workWidth()));
 
-			setHeightOfRow(row->previous());
+			setHeightOfRow(boost::prior(row));
 
-			y -= row->previous()->height();
+			y -= boost::prior(row)->height();
 
 			postPaint(y);
 
@@ -1719,10 +1724,11 @@
 				  false, cursor.boundary());
 			// cursor MUST be in row now.
 
-			if (row->next() && row->next()->par() == row->par())
-				need_break_row = row->next();
+			if (boost::next(row) != rows().end() &&
+			    boost::next(row)->par() == row->par())
+				need_break_row = boost::next(row);
 			else
-				need_break_row = 0;
+				need_break_row = rows().end();
 
 			// check, wether the last characters font has changed.
 			if (cursor.pos() && cursor.pos() == cursor.par()->size()
@@ -1738,17 +1744,19 @@
 	if (row->fill() >= 0) {
 		// needed because a newline will set fill to -1. Otherwise
 		// we would not get a rebreak!
-		row->fill(fill(*row, workWidth()));
+		row->fill(fill(row, workWidth()));
 	}
 
 	if (c == Paragraph::META_INSET || row->fill() < 0) {
 		postPaint(y);
 		breakAgainOneRow(row);
 		// will the cursor be in another row now?
-		if (row->lastPos() <= cursor.pos() + 1 && row->next()) {
-			if (row->next() && row->next()->par() == row->par())
+		if (lastPos(this, row) <= cursor.pos() + 1 &&
+		    boost::next(row) != rows().end()) {
+			if (boost::next(row) != rows().end() &&
+			    boost::next(row)->par() == row->par())
 				// this should always be true
-				row = row->next();
+				++row;
 			breakAgainOneRow(row);
 		}
 		current_font = rawtmpfont;
@@ -1760,10 +1768,11 @@
 		    != cursor.boundary())
 			setCursor(cursor.par(), cursor.pos(), false,
 			  !cursor.boundary());
-		if (row->next() && row->next()->par() == row->par())
-			need_break_row = row->next();
+		if (boost::next(row) != rows().end() &&
+		    boost::next(row)->par() == row->par())
+			need_break_row = boost::next(row);
 		else
-			need_break_row = 0;
+			need_break_row = rows().end();
 	} else {
 		// FIXME: similar code is duplicated all over - make resetHeightOfRow
 		int const tmpheight = row->height();
@@ -1812,53 +1821,52 @@
 }
 
 
-void LyXText::prepareToPrint(RowList::iterator rit, float & x,
+void LyXText::prepareToPrint(RowList::iterator row, float & x,
 			     float & fill_separator,
 			     float & fill_hfill,
 			     float & fill_label_hfill,
 			     bool bidi)
 {
 	float nlh;
-	float ns;
 
-	float w = rit->fill();
+	float w = row->fill();
 	fill_hfill = 0;
 	fill_label_hfill = 0;
 	fill_separator = 0;
 	fill_label_hfill = 0;
 
 	bool const is_rtl =
-		rit->par()->isRightToLeftPar(bv()->buffer()->params);
+		row->par()->isRightToLeftPar(bv()->buffer()->params);
 	if (is_rtl) {
 		x = (workWidth() > 0)
-			? rightMargin(*bv()->buffer(), *rit) : 0;
+			? rightMargin(*bv()->buffer(), *row) : 0;
 	} else
 		x = (workWidth() > 0)
-			? leftMargin(rit) : 0;
+			? leftMargin(*row) : 0;
 
 	// is there a manual margin with a manual label
-	LyXLayout_ptr const & layout = rit->par()->layout();
+	LyXLayout_ptr const & layout = row->par()->layout();
 
 	if (layout->margintype == MARGIN_MANUAL
 	    && layout->labeltype == LABEL_MANUAL) {
 		/// We might have real hfills in the label part
-		nlh = rit->numberOfLabelHfills();
+		nlh = numberOfLabelHfills(this, row);
 
 		// A manual label par (e.g. List) has an auto-hfill
 		// between the label text and the body of the
 		// paragraph too.
 		// But we don't want to do this auto hfill if the par
 		// is empty.
-		if (!rit->par()->empty())
+		if (!row->par()->empty())
 			++nlh;
 
-		if (nlh && !rit->par()->getLabelWidthString().empty()) {
-			fill_label_hfill = labelFill(*rit) / nlh;
+		if (nlh && !row->par()->getLabelWidthString().empty()) {
+			fill_label_hfill = labelFill(*row) / nlh;
 		}
 	}
 
 	// are there any hfills in the row?
-	float const nh = rit->numberOfHfills();
+	float const nh = numberOfHfills(this, row);
 
 	if (nh) {
 		if (w > 0)
@@ -1866,26 +1874,26 @@
 	// we don't have to look at the alignment if it is ALIGN_LEFT and
 	// if the row is already larger then the permitted width as then
 	// we force the LEFT_ALIGN'edness!
-	} else if (static_cast<int>(rit->width()) < workWidth()) {
+	} else if (static_cast<int>(row->width()) < workWidth()) {
 		// is it block, flushleft or flushright?
 		// set x how you need it
 		int align;
-		if (rit->par()->params().align() == LYX_ALIGN_LAYOUT) {
+		if (row->par()->params().align() == LYX_ALIGN_LAYOUT) {
 			align = layout->align;
 		} else {
-			align = rit->par()->params().align();
+			align = row->par()->params().align();
 		}
 
 		// center displayed insets
 		Inset * inset;
-		if (rit->pos() < rit->par()->size()
-		    && rit->par()->isInset(rit->pos())
-		    && (inset = rit->par()->getInset(rit->pos()))
+		if (row->pos() < row->par()->size()
+		    && row->par()->isInset(row->pos())
+		    && (inset = row->par()->getInset(row->pos()))
 		    && (inset->display())) // || (inset->scroll() < 0)))
 		    align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
 			? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
 		// ERT insets should always be LEFT ALIGNED on screen
-		inset = rit->par()->inInset();
+		inset = row->par()->inInset();
 		if (inset && inset->owner() &&
 			inset->owner()->lyxCode() == Inset::ERT_CODE)
 		{
@@ -1894,7 +1902,9 @@
 
 		switch (align) {
 	    case LYX_ALIGN_BLOCK:
-			ns = rit->numberOfSeparators();
+#warning REWRITE THIS! (Lgb)
+#if 0
+			float ns = rit->numberOfSeparators();
 			if (ns && boost::next(rit) != rows().end() &&
 			    boost::next(rit)->par() == rit->par() &&
 			    !(boost::next(rit)->par()->isNewline(boost::next(rit)->pos() - 1))
@@ -1907,6 +1917,7 @@
 			} else if (is_rtl) {
 				x += w;
 			}
+#endif
 			break;
 	    case LYX_ALIGN_RIGHT:
 			x += w;
@@ -1919,16 +1930,16 @@
 	if (!bidi)
 		return;
 
-	computeBidiTables(bv()->buffer(), *rit);
+	computeBidiTables(bv()->buffer(), row);
 	if (is_rtl) {
-		pos_type body_pos = rit->par()->beginningOfBody();
-		pos_type last = rit->lastPos();
+		pos_type body_pos = row->par()->beginningOfBody();
+		pos_type last = lastPos(this, row);
 
 		if (body_pos > 0 &&
 		    (body_pos - 1 > last ||
-		     !rit->par()->isLineSeparator(body_pos - 1))) {
+		     !row->par()->isLineSeparator(body_pos - 1))) {
 			x += font_metrics::width(layout->labelsep,
-					    getLabelFont(bv()->buffer(), rit->par()));
+					    getLabelFont(bv()->buffer(), row->par()));
 			if (body_pos - 1 <= last)
 				x += fill_label_hfill;
 		}
@@ -2610,7 +2621,7 @@
 		pos_type z;
 		// remember that a space at the end of a row doesnt count
 		// when calculating the fill
-		if (cursor.pos() < row->lastPos() ||
+		if (cursor.pos() < lastPos(this, row) ||
 		    !cursor.par()->isLineSeparator(cursor.pos())) {
 			row->fill(row->fill() + singleWidth(
 							    cursor.par(),
@@ -2683,7 +2694,7 @@
 				if (row->pos() >= row->par()->size()) {
 					// remove it
 					removeRow(row);
-					need_break_row = 0;
+					need_break_row = rows().end();
 				} else {
 					breakAgainOneRow(row);
 					if (boost::next(row) != rows().end() &&
@@ -2695,7 +2706,7 @@
 
 				// set the dimensions of the row above
 				y -= tmprow->height();
-				tmprow->fill(fill(*tmprow, workWidth()));
+				tmprow->fill(fill(tmprow, workWidth()));
 				setHeightOfRow(tmprow);
 
 				postPaint(y);
@@ -2716,14 +2727,14 @@
 		// break the cursor row again
 		if (boost::next(row) != rows().end() &&
 		    boost::next(row)->par() == row->par() &&
-		    (row->lastPos() == row->par()->size() - 1 ||
-		     rowBreakPoint(*row) != row->lastPos())) {
+		    (lastPos(this, row) == row->par()->size() - 1 ||
+		     rowBreakPoint(*row) != lastPos(this, row))) {
 
 			// it can happen that a paragraph loses one row
 			// without a real breakup. This is when a word
 			// is to long to be broken. Well, I don t care this
 			// hack ;-)
-			if (row->lastPos() == row->par()->size() - 1)
+			if (lastPos(this, row) == row->par()->size() - 1)
 				removeRow(boost::next(row));
 
 			postPaint(y);
@@ -2732,7 +2743,7 @@
 			// will the cursor be in another row now?
 			if (boost::next(row) != rows().end() &&
 			    boost::next(row)->par() == row->par() &&
-			    row->lastPos() <= cursor.pos()) {
+			    lastPos(this, row) <= cursor.pos()) {
 				++row;
 				breakAgainOneRow(row);
 			}
@@ -2746,7 +2757,7 @@
 				need_break_row = rows().end();
 		} else  {
 			// set the dimensions of the row
-			row->fill(fill(*row, workWidth()));
+			row->fill(fill(row, workWidth()));
 			int const tmpheight = row->height();
 			setHeightOfRow(row);
 			if (tmpheight == row->height()) {
-- 
        Lgb

Reply via email to