#include "BufferView.h"
#include "buffer.h"
#include "insets/updatableinset.h"
+#include "insets/insettext.h"
#include "debug.h"
#include "support/LAssert.h"
if (result)
return result;
}
- return bv->text->ownerParagraph();
+ return &*bv->text->ownerParagraphs().begin();
}
{
Buffer * b = bv->buffer();
- Paragraph * before =
- b->getParFromID(undo.number_of_before_par);
- Paragraph * behind =
- b->getParFromID(undo.number_of_behind_par);
+ Paragraph * before = &*b->getParFromID(undo.number_of_before_par);
+ Paragraph * behind = &*b->getParFromID(undo.number_of_behind_par);
Paragraph * tmppar;
Paragraph * tmppar2;
// is stored in the undo. So restore
// the text informations.
if (undo.kind == Undo::EDIT) {
- tmppar2->setContentsFromPar(tmppar);
+ tmppar2->setContentsFromPar(*tmppar);
tmppar2 = tmppar2->next();
}
}
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;
}
}
if (behind)
endpar = behind->next();
- tmppar = bv->buffer()->getParFromID(undo.number_of_cursor_par);
+ tmppar = &*bv->buffer()->getParFromID(undo.number_of_cursor_par);
UpdatableInset* it = 0;
if (undopar)
it = static_cast<UpdatableInset*>(undopar->inInset());
t->updateCounters();
bv->fitCursor();
}
- bv->updateInset(it, false);
+ bv->updateInset(it);
bv->text->setCursorIntern(bv->text->cursor.par(),
bv->text->cursor.pos());
} else {
bool createUndo(BufferView * bv, Undo::undo_kind kind,
- Paragraph const * first, Paragraph const * behind, shared_ptr<Undo> & u)
+ ParagraphList::iterator itfirst, ParagraphList::iterator itbehind,
+ shared_ptr<Undo> & u)
{
+ Paragraph * first = &*itfirst;
+ Paragraph * behind = &*itbehind;
lyx::Assert(first);
int before_number = -1;
}
// create a new Undo
- Paragraph * undopar;
+ Paragraph * undopar = 0; // nothing to replace yet (undo of delete maybe)
- Paragraph * start = const_cast<Paragraph *>(first);
- Paragraph * end = 0;
+ Paragraph * start = first;
+ Paragraph * end = &*boost::prior(itbehind);
- if (behind)
- end = const_cast<Paragraph*>(behind->previous());
- else {
- end = start;
- while (end->next())
- end = end->next();
- }
if (start && end && (start != end->next()) &&
((before_number != behind_number) ||
((before_number < 0) && (behind_number < 0))))
tmppar2 = tmppar2->next();
}
tmppar2->next(0);
- } else
- undopar = 0; // nothing to replace (undo of delete maybe)
+ }
int cursor_par = undoCursor(bv).par()->id();
- int cursor_pos = undoCursor(bv).pos();
+ int cursor_pos = undoCursor(bv).pos();
u.reset(new Undo(kind, inset_id,
before_number, behind_number,
finishUndo();
if (!undo_frozen) {
- Paragraph * first = b->getParFromID(undo->number_of_before_par);
+ Paragraph * first = &*b->getParFromID(undo->number_of_before_par);
if (first && first->next())
first = first->next();
else if (!first)
finishUndo();
if (!undo_frozen) {
- Paragraph * first = bv->buffer()->getParFromID(undo->number_of_before_par);
+ Paragraph * first = &*bv->buffer()->getParFromID(undo->number_of_before_par);
if (first && first->next())
first = first->next();
else if (!first)
if (first) {
shared_ptr<Undo> u;
if (createUndo(bv, undo->kind, first,
- bv->buffer()->getParFromID(undo->number_of_behind_par), u))
+ &*bv->buffer()->getParFromID(undo->number_of_behind_par), u))
bv->buffer()->undostack.push(u);
}
}
void setUndo(BufferView * bv, Undo::undo_kind kind,
- Paragraph const * first, Paragraph const * behind)
+ ParagraphList::iterator first, ParagraphList::iterator behind)
{
if (!undo_frozen) {
shared_ptr<Undo> u;
void setRedo(BufferView * bv, Undo::undo_kind kind,
- Paragraph const * first, Paragraph const * behind)
+ ParagraphList::iterator first, ParagraphList::iterator behind)
{
shared_ptr<Undo> u;
if (createUndo(bv, kind, first, behind, u))
void setCursorParUndo(BufferView * bv)
{
- setUndo(bv, Undo::FINISH, bv->text->cursor.par(),
+ setUndo(bv, Undo::FINISH, &*bv->text->cursor.par(),
bv->text->cursor.par()->next());
}