]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetIndex.cpp
index aaef4d43c5479aeec2046a272e89c78500ed3d7f..e46e6cea8016168a921ddad2c26523f53ba7f0a1 100644 (file)
 
 #include "InsetIndex.h"
 
+#include "Buffer.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 #include "sgml.h"
+#include "TocBackend.h"
 
-#include "support/std_ostream.h"
+#include "support/gettext.h"
 
+#include <ostream>
 
-namespace lyx {
+using namespace std;
 
-using std::string;
-using std::ostream;
+namespace lyx {
 
 
 InsetIndex::InsetIndex(BufferParams const & bp)
@@ -54,19 +55,32 @@ Inset * InsetIndex::clone() const
 }
 
 
-void InsetIndex::write(Buffer const & buf, std::ostream & os) const
+void InsetIndex::write(Buffer const & buf, ostream & os) const
 {
        os << to_utf8(name()) << "\n";
        InsetCollapsable::write(buf, os);
 }
 
 
+void InsetIndex::addToToc(Buffer const & buf,
+       ParConstIterator const & cpit) const
+{
+       ParConstIterator pit = cpit;
+       pit.push_back(*this);
+
+       Toc & toc = buf.tocBackend().toc("index");
+       docstring str;
+       str = getNewLabel(str);
+       toc.push_back(TocItem(pit, 0, str));
+}
+
+
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
        : InsetCommand(p, string())
 {}
 
 
-CommandInfo const * InsetPrintIndex::findInfo(std::string const & /* cmdName */)
+CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */)
 {
        static const char * const paramnames[] = {"name", ""};
        static const bool isoptional[] = {false};
@@ -92,5 +106,4 @@ InsetCode InsetPrintIndex::lyxCode() const
        return INDEX_PRINT_CODE;
 }
 
-
 } // namespace lyx