]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.cpp
make code look a bit more uniform
[lyx.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 "Buffer.h"
15 #include "DispatchResult.h"
16 #include "FuncRequest.h"
17 #include "FuncStatus.h"
18 #include "LaTeXFeatures.h"
19 #include "MetricsInfo.h"
20 #include "sgml.h"
21 #include "TocBackend.h"
22
23 #include "support/gettext.h"
24
25 #include <ostream>
26
27 using namespace std;
28
29 namespace lyx {
30
31 /////////////////////////////////////////////////////////////////////
32 //
33 // InsetIndex
34 //
35 ///////////////////////////////////////////////////////////////////////
36
37
38 InsetIndex::InsetIndex(Buffer const & buf)
39         : InsetCollapsable(buf)
40 {}
41
42
43 int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
44 {
45         os << "<indexterm><primary>";
46         int const i = InsetText::docbook(os, runparams);
47         os << "</primary></indexterm>";
48         return i;
49 }
50
51
52 void InsetIndex::write(ostream & os) const
53 {
54         os << to_utf8(name()) << "\n";
55         InsetCollapsable::write(os);
56 }
57
58
59 void InsetIndex::addToToc(ParConstIterator const & cpit) const
60 {
61         ParConstIterator pit = cpit;
62         pit.push_back(*this);
63
64         Toc & toc = buffer().tocBackend().toc("index");
65         docstring str;
66         str = getNewLabel(str);
67         toc.push_back(TocItem(pit, 0, str));
68 }
69
70
71 /////////////////////////////////////////////////////////////////////
72 //
73 // InsetPrintIndex
74 //
75 ///////////////////////////////////////////////////////////////////////
76
77 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
78         : InsetCommand(p, string())
79 {}
80
81
82 ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
83 {
84         static ParamInfo param_info_;
85         if (param_info_.empty())
86                 param_info_.add("name", ParamInfo::LATEX_REQUIRED);
87         return param_info_;
88 }
89
90
91 docstring InsetPrintIndex::screenLabel() const
92 {
93         return _("Index");
94 }
95
96
97 void InsetPrintIndex::validate(LaTeXFeatures & features) const
98 {
99         features.require("makeidx");
100 }
101
102
103 InsetCode InsetPrintIndex::lyxCode() const
104 {
105         return INDEX_PRINT_CODE;
106 }
107
108 } // namespace lyx