#include "lyxrc.h"
#include "lyxrow.h"
#include "lyxrow_funcs.h"
+#include "metricsinfo.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "rowpainter.h"
#include "text_funcs.h"
-#include "undo_funcs.h"
+#include "undo.h"
#include "vspace.h"
#include "WordLangTuple.h"
ParagraphList::iterator pit = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
for (height = 0; pit != end; ++pit) {
- RowList::iterator rit = pit->rows.begin();
- RowList::iterator rend = pit->rows.end();
- for ( ; rit != rend ; ++rit) {
- rit->y(height);
- height += rit->height();
- }
+ pit->y = height;
+ height += pit->height;
}
}
int LyXText::getRealCursorX() const
{
int x = cursor.x();
- if (the_locking_inset && (the_locking_inset->getLyXText(bv())!= this))
+ if (the_locking_inset && the_locking_inset->getLyXText(bv()) != this)
x = the_locking_inset->getLyXText(bv())->getRealCursorX();
return x;
}
// There are some issues in this file and I don't think they are
// really related to the FIX_DOUBLE_SPACE patch. I'd rather think that
// this is a problem that has been here almost from day one and that a
-// larger userbase with differenct access patters triggers the bad
+// larger userbase with different access patters triggers the bad
// behaviour. (segfaults.) What I think happen is: In several places
// we store the paragraph in the current cursor and then moves the
// cursor. This movement of the cursor will delete paragraph at the
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
- if (font.language()->RightToLeft()) {
+ if (!font.language()->RightToLeft()) {
if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1)
&& font.language()->lang() == "arabic") {
lyx::pos_type LyXText::log2vis(lyx::pos_type pos) const
{
- if (bidi_start == -1)
- return pos;
- else
- return log2vis_list[pos - bidi_start];
+ return (bidi_start == -1) ? pos : log2vis_list[pos - bidi_start];
}
lyx::pos_type LyXText::vis2log(lyx::pos_type pos) const
{
- if (bidi_start == -1)
- return pos;
- else
- return vis2log_list[pos - bidi_start];
+ return (bidi_start == -1) ? pos : vis2log_list[pos - bidi_start];
}
lyx::pos_type LyXText::bidi_level(lyx::pos_type pos) const
{
- if (bidi_start == -1)
- return 0;
- else
- return bidi_levels[pos - bidi_start];
+ return (bidi_start == -1) ? 0 : bidi_levels[pos - bidi_start];
}
bool LyXText::bidi_InRange(lyx::pos_type pos) const
{
- return bidi_start == -1 ||
- (bidi_start <= pos && pos <= bidi_end);
+ return bidi_start == -1 || (bidi_start <= pos && pos <= bidi_end);
}
-void LyXText::computeBidiTables(ParagraphList::iterator pit,
- Buffer const & buf, RowList::iterator row) const
+void LyXText::computeBidiTables(Paragraph const & par,
+ Buffer const & buf, Row & row) const
{
bidi_same_direction = true;
if (!lyxrc.rtl_support) {
return;
}
- InsetOld * inset = pit->inInset();
+ InsetOld * inset = par.inInset();
if (inset && inset->owner() &&
inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
bidi_start = -1;
return;
}
- bidi_start = row->pos();
- bidi_end = lastPos(*pit, row);
+ bidi_start = row.pos();
+ bidi_end = lastPos(par, row);
if (bidi_start > bidi_end) {
bidi_start = -1;
BufferParams const & bufparams = buf.params();
pos_type stack[2];
- bool const rtl_par =
- pit->isRightToLeftPar(bufparams);
+ bool const rtl_par = par.isRightToLeftPar(bufparams);
int level = 0;
bool rtl = false;
bool rtl0 = false;
- pos_type const body_pos = pit->beginningOfBody();
+ pos_type const body_pos = par.beginningOfBody();
for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
- bool is_space = pit->isLineSeparator(lpos);
+ bool is_space = par.isLineSeparator(lpos);
pos_type const pos =
(is_space && lpos + 1 <= bidi_end &&
- !pit->isLineSeparator(lpos + 1) &&
- !pit->isNewline(lpos + 1))
+ !par.isLineSeparator(lpos + 1) &&
+ !par.isNewline(lpos + 1))
? lpos + 1 : lpos;
- LyXFont font = pit->getFontSettings(bufparams, pos);
+ LyXFont font = par.getFontSettings(bufparams, pos);
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
font.number() == LyXFont::ON &&
- pit->getFontSettings(bufparams, lpos - 1).number()
+ par.getFontSettings(bufparams, lpos - 1).number()
== LyXFont::ON) {
- font = pit->getFontSettings(bufparams, lpos);
+ font = par.getFontSettings(bufparams, lpos);
is_space = false;
}
-
bool new_rtl = font.isVisibleRightToLeft();
bool new_rtl0 = font.isRightToLeft();
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;
+ new_level = rtl_par ? 1 : 0;
+ new_rtl0 = rtl_par;
+ new_rtl = rtl_par;
} else if (new_rtl0)
- new_level = (new_rtl) ? 1 : 2;
+ new_level = new_rtl ? 1 : 2;
else
- new_level = (rtl_par) ? 2 : 0;
+ new_level = rtl_par ? 2 : 0;
if (is_space && new_level >= level) {
new_level = level;
if (level == new_level && rtl0 != new_rtl0) {
--new_level2;
- log2vis_list[lpos - bidi_start] = (rtl) ? 1 : -1;
+ log2vis_list[lpos - bidi_start] = rtl ? 1 : -1;
} else if (level < new_level) {
- log2vis_list[lpos - bidi_start] = (rtl) ? -1 : 1;
+ log2vis_list[lpos - bidi_start] = rtl ? -1 : 1;
if (new_level > rtl_par)
bidi_same_direction = false;
} else
- log2vis_list[lpos - bidi_start] = (new_rtl) ? -1 : 1;
+ log2vis_list[lpos - bidi_start] = new_rtl ? -1 : 1;
rtl = new_rtl;
rtl0 = new_rtl0;
bidi_levels[lpos - bidi_start] = new_level;
return false;
if (!bidi_InRange(pos - 1)) {
- /// This can happen if pos is the first char of a row.
- /// Returning false in this case is incorrect!
+ // This can happen if pos is the first char of a row.
+ // Returning false in this case is incorrect!
return false;
}
case MARGIN_RIGHT_ADDRESS_BOX:
{
// ok, a terrible hack. The left margin depends on the widest
- // row in this paragraph. Do not care about footnotes, they
- // are *NOT* allowed in the LaTeX realisation of this layout.
-
- // find the first row of this paragraph
+ // row in this paragraph.
RowList::iterator rit = pit->rows.begin();
RowList::iterator end = pit->rows.end();
int minfill = rit->fill();
}
-int LyXText::rightMargin(ParagraphList::iterator pit,
+int LyXText::rightMargin(Paragraph const & par,
Buffer const & buf, Row const &) const
{
LyXTextClass const & tclass = buf.params().getLyXTextClass();
- LyXLayout_ptr const & layout = pit->layout();
+ LyXLayout_ptr const & layout = par.layout();
return PAPER_MARGIN
+ font_metrics::signedWidth(tclass.rightmargin(),
- tclass.defaultfont());
+ tclass.defaultfont())
+ font_metrics::signedWidth(layout->rightmargin,
tclass.defaultfont())
- * 4 / (pit->getDepth() + 4);
+ * 4 / (par.getDepth() + 4);
}
// this needs special handling - only newlines count as a break point
pos_type addressBreakPoint(pos_type i, Paragraph const & par)
{
- for (; i < par.size(); ++i) {
+ for (; i < par.size(); ++i)
if (par.isNewline(i))
return i;
- }
return par.size();
}
Row const & row) const
{
// maximum pixel width of a row.
- int width = workWidth()
- - rightMargin(pit, *bv()->buffer(), row);
+ int width = workWidth() - rightMargin(*pit, *bv()->buffer(), row);
// inset->textWidth() returns -1 via workWidth(),
// but why ?
point = i;
break;
}
+ // Break before...
+ if (i + 1 < last) {
+ InsetOld * in = pit->getInset(i + 1);
+ if (in && in->display()) {
+ point = i;
+ break;
+ }
+ // ...and after.
+ in = pit->getInset(i);
+ if (in && in->display()) {
+ point = i;
+ break;
+ }
+ }
char const c = pit->getChar(i);
if (i > endPosOfFontSpan) {
x += thiswidth;
chunkwidth += thiswidth;
- InsetOld * in = pit->isInset(i) ? pit->getInset(i) : 0;
+ InsetOld * in = pit->getInset(i);
// break before a character that will fall off
// the right of the row
if (x >= width) {
// if no break before, break here
- if (point == last || chunkwidth >= (width - left)) {
- if (pos < i)
+ if (point == last || chunkwidth >= width - left) {
+ if (pos < i) {
point = i - 1;
- else
- point = i;
+ break;
+ }
}
- break;
}
if (!in || in->isChar()) {
point = i;
chunkwidth = 0;
}
- continue;
}
-
- continue;
}
if (point == last && x >= width) {
// returns the minimum space a row needs on the screen in pixel
-int LyXText::fill(ParagraphList::iterator pit,
- RowList::iterator row, int paper_width) const
+int LyXText::fill(ParagraphList::iterator pit, Row & row, int paper_width) const
{
if (paper_width < 0)
return 0;
// special handling of the right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- int const tmpfill = row->fill();
- row->fill(0); // the minfill in MarginLeft()
- w = leftMargin(pit, *row);
- row->fill(tmpfill);
+ int const tmpfill = row.fill();
+ row.fill(0); // the minfill in MarginLeft()
+ w = leftMargin(pit, row);
+ row.fill(tmpfill);
} else
- w = leftMargin(pit, *row);
+ w = leftMargin(pit, row);
pos_type const body_pos = pit->beginningOfBody();
- pos_type i = row->pos();
+ pos_type i = row.pos();
if (! pit->empty() && i <= last) {
// We re-use the font resolution for the entire span when possible
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1);
- int left_margin = labelEnd(pit, *row);
+ int left_margin = labelEnd(pit, row);
if (w < left_margin)
w = left_margin;
}
w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (last >= 0 && pit->isLineSeparator(last))
w -= singleWidth(pit, last);
- int const left_margin = labelEnd(pit, *row);
+ int const left_margin = labelEnd(pit, row);
if (w < left_margin)
w = left_margin;
}
- int const fill = paper_width - w - rightMargin(pit, *bv()->buffer(), *row);
+ int const fill = paper_width - w - rightMargin(*pit, *bv()->buffer(), row);
// If this case happens, it means that our calculation
// of the widths of the chars when we do rowBreakPoint()
if (lyxerr.debugging() && fill < 0) {
lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
<< " w " << w << " paper_width " << paper_width
- << " right margin " << rightMargin(pit, *bv()->buffer(), *row) << endl;
+ << " right margin " << rightMargin(*pit, *bv()->buffer(), row) << endl;
}
return fill;
}
}
-void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
+void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
{
// get the maximum ascent and the maximum descent
double layoutasc = 0;
// as max get the first character of this row then it can increase but not
// decrease the height. Just some point to start with so we don't have to
// do the assignment below too often.
- LyXFont font = getFont(pit, rit->pos());
+ LyXFont font = getFont(pit, row.pos());
LyXFont::FONT_SIZE const tmpsize = font.size();
font = getLayoutFont(pit);
LyXFont::FONT_SIZE const size = font.size();
int maxdesc = int(font_metrics::maxDescent(font) *
layout->spacing.getValue() * spacing_val);
- pos_type const pos_end = lastPos(*pit, rit);
+ pos_type const pos_end = lastPos(*pit, row);
int labeladdon = 0;
int maxwidth = 0;
if (!pit->empty()) {
// We re-use the font resolution for the entire font span when possible
- LyXFont font = getFont(pit, rit->pos());
- lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(rit->pos());
+ LyXFont font = getFont(pit, row.pos());
+ lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(row.pos());
// Optimisation
Paragraph const & par = *pit;
// Check if any insets are larger
- for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
+ for (pos_type pos = row.pos(); pos <= pos_end; ++pos) {
// Manual inlined optimised version of common case of
// "maxwidth += singleWidth(pit, pos);"
char const c = par.getChar(pos);
// This is not completely correct, but we can live with the small,
// cosmetic error for now.
LyXFont::FONT_SIZE maxsize =
- pit->highestFontInRange(rit->pos(), pos_end, size);
+ pit->highestFontInRange(row.pos(), pos_end, size);
if (maxsize > font.size()) {
font.setSize(maxsize);
maxasc = max(maxasc, font_metrics::maxAscent(font));
++maxasc;
++maxdesc;
- rit->ascent_of_text(maxasc);
+ row.ascent_of_text(maxasc);
// is it a top line?
- if (!rit->pos()) {
+ if (!row.pos()) {
BufferParams const & bufparams = bv()->buffer()->params();
// some parksips VERY EASY IMPLEMENTATION
if (bv()->buffer()->params().paragraph_separation ==
prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = (layout->itemsep * defaultRowHeight());
- } else if (rit != firstRow()) {
+ } else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
tmptop = layout->topsep;
- //if (boost::prior(pit)->getDepth() >= pit->getDepth())
- // tmptop -= getPar(previousRow(rit))->layout()->bottomsep;
-
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
} else if (pit->params().lineTop()) {
}
// is it a bottom line?
- if (boost::next(rit) == pit->rows.end()) {
+ if (row.end() == pit->size()) {
// the bottom margin
ParagraphList::iterator nextpit = boost::next(pit);
if (nextpit == ownerParagraphs().end() && !isInInset())
maxasc += int(layoutasc * 2 / (2 + pit->getDepth()));
maxdesc += int(layoutdesc * 2 / (2 + pit->getDepth()));
- rit->height(maxasc + maxdesc + labeladdon);
- rit->baseline(maxasc + labeladdon);
- rit->top_of_text(rit->baseline() - font_metrics::maxAscent(font));
+ row.height(maxasc + maxdesc + labeladdon);
+ row.baseline(maxasc + labeladdon);
+ row.top_of_text(row.baseline() - font_metrics::maxAscent(font));
- double x = 0;
- rit->width(int(maxwidth + x));
+ row.width(maxwidth);
if (inset_owner) {
width = max(0, workWidth());
RowList::iterator rit = firstRow();
// same Paragraph one to the right and make a rebreak
void LyXText::insertChar(char c)
{
- recordUndo(bv(), Undo::INSERT, ownerParagraphs(), cursor.par(), cursor.par());
+ recordUndo(Undo::INSERT, this, cursor.par(), cursor.par());
// When the free-spacing option is set for the current layout,
// disable the double-space checking
bool const is_rtl =
pit->isRightToLeftPar(bv()->buffer()->params());
if (is_rtl)
- x = workWidth() > 0 ? rightMargin(pit, *bv()->buffer(), *rit) : 0;
+ x = workWidth() > 0 ? rightMargin(*pit, *bv()->buffer(), *rit) : 0;
else
x = workWidth() > 0 ? leftMargin(pit, *rit) : 0;
if (layout->margintype == MARGIN_MANUAL
&& layout->labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part
- int nlh = numberOfLabelHfills(*pit, rit);
+ int nlh = numberOfLabelHfills(*pit, *rit);
// A manual label par (e.g. List) has an auto-hfill
// between the label text and the body of the
}
// are there any hfills in the row?
- int const nh = numberOfHfills(*pit, rit);
+ int const nh = numberOfHfills(*pit, *rit);
if (nh) {
if (w > 0)
align = LYX_ALIGN_LEFT;
}
+ // Display-style insets should always be on a centred row
+ // The test on pit->size() is to catch zero-size pars, which
+ // would trigger the assert in Paragraph::getInset().
+ inset = pit->size() ? pit->getInset(rit->pos()) : 0;
+ if (inset && inset->display()) {
+ align = LYX_ALIGN_CENTER;
+ }
+
switch (align) {
case LYX_ALIGN_BLOCK:
{
- int const ns = numberOfSeparators(*pit, rit);
+ int const ns = numberOfSeparators(*pit, *rit);
RowList::iterator next_row = boost::next(rit);
+ bool disp_inset = false;
+ if (next_row != pit->rows.end()) {
+ InsetOld * in = pit->getInset(next_row->pos());
+ if (in)
+ disp_inset = in->display();
+ }
+ // If we have separators, this is not the last row of a
+ // par, does not end in newline, and is not row above a
+ // display inset... then stretch it
if (ns
- && next_row != pit->rows.end()
+ && rit->end() < pit->size()
&& !pit->isNewline(next_row->pos() - 1)
+ && !disp_inset
) {
fill_separator = w / ns;
} else if (is_rtl) {
}
}
- computeBidiTables(pit, *bv()->buffer(), rit);
+ computeBidiTables(*pit, *bv()->buffer(), *rit);
if (is_rtl) {
pos_type body_pos = pit->beginningOfBody();
- pos_type last = lastPos(*pit, rit);
+ pos_type last = lastPos(*pit, *rit);
if (body_pos > 0 &&
(body_pos - 1 > last ||
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- recordUndo(bv(), Undo::INSERT, ownerParagraphs(), startc.par());
+ recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->acceptChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- recordUndo(bv(), Undo::INSERT, ownerParagraphs(), startc.par());
+ recordUndo(Undo::INSERT, this, startc.par());
getPar(startc)->rejectChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value)
{
if (the_locking_inset) {
- WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);
+ WordLangTuple word =
+ the_locking_inset->selectNextWordToSpellcheck(bv(), value);
if (!word.word().empty()) {
value += float(cursor.y());
value /= float(height);
cursorPar()->isInset(cursor.pos())) {
// lock the inset!
FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
- cursorPar()->getInset(cursor.pos())->localDispatch(cmd);
+ cursorPar()->getInset(cursor.pos())->dispatch(cmd);
// now call us again to do the above trick
// but obviously we have to start from down below ;)
return bv()->text->selectNextWordToSpellcheck(value);
// Finally, we copy the word to a string and return it
string str;
if (selection.cursor.pos() < cursor.pos()) {
- pos_type i;
- for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
+ for (pos_type i = selection.cursor.pos(); i < cursor.pos(); ++i) {
if (!cursorPar()->isInset(i))
str += cursorPar()->getChar(i);
}
selection.cursor = cursor;
cursor = tmpcursor;
setSelection();
-
- // Great, CutSelection() gets rid of multiple spaces.
cutSelection(true, false);
}
}
setCursor(to.par(), to.pos() + 1);
}
- recordUndo(bv(), Undo::ATOMIC, ownerParagraphs(), from.par(), to.par());
+ recordUndo(Undo::ATOMIC, this, from.par(), to.par());
pos_type pos = from.pos();
int par = from.par();
// if you had success make a backspace
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
- recordUndo(bv(), Undo::DELETE, ownerParagraphs(), old_cursor.par());
+ recordUndo(Undo::DELETE, this, old_cursor.par());
backspace();
}
}
}
if (cursor.par() != 0)
- recordUndo(bv(), Undo::DELETE, ownerParagraphs(),
- cursor.par() - 1, cursor.par());
+ recordUndo(Undo::DELETE, this, cursor.par() - 1, cursor.par());
ParagraphList::iterator tmppit = cursorPar();
// We used to do cursorLeftIntern() here, but it is
} else {
// this is the code for a normal backspace, not pasting
// any paragraphs
- recordUndo(bv(), Undo::DELETE, ownerParagraphs(), cursor.par());
+ recordUndo(Undo::DELETE, this, cursor.par());
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
RowList::iterator LyXText::cursorRow() const
{
- return getRow(cursorPar(), cursor.pos());
+ return getRow(*cursorPar(), cursor.pos());
}
RowList::iterator LyXText::getRow(LyXCursor const & cur) const
{
- return getRow(getPar(cur), cur.pos());
+ return getRow(*getPar(cur), cur.pos());
}
-RowList::iterator
-LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
+RowList::iterator LyXText::getRow(Paragraph & par, pos_type pos) const
{
- RowList::iterator rit = boost::prior(pit->rows.end());
- RowList::iterator const begin = pit->rows.begin();
+ RowList::iterator rit = boost::prior(par.rows.end());
+ RowList::iterator const begin = par.rows.begin();
while (rit != begin && rit->pos() > pos)
--rit;
}
-// returns pointer to some fancy row 'below' specified row
-RowList::iterator LyXText::cursorIRow() const
-{
- return getRow(cursorPar(), cursor.pos());
-}
-
-
-RowList::iterator LyXText::getRowNearY(int y,
- ParagraphList::iterator & pit) const
+RowList::iterator
+LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
{
//lyxerr << "getRowNearY: y " << y << endl;
RowList::iterator rit = lastRow();
RowList::iterator rbegin = firstRow();
- while (rit != rbegin && static_cast<int>(rit->y()) > y)
+ while (rit != rbegin && int(pit->y + rit->y_offset()) > y)
previousRow(pit, rit);
return rit;
{
return std::distance(ownerParagraphs().begin(), pit);
}
+
+
+int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
+{
+ // remove rows of paragraph, keep track of height changes
+ height -= pit->height;
+ pit->rows.clear();
+
+ // redo insets
+ InsetList::iterator ii = pit->insetlist.begin();
+ InsetList::iterator iend = pit->insetlist.end();
+ for (; ii != iend; ++ii) {
+ Dimension dim;
+ MetricsInfo mi(bv(), getFont(pit, ii->pos), workWidth());
+ ii->inset->metrics(mi, dim);
+ }
+
+ // rebreak the paragraph
+ int par_width = 0;
+ int const ww = workWidth();
+ pit->height = 0;
+
+ for (pos_type z = 0; z < pit->size() + 1; ) {
+ Row row(z);
+ z = rowBreakPoint(pit, row) + 1;
+ row.end(z);
+ pit->rows.push_back(row);
+ RowList::iterator rit = boost::prior(pit->rows.end());
+ int const f = fill(pit, *rit, ww);
+ int const w = ww - f;
+ par_width = std::max(par_width, w);
+ rit->fill(f);
+ rit->width(w);
+ prepareToPrint(pit, rit);
+ setHeightOfRow(pit, *rit);
+ rit->y_offset(pit->height);
+ pit->height += rit->height();
+ }
+ height += pit->height;
+
+ //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
+ return par_width;
+}
+
+
+int LyXText::redoParagraphs(ParagraphList::iterator start,
+ ParagraphList::iterator end)
+{
+ int pars_width = 0;
+ for ( ; start != end; ++start) {
+ int par_width = redoParagraphInternal(start);
+ pars_width = std::max(par_width, pars_width);
+ }
+ updateRowPositions();
+ return pars_width;
+}
+
+
+void LyXText::redoParagraph(ParagraphList::iterator pit)
+{
+ redoParagraphInternal(pit);
+ updateRowPositions();
+}
+
+
+void LyXText::fullRebreak()
+{
+ redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
+ redoCursor();
+ selection.cursor = cursor;
+}
+
+
+void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
+{
+ lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
+ << " workWidth: " << workWidth() << "\nfont: " << mi.base.font << endl;
+ //BOOST_ASSERT(mi.base.textwidth);
+
+ // rebuild row cache
+ width = 0;
+ ///height = 0;
+
+ //anchor_y_ = 0;
+ width = redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
+
+ // final dimension
+ dim.asc = firstRow()->ascent_of_text();
+ dim.des = height - dim.asc;
+ dim.wid = std::max(mi.base.textwidth, int(width));
+}