]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.cpp
Remove TextClassPtr without losing the type safety it provided.
[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 InsetIndex::InsetIndex(BufferParams const & bp)
33         : InsetCollapsable(bp)
34 {}
35
36
37 InsetIndex::InsetIndex(InsetIndex const & in)
38         : InsetCollapsable(in)
39 {}
40
41
42 int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
43 {
44         os << "<indexterm><primary>";
45         int const i = InsetText::docbook(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(ostream & os) const
58 {
59         os << to_utf8(name()) << "\n";
60         InsetCollapsable::write(os);
61 }
62
63
64 void InsetIndex::addToToc(ParConstIterator const & cpit) const
65 {
66         ParConstIterator pit = cpit;
67         pit.push_back(*this);
68
69         Toc & toc = buffer().tocBackend().toc("index");
70         docstring str;
71         str = getNewLabel(str);
72         toc.push_back(TocItem(pit, 0, str));
73 }
74
75
76 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
77         : InsetCommand(p, string())
78 {}
79
80
81 ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
82 {
83         static ParamInfo param_info_;
84         if (param_info_.empty()) {
85                 param_info_.add("name", ParamInfo::LATEX_REQUIRED);
86         }
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