From c05db366bb4e6d7ade07fea849062af5721c20f7 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 27 Feb 2008 16:23:27 +0000 Subject: [PATCH] He he he, something I've been dreaming of for a long time: label and reference navigator! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23284 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetLabel.cpp | 4 ---- src/insets/InsetRef.cpp | 21 ++++++++++++++++++++- src/insets/InsetRef.h | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index eb471f5d04..e7f321fad5 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -66,10 +66,6 @@ docstring const InsetLabel::getScreenLabel(Buffer const &) const void InsetLabel::addToToc(Buffer const & buf, ParConstIterator const & cpit) const { - //FIXME: It would be really, really, really nice if we could - // construct a tree here with all the cross-reference to this - // label. - Toc & toc = buf.tocBackend().toc("label"); toc.push_back(TocItem(cpit, 0, getScreenLabel(buf))); } diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index f9cdd8b325..ddbff5ebb5 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -15,13 +15,15 @@ #include "Cursor.h" #include "DispatchResult.h" #include "FuncRequest.h" -#include "support/gettext.h" #include "LaTeXFeatures.h" #include "LyXFunc.h" #include "OutputParams.h" +#include "ParIterator.h" #include "sgml.h" +#include "TocBackend.h" #include "support/docstream.h" +#include "support/gettext.h" #include "support/lstrings.h" using namespace std; @@ -153,6 +155,23 @@ void InsetRef::textString(Buffer const & buf, odocstream & os) const } +void InsetRef::addToToc(Buffer const & buf, + ParConstIterator const & cpit) const +{ + docstring const & label = getParam("reference"); + Toc & toc = buf.tocBackend().toc("label"); + Toc::const_iterator it = toc.begin(); + Toc::const_iterator end = toc.end(); + for (; it != end; ++it) { + if (it->str() == label) { + ++it; + toc.insert(it, TocItem(cpit, 1, getScreenLabel(buf))); + break; + } + } +} + + void InsetRef::validate(LaTeXFeatures & features) const { if (getCmdName() == "vref" || getCmdName() == "vpageref") diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index f9a45fbb3d..7d8b37d3ca 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -62,6 +62,8 @@ public: static std::string defaultCommand() { return "ref"; }; /// static bool isCompatibleCommand(std::string const & s); + /// + void addToToc(Buffer const &, ParConstIterator const &) const; protected: /// InsetRef(InsetRef const &); -- 2.39.2