From 175100005969ed5c93680a9c361eb0d290688d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 1 Aug 2003 12:20:27 +0000 Subject: [PATCH] spend extra cycles for simpler redoParagraph logic git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7471 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/text2.C | 68 ++++++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/src/text2.C b/src/text2.C index 0c798d4bc8..a1a4327721 100644 --- a/src/text2.C +++ b/src/text2.C @@ -631,80 +631,48 @@ RowList::iterator LyXText::firstRow(ParagraphList::iterator pit) // rebreaks all paragraphs between the specified pars // This function is needed after SetLayout and SetFont etc. void LyXText::redoParagraphs(ParagraphList::iterator start, - ParagraphList::iterator endpit) + ParagraphList::iterator end) { - RowList::iterator rit = firstRow(start); + for ( ; start != end; ++start) + redoParagraph(start); +} + + +void LyXText::redoParagraph(ParagraphList::iterator pit) +{ + RowList::iterator rit = firstRow(pit); if (rit == rows().end()) { lyxerr << "LyXText::redoParagraphs: should not happen\n"; Assert(0); } - ParagraphList::iterator first_phys_pit; - RowList::iterator prevrit; - if (rit == rows().begin()) { - // A trick/hack for UNDO. - // This is needed because in an UNDO/REDO we could have - // changed the ownerParagraph() so the paragraph inside - // the row is NOT my really first par anymore. - // Got it Lars ;) (Jug 20011206) - first_phys_pit = ownerParagraphs().begin(); - prevrit = rows().end(); - } else { - first_phys_pit = rit->par(); - while (rit != rows().begin() - && boost::prior(rit)->par() == first_phys_pit) - { - --rit; - } - prevrit = boost::prior(rit); - } - // remove it - while (rit != rows().end() && rit->par() != endpit) { + while (rit != rows().end() && rit->par() == pit) { RowList::iterator rit2 = rit++; removeRow(rit2); } - // Reinsert the paragraphs. - ParagraphList::iterator tmppit = first_phys_pit; - - while (tmppit != ownerParagraphs().end()) { - insertParagraph(tmppit, rit); - while (rit != rows().end() && rit->par() == tmppit) - ++rit; - ++tmppit; - if (tmppit == endpit) - break; - } - if (prevrit != rows().end()) - setHeightOfRow(prevrit); - else - setHeightOfRow(rows().begin()); - postPaint(); - if (rit != rows().end()) - setHeightOfRow(rit); - + // Reinsert the paragraph. + insertParagraph(pit, rit); + setHeightOfRow(rows().begin()); updateCounters(); } -void LyXText::redoParagraph(ParagraphList::iterator pit) -{ - redoParagraphs(pit, boost::next(pit)); -} - - void LyXText::fullRebreak() { - init(bv()); + lyxerr << "fullRebreak\n"; + redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); setCursorIntern(cursor.par(), cursor.pos()); + selection.cursor = cursor; } void LyXText::metrics(MetricsInfo & mi, Dimension & dim) { - //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth << "\n"; + lyxerr << "LyXText::metrics: width: " << mi.base.textwidth << "\n"; + //Assert(mi.base.textwidth); // rebuild row cache rowlist_.clear();