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
This commit is contained in:
Abdelrazak Younes 2008-02-27 16:23:27 +00:00
parent 7307e07108
commit c05db366bb
3 changed files with 22 additions and 5 deletions

View File

@ -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)));
}

View File

@ -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")

View File

@ -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 &);