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"
20 #include "InsetIterator.h"
21 #include "LaTeXFeatures.h"
22 #include "MetricsInfo.h"
25 #include "support/docstream.h"
33 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
34 : InsetCommand(p, "nomenclature"),
35 nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
39 CommandInfo const * InsetNomencl::findInfo(std::string const & /* cmdName */)
41 static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
42 static const bool isoptional[] = {true, false, false};
43 static const CommandInfo info = {3, paramnames, isoptional};
48 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
54 int InsetNomencl::docbook(Buffer const &, odocstream & os,
55 OutputParams const &) const
57 os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
58 << sgml::escapeString(getParam("symbol"))
64 int InsetNomencl::docbookGlossary(odocstream & os) const
66 os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
68 << sgml::escapeString(getParam("symbol"))
71 << sgml::escapeString(getParam("description"))
72 << "</para></glossdef>\n"
78 void InsetNomencl::validate(LaTeXFeatures & features) const
80 features.require("nomencl");
84 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
85 : InsetCommand(p, string())
89 CommandInfo const * InsetPrintNomencl::findInfo(std::string const & /* cmdName */)
91 static const char * const paramnames[] = {"labelwidth", ""};
92 static const bool isoptional[] = {true};
93 static const CommandInfo info = {1, paramnames, isoptional};
98 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
100 return _("Nomenclature");
104 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
105 OutputParams const &) const
107 os << "<glossary>\n";
109 for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
110 if (it->lyxCode() == NOMENCL_CODE) {
111 newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
113 } else if(it->lyxCode() == NOTE_CODE &&
114 static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
115 // Don't output anything nested in note insets
116 size_t const depth = it.depth();
118 while (it.depth() > depth)
124 os << "</glossary>\n";
129 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
131 features.require("nomencl");
135 InsetCode InsetPrintNomencl::lyxCode() const
137 return NOMENCL_PRINT_CODE;