]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.cpp
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the...
[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 "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(Buffer const & buf, odocstream & os,
43                         OutputParams const & runparams) const
44 {
45         os << "<indexterm><primary>";
46         int const i = InsetText::docbook(buf, os, runparams);
47         os << "</primary></indexterm>";
48         return i;
49 }
50
51
52 Inset * InsetIndex::clone() const
53 {
54         return new InsetIndex(*this);
55 }
56
57
58 void InsetIndex::write(Buffer const & buf, ostream & os) const
59 {
60         os << to_utf8(name()) << "\n";
61         InsetCollapsable::write(buf, os);
62 }
63
64
65 void InsetIndex::addToToc(Buffer const & buf,
66         ParConstIterator const & cpit) const
67 {
68         ParConstIterator pit = cpit;
69         pit.push_back(*this);
70
71         Toc & toc = buf.tocBackend().toc("index");
72         docstring str;
73         str = getNewLabel(str);
74         toc.push_back(TocItem(pit, 0, str));
75 }
76
77
78 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
79         : InsetCommand(p, string())
80 {}
81
82
83 ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
84 {
85         static ParamInfo param_info_;
86         if (param_info_.empty()) {
87                 param_info_.add("name", ParamInfo::LATEX_REQUIRED);
88         }
89         return param_info_;
90 }
91
92
93 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
94 {
95         return _("Index");
96 }
97
98
99 void InsetPrintIndex::validate(LaTeXFeatures & features) const
100 {
101         features.require("makeidx");
102 }
103
104
105 InsetCode InsetPrintIndex::lyxCode() const
106 {
107         return INDEX_PRINT_CODE;
108 }
109
110 } // namespace lyx