From e14a0ad50f3f111519112ae604eabe3b15b1861c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 27 Feb 2008 17:02:17 +0000 Subject: [PATCH] InsetRef::addTocToc(): add an entry for the referenced label if not already present. Next step is to rebuild the Toc in InsetLabel::addTocToc() for this case. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23286 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetRef.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index b9e7909b22..7da23941b6 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -160,18 +160,24 @@ void InsetRef::addToToc(Buffer const & buf, { docstring const & label = getParam("reference"); Toc & toc = buf.tocBackend().toc("label"); - Toc::const_iterator it = toc.begin(); - Toc::const_iterator end = toc.end(); + Toc::iterator it = toc.begin(); + Toc::iterator end = toc.end(); for (; it != end; ++it) { if (it->str() == label) break; } - if (it == end) - //FIXME: this is an orphan, is this really possible? - return; - docstring const reflabel = getScreenLabel(buf); + if (it == end) { + // This label has not been parsed yet so we just add it temporarily. + // InsetLabel::addTocToc() will fix that later. + toc.push_back(TocItem(cpit, 0, label)); + toc.push_back(TocItem(cpit, 1, reflabel)); + return; + } + + // The Toc item for this label already exists so let's add + // this inset to this node. ++it; while (it->str() == reflabel && it != end) ++it;