]> git.lyx.org Git - lyx.git/blob - src/insets/InsetIndex.cpp
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[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 "DispatchResult.h"
15 #include "FuncRequest.h"
16 #include "gettext.h"
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19 #include "sgml.h"
20
21 #include "support/std_ostream.h"
22
23
24 namespace lyx {
25
26 using std::string;
27 using std::ostream;
28
29
30 InsetIndex::InsetIndex(InsetCommandParams const & p)
31         : InsetCommand(p, "index")
32 {}
33
34
35 docstring const InsetIndex::getScreenLabel(Buffer const &) const
36 {
37         size_t const maxLabelChars = 25;
38
39         docstring label = _("Idx: ") + getParam("name");
40         if (label.size() > maxLabelChars) {
41                 label.erase(maxLabelChars - 3);
42                 label += "...";
43         }
44         return label;
45 }
46
47
48 int InsetIndex::docbook(Buffer const &, odocstream & os,
49                         OutputParams const &) const
50 {
51         os << "<indexterm><primary>"
52            << sgml::escapeString(getParam("name"))
53            << "</primary></indexterm>";
54         return 0;
55 }
56
57
58 Inset::Code InsetIndex::lyxCode() const
59 {
60         return Inset::INDEX_CODE;
61 }
62
63
64
65 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
66         : InsetCommand(p, string())
67 {}
68
69
70 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
71 {
72         return _("Index");
73 }
74
75
76 void InsetPrintIndex::validate(LaTeXFeatures & features) const
77 {
78         features.require("makeidx");
79 }
80
81
82 Inset::Code InsetPrintIndex::lyxCode() const
83 {
84         return Inset::INDEX_PRINT_CODE;
85 }
86
87
88 } // namespace lyx