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