]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.cpp
This should be the last of the commits refactoring the InsetLayout code.
[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(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 CommandInfo const * InsetPrintIndex::findInfo(string const & /* cmdName */)
84 {
85         static const char * const paramnames[] = {"name", ""};
86         static const bool isoptional[] = {false};
87         static const CommandInfo info = {1, paramnames, isoptional};
88         return &info;
89 }
90
91
92 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
93 {
94         return _("Index");
95 }
96
97
98 void InsetPrintIndex::validate(LaTeXFeatures & features) const
99 {
100         features.require("makeidx");
101 }
102
103
104 InsetCode InsetPrintIndex::lyxCode() const
105 {
106         return INDEX_PRINT_CODE;
107 }
108
109 } // namespace lyx