]> git.lyx.org Git - lyx.git/commitdiff
op-1-a.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 16 Apr 2003 00:02:38 +0000 (00:02 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 16 Apr 2003 00:02:38 +0000 (00:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6821 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/ParagraphList.C
src/lyxtext.h
src/text2.C
src/undo_funcs.C

index ffd15422d4390a183d33bfcc5bb6ef0bba093435..d1b0ef8025cbbbe3ede92033955346160c3985c9 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-16  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * undo_funcs.C (textHandleUndo): ajust (rather big adsjust this one)
+
+       * text2.C (deleteEmptyParagraphMechanism): adjust
+
+       * text2.[Ch] (ownerParagraph): delete func (both of them 
+
 2003-04-15  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * text_funcs.C (transposeChars): use ParagraphList::iterator here.
index 65f1e0ebcec71d1ff9fc2631b4414f378b53d60c..40b5dc20dba1c82466166b4cc886bea041351819 100644 (file)
@@ -168,6 +168,8 @@ void ParagraphList::erase(ParagraphList::iterator it)
        if (next)
                next->previous_ = prev;
 
+       it->previous_ = 0;
+       it->next_ = 0;
        delete &*it;
 #else
        Paragraph * prev = it->prev_par_;
index adf0ce3db21e0841dc739a8fd02a73c96c2f725f..3a8a05644b1f182b2ccdd089d27074aee86d96e7 100644 (file)
@@ -633,10 +633,6 @@ public:
        // special owner functions
        ///
        ParagraphList & ownerParagraphs() const;
-       //
-       void ownerParagraph(Paragraph *) const;
-       // set it searching first for the right owner using the paragraph id
-       void ownerParagraph(int id, Paragraph *) const;
 
        /// return true if this is owned by an inset.
        bool isInInset() const;
index b3c34c090877fec72ed9bd7bc6fe7a195eecbf0d..3f4bfb310915f5ab1a0ea8b78e9c4aef47b9c27b 100644 (file)
@@ -2254,6 +2254,10 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
 
                deleted = true;
 
+               bool selection_position_was_oldcursor_position = (
+                       selection.cursor.par()  == old_cursor.par()
+                       && selection.cursor.pos() == old_cursor.pos());
+
                if (old_cursor.row() != rows().begin()) {
                        RowList::iterator
                                prevrow = boost::prior(old_cursor.row());
@@ -2272,12 +2276,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
 
                        // delete old row
                        removeRow(old_cursor.row());
-                       if (ownerParagraphs().begin() == old_cursor.par()) {
-                               ownerParagraph(&*boost::next(ownerParagraphs().begin()));
-                       }
-#warning FIXME Do the proper ParagraphList operation here (Lgb)
                        // delete old par
-                       delete &*old_cursor.par();
+                       ownerParagraphs().erase(old_cursor.par());
 
                        /* Breakagain the next par. Needed because of
                         * the parindent that can occur or dissappear.
@@ -2308,11 +2308,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                        // delete old row
                        removeRow(old_cursor.row());
                        // delete old par
-                       if (ownerParagraphs().begin() == old_cursor.par()) {
-                               ownerParagraph(&*boost::next(ownerParagraphs().begin()));
-                       }
-#warning FIXME Do the proper ParagraphList operations here. (Lgb)
-                       delete &*old_cursor.par();
+                       ownerParagraphs().erase(old_cursor.par());
 
                        /* Breakagain the next par. Needed because of
                           the parindent that can occur or dissappear.
@@ -2327,8 +2323,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                // correct cursor y
                setCursorIntern(cursor.par(), cursor.pos());
 
-               if (selection.cursor.par()  == old_cursor.par()
-                   && selection.cursor.pos() == old_cursor.pos()) {
+               if (selection_position_was_oldcursor_position) {
                        // correct selection
                        selection.cursor = cursor;
                }
@@ -2354,27 +2349,6 @@ ParagraphList & LyXText::ownerParagraphs() const
 }
 
 
-void LyXText::ownerParagraph(Paragraph * p) const
-{
-       if (inset_owner) {
-               inset_owner->paragraph(p);
-       } else {
-               bv_owner->buffer()->paragraphs.set(p);
-       }
-}
-
-
-void LyXText::ownerParagraph(int id, Paragraph * p) const
-{
-       Paragraph * op = bv_owner->buffer()->getParFromID(id);
-       if (op && op->inInset()) {
-               static_cast<InsetText *>(op->inInset())->paragraph(p);
-       } else {
-               ownerParagraph(p);
-       }
-}
-
-
 LyXText::refresh_status LyXText::refreshStatus() const
 {
        return refresh_status_;
index 2165f5405ccf04da50462d04630998c2e3378871..6235df6fa9b6c19f88ebc0bbbfccada51a167bff 100644 (file)
@@ -14,6 +14,7 @@
 #include "BufferView.h"
 #include "buffer.h"
 #include "insets/updatableinset.h"
+#include "insets/insettext.h"
 #include "debug.h"
 #include "support/LAssert.h"
 
@@ -166,17 +167,28 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                undopar->previous(before);
                if (before)
                        before->next(undopar);
-               else
-                       bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(),
-                                                undopar);
-
+               else {
+                       int id = firstUndoParagraph(bv, undo.number_of_inset_id)->id();
+                       Paragraph * op = bv->buffer()->getParFromID(id);
+                       if (op && op->inInset()) {
+                               static_cast<InsetText*>(op->inInset())->paragraph(undopar);
+                       } else {
+                               bv->buffer()->paragraphs.set(undopar);
+                       }
+               }
        } else {
                // We enter here on DELETE undo operations where we have to
                // substitue the second paragraph with the first if the removed
                // one is the first!
                if (!before && behind) {
-                       bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(),
-                                                behind);
+                       int id = firstUndoParagraph(bv, undo.number_of_inset_id)->id();
+                       Paragraph * op = bv->buffer()->getParFromID(id);
+                       if (op && op->inInset()) {
+                               static_cast<InsetText*>(op->inInset())->paragraph(behind);
+                       } else {
+                               bv->buffer()->paragraphs.set(behind);
+                       }
+
                        undopar = behind;
                }
        }