]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.cpp
Add list of Indexes.
[features.git] / src / insets / InsetIndex.cpp
1 /**
2  * \file InsetIndex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10 #include <config.h>
11
12 #include "InsetIndex.h"
13
14 #include "DispatchResult.h"
15 #include "FuncRequest.h"
16 #include "FuncStatus.h"
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19 #include "sgml.h"
20 #include "TocBackend.h"
21
22 #include "support/gettext.h"
23
24 #include <ostream>
25
26 using namespace std;
27
28 namespace lyx {
29
30
31 InsetIndex::InsetIndex(BufferParams const & bp)
32         : InsetCollapsable(bp)
33 {}
34
35
36 InsetIndex::InsetIndex(InsetIndex const & in)
37         : InsetCollapsable(in)
38 {}
39
40
41 int InsetIndex::docbook(Buffer const & buf, odocstream & os,
42                         OutputParams const & runparams) const
43 {
44         os << "<indexterm><primary>";
45         int const i = InsetText::docbook(buf, os, runparams);
46         os << "</primary></indexterm>";
47         return i;
48 }
49
50
51 Inset * InsetIndex::clone() const
52 {
53         return new InsetIndex(*this);
54 }
55
56
57 void InsetIndex::write(Buffer const & buf, ostream & os) const
58 {
59         os << to_utf8(name()) << "\n";
60         InsetCollapsable::write(buf, os);
61 }
62
63
64 void InsetIndex::addToToc(TocList & toclist, Buffer const & buf, ParConstIterator const &) const
65 {
66         ParConstIterator pit = par_const_iterator_begin(*this);
67
68         Toc & toc = toclist["index"];
69         docstring str;
70         str = getNewLabel(str);
71         toc.push_back(TocItem(pit, 0, str));
72 }
73
74
75 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
76         : InsetCommand(p, string())
77 {}
78
79
80 CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */)
81 {
82         static const char * const paramnames[] = {"name", ""};
83         static const bool isoptional[] = {false};
84         static const CommandInfo info = {1, paramnames, isoptional};
85         return &info;
86 }
87
88
89 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
90 {
91         return _("Index");
92 }
93
94
95 void InsetPrintIndex::validate(LaTeXFeatures & features) const
96 {
97         features.require("makeidx");
98 }
99
100
101 InsetCode InsetPrintIndex::lyxCode() const
102 {
103         return INDEX_PRINT_CODE;
104 }
105
106 } // namespace lyx