From 901c09250485d0f8ac610474635afdef7f205483 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 10 Mar 2003 04:59:48 +0000 Subject: [PATCH] fix break before minipages too git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6411 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/text.C | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e85f2081d7..670b89adfc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-03-10 John Levon + + * text.C: fix break before a minipage + 2003-03-10 John Levon * text.C: fix the last commit diff --git a/src/text.C b/src/text.C index 1c117d7051..e23daf91d2 100644 --- a/src/text.C +++ b/src/text.C @@ -727,7 +727,11 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const // or the end of the par, then choose the possible break // nearest that. - int x = leftMargin(&bv, &row); + int const left = leftMargin(&bv, &row); + int x = left; + + // pixel width since last breakpoint + int chunkwidth = 0; for (i = pos; i < last; ++i) { @@ -738,19 +742,22 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const break; } - x += singleWidth(&bv, par, i, c); + int thiswidth = singleWidth(&bv, par, i, c); // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { - x += font_metrics::width(layout->labelsep, + thiswidth += font_metrics::width(layout->labelsep, getLabelFont(bv.buffer(), par)); if (par->isLineSeparator(i - 1)) - x-= singleWidth(&bv, par, i - 1); + thiswidth -= singleWidth(&bv, par, i - 1); int left_margin = labelEnd(bv, row); - if (x < left_margin) - x = left_margin; + if (thiswidth < left_margin) + thiswidth = left_margin; } + x += thiswidth; + chunkwidth += thiswidth; + Inset * in = par->isInset(i) ? par->getInset(i) : 0; bool display = (in && (in->display() || in->needFullRow())); @@ -765,8 +772,9 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const // break before a character that will fall off // the right of the row if (x >= width) { - // if no break before or this is a fullrow inset, break here. - if (point == last || display) { + // if no break before or we are at an inset + // that will take up a row, break here + if (point == last || display || chunkwidth >= (width - left)) { if (pos < i) point = i - 1; else @@ -777,8 +785,10 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const if (!in || in->isChar()) { // some insets are line separators too - if (par->isLineSeparator(i)) + if (par->isLineSeparator(i)) { point = i; + chunkwidth = 0; + } continue; } -- 2.39.5