- // replace the paragraphs with the undo informations
-
- Paragraph * tmppar3 = undo->par;
- undo->par = 0; /* otherwise the undo destructor would
- delete the paragraph */
-
- // get last undo par and set the right(new) inset-owner of the
- // paragraph if there is any. This is not needed if we don't have
- // a paragraph before because then in is automatically done in the
- // function which assigns the first paragraph to an InsetText. (Jug)
- Paragraph * tmppar4 = tmppar3;
- if (tmppar4) {
- Inset * in = 0;
- if (before)
- in = before->inInset();
- tmppar4->setInsetOwner(in);
- while (tmppar4->next()) {
- tmppar4 = tmppar4->next();
- tmppar4->setInsetOwner(in);
- }
- }
-
- // now remove the old text if there is any
-#ifdef DELETE_UNUSED_PARAGRAPHS
- std::vector<Paragraph *> vvpar;
-#endif
- if (before != behind || (!behind && !before)) {
- if (before)
- tmppar5 = before->next();
- else
- tmppar5 = firstUndoParagraph(bv, undo->number_of_inset_id);
- tmppar2 = tmppar3;
- while (tmppar5 && tmppar5 != behind) {
-#ifdef DELETE_UNUSED_PARAGRAPHS
- vvpar.push_back(tmppar5);
-#endif
- tmppar = tmppar5;
- tmppar5 = tmppar5->next();
- // a memory optimization for edit:
- // Only layout information
- // is stored in the undo. So restore
- // the text informations.
- if (undo->kind == Undo::EDIT) {
- tmppar2->setContentsFromPar(tmppar);
-#ifndef DELETE_UNUSED_PARAGRAPHS
- tmppar->clearContents();
-#endif
- tmppar2 = tmppar2->next();
- }
- }
- }
-
- // put the new stuff in the list if there is one
- if (tmppar3){
- if (before)
- before->next(tmppar3);
- else
- bv->text->ownerParagraph(tmppar3->id(),
- tmppar3);
-
- tmppar3->previous(before);
- } else {
- // Do we really enter here ??? (Jug)
- if (!before && behind) {
- bv->text->ownerParagraph(behind);
- tmppar3 = behind;
- }
- }
- if (tmppar4) {
- tmppar4->next(behind);
- if (behind)
- behind->previous(tmppar4);
- }
-
-
- // Set the cursor for redoing
- if (before) {
- Inset * it = before->inInset();
- if (it)
- it->getLyXText(bv)->setCursorIntern(bv, before, 0);
- else
- bv->text->setCursorIntern(bv, before, 0);
+ // replace the paragraphs with the undo informations
+
+ Paragraph * undopar = undo.par;
+ undo.par = 0; /* otherwise the undo destructor would
+ delete the paragraph */
+
+ // get last undo par and set the right(new) inset-owner of the
+ // paragraph if there is any. This is not needed if we don't have
+ // a paragraph before because then in is automatically done in the
+ // function which assigns the first paragraph to an InsetText. (Jug)
+ Paragraph * lastundopar = undopar;
+ if (lastundopar) {
+ Inset * in = 0;
+ if (before)
+ in = before->inInset();
+ else if (undo.number_of_inset_id >= 0)
+ in = bv->buffer()->getInsetFromID(undo.number_of_inset_id);
+ lastundopar->setInsetOwner(in);
+ while (lastundopar->next()) {
+ lastundopar = lastundopar->next();
+ lastundopar->setInsetOwner(in);