]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNomencl.cpp
Make undo action no-ops when the buffer is read-only
[lyx.git] / src / insets / InsetNomencl.cpp
index c762e33d67e60586e694187e7cf6ee8f5524782f..1d77826602497d3368268498770be2329ea64a04 100644 (file)
 #include "Encoding.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "InsetIterator.h"
+#include "InsetLayout.h"
 #include "InsetList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "LyX.h"
-#include "OutputParams.h"
 #include "xml.h"
 #include "texstream.h"
 #include "TocBackend.h"
@@ -53,8 +52,7 @@ namespace lyx {
 /////////////////////////////////////////////////////////////////////
 
 InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p)
-       : InsetCommand(buf, p),
-         nomenclature_entry_id(xml::uniqueID(from_ascii("nomen")))
+       : InsetCommand(buf, p)
 {}
 
 
@@ -106,7 +104,7 @@ int InsetNomencl::plaintext(odocstringstream & os,
 
 void InsetNomencl::docbook(XMLStream & xs, OutputParams const &) const
 {
-       docstring attr = "linkend=\"" + nomenclature_entry_id + "\"";
+       docstring attr = "linkend=\"" + xml::cleanID(from_ascii("nomen") + getParam("symbol")) + "\"";
        xs << xml::StartTag("glossterm", attr);
        xs << xml::escapeString(getParam("symbol"));
        xs << xml::EndTag("glossterm");
@@ -171,7 +169,7 @@ docstring InsetPrintNomencl::screenLabel() const
 
 
 struct NomenclEntry {
-       NomenclEntry() : par(0) {}
+       NomenclEntry() : par(nullptr) {}
        NomenclEntry(docstring s, docstring d, Paragraph const * p)
          : symbol(s), desc(d), par(p)
        {}
@@ -348,9 +346,8 @@ void InsetPrintNomencl::docbook(XMLStream & xs, OutputParams const & runparams)
        EntryMap::const_iterator const een = entries.end();
        for (; eit != een; ++eit) {
                NomenclEntry const & ne = eit->second;
-               string const parid = ne.par->magicLabel();
 
-               xs << xml::StartTag("glossentry", "xml:id=\"" + parid + "\"");
+               xs << xml::StartTag("glossentry", "xml:id=\"" + xml::cleanID(from_ascii("nomen") + ne.symbol) + "\"");
                xs << xml::CR();
                xs << xml::StartTag("glossterm");
                xs << ne.symbol;
@@ -381,7 +378,7 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
 
        int w = 0;
        docstring symb;
-       InsetNomencl const * nomencl = 0;
+       InsetNomencl const * nomencl = nullptr;
        ParagraphList::const_iterator it = buffer.paragraphs().begin();
        ParagraphList::const_iterator end = buffer.paragraphs().end();
 
@@ -396,10 +393,13 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
                                continue;
                        nomencl = static_cast<InsetNomencl const *>(inset);
                        // Use proper formatting. We do not escape makeindex chars here
-                       docstring const symbol = nomencl ?
+                       docstring symbol = nomencl ?
                                nomencl->params().prepareCommand(runparams, nomencl->getParam("symbol"),
                                                        ParamInfo::HANDLING_LATEXIFY)
                                : docstring();
+                       // strip out % characters which are used as escape in nomencl
+                       // but act as comment in our context here
+                       symbol = subst(symbol, from_ascii("%"), docstring());
                        // This is only an approximation,
                        // but the best we can get.
                        int const wx = use_gui ?