]> git.lyx.org Git - features.git/commitdiff
parlist-9-a.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 13 Apr 2003 02:23:30 +0000 (02:23 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 13 Apr 2003 02:23:30 +0000 (02:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6787 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/CutAndPaste.C
src/CutAndPaste.h
src/text.C
src/text2.C

index 2cb3673e565a703faa499ef3c1d985a067403d1c..8c733bcdcfccfbe6b26c249d6cece05cddde1d86 100644 (file)
@@ -1,5 +1,10 @@
 2003-04-13  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
+       * text.C, text2.C: exchange all usage of Paragraph::next with
+       boost::next(ParagraphList::iterator)
+
+       * CutAndPaste.C (cutSelection): change 2. arg to a Paragraph*
+
        * text2.C (cursorTop): simplify implementation
        (cursorBottom): ditto
        (setParagraph): use ParagraphList::iterator
index 18d131816c5b040d6c97b2af41b3083ec044a88f..4593486a11cfc50845b69af081bc872cd1225ba0 100644 (file)
@@ -62,7 +62,7 @@ textclass_type textclass = 0;
 } // namespace anon
 
 
-bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
+bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph * endpar,
                               int start, int & end, textclass_type tc,
                               bool doclear, bool realcut)
 {
@@ -70,10 +70,10 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                return false;
 
        if (realcut) {
-               copySelection(startpar, *endpar, start, end, tc);
+               copySelection(startpar, endpar, start, end, tc);
        }
 
-       if (!endpar || startpar == *endpar) {
+       if (!endpar || startpar == endpar) {
                if (startpar->erase(start, end)) {
                        // Some chars were erased, go to start to be safe
                        end = start;
@@ -85,7 +85,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
 
        // clear end/begin fragments of the first/last par in selection
        actually_erased |= (startpar)->erase(start, startpar->size());
-       if ((*endpar)->erase(0, end)) {
+       if (endpar->erase(0, end)) {
                actually_erased = true;
                end = 0;
        }
@@ -102,7 +102,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                Paragraph * next = pit->next();
 
                // "erase" the contents of the par
-               if (pit != *endpar) {
+               if (pit != endpar) {
                        actually_erased |= pit->erase(0, pit->size());
 
                        // remove the par if it's now empty
@@ -116,7 +116,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                        }
                }
 
-               if (pit == *endpar)
+               if (pit == endpar)
                        break;
 
                pit = next;
@@ -152,7 +152,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                // the insets paragraphs, and not the buffers. (Lgb)
                mergeParagraph(buffer->params, buffer->paragraphs, startpar);
                // this because endpar gets deleted here!
-               (*endpar) = startpar;
+               endpar = startpar;
        }
 
        return true;
index 80be21aa0134a91aa6369461eb6b0a45ffda2242..61b0402152f3cc31fd455a512c4f0f331fca122c 100644 (file)
@@ -21,7 +21,7 @@ class LyXTextClass;
 namespace CutAndPaste {
 
 /// realcut == false is we actually want a delete
-bool cutSelection(Paragraph * startpar, Paragraph ** endpar,
+bool cutSelection(Paragraph * startpar, Paragraph * endpar,
                  int start, int & end, lyx::textclass_type tc,
                  bool doclear = false, bool realcut = true);
 
index 821b17d010c2c3ac88dc08e85a4318a967fd28bb..a93f0662bb24e9d2c18965996a63ac8665c3045b 100644 (file)
@@ -1248,7 +1248,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                // a section, or between the items of a itemize or enumerate
                // environment
                if (!firstpit->params().pagebreakBottom()
-                   && rit->par()->next()) {
+                   && boost::next(rit->par()) != ownerParagraphs().end()) {
                        ParagraphList::iterator nextpit = boost::next(rit->par());
                        ParagraphList::iterator comparepit = rit->par();
                        float usual = 0;
@@ -1485,7 +1485,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
                        cursor.par()->applyLayout(tclass.defaultLayout());
                else
                        // set to standard-layout
-                       cursor.par()->next()->applyLayout(tclass.defaultLayout());
+                       boost::next(cursor.par())->applyLayout(tclass.defaultLayout());
        }
 
        // if the cursor is at the beginning of a row without prior newline,
@@ -1522,17 +1522,18 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
        // When ::breakParagraph is called from within an inset we must
        // ensure that the correct ParagraphList is used. Today that is not
        // the case and the Buffer::paragraphs is used. Not good. (Lgb)
-       while (!cursor.par()->next()->empty()
-         && cursor.par()->next()->isNewline(0))
-          cursor.par()->next()->erase(0);
+       ParagraphList::iterator next_par = boost::next(cursor.par());
 
-       insertParagraph(cursor.par()->next(), boost::next(cursor.row()));
+       while (!next_par->empty() && next_par->isNewline(0))
+               next_par->erase(0);
+
+       insertParagraph(next_par, boost::next(cursor.row()));
        updateCounters();
 
        // This check is necessary. Otherwise the new empty paragraph will
        // be deleted automatically. And it is more friendly for the user!
        if (cursor.pos() || isempty)
-               setCursor(boost::next(cursor.par()), 0);
+               setCursor(next_par, 0);
        else
                setCursor(cursor.par(), 0);
 
@@ -1955,8 +1956,8 @@ void LyXText::cursorRightOneWord()
        // CHECK See comment on top of text.C
 
        if (tmpcursor.pos() == tmpcursor.par()->size()
-           && tmpcursor.par()->next()) {
-                       tmpcursor.par(tmpcursor.par()->next());
+           && boost::next(tmpcursor.par()) != ownerParagraphs().end()) {
+                       tmpcursor.par(boost::next(tmpcursor.par()));
                        tmpcursor.pos(0);
        } else {
                int steps = 0;
@@ -2133,7 +2134,7 @@ void LyXText::rejectChange()
                startc.par()->rejectChange(startc.pos(), endc.pos());
                finishUndo();
                clearSelection();
-               redoParagraphs(startc, startc.par()->next());
+               redoParagraphs(startc, boost::next(startc.par()));
                setCursorIntern(startc.par(), 0);
        }
 #warning handle multi par selection
@@ -2154,9 +2155,9 @@ LyXText::selectNextWordToSpellcheck(float & value)
                }
                // we have to go on checking so move cursor to the next char
                if (cursor.pos() == cursor.par()->size()) {
-                       if (!cursor.par()->next())
+                       if (boost::next(cursor.par()) == ownerParagraphs().end())
                                return word;
-                       cursor.par(cursor.par()->next());
+                       cursor.par(boost::next(cursor.par()));
                        cursor.pos(0);
                } else
                        cursor.pos(cursor.pos() + 1);
index 1a801ee63c4ec17498a1ba4fc107546159213ba8..bfa4b4ff010062bbc82d245dae85f6a3049252d2 100644 (file)
@@ -389,19 +389,22 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
                   LyXCursor & send_cur,
                   string const & layout)
 {
-       Paragraph * endpar = send_cur.par()->next();
-       Paragraph * undoendpar = endpar;
+       ParagraphList::iterator endpit = boost::next(send_cur.par());
+       ParagraphList::iterator undoendpit = endpit;
 
-       if (endpar && endpar->getDepth()) {
-               while (endpar && endpar->getDepth()) {
-                       endpar = endpar->next();
-                       undoendpar = endpar;
+       if (endpit != ownerParagraphs().end() &&
+           endpit->getDepth()) {
+               while (endpit != ownerParagraphs().end() &&
+                      endpit->getDepth()) {
+                       ++endpit;
+                       undoendpit = endpit;
                }
-       } else if (endpar) {
-               endpar = endpar->next(); // because of parindents etc.
+       } else if (endpit != ownerParagraphs().end()) {
+               // because of parindents etc.
+               ++endpit;
        }
 
-       setUndo(bv(), Undo::EDIT, &*sstart_cur.par(), undoendpar);
+       setUndo(bv(), Undo::EDIT, &*sstart_cur.par(), &*undoendpit);
 
        // ok we have a selection. This is always between sstart_cur
        // and sel_end cursor
@@ -428,7 +431,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
                ++pit;
        } while (pit != epit);
 
-       return endpar;
+       return endpit;
 }
 
 
@@ -591,12 +594,12 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
                        cursor.pos(cursor.pos() + 1);
                } else {
                        cursor.pos(0);
-                       cursor.par(cursor.par()->next());
+                       cursor.par(boost::next(cursor.par()));
                }
        }
        unFreezeUndo();
 
-       redoParagraphs(selection.start, selection.end.par()->next());
+       redoParagraphs(selection.start, boost::next(selection.end.par()));
 
        // we have to reset the selection, because the
        // geometry could have changed, but we keep
@@ -830,7 +833,7 @@ string const LyXText::selectionAsString(Buffer const * buffer,
 #warning FIXME Why isnt ParagraphList::iterator used here?
        // as loop variable.
        LyXCursor tmpcur(selection.start);
-       tmpcur.par(tmpcur.par()->next());
+       tmpcur.par(boost::next(tmpcur.par()));
        while (tmpcur.par() != endpit) {
                result += tmpcur.par()->asString(buffer, 0,
                                                 tmpcur.par()->size(),
@@ -1339,51 +1342,53 @@ void LyXText::cutSelection(bool doclear, bool realcut)
        // and selection.end
 
        // make sure that the depth behind the selection are restored, too
-       Paragraph * endpar = selection.end.par()->next();
-       Paragraph * undoendpar = endpar;
+       ParagraphList::iterator endpit = boost::next(selection.end.par());
+       ParagraphList::iterator undoendpit = endpit;
 
-       if (endpar && endpar->getDepth()) {
-               while (endpar && endpar->getDepth()) {
-                       endpar = endpar->next();
-                       undoendpar = endpar;
+       if (endpit != ownerParagraphs().end() &&
+           endpit->getDepth()) {
+               while (endpit != ownerParagraphs().end() &&
+                      endpit->getDepth()) {
+                       ++endpit;
+                       undoendpit = endpit;
                }
-       } else if (endpar) {
-               endpar = endpar->next(); // because of parindents etc.
+       } else if (endpit != ownerParagraphs().end()) {
+               // because of parindents etc.
+               ++endpit;
        }
 
-       setUndo(bv(), Undo::DELETE,
-               &*selection.start.par(), undoendpar);
+       setUndo(bv(), Undo::DELETE, &*selection.start.par(), &*undoendpit);
 
        // there are two cases: cut only within one paragraph or
        // more than one paragraph
        if (selection.start.par() == selection.end.par()) {
                // only within one paragraph
-               endpar = &*selection.end.par();
+               endpit = selection.end.par();
                int pos = selection.end.pos();
-               CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
+               CutAndPaste::cutSelection(&*selection.start.par(), &*endpit,
                                          selection.start.pos(), pos,
                                          bv()->buffer()->params.textclass,
                                          doclear, realcut);
                selection.end.pos(pos);
        } else {
-               endpar = &*selection.end.par();
+               endpit = selection.end.par();
                int pos = selection.end.pos();
-               CutAndPaste::cutSelection(&*selection.start.par(), &endpar,
+               CutAndPaste::cutSelection(&*selection.start.par(), &*endpit,
                                          selection.start.pos(), pos,
                                          bv()->buffer()->params.textclass,
                                          doclear, realcut);
-               cursor.par(endpar);
-               selection.end.par(endpar);
+               cursor.par(endpit);
+               selection.end.par(endpit);
                selection.end.pos(pos);
                cursor.pos(selection.end.pos());
        }
-       endpar = endpar->next();
+       ++endpit;
 
        // sometimes necessary
        if (doclear)
                selection.start.par()->stripLeadingSpaces();
 
-       redoParagraphs(selection.start, endpar);
+       redoParagraphs(selection.start, endpit);
 
        // cutSelection can invalidate the cursor so we need to set
        // it anew. (Lgb)
@@ -2076,8 +2081,8 @@ void LyXText::cursorRight(bool internal)
                if (!internal &&
                    isBoundary(bv()->buffer(), *cursor.par(), cursor.pos()))
                        setCursor(cursor.par(), cursor.pos(), true, true);
-       } else if (cursor.par()->next())
-               setCursor(cursor.par()->next(), 0);
+       } else if (boost::next(cursor.par()) != ownerParagraphs().end())
+               setCursor(boost::next(cursor.par()), 0);
 }
 
 
@@ -2142,8 +2147,8 @@ void LyXText::cursorUpParagraph()
 
 void LyXText::cursorDownParagraph()
 {
-       if (cursor.par()->next()) {
-               setCursor(cursor.par()->next(), 0);
+       if (boost::next(cursor.par()) != ownerParagraphs().end()) {
+               setCursor(boost::next(cursor.par()), 0);
        } else {
                setCursor(cursor.par(), cursor.par()->size());
        }
@@ -2219,7 +2224,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                    && old_cursor.par()->isLineSeparator(old_cursor.pos())
                    && old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) {
                        old_cursor.par()->erase(old_cursor.pos() - 1);
-                       redoParagraphs(old_cursor, old_cursor.par()->next());
+                       redoParagraphs(old_cursor, boost::next(old_cursor.par()));
 
 #ifdef WITH_WARNINGS
 #warning This will not work anymore when we have multiple views of the same buffer
@@ -2273,12 +2278,14 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                        const_cast<LyXText *>(this)->postPaint(old_cursor.y() - old_cursor.row()->baseline() - prevrow->height());
                        tmpcursor = cursor;
                        cursor = old_cursor; // that undo can restore the right cursor position
-                       Paragraph * endpar = old_cursor.par()->next();
-                       while (endpar && endpar->getDepth()) {
-                               endpar = endpar->next();
+                       #warning FIXME. --end() iterator is usable here
+                       ParagraphList::iterator endpit = boost::next(old_cursor.par());
+                       while (endpit != ownerParagraphs().end() &&
+                              endpit->getDepth()) {
+                               ++endpit;
                        }
 
-                       setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
+                       setUndo(bv(), Undo::DELETE, &*old_cursor.par(), &*endpit);
                        cursor = tmpcursor;
 
                        // delete old row
@@ -2306,12 +2313,14 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
 
                        tmpcursor = cursor;
                        cursor = old_cursor; // that undo can restore the right cursor position
-                       Paragraph * endpar = old_cursor.par()->next();
-                       while (endpar && endpar->getDepth()) {
-                               endpar = endpar->next();
+#warning FIXME. --end() iterator is usable here
+                       ParagraphList::iterator endpit = boost::next(old_cursor.par());
+                       while (endpit != ownerParagraphs().end() &&
+                              endpit->getDepth()) {
+                               ++endpit;
                        }
 
-                       setUndo(bv(), Undo::DELETE, &*old_cursor.par(), endpar);
+                       setUndo(bv(), Undo::DELETE, &*old_cursor.par(), &*endpit);
                        cursor = tmpcursor;
 
                        // delete old row
@@ -2344,8 +2353,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
        }
        if (!deleted) {
                if (old_cursor.par()->stripLeadingSpaces()) {
-                       redoParagraphs(old_cursor,
-                                      old_cursor.par()->next());
+                       redoParagraphs(old_cursor, boost::next(old_cursor.par()));
                        // correct cursor y
                        setCursorIntern(cursor.par(), cursor.pos());
                        selection.cursor = cursor;