From aef2959b268144bd433a6577baf0cbff971e6c5f Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 3 Mar 2008 13:31:44 +0000 Subject: [PATCH] Add "DUPLICATE:" prefix to screen labels. 1.6 won't allow them now but importing a 1.5 documents can contain duplicate labels. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23412 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetLabel.cpp | 11 +++++++---- src/insets/InsetLabel.h | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 15843c18fd..80d46ab750 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -100,17 +100,20 @@ void InsetLabel::getLabelList(vector & list) const docstring InsetLabel::screenLabel() const { - return getParam("name"); + return screen_label_; } void InsetLabel::updateLabels(ParIterator const &) { docstring const & label = getParam("name"); - if (buffer().insetLabel(label)) + if (buffer().insetLabel(label)) { // Problem: We already have an InsetLabel with the same name! + screen_label_ = _("DUPLICATE: ") + label; return; + } buffer().setInsetLabel(label, this); + screen_label_ = label; } @@ -119,10 +122,10 @@ void InsetLabel::addToToc(ParConstIterator const & cpit) const docstring const & label = getParam("name"); Toc & toc = buffer().tocBackend().toc("label"); if (buffer().insetLabel(label) != this) { - toc.push_back(TocItem(cpit, 0, _("DUPLICATE: ") + label)); + toc.push_back(TocItem(cpit, 0, screen_label_)); return; } - toc.push_back(TocItem(cpit, 0, label)); + toc.push_back(TocItem(cpit, 0, screen_label_)); Buffer::References const & refs = buffer().references(label); Buffer::References::const_iterator it = refs.begin(); Buffer::References::const_iterator end = refs.end(); diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 7fe8a0c290..ca86840045 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -61,6 +61,8 @@ protected: private: /// Inset * clone() const { return new InsetLabel(*this); } + /// + docstring screen_label_; };