diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index a30f400407..668d2b51ae 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -43,10 +43,12 @@ #include "insets/InsetGraphics.h" #include "insets/InsetGraphicsParams.h" #include "insets/InsetInclude.h" +#include "insets/InsetLabel.h" #include "insets/InsetTabular.h" #include "mathed/MathData.h" #include "mathed/InsetMath.h" +#include "mathed/InsetMathHull.h" #include "mathed/MathSupport.h" #include "support/debug.h" @@ -229,6 +231,33 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist, it->setBuffer(const_cast(buffer)); switch (it->lyxCode()) { + case MATH_HULL_CODE: { + // check for equation labels and resolve duplicates + InsetMathHull & ins = static_cast(*it); + std::vector labels = ins.getLabels(); + for (size_t i = 0; i != labels.size(); ++i) { + if (!labels[i]) + continue; + InsetLabel * lab = labels[i]; + docstring const oldname = lab->getParam("name"); + lab->updateCommand(oldname, false); + docstring const newname = lab->getParam("name"); + if (oldname != newname) { + // adapt the references + for (InsetIterator itt = inset_iterator_begin(in); + itt != i_end; ++itt) { + if (itt->lyxCode() == REF_CODE) { + InsetCommand & ref = + dynamic_cast(*itt); + if (ref.getParam("reference") == oldname) + ref.setParam("reference", newname); + } + } + } + } + break; + } + case LABEL_CODE: { // check for duplicates InsetCommand & lab = static_cast(*it); diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 1e94d6badc..e4be68d01c 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -60,6 +60,8 @@ public: /// void label(row_type row, docstring const & label); /// + std::vector getLabels() { return label_; } + /// ColorCode backgroundColor(PainterInfo const &) const; /// void numbered(row_type row, bool num);