+ text->SetUndo(buffer(), kind,
+#ifndef NEW_INSETS
+ text->cursor.par()->
+ ParFromPos(text->cursor.pos())->previous,
+ text->cursor.par()->
+ ParFromPos(text->cursor.pos())->next
+#else
+ text->cursor.par()->previous,
+ text->cursor.par()->next
+#endif
+ );
+}
+
+
+void BufferView::updateInset(Inset * inset, bool mark_dirty)
+{
+ if (!inset)
+ return;
+
+ // first check for locking insets
+ if (the_locking_inset) {
+ if (the_locking_inset == inset) {
+ if (text->UpdateInset(this, inset)){
+ update();
+ if (mark_dirty){
+ if (buffer()->isLyxClean())
+ owner()->getMiniBuffer()->
+ setTimer(4);
+ buffer()->markDirty();
+ }
+ updateScrollbar();
+ return;
+ }
+ } else if (the_locking_inset->UpdateInsetInInset(this,inset)) {
+ if (text->UpdateInset(this, the_locking_inset)) {
+ update();
+ if (mark_dirty){
+ if (buffer()->isLyxClean())
+ owner()->getMiniBuffer()->
+ setTimer(4);
+ buffer()->markDirty();
+ }
+ updateScrollbar();
+ return;
+ }
+ }
+ }
+
+ // then check the current buffer
+ if (available()) {
+ hideCursor();
+ update(BufferView::UPDATE);
+ if (text->UpdateInset(this, inset)){
+ if (mark_dirty)
+ update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ else
+ update(SELECT);
+ return;
+ }
+ }
+}
+
+bool BufferView::ChangeRefs(string const & from, string const & to)
+{
+ bool flag = false;
+ LyXParagraph * par = buffer()->paragraph;
+ LyXCursor cursor = text->cursor;
+ LyXCursor tmpcursor = cursor;
+#ifndef NEW_INSETS
+ cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos()));
+ cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos()));
+#else
+ cursor.par(tmpcursor.par());
+ cursor.pos(tmpcursor.pos());
+#endif
+
+ while (par) {
+ bool flag2 = false;
+ for (LyXParagraph::inset_iterator it = par->inset_iterator_begin();
+ it != par->inset_iterator_end(); ++it) {
+ if ((*it)->LyxCode() == Inset::REF_CODE) {
+ InsetCommand * inset = static_cast<InsetCommand *>(*it);
+ if (inset->getContents() == from) {
+ inset->setContents(to);
+ flag2 = true;
+ }
+ }
+ }
+ if (flag2) {
+ flag = true;
+#ifndef NEW_INSETS
+ if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
+#endif
+ // this is possible now, since SetCursor takes
+ // care about footnotes
+ text->SetCursorIntern(this, par, 0);
+ text->RedoParagraphs(this, text->cursor,
+ text->cursor.par()->Next());
+ text->FullRebreak(this);
+#ifndef NEW_INSETS
+ }
+#endif
+ }
+ par = par->next;
+ }
+ text->SetCursorIntern(this, cursor.par(), cursor.pos());
+ return flag;