]> git.lyx.org Git - lyx.git/blob - src/insets/InsetNomencl.cpp
getting rid of superfluous std:: statements.
[lyx.git] / src / insets / InsetNomencl.cpp
1 /**
2  * \file InsetNomencl.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  * \author O. U. Baran
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 #include <config.h>
12
13 #include "InsetNomencl.h"
14 #include "InsetNote.h"
15
16 #include "Buffer.h"
17 #include "DispatchResult.h"
18 #include "FuncRequest.h"
19 #include "support/gettext.h"
20 #include "InsetIterator.h"
21 #include "LaTeXFeatures.h"
22 #include "MetricsInfo.h"
23 #include "sgml.h"
24
25 #include "support/docstream.h"
26
27 using namespace std;
28
29 namespace lyx {
30
31
32 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
33         : InsetCommand(p, "nomenclature"),
34           nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
35 {}
36
37
38 CommandInfo const * InsetNomencl::findInfo(string const & /* cmdName */)
39 {
40         static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
41         static const bool isoptional[] = {true, false, false};
42         static const CommandInfo info = {3, paramnames, isoptional};
43         return &info;
44 }
45
46
47 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
48 {
49         return _("Nom");
50 }
51
52
53 int InsetNomencl::docbook(Buffer const &, odocstream & os,
54                 OutputParams const &) const
55 {
56         os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
57            << sgml::escapeString(getParam("symbol"))
58            << "</glossterm>";
59         return 0;
60 }
61
62
63 int InsetNomencl::docbookGlossary(odocstream & os) const
64 {
65         os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
66            << "<glossterm>"
67            << sgml::escapeString(getParam("symbol"))
68            << "</glossterm>\n"
69            << "<glossdef><para>"
70            << sgml::escapeString(getParam("description"))
71            << "</para></glossdef>\n"
72            <<"</glossentry>\n";
73         return 4;
74 }
75
76
77 void InsetNomencl::validate(LaTeXFeatures & features) const
78 {
79         features.require("nomencl");
80 }
81
82
83 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
84         : InsetCommand(p, string())
85 {}
86
87
88 CommandInfo const * InsetPrintNomencl::findInfo(string const & /* cmdName */)
89 {
90                 static const char * const paramnames[] = {"labelwidth", ""};
91                 static const bool isoptional[] = {true};
92                 static const CommandInfo info = {1, paramnames, isoptional};
93                 return &info;
94 }
95
96
97 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
98 {
99         return _("Nomenclature");
100 }
101
102
103 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
104                 OutputParams const &) const
105 {
106         os << "<glossary>\n";
107         int newlines = 2;
108         for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
109                 if (it->lyxCode() == NOMENCL_CODE) {
110                         newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
111                         ++it;
112                 } else if(it->lyxCode() == NOTE_CODE &&
113                           static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
114                         // Don't output anything nested in note insets
115                         size_t const depth = it.depth();
116                         ++it;
117                         while (it.depth() > depth)
118                                 ++it;
119                 } else {
120                         ++it;
121                 }
122         }
123         os << "</glossary>\n";
124         return newlines;
125 }
126
127
128 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
129 {
130         features.require("nomencl");
131 }
132
133
134 InsetCode InsetPrintNomencl::lyxCode() const
135 {
136         return NOMENCL_PRINT_CODE;
137 }
138
139
140 } // namespace lyx