When pasting a math inset with a label, check for duplicates (as we do outside math)

(bug 6218)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33230 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-01-27 08:41:19 +00:00
parent f68fcc98a9
commit a484f95910
2 changed files with 31 additions and 0 deletions

View File

@ -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 &>(buffer));
switch (it->lyxCode()) {
case MATH_HULL_CODE: {
// check for equation labels and resolve duplicates
InsetMathHull & ins = static_cast<InsetMathHull &>(*it);
std::vector<InsetLabel *> 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<InsetCommand &>(*itt);
if (ref.getParam("reference") == oldname)
ref.setParam("reference", newname);
}
}
}
}
break;
}
case LABEL_CODE: {
// check for duplicates
InsetCommand & lab = static_cast<InsetCommand &>(*it);

View File

@ -60,6 +60,8 @@ public:
///
void label(row_type row, docstring const & label);
///
std::vector<InsetLabel *> getLabels() { return label_; }
///
ColorCode backgroundColor(PainterInfo const &) const;
///
void numbered(row_type row, bool num);