]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / InsetIndex.cpp
index 9a41978d9b31f476794af4f91a83d99d221306f4..1c9ceda8444009b517969e514877f668155dd356 100644 (file)
 
 #include "InsetIndex.h"
 
+#include "Buffer.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "support/gettext.h"
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 #include "sgml.h"
+#include "TocBackend.h"
+
+#include "support/gettext.h"
 
 #include <ostream>
 
@@ -25,55 +28,67 @@ using namespace std;
 
 namespace lyx {
 
-
-InsetIndex::InsetIndex(BufferParams const & bp)
-       : InsetCollapsable(bp)
-{}
+/////////////////////////////////////////////////////////////////////
+//
+// InsetIndex
+//
+///////////////////////////////////////////////////////////////////////
 
 
-InsetIndex::InsetIndex(InsetIndex const & in)
-       : InsetCollapsable(in)
+InsetIndex::InsetIndex(Buffer const & buf)
+       : InsetCollapsable(buf)
 {}
 
 
-int InsetIndex::docbook(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 {
        os << "<indexterm><primary>";
-       int const i = InsetText::docbook(buf, os, runparams);
+       int const i = InsetText::docbook(os, runparams);
        os << "</primary></indexterm>";
        return i;
 }
 
 
-Inset * InsetIndex::clone() const
+void InsetIndex::write(ostream & os) const
 {
-       return new InsetIndex(*this);
+       os << to_utf8(name()) << "\n";
+       InsetCollapsable::write(os);
 }
 
 
-void InsetIndex::write(Buffer const & buf, ostream & os) const
+void InsetIndex::addToToc(ParConstIterator const & cpit) const
 {
-       os << to_utf8(name()) << "\n";
-       InsetCollapsable::write(buf, os);
+       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())
 {}
 
 
-CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */)
+ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
 {
-       static const char * const paramnames[] = {"name", ""};
-       static const bool isoptional[] = {false};
-       static const CommandInfo info = {1, paramnames, isoptional};
-       return &info;
+       static ParamInfo param_info_;
+       if (param_info_.empty())
+               param_info_.add("name", ParamInfo::LATEX_REQUIRED);
+       return param_info_;
 }
 
 
-docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
+docstring InsetPrintIndex::screenLabel() const
 {
        return _("Index");
 }
@@ -90,5 +105,4 @@ InsetCode InsetPrintIndex::lyxCode() const
        return INDEX_PRINT_CODE;
 }
 
-
 } // namespace lyx