]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
He he he, something I've been dreaming of for a long time: label and reference navigator!
[lyx.git] / src / insets / InsetRef.cpp
index f9cdd8b32504a71f1e9024587fa3aee3276566e7..ddbff5ebb5a362e5b7aece417a6ca17f286321f2 100644 (file)
 #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")