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 CommandInfo const * InsetNomencl::findInfo(string const & /* cmdName */)
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};
47 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
53 int InsetNomencl::docbook(Buffer const &, odocstream & os,
54 OutputParams const &) const
56 os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
57 << sgml::escapeString(getParam("symbol"))
63 int InsetNomencl::docbookGlossary(odocstream & os) const
65 os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
67 << sgml::escapeString(getParam("symbol"))
70 << sgml::escapeString(getParam("description"))
71 << "</para></glossdef>\n"
77 void InsetNomencl::validate(LaTeXFeatures & features) const
79 features.require("nomencl");
83 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
84 : InsetCommand(p, string())
88 CommandInfo const * InsetPrintNomencl::findInfo(string const & /* cmdName */)
90 static const char * const paramnames[] = {"labelwidth", ""};
91 static const bool isoptional[] = {true};
92 static const CommandInfo info = {1, paramnames, isoptional};
97 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
99 return _("Nomenclature");
103 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
104 OutputParams const &) const
106 os << "<glossary>\n";
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);
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();
117 while (it.depth() > depth)
123 os << "</glossary>\n";
128 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
130 features.require("nomencl");
134 InsetCode InsetPrintNomencl::lyxCode() const
136 return NOMENCL_PRINT_CODE;