From: André Pönitz Date: Thu, 14 Aug 2003 11:16:31 +0000 (+0000) Subject: some more getPar removals X-Git-Tag: 1.6.10~16296 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=648523b3897cf79d782ab6c44a991de7942f111a;p=features.git some more getPar removals git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7539 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/lyxrow_funcs.C b/src/lyxrow_funcs.C index 586c1f0320..748b8eb755 100644 --- a/src/lyxrow_funcs.C +++ b/src/lyxrow_funcs.C @@ -17,8 +17,7 @@ using std::min; bool isParEnd(LyXText const & lt, ParagraphList::iterator pit, RowList::iterator rit) { - RowList::iterator next_row = boost::next(rit); - return next_row == lt.rows().end() || lt.getPar(next_row) != pit; + return boost::next(rit) == lt.endRow(pit); } diff --git a/src/lyxtext.h b/src/lyxtext.h index a2814910c8..19e1579832 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -522,6 +522,14 @@ public: RowList::iterator beginRow(ParagraphList::iterator pit) const; /// return row "behind" last of par RowList::iterator endRow(ParagraphList::iterator pit) const; + /// return first row of text + RowList::iterator firstRow() const; + /// return row "behind" last of par + RowList::iterator lastRow() const; + /// return next row crossing paragraph boundaries + RowList::iterator nextRow(RowList::iterator rit) const; + /// return previous row crossing paragraph boundaries + RowList::iterator previousRow(RowList::iterator rit) const; private: /** Cursor related data. diff --git a/src/text.C b/src/text.C index 38cdcd5b2d..3087ef14de 100644 --- a/src/text.C +++ b/src/text.C @@ -1246,8 +1246,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit) } // is it a bottom line? - RowList::iterator next_rit = boost::next(rit); - if (next_rit == rows().end() || getPar(next_rit) != pit) { + if (boost::next(rit) == endRow(pit)) { // the bottom margin ParagraphList::iterator nextpit = boost::next(pit); if (nextpit == ownerParagraphs().end() && @@ -1627,14 +1626,12 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, { int const ns = numberOfSeparators(*this, pit, rit); RowList::iterator next_row = boost::next(rit); - ParagraphList::iterator next_pit; - - if (ns && next_row != rowlist_.end() && - (next_pit = getPar(next_row)) == pit && - !(next_pit->isNewline(next_row->pos() - 1)) - && !(next_pit->isInset(next_row->pos()) && - next_pit->getInset(next_row->pos()) && - next_pit->getInset(next_row->pos())->display()) + if (ns + && next_row != endRow(pit) + && !pit->isNewline(next_row->pos() - 1) + && !(pit->isInset(next_row->pos()) + && pit->getInset(next_row->pos()) + && pit->getInset(next_row->pos())->display()) ) { fill_separator = w / ns; } else if (is_rtl) { @@ -2153,23 +2150,15 @@ RowList::iterator LyXText::getRow(LyXCursor const & cur) const RowList::iterator LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const { - if (rows().empty()) - return rowlist_.end(); - - // find the first row of the specified paragraph - RowList::iterator rit = rowlist_.begin(); - RowList::iterator end = rowlist_.end(); - while (boost::next(rit) != end && getPar(rit) != pit) { + RowList::iterator rit = beginRow(pit); + RowList::iterator end = endRow(pit); + +#warning Why is this next thing needed? (Andre) + while (rit != end + && rit->pos() < pos + && boost::next(rit) != end + && boost::next(rit)->pos() <= pos) ++rit; - } - - // now find the wanted row - while (rit->pos() < pos - && boost::next(rit) != end - && getPar(boost::next(rit)) == pit - && boost::next(rit)->pos() <= pos) { - ++rit; - } return rit; } @@ -2182,20 +2171,20 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const y = 0; if (rows().empty()) - return rowlist_.end(); + return firstRow(); + + RowList::iterator beg = beginRow(pit); + RowList::iterator end = endRow(pit); + RowList::iterator rit; // find the first row of the specified paragraph - RowList::iterator rit = rowlist_.begin(); - RowList::iterator end = rowlist_.end(); - while (boost::next(rit) != end && getPar(rit) != pit) { + for (rit = firstRow(); rit != beg; rit = nextRow(rit)) y += rit->height(); - ++rit; - } // now find the wanted row - while (rit->pos() < pos + while (rit != end + && rit->pos() < pos && boost::next(rit) != end - && getPar(boost::next(rit)) == pit && boost::next(rit)->pos() <= pos) { y += rit->height(); ++rit; @@ -2316,3 +2305,27 @@ RowList::iterator LyXText::endRow(ParagraphList::iterator pit) const { return beginRow(boost::next(pit)); } + + +RowList::iterator LyXText::firstRow() const +{ + return rowlist_.begin(); +} + + +RowList::iterator LyXText::lastRow() const +{ + return boost::prior(rowlist_.end()); +} + + +RowList::iterator LyXText::nextRow(RowList::iterator rit) const +{ + return boost::next(rit); +} + + +RowList::iterator LyXText::previousRow(RowList::iterator rit) const +{ + return boost::prior(rit); +} diff --git a/src/text2.C b/src/text2.C index 95cad09c2b..9adca2d484 100644 --- a/src/text2.C +++ b/src/text2.C @@ -618,24 +618,8 @@ void LyXText::redoParagraphs(ParagraphList::iterator start, void LyXText::redoParagraph(ParagraphList::iterator pit) { -#if 0 - // find first row of given par - RowList::iterator first; - for (first = rows().begin(); first != rows().end(); ++first) - if (getPar(first) == pit) - break; - - // find last row of given par - RowList::iterator last = first; - for ( ; last != rows().end() && getPar(last) == pit; ++last) - ; - - Assert(first == beginRow(pit)); - Assert(last == endRow(pit)); -#else RowList::iterator first = beginRow(pit); RowList::iterator last = endRow(pit); -#endif // remove paragraph from rowlist while (first != last) { @@ -1655,11 +1639,9 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, boundary = false; // This (rtl_support test) is not needed, but gives - // some speedup if rtl_support=false - RowList::iterator next_rit = boost::next(rit); - - bool const lastrow = lyxrc.rtl_support && - (next_rit == rowlist_.end() || getPar(next_rit) != pit); + // some speedup if rtl_support == false + bool const lastrow = lyxrc.rtl_support + && boost::next(rit) == endRow(pit); // If lastrow is false, we don't need to compute // the value of rtl. @@ -1667,8 +1649,8 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit, ? pit->isRightToLeftPar(bv()->buffer()->params) : false; if (lastrow && - ((rtl && left_side && vc == rit->pos() && x < tmpx - 5) || - (!rtl && !left_side && vc == last + 1 && x > tmpx + 5))) + ((rtl && left_side && vc == rit->pos() && x < tmpx - 5) || + (!rtl && !left_side && vc == last + 1 && x > tmpx + 5))) c = last + 1; else if (vc == rit->pos()) { c = vis2log(vc);