2 * \file InsetNomencl.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
13 #include "InsetNomencl.h"
14 #include "InsetNote.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"
25 #include "support/docstream.h"
32 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
33 : InsetCommand(p, "nomenclature"),
34 nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
38 ParamInfo const & InsetNomencl::findInfo(string const & /* cmdName */)
40 static ParamInfo param_info_;
41 if (param_info_.empty()) {
42 param_info_.add("prefix", ParamInfo::LATEX_OPTIONAL);
43 param_info_.add("symbol", ParamInfo::LATEX_REQUIRED);
44 param_info_.add("description", ParamInfo::LATEX_REQUIRED);
50 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
56 int InsetNomencl::docbook(Buffer const &, odocstream & os,
57 OutputParams const &) const
59 os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
60 << sgml::escapeString(getParam("symbol"))
66 int InsetNomencl::docbookGlossary(odocstream & os) const
68 os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
70 << sgml::escapeString(getParam("symbol"))
73 << sgml::escapeString(getParam("description"))
74 << "</para></glossdef>\n"
80 void InsetNomencl::validate(LaTeXFeatures & features) const
82 features.require("nomencl");
86 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
87 : InsetCommand(p, string())
91 ParamInfo const & InsetPrintNomencl::findInfo(string const & /* cmdName */)
93 static ParamInfo param_info_;
94 if (param_info_.empty()) {
95 param_info_.add("labelwidth", ParamInfo::LATEX_REQUIRED);
101 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
103 return _("Nomenclature");
107 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
108 OutputParams const &) const
110 os << "<glossary>\n";
112 for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
113 if (it->lyxCode() == NOMENCL_CODE) {
114 newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
116 } else if(it->lyxCode() == NOTE_CODE &&
117 static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
118 // Don't output anything nested in note insets
119 size_t const depth = it.depth();
121 while (it.depth() > depth)
127 os << "</glossary>\n";
132 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
134 features.require("nomencl");
138 InsetCode InsetPrintNomencl::lyxCode() const
140 return NOMENCL_PRINT_CODE;