]> 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 642d99a3a98c58c4592de0b6f1870ebfaf6748f8..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;
@@ -56,8 +58,8 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
 {
        static ParamInfo param_info_;
        if (param_info_.empty()) {
-               param_info_.add("name", true);
-               param_info_.add("reference", false);
+               param_info_.add("name", ParamInfo::LATEX_OPTIONAL);
+               param_info_.add("reference", ParamInfo::LATEX_REQUIRED);
        }
        return param_info_;
 }
@@ -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")