]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNomencl.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / insets / InsetNomencl.cpp
index 8cb01e8b46291440724b18355d87ff8bd49dfd79..306498feb6338ba4fb97c0d69d2f7fcdacaedbb1 100644 (file)
@@ -24,7 +24,9 @@
 #include "InsetList.h"
 #include "LaTeXFeatures.h"
 #include "Length.h"
+#include "LyX.h"
 #include "MetricsInfo.h"
+#include "output_xhtml.h"
 #include "sgml.h"
 
 #include "frontends/FontMetrics.h"
@@ -45,8 +47,8 @@ namespace lyx {
 //
 /////////////////////////////////////////////////////////////////////
 
-InsetNomencl::InsetNomencl(InsetCommandParams const & p)
-       : InsetCommand(p, "nomenclature"),
+InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p)
+       : InsetCommand(buf, p, "nomenclature"),
          nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
 {}
 
@@ -97,6 +99,12 @@ int InsetNomencl::docbook(odocstream & os, OutputParams const &) const
 }
 
 
+docstring InsetNomencl::xhtml(XHTMLStream &, OutputParams const &) const
+{
+       return docstring();
+}
+
+
 int InsetNomencl::docbookGlossary(odocstream & os) const
 {
        os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
@@ -123,8 +131,8 @@ void InsetNomencl::validate(LaTeXFeatures & features) const
 //
 /////////////////////////////////////////////////////////////////////
 
-InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
-       : InsetCommand(p, "nomencl_print")
+InsetPrintNomencl::InsetPrintNomencl(Buffer * buf, InsetCommandParams const & p)
+       : InsetCommand(buf, p, "nomencl_print")
 {}
 
 
@@ -191,6 +199,11 @@ bool InsetPrintNomencl::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
+docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const &) const
+{
+       return docstring();
+}
+
 
 int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const
 {
@@ -242,8 +255,9 @@ docstring nomenclWidest(Buffer const & buffer)
                                nomencl->getParam("symbol");
                        // This is only an approximation,
                        // but the best we can get.
-                       int const wx =
-                               theFontMetrics(Font()).width(symbol);
+                       int const wx = use_gui ?
+                               theFontMetrics(Font()).width(symbol) :
+                               symbol.size();
                        if (wx > w) {
                                w = wx;
                                symb = symbol;
@@ -262,20 +276,12 @@ int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const
        if (getParam("set_width") == "auto") {
                docstring widest = nomenclWidest(buffer());
                // Set the label width via nomencl's command \nomlabelwidth.
-               // This must be output before the command
-               // \printnomenclature
+               // This must be output before the command \printnomenclature
                if (!widest.empty()) {
-                       // assure that the width is never below the
-                       // value predefined in nomencl.cfg
-                       os << "\\newlength{\\symbwidth}\n";
-                       os << "\\settowidth{\\symbwidth}{"
+                       os << "\\settowidth{\\nomlabelwidth}{"
                           << widest
                           << "}\n";
-                       os << "\\ifthenelse{%\n";
-                       os << "\\lengthtest{\\symbwidth < \\nomlabelwidth}}\n";
-                       os << " {\\setlength{\\symbwidth}{\\nomlabelwidth}}\n";
-                       os << " {}\n";
-                       lines += 6;
+                       ++lines;
                }
        } else if (getParam("set_width") == "custom") {
                // custom length as optional arg of \printnomenclature
@@ -297,8 +303,6 @@ int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const
 void InsetPrintNomencl::validate(LaTeXFeatures & features) const
 {
        features.require("nomencl");
-       // needed for InsetPrintNomencl::latex
-       features.require("ifthen");
 }