]> git.lyx.org Git - features.git/commitdiff
some more getPar removals
authorAndré Pönitz <poenitz@gmx.net>
Thu, 14 Aug 2003 11:16:31 +0000 (11:16 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 14 Aug 2003 11:16:31 +0000 (11:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7539 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxrow_funcs.C
src/lyxtext.h
src/text.C
src/text2.C

index 586c1f0320488098243a379587a00b8e1c7175d1..748b8eb7557ee4952028031c33d59d73e2a39ed3 100644 (file)
@@ -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);
 }
 
 
index a2814910c87a4f640f6481648279d41464581b28..19e15798322e9e4d0928474a56263c282b983abb 100644 (file)
@@ -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.
index 38cdcd5b2d0509a7bd9505e2316d91f3d06689fb..3087ef14de72df54444b929c26d9575c3a7d9dc8 100644 (file)
@@ -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);
+}
index 95cad09c2bfaca55f4380ff3b9f7172859408518..9adca2d484e6a8ef00a590f30ad676c0258d8aaa 100644 (file)
@@ -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);