2006-11-04 17:55:36 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetNomencl.cpp
|
2006-11-04 17:55:36 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author O. U. Baran
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetNomencl.h"
|
|
|
|
|
#include "InsetNote.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "DispatchResult.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "InsetIterator.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "MetricsInfo.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
#include "sgml.h"
|
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
|
#include "support/docstream.h"
|
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetNomencl::InsetNomencl(InsetCommandParams const & p)
|
2006-11-10 21:13:17 +00:00
|
|
|
|
: InsetCommand(p, "nomenclature"),
|
2007-04-29 22:21:00 +00:00
|
|
|
|
nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
|
2006-11-04 17:55:36 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
CommandInfo const * InsetNomencl::findInfo(string const & /* cmdName */)
|
2007-10-25 04:13:56 +00:00
|
|
|
|
{
|
|
|
|
|
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
|
|
|
|
|
static const bool isoptional[] = {true, false, false};
|
|
|
|
|
static const CommandInfo info = {3, paramnames, isoptional};
|
|
|
|
|
return &info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
|
docstring const InsetNomencl::getScreenLabel(Buffer const &) const
|
|
|
|
|
{
|
2007-04-29 22:21:00 +00:00
|
|
|
|
return _("Nom");
|
2006-11-04 17:55:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-10 21:13:17 +00:00
|
|
|
|
int InsetNomencl::docbook(Buffer const &, odocstream & os,
|
|
|
|
|
OutputParams const &) const
|
2006-11-04 17:55:36 +00:00
|
|
|
|
{
|
2007-04-29 22:21:00 +00:00
|
|
|
|
os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
<< sgml::escapeString(getParam("symbol"))
|
2006-11-10 15:45:42 +00:00
|
|
|
|
<< "</glossterm>";
|
2006-11-04 17:55:36 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-10 15:45:42 +00:00
|
|
|
|
int InsetNomencl::docbookGlossary(odocstream & os) const
|
|
|
|
|
{
|
2007-04-29 22:21:00 +00:00
|
|
|
|
os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
|
2006-11-10 15:45:42 +00:00
|
|
|
|
<< "<glossterm>"
|
|
|
|
|
<< sgml::escapeString(getParam("symbol"))
|
|
|
|
|
<< "</glossterm>\n"
|
|
|
|
|
<< "<glossdef><para>"
|
|
|
|
|
<< sgml::escapeString(getParam("description"))
|
|
|
|
|
<< "</para></glossdef>\n"
|
|
|
|
|
<<"</glossentry>\n";
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
|
void InsetNomencl::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
|
|
|
|
features.require("nomencl");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
|
|
|
|
|
: InsetCommand(p, string())
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
CommandInfo const * InsetPrintNomencl::findInfo(string const & /* cmdName */)
|
2007-10-25 04:13:56 +00:00
|
|
|
|
{
|
|
|
|
|
static const char * const paramnames[] = {"labelwidth", ""};
|
|
|
|
|
static const bool isoptional[] = {true};
|
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
|
return &info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
|
docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
|
|
|
|
|
{
|
2007-04-29 22:21:00 +00:00
|
|
|
|
return _("Nomenclature");
|
2006-11-04 17:55:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-10 15:45:42 +00:00
|
|
|
|
int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
|
2006-11-10 21:13:17 +00:00
|
|
|
|
OutputParams const &) const
|
2006-11-04 17:55:36 +00:00
|
|
|
|
{
|
2006-11-10 15:45:42 +00:00
|
|
|
|
os << "<glossary>\n";
|
|
|
|
|
int newlines = 2;
|
|
|
|
|
for (InsetIterator it = inset_iterator_begin(buf.inset()); it;) {
|
2007-10-13 09:04:52 +00:00
|
|
|
|
if (it->lyxCode() == NOMENCL_CODE) {
|
2006-11-10 15:45:42 +00:00
|
|
|
|
newlines += static_cast<InsetNomencl const &>(*it).docbookGlossary(os);
|
|
|
|
|
++it;
|
2007-10-13 09:04:52 +00:00
|
|
|
|
} else if(it->lyxCode() == NOTE_CODE &&
|
2007-05-28 22:27:45 +00:00
|
|
|
|
static_cast<InsetNote const &>(*it).params().type == InsetNoteParams::Note) {
|
2006-11-10 15:45:42 +00:00
|
|
|
|
// Don't output anything nested in note insets
|
|
|
|
|
size_t const depth = it.depth();
|
|
|
|
|
++it;
|
|
|
|
|
while (it.depth() > depth)
|
|
|
|
|
++it;
|
|
|
|
|
} else {
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
os << "</glossary>\n";
|
|
|
|
|
return newlines;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetPrintNomencl::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
|
|
|
|
features.require("nomencl");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-13 09:04:52 +00:00
|
|
|
|
InsetCode InsetPrintNomencl::lyxCode() const
|
2006-11-04 17:55:36 +00:00
|
|
|
|
{
|
2007-10-13 09:04:52 +00:00
|
|
|
|
return NOMENCL_PRINT_CODE;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|