]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
do what the FIXME suggested
[lyx.git] / src / CutAndPaste.cpp
index 7e980ddd6ab62aeb4f824e332263807e9b09b699..f661b3462bf43a92d086c31ad2fbe8da91a56d41 100644 (file)
@@ -225,7 +225,7 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                        // check for duplicates
                        InsetCommand & lab = static_cast<InsetCommand &>(*it);
                        docstring const oldname = lab.getParam("name");
-                       lab.update(oldname, false);
+                       lab.updateCommand(oldname, false);
                        docstring const newname = lab.getParam("name");
                        if (oldname != newname) {
                                // adapt the references
@@ -240,6 +240,25 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                        break;
                }
 
+               case BIBITEM_CODE: {
+                       // check for duplicates
+                       InsetCommand & bib = static_cast<InsetCommand &>(*it);
+                       docstring const oldkey = bib.getParam("key");
+                       bib.updateCommand(oldkey, false);
+                       docstring const newkey = bib.getParam("key");
+                       if (oldkey != newkey) {
+                               // adapt the references
+                               for (InsetIterator itt = inset_iterator_begin(in); itt != i_end; ++itt) {
+                                       if (itt->lyxCode() == CITE_CODE) {
+                                               InsetCommand & ref = dynamic_cast<InsetCommand &>(*itt);
+                                               if (ref.getParam("key") == oldkey)
+                                                       ref.setParam("key", newkey);
+                                       }
+                               }
+                       }
+                       break;
+               }
+
                default:
                        break; // nothing
                }