Andre Poenitz <[EMAIL PROTECTED]> writes:

| On Wed, Jun 18, 2003 at 04:54:14PM +0200, Lars Gullik Bjønnes wrote:
| > would be nice to fix those.
| 
| insets/insetert.C:    if (boost::next(inset.paragraphs.begin()) !=
| inset.paragraphs.end() ||

[...]

I have them fixed in my tree.

So this is an updated bnext patch.

? src/frontends/xforms/lyx_forms.h
? src/frontends/xforms/lyx_xpm.h
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.18
diff -u -p -r1.18 rowpainter.C
--- src/rowpainter.C	30 May 2003 06:48:20 -0000	1.18
+++ src/rowpainter.C	18 Jun 2003 15:17:26 -0000
@@ -452,8 +452,10 @@ void RowPainter::paintDepthBar()
 	if (row_ != text_.rows().begin())
 		prev_depth = boost::prior(row_)->par()->getDepth();
 	Paragraph::depth_type next_depth = 0;
-	if (boost::next(row_) != text_.rows().end())
-		next_depth = boost::next(row_)->par()->getDepth();
+
+	RowList::iterator next_row = boost::next(row_);
+	if (next_row != text_.rows().end())
+		next_depth = next_row->par()->getDepth();
 
 	for (Paragraph::depth_type i = 1; i <= depth; ++i) {
 		int x = (PAPER_MARGIN / 5) * i + xo_;
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.367
diff -u -p -r1.367 text.C
--- src/text.C	12 Jun 2003 11:09:53 -0000	1.367
+++ src/text.C	18 Jun 2003 15:17:26 -0000
@@ -1731,9 +1731,10 @@ void LyXText::insertChar(char c)
 				  false, cursor.boundary());
 			// cursor MUST be in row now.
 
-			if (boost::next(row) != rows().end() &&
-			    boost::next(row)->par() == row->par())
-				need_break_row = boost::next(row);
+			RowList::iterator next_row = boost::next(row);
+			if (next_row != rows().end() &&
+			    next_row->par() == row->par())
+				need_break_row = next_row;
 			else
 				need_break_row = rows().end();
 
@@ -1757,13 +1758,18 @@ void LyXText::insertChar(char c)
 	if (c == Paragraph::META_INSET || row->fill() < 0) {
 		postPaint(y);
 		breakAgainOneRow(row);
+
+		RowList::iterator next_row = boost::next(row);
+
 		// will the cursor be in another row now?
 		if (lastPos(*this, row) <= cursor.pos() + 1 &&
-		    boost::next(row) != rows().end()) {
-			if (boost::next(row) != rows().end() &&
-			    boost::next(row)->par() == row->par())
+		    next_row != rows().end()) {
+			if (next_row != rows().end() &&
+			    next_row->par() == row->par()) {
 				// this should always be true
 				++row;
+			}
+
 			breakAgainOneRow(row);
 		}
 		current_font = rawtmpfont;
@@ -1775,9 +1781,12 @@ void LyXText::insertChar(char c)
 		    != cursor.boundary())
 			setCursor(cursor.par(), cursor.pos(), false,
 			  !cursor.boundary());
-		if (boost::next(row) != rows().end() &&
-		    boost::next(row)->par() == row->par())
-			need_break_row = boost::next(row);
+
+		next_row = boost::next(row);
+
+		if (next_row != rows().end() &&
+		    next_row->par() == row->par())
+			need_break_row = next_row;
 		else
 			need_break_row = rows().end();
 	} else {
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.371
diff -u -p -r1.371 text2.C
--- src/text2.C	17 Jun 2003 15:33:46 -0000	1.371
+++ src/text2.C	18 Jun 2003 15:17:27 -0000
@@ -1243,14 +1243,16 @@ void LyXText::updateCounters()
 	// CHECK if this is really needed. (Lgb)
 	bv()->buffer()->params.getLyXTextClass().counters().reset();
 
-	for (; pit != ownerParagraphs().end(); ++pit) {
+	ParagraphList::iterator beg = ownerParagraphs().begin();
+	ParagraphList::iterator end = ownerParagraphs().end();
+	for (; pit != end; ++pit) {
 		while (rowit->par() != pit)
 			++rowit;
 
 		string const oldLabel = pit->params().labelString();
 
 		size_t maxdepth = 0;
-		if (pit != ownerParagraphs().begin())
+		if (pit != beg)
 			maxdepth = boost::prior(pit)->getMaxDepthAfter();
 
 		if (pit->params().depth() > maxdepth)
@@ -1458,7 +1460,9 @@ void LyXText::replaceSelectionWithString
 				  selection.start.pos());
 
 	// Insert the new string
-	for (string::const_iterator cit = str.begin(); cit != str.end(); ++cit) {
+	string::const_iterator cit = str.begin();
+	string::const_iterator end = str.end();
+	for (; cit != end; ++cit) {
 		selection.end.par()->insertChar(pos, (*cit), font);
 		++pos;
 	}
@@ -1498,7 +1502,9 @@ void LyXText::insertStringAsParagraphs(s
 {
 	string linestr(str);
 	bool newline_inserted = false;
-	for (string::size_type i = 0; i < linestr.length(); ++i) {
+	string::size_type const siz = linestr.length();
+
+	for (string::size_type i = 0; i < siz; ++i) {
 		if (linestr[i] == '\n') {
 			if (newline_inserted) {
 				// we know that \r will be ignored by
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.81
diff -u -p -r1.81 text3.C
--- src/text3.C	17 Jun 2003 15:33:47 -0000	1.81
+++ src/text3.C	18 Jun 2003 15:17:27 -0000
@@ -343,10 +343,11 @@ void LyXText::cursorNext()
 		}
 	}
 	bv()->screen().draw(bv()->text, bv(), new_y);
-	if (boost::next(cursor.row()) != rows().end()) {
+
+	RowList::iterator next_row = boost::next(cursor.row());
+	if (next_row != rows().end()) {
 		LyXCursor cur;
-		setCursor(cur, boost::next(cursor.row())->par(),
-			  boost::next(cursor.row())->pos(), false);
+		setCursor(cur, next_row->par(), next_row->pos(), false);
 		if (cur.y() < top_y() + bv()->workHeight()) {
 			cursorDown(true);
 		}
Index: src/insets/insetert.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v
retrieving revision 1.131
diff -u -p -r1.131 insetert.C
--- src/insets/insetert.C	16 Jun 2003 11:49:30 -0000	1.131
+++ src/insets/insetert.C	18 Jun 2003 15:17:28 -0000
@@ -519,8 +519,7 @@ string const InsetERT::get_new_label() c
 		la += inset.paragraphs.begin()->getChar(j);
 		++i;
 	}
-	if (boost::next(inset.paragraphs.begin()) != inset.paragraphs.end() ||
-	    (i > 0 && j < p_siz)) {
+	if (p_siz > 1 || (i > 0 && j < p_siz)) {
 		la += "...";
 	}
 	if (la.empty()) {
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.409
diff -u -p -r1.409 insettext.C
--- src/insets/insettext.C	17 Jun 2003 15:33:48 -0000	1.409
+++ src/insets/insettext.C	18 Jun 2003 15:17:29 -0000
@@ -453,8 +453,7 @@ void InsetText::update(BufferView * bv, 
 		return;
 	}
 
-	if (!autoBreakRows &&
-	    boost::next(paragraphs.begin()) != paragraphs.end())
+	if (!autoBreakRows && paragraphs.size() > 1)
 		collapseParagraphs(bv);
 
 	if (the_locking_inset) {
@@ -516,14 +515,8 @@ void InsetText::setUpdateStatus(BufferVi
 
 void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
 {
-#if 0
-	if (!autoBreakRows &&
-	    boost::next(paragraphs.begin()) != paragraphs.end())
-		collapseParagraphs(bv);
-#else
 	if (!autoBreakRows && paragraphs.size() > 1)
 		collapseParagraphs(bv);
-#endif
 
 	bool clear = false;
 	if (!lt) {
@@ -591,10 +584,11 @@ void InsetText::insetUnlock(BufferView *
 	} else
 		bv->owner()->setLayout(bv->text->cursor.par()->layout()->name());
 	// hack for deleteEmptyParMech
-	if (!paragraphs.begin()->empty()) {
-		lt->setCursor(paragraphs.begin(), 0);
-	} else if (boost::next(paragraphs.begin()) != paragraphs.end()) {
-		lt->setCursor(boost::next(paragraphs.begin()), 0);
+	ParagraphList::iterator first_par = paragraphs.begin();
+	if (!first_par->empty()) {
+		lt->setCursor(first_par, 0);
+	} else if (paragraphs.size() > 1) {
+		lt->setCursor(boost::next(first_par), 0);
 	}
 	if (clear)
 		lt = 0;
@@ -625,8 +619,7 @@ void InsetText::lockInset(BufferView * b
 	finishUndo();
 	// If the inset is empty set the language of the current font to the
 	// language to the surronding text (if different).
-	if (paragraphs.begin()->empty() &&
-	    boost::next(paragraphs.begin()) == paragraphs.end() &&
+	if (paragraphs.begin()->empty() && paragraphs.size() == 1 &&
 		bv->getParentLanguage(this) != lt->current_font.language()) {
 		LyXFont font(LyXFont::ALL_IGNORE);
 		font.setLanguage(bv->getParentLanguage(this));
@@ -729,11 +722,12 @@ bool InsetText::unlockInsetInInset(Buffe
 
 bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
 {
-	if (!autoBreakRows &&
-	    boost::next(paragraphs.begin()) != paragraphs.end())
+	if (!autoBreakRows && paragraphs.size() > 1)
 		collapseParagraphs(bv);
+
 	if (inset == this)
 		return true;
+
 	bool clear = false;
 	if (!lt) {
 		lt = getLyXText(bv);
@@ -1010,8 +1004,8 @@ Inset::RESULT InsetText::localDispatch(F
 		// If the inset is empty set the language of the current font to the
 		// language to the surronding text (if different).
 		if (paragraphs.begin()->empty() &&
-				boost::next(paragraphs.begin()) == paragraphs.end()&&
-			bv->getParentLanguage(this) != lt->current_font.language())
+		    paragraphs.size() == 1 &&
+		    bv->getParentLanguage(this) != lt->current_font.language())
 		{
 			LyXFont font(LyXFont::ALL_IGNORE);
 			font.setLanguage(bv->getParentLanguage(this));
@@ -1045,7 +1039,8 @@ Inset::RESULT InsetText::localDispatch(F
 	}
 
 	bool was_empty = (paragraphs.begin()->empty() &&
-			  boost::next(paragraphs.begin()) == paragraphs.end());
+			  paragraphs.size() == 1);
+
 	no_selection = false;
 	RESULT result = UpdatableInset::localDispatch(cmd);
 	if (result != UNDISPATCHED)
@@ -1425,7 +1420,7 @@ Inset::RESULT InsetText::localDispatch(F
 	/// If the action has deleted all text in the inset, we need to change the
 	// language to the language of the surronding text.
 	if (!was_empty && paragraphs.begin()->empty() &&
-	    boost::next(paragraphs.begin()) == paragraphs.end()) {
+	    paragraphs.size() == 1) {
 		LyXFont font(LyXFont::ALL_IGNORE);
 		font.setLanguage(bv->getParentLanguage(this));
 		setFont(bv, font, false);
@@ -1830,28 +1825,38 @@ void InsetText::setFont(BufferView * bv,
 		the_locking_inset->setFont(bv, font, toggleall, selectall);
 		return;
 	}
-	if ((boost::next(paragraphs.begin()) == paragraphs.end() &&
-	     paragraphs.begin()->empty()) || cpar(bv)->empty()) {
+
+	if ((paragraphs.size() == 1 && paragraphs.begin()->empty())
+	    || cpar(bv)->empty()) {
 		getLyXText(bv)->setFont(font, toggleall);
 		return;
 	}
+
 	bool clear = false;
 	if (!lt) {
 		lt = getLyXText(bv);
 		clear = true;
 	}
+
 	if (lt->selection.set()) {
 		setUndo(bv, Undo::EDIT, lt->cursor.par());
 	}
+
 	if (selectall)
 		selectAll(bv);
+
 	lt->toggleFree(font, toggleall);
+
 	if (selectall)
 		lt->clearSelection();
+
 	bv->fitCursor();
+
 	bool flag = (selectall || lt->selection.set());
+
 	if (clear)
 		lt = 0;
+
 	if (flag)
 		updateLocal(bv, FULL, true);
 	else
@@ -2171,8 +2176,8 @@ void InsetText::resizeLyXText(BufferView
 		return;
 	}
 	do_resize = 0;
-	if (boost::next(paragraphs.begin()) == paragraphs.end() &&
-	    paragraphs.begin()->empty()) { // no data, resize not neccessary!
+	if (paragraphs.size() == 1 && paragraphs.begin()->empty()) {
+		// no data, resize not neccessary!
 		// we have to do this as a fixed width may have changed!
 		LyXText * t = getLyXText(bv);
 		saveLyXTextState(t);
@@ -2180,6 +2185,7 @@ void InsetText::resizeLyXText(BufferView
 		restoreLyXTextState(t);
 		return;
 	}
+
 	// one endless line, resize normally not necessary
 	if (!force && getMaxWidth(bv, this) < 0)
 		return;
@@ -2188,6 +2194,7 @@ void InsetText::resizeLyXText(BufferView
 	if (it == cache.end()) {
 		return;
 	}
+
 	lyx::Assert(it->second.text.get());
 
 	LyXText * t = it->second.text.get();
@@ -2199,6 +2206,7 @@ void InsetText::resizeLyXText(BufferView
 
 	t->init(bv, true);
 	restoreLyXTextState(t);
+
 	if (the_locking_inset) {
 		inset_x = cix(bv) - top_x + drawTextXOffset;
 		inset_y = ciy(bv) + drawTextYOffset;
@@ -2551,26 +2559,31 @@ void InsetText::collapseParagraphs(Buffe
 {
 	LyXText * llt = getLyXText(bv);
 
-	while (boost::next(paragraphs.begin()) != paragraphs.end()) {
-		if (!paragraphs.begin()->empty() &&
-		    !boost::next(paragraphs.begin())->empty() &&
-			!paragraphs.begin()->isSeparator(paragraphs.begin()->size() - 1))
-		{
-			paragraphs.begin()->insertChar(paragraphs.begin()->size(), ' ');
+	while (paragraphs.size() > 1) {
+		ParagraphList::iterator first_par = paragraphs.begin();
+		ParagraphList::iterator next_par = boost::next(first_par);
+		size_t const first_par_size = first_par->size();
+
+		if (!first_par->empty() &&
+		    !next_par->empty() &&
+		    !first_par->isSeparator(first_par_size - 1)) {
+			first_par->insertChar(first_par_size, ' ');
 		}
+
 		if (llt->selection.set()) {
-			if (llt->selection.start.par() == boost::next(paragraphs.begin())) {
-				llt->selection.start.par(paragraphs.begin());
+			if (llt->selection.start.par() == next_par) {
+				llt->selection.start.par(first_par);
 				llt->selection.start.pos(
-					llt->selection.start.pos() + paragraphs.begin()->size());
+					llt->selection.start.pos() + first_par_size);
 			}
-			if (llt->selection.end.par() == boost::next(paragraphs.begin())) {
-				llt->selection.end.par(paragraphs.begin());
+			if (llt->selection.end.par() == next_par) {
+				llt->selection.end.par(first_par);
 				llt->selection.end.pos(
-					llt->selection.end.pos() + paragraphs.begin()->size());
+					llt->selection.end.pos() + first_par_size);
 			}
 		}
-		mergeParagraph(bv->buffer()->params, paragraphs, paragraphs.begin());
+
+		mergeParagraph(bv->buffer()->params, paragraphs, first_par);
 	}
 	reinitLyXText();
 }
-- 
        Lgb

Reply via email to