]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Regularly check if preview is modified when visible on screen
[lyx.git] / src / insets / InsetIndex.cpp
index aff40805d4c360002b2093bb1797d6bdece57e77..38472f0bdcc0911f3e1eaff40c0747c2bd9f6036 100644 (file)
@@ -28,6 +28,7 @@
 #include "output_latex.h"
 #include "output_xhtml.h"
 #include "sgml.h"
+#include "texstream.h"
 #include "TextClass.h"
 #include "TocBackend.h"
 
@@ -74,9 +75,10 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
        }
 
        // get contents of InsetText as LaTeX and plaintext
-       TexRow texrow;
        odocstringstream ourlatex;
-       otexstream ots(ourlatex, texrow);
+       // FIXME: do Tex/Row correspondence (I don't currently understand what is
+       // being generated from latexstr below)
+       otexstream ots(ourlatex);
        InsetText::latex(ots, runparams);
        odocstringstream ourplain;
        InsetText::plaintext(ourplain, runparams);
@@ -349,7 +351,7 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params)
 
 
 void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
-                                                 UpdateType utype) const
+                                                 UpdateType utype, TocBackend & backend) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
@@ -359,9 +361,11 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
                type += ":" + to_utf8(params_.index);
        // this is unlikely to be terribly long
        text().forOutliner(str, INT_MAX);
-       buffer().tocBackend().toc(type)->push_back(TocItem(pit, 0, str, output_active));
+       TocBuilder & b = backend.builder(type);
+       b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active, utype);
+       InsetCollapsable::addToToc(cpit, output_active, utype, backend);
+       b.pop();
 }
 
 
@@ -432,8 +436,10 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
        static ParamInfo param_info_;
        if (param_info_.empty()) {
                param_info_.add("type", ParamInfo::LATEX_OPTIONAL,
-                               ParamInfo::HANDLING_ESCAPE);
-               param_info_.add("name", ParamInfo::LATEX_REQUIRED);
+                               ParamInfo::HANDLING_ESCAPE);
+               param_info_.add("name", ParamInfo::LATEX_OPTIONAL,
+                               ParamInfo::HANDLING_LATEXIFY);
+               param_info_.add("literal", ParamInfo::LYX_INTERNAL);
        }
        return param_info_;
 }
@@ -556,11 +562,20 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
+void InsetPrintIndex::updateBuffer(ParIterator const &, UpdateType)
+{
+       Index const * index =
+               buffer().masterParams().indiceslist().findShortcut(getParam("type"));
+       if (index)
+               setParam("name", index->index());
+}
+
+
 void InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (!buffer().masterBuffer()->params().use_indices) {
                if (getParam("type") == from_ascii("idx"))
-                       os << "\\printindex{}";
+                       os << "\\printindex" << termcmd;
                return;
        }
        OutputParams runparams = runparams_in;
@@ -573,6 +588,7 @@ void InsetPrintIndex::validate(LaTeXFeatures & features) const
        features.require("makeidx");
        if (buffer().masterBuffer()->params().use_indices)
                features.require("splitidx");
+       InsetCommand::validate(features);
 }