]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / InsetIndex.cpp
index f4088a0518176fb23c83f784577df710b7acd2b4..1c9ceda8444009b517969e514877f668155dd356 100644 (file)
 
 #include "InsetIndex.h"
 
+#include "Buffer.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
-#include "gettext.h"
+#include "FuncStatus.h"
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 #include "sgml.h"
+#include "TocBackend.h"
 
-#include "support/std_ostream.h"
+#include "support/gettext.h"
 
+#include <ostream>
+
+using namespace std;
 
 namespace lyx {
 
-using std::string;
-using std::ostream;
+/////////////////////////////////////////////////////////////////////
+//
+// InsetIndex
+//
+///////////////////////////////////////////////////////////////////////
 
 
-InsetIndex::InsetIndex(InsetCommandParams const & p)
-       : InsetCommand(p, "index")
+InsetIndex::InsetIndex(Buffer const & buf)
+       : InsetCollapsable(buf)
 {}
 
 
-docstring const InsetIndex::getScreenLabel(Buffer const &) const
+int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 {
-       return _("Idx");
+       os << "<indexterm><primary>";
+       int const i = InsetText::docbook(os, runparams);
+       os << "</primary></indexterm>";
+       return i;
 }
 
 
-int InsetIndex::docbook(Buffer const &, odocstream & os,
-                       OutputParams const &) const
+void InsetIndex::write(ostream & os) const
 {
-       os << "<indexterm><primary>"
-          << sgml::escapeString(getParam("name"))
-          << "</primary></indexterm>";
-       return 0;
+       os << to_utf8(name()) << "\n";
+       InsetCollapsable::write(os);
 }
 
 
-Inset::Code InsetIndex::lyxCode() const
+void InsetIndex::addToToc(ParConstIterator const & cpit) const
 {
-       return Inset::INDEX_CODE;
+       ParConstIterator pit = cpit;
+       pit.push_back(*this);
+
+       Toc & toc = buffer().tocBackend().toc("index");
+       docstring str;
+       str = getNewLabel(str);
+       toc.push_back(TocItem(pit, 0, str));
 }
 
 
+/////////////////////////////////////////////////////////////////////
+//
+// InsetPrintIndex
+//
+///////////////////////////////////////////////////////////////////////
 
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
        : InsetCommand(p, string())
 {}
 
 
-docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
+ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
+{
+       static ParamInfo param_info_;
+       if (param_info_.empty())
+               param_info_.add("name", ParamInfo::LATEX_REQUIRED);
+       return param_info_;
+}
+
+
+docstring InsetPrintIndex::screenLabel() const
 {
        return _("Index");
 }
@@ -72,10 +100,9 @@ void InsetPrintIndex::validate(LaTeXFeatures & features) const
 }
 
 
-Inset::Code InsetPrintIndex::lyxCode() const
+InsetCode InsetPrintIndex::lyxCode() const
 {
-       return Inset::INDEX_PRINT_CODE;
+       return INDEX_PRINT_CODE;
 }
 
-
 } // namespace lyx