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 "InsetIterator.h"
20 #include "LaTeXFeatures.h"
21 #include "MetricsInfo.h"
24 #include "support/docstream.h"
25 #include "support/gettext.h"
32 /////////////////////////////////////////////////////////////////////
36 /////////////////////////////////////////////////////////////////////
38 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
39 : InsetCommand(p, "nomenclature"),
40 nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
44 ParamInfo const & InsetNomencl::findInfo(string const & /* cmdName */)
46 static ParamInfo param_info_;
47 if (param_info_.empty()) {
48 param_info_.add("prefix", ParamInfo::LATEX_OPTIONAL);
49 param_info_.add("symbol", ParamInfo::LATEX_REQUIRED);
50 param_info_.add("description", ParamInfo::LATEX_REQUIRED);
56 docstring InsetNomencl::screenLabel() const
62 int InsetNomencl::docbook(odocstream & os, OutputParams const &) const
64 os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
65 << sgml::escapeString(getParam("symbol"))
71 int InsetNomencl::docbookGlossary(odocstream & os) const
73 os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
75 << sgml::escapeString(getParam("symbol"))
78 << sgml::escapeString(getParam("description"))
79 << "</para></glossdef>\n"
85 void InsetNomencl::validate(LaTeXFeatures & features) const
87 features.require("nomencl");
91 /////////////////////////////////////////////////////////////////////
95 /////////////////////////////////////////////////////////////////////
97 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
98 : InsetCommand(p, string())
102 ParamInfo const & InsetPrintNomencl::findInfo(string const & /* cmdName */)
104 static ParamInfo param_info_;
105 if (param_info_.empty()) {
106 param_info_.add("labelwidth", ParamInfo::LATEX_REQUIRED);
112 docstring InsetPrintNomencl::screenLabel() const
114 return _("Nomenclature");
118 int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const
120 os << "<glossary>\n";
122 InsetIterator it = inset_iterator_begin(buffer().inset());
124 if (it->lyxCode() == NOMENCL_CODE) {
125 newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
127 } else if (!it->producesOutput()) {
128 // Ignore contents of insets that are not in output
129 size_t const depth = it.depth();
131 while (it.depth() > depth)
137 os << "</glossary>\n";
142 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
144 features.require("nomencl");
148 InsetCode InsetPrintNomencl::lyxCode() const
150 return NOMENCL_PRINT_CODE;