+ setUndo(this, kind,
+ text->cursor.par(),
+ text->cursor.par()->next());
+}
+
+
+void BufferView::updateInset(Inset * inset, bool mark_dirty)
+{
+ pimpl_->updateInset(inset, mark_dirty);
+}
+
+
+bool BufferView::ChangeInsets(Inset::Code code,
+ string const & from, string const & to)
+{
+ bool flag = false;
+ LyXCursor cursor = text->cursor;
+ LyXCursor tmpcursor = cursor;
+ cursor.par(tmpcursor.par());
+ cursor.pos(tmpcursor.pos());
+
+ ParIterator end = buffer()->par_iterator_end();
+ for (ParIterator it = buffer()->par_iterator_begin();
+ it != end; ++it) {
+ Paragraph * par = *it;
+ bool flag2 = false;
+ for (Paragraph::inset_iterator it2 = par->inset_iterator_begin();
+ it2 != par->inset_iterator_end(); ++it2) {
+ if ((*it2)->lyxCode() == code) {
+ InsetCommand * inset = static_cast<InsetCommand *>(*it2);
+ if (inset->getContents() == from) {
+ inset->setContents(to);
+ flag2 = true;
+ }
+ }
+ }
+ if (flag2) {
+ flag = true;
+#warning Fix me
+ // The test it.size()==1 was needed to prevent crashes.
+ // How to set the cursor corretly when it.size()>1 ??
+ if (it.size() == 1) {
+ text->setCursorIntern(this, par, 0);
+ text->redoParagraphs(this, text->cursor,
+ text->cursor.par()->next());
+ text->fullRebreak(this);
+ }
+ }
+ }
+ text->setCursorIntern(this, cursor.par(), cursor.pos());
+ return flag;
+}
+
+
+bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
+{
+ // Check if the label 'from' appears more than once
+ vector<string> labels = buffer()->getLabelList();
+ if (count(labels.begin(), labels.end(), from) > 1)
+ return false;
+
+ return ChangeInsets(Inset::REF_CODE, from, to);
+}
+
+
+bool BufferView::ChangeCitationsIfUnique(string const & from, string const & to)
+{
+
+ vector<pair<string,string> > keys = buffer()->getBibkeyList();
+ if (count_if(keys.begin(), keys.end(),
+ lyx::equal_1st_in_pair<string,string>(from))
+ > 1)
+ return false;
+
+ return ChangeInsets(Inset::CITE_CODE, from, to);
+}
+
+
+UpdatableInset * BufferView::theLockingInset() const
+{
+ // If NULL is not allowed we should put an Assert here. (Lgb)
+ if (text)
+ return text->the_locking_inset;
+ return 0;
+}
+
+
+void BufferView::theLockingInset(UpdatableInset * inset)
+{
+ text->the_locking_inset = inset;
+}
+
+
+LyXText * BufferView::getLyXText() const
+{
+ if (theLockingInset()) {
+ LyXText * txt = theLockingInset()->getLyXText(this, true);
+ if (txt)
+ return txt;
+ }
+ return text;
+}
+
+
+LyXText * BufferView::getParentText(Inset * inset) const
+{
+ if (inset->owner()) {
+ LyXText * txt = inset->getLyXText(this);
+ inset = inset->owner();
+ while (inset && inset->getLyXText(this) == txt)
+ inset = inset->owner();
+ if (inset)
+ return inset->getLyXText(this);
+ }
+ return text;
+}
+
+
+Language const * BufferView::getParentLanguage(Inset * inset) const
+{
+ LyXText * text = getParentText(inset);
+ return text->cursor.par()->getFontSettings(buffer()->params,
+ text->cursor.pos()).language();