From: Lars Gullik Bjønnes Date: Wed, 16 Apr 2003 00:02:38 +0000 (+0000) Subject: op-1-a.diff X-Git-Tag: 1.6.10~16956 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1c1473e7ec4a5de90d0e1b6f93ebf5770d18cd75;p=lyx.git op-1-a.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6821 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index ffd15422d4..d1b0ef8025 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-04-16 Lars Gullik Bjønnes + + * 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 * text_funcs.C (transposeChars): use ParagraphList::iterator here. diff --git a/src/ParagraphList.C b/src/ParagraphList.C index 65f1e0ebce..40b5dc20db 100644 --- a/src/ParagraphList.C +++ b/src/ParagraphList.C @@ -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_; diff --git a/src/lyxtext.h b/src/lyxtext.h index adf0ce3db2..3a8a05644b 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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; diff --git a/src/text2.C b/src/text2.C index b3c34c0908..3f4bfb3109 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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(op->inInset())->paragraph(p); - } else { - ownerParagraph(p); - } -} - - LyXText::refresh_status LyXText::refreshStatus() const { return refresh_status_; diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 2165f5405c..6235df6fa9 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -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(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(op->inInset())->paragraph(behind); + } else { + bv->buffer()->paragraphs.set(behind); + } + undopar = behind; } }