]> git.lyx.org Git - features.git/blob - src/insets/InsetIndex.cpp
* InsetXXX::addToToc(): properly use passed ParConstIterator.
[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,
65         ParConstIterator const & cpit) const
66 {
67         ParConstIterator pit = cpit;
68         pit.push_back(*this);
69
70         Toc & toc = toclist["index"];
71         docstring str;
72         str = getNewLabel(str);
73         toc.push_back(TocItem(pit, 0, str));
74 }
75
76
77 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
78         : InsetCommand(p, string())
79 {}
80
81
82 CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */)
83 {
84         static const char * const paramnames[] = {"name", ""};
85         static const bool isoptional[] = {false};
86         static const CommandInfo info = {1, paramnames, isoptional};
87         return &info;
88 }
89
90
91 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) 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