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"
31 InsetNomencl::InsetNomencl(InsetCommandParams const & p)
32 : InsetCommand(p, "nomenclature"),
33 nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
37 CommandInfo const * InsetNomencl::findInfo(std::string const & /* cmdName */)
39 static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
40 static const bool isoptional[] = {true, false, false};
41 static const CommandInfo info = {3, paramnames, isoptional};
46 docstring const InsetNomencl::getScreenLabel(Buffer const &) const
52 int InsetNomencl::docbook(Buffer const &, odocstream & os,
53 OutputParams const &) const
55 os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
56 << sgml::escapeString(getParam("symbol"))
62 int InsetNomencl::docbookGlossary(odocstream & os) const
64 os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
66 << sgml::escapeString(getParam("symbol"))
69 << sgml::escapeString(getParam("description"))
70 << "</para></glossdef>\n"
76 void InsetNomencl::validate(LaTeXFeatures & features) const
78 features.require("nomencl");
82 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
83 : InsetCommand(p, string())
87 CommandInfo const * InsetPrintNomencl::findInfo(std::string const & /* cmdName */)
89 static const char * const paramnames[] = {"labelwidth", ""};
90 static const bool isoptional[] = {true};
91 static const CommandInfo info = {1, paramnames, isoptional};
96 docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
98 return _("Nomenclature");
102 int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
103 OutputParams const &) const
105 os << "<glossary>\n";
107 for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
108 if (it->lyxCode() == NOMENCL_CODE) {
109 newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
111 } else if(it->lyxCode() == NOTE_CODE &&
112 static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
113 // Don't output anything nested in note insets
114 size_t const depth = it.depth();
116 while (it.depth() > depth)
122 os << "</glossary>\n";
127 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
129 features.require("nomencl");
133 InsetCode InsetPrintNomencl::lyxCode() const
135 return NOMENCL_PRINT_CODE;