speed up workWidth code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2900 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-10-19 12:34:31 +00:00
parent 5507c1ad69
commit a80bee35b9
2 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2001-10-19 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* text.C (workWidth): do not search for the exact row when
margintype is not MARGIN_RIGHT_ADDRESS_BOX. This is an
optimization for big documents.
2001-10-18 Juergen Vigna <jug@sad.it>
* text.C (workWidth): new function with added Inset * parameter.

View File

@ -68,7 +68,7 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
{
Buffer::inset_iterator it;
Paragraph * par = 0;
Paragraph::size_type pos;
Paragraph::size_type pos = 0;
for(it=bview->buffer()->inset_iterator_begin();
it != bview->buffer()->inset_iterator_end();
@ -80,20 +80,38 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
break;
}
}
if (par) {
if (!par) {
lyxerr << "LyXText::workWidth: cannot find inset!" <<endl;
return workWidth(bview);
}
LyXLayout const & layout =
textclasslist.Style(bview->buffer()->params.textclass,
par->getLayout());
if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) {
// Optimization here: in most cases, the real row is
// not needed, but only the par/pos values. So we just
// construct a dummy row for leftMargin. (JMarc)
Row dummyrow;
dummyrow.par(par);
dummyrow.pos(pos);
return workWidth(bview) - leftMargin(bview, &dummyrow);
} else {
Row * row = firstrow;
for(; row; row = row->next()) {
if ((row->par() == par && row->pos() >= pos)) {
if (!row->next())
break;
else if ((row->next()->par() == par) &&
(row->next()->pos() >= pos))
(row->next()->pos() >= pos))
continue;
}
}
if (row) {
return workWidth(bview) - leftMargin(bview, row);
}
}
}
return workWidth(bview);
}