]> git.lyx.org Git - lyx.git/blob - src/insets/insetnomencl.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetnomencl.C
1 /**
2  * \file insetnomencl.C
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 "gettext.h"
20 #include "insetiterator.h"
21 #include "LaTeXFeatures.h"
22 #include "metricsinfo.h"
23 #include "sgml.h"
24
25
26 namespace lyx {
27
28 using std::string;
29
30
31 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
32         : InsetCommand(p, "nomenclature"),
33           glossary_entry_id(sgml::uniqueID(from_ascii("gloss")))
34 {}
35
36
37 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
38 {
39         return _("Glo");
40 }
41
42
43 int InsetNomencl::docbook(Buffer const &, odocstream & os,
44                 OutputParams const &) const
45 {
46         os << "<glossterm linkend=\"" << glossary_entry_id << "\">"
47            << sgml::escapeString(getParam("symbol"))
48            << "</glossterm>";
49         return 0;
50 }
51
52
53 int InsetNomencl::docbookGlossary(odocstream & os) const
54 {
55         os << "<glossentry id=\"" << glossary_entry_id << "\">\n"
56            << "<glossterm>"
57            << sgml::escapeString(getParam("symbol"))
58            << "</glossterm>\n"
59            << "<glossdef><para>"
60            << sgml::escapeString(getParam("description"))
61            << "</para></glossdef>\n"
62            <<"</glossentry>\n";
63         return 4;
64 }
65
66
67 void InsetNomencl::validate(LaTeXFeatures & features) const
68 {
69         features.require("nomencl");
70 }
71
72
73 InsetBase::Code InsetNomencl::lyxCode() const
74 {
75         return InsetBase::NOMENCL_CODE;
76 }
77
78
79 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
80         : InsetCommand(p, string())
81 {}
82
83
84 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
85 {
86         return _("Glossary");
87 }
88
89
90 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
91                 OutputParams const &) const
92 {
93         os << "<glossary>\n";
94         int newlines = 2;
95         for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
96                 if (it->lyxCode() == InsetBase::NOMENCL_CODE) {
97                         newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
98                         ++it;
99                 } else if(it->lyxCode() == InsetBase::NOTE_CODE &&
100                           static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
101                         // Don't output anything nested in note insets
102                         size_t const depth = it.depth();
103                         ++it;
104                         while (it.depth() > depth)
105                                 ++it;
106                 } else {
107                         ++it;
108                 }
109         }
110         os << "</glossary>\n";
111         return newlines;
112 }
113
114
115 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
116 {
117         features.require("nomencl");
118 }
119
120
121 InsetBase::Code InsetPrintNomencl::lyxCode() const
122 {
123         return InsetBase::NOMENCL_PRINT_CODE;
124 }
125
126
127 } // namespace lyx