+
+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;
+}