]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetText.cpp
Add Nomenclature to the TOC.
[lyx.git] / src / insets / InsetText.cpp
index b3baf93ba14aa13e0f3e630f64f528aba11bdf67..8c9d3df314c60aef7c046b0ced9fff0ec17bb4ac 100644 (file)
@@ -811,7 +811,7 @@ void InsetText::forToc(docstring & os, size_t maxlen) const
 }
 
 
-void InsetText::addToToc(DocIterator const & cdit) const
+void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
 {
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
@@ -819,6 +819,9 @@ void InsetText::addToToc(DocIterator const & cdit) const
 
        BufferParams const & bufparams = buffer_->params();
        int const min_toclevel = bufparams.documentClass().min_toclevel();
+       // we really should have done this before we got here, but it
+       // can't hurt too much to do it again
+       bool const doing_output = output_active && producesOutput();
 
        // For each paragraph, traverse its insets and let them add
        // their toc items
@@ -835,7 +838,7 @@ void InsetText::addToToc(DocIterator const & cdit) const
                        Inset & inset = *it->inset;
                        dit.pos() = it->pos;
                        //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
-                       inset.addToToc(dit);
+                       inset.addToToc(dit, doing_output);
                        if (inset.lyxCode() == ARG_CODE)
                                arginset = inset.asInsetText();
                }
@@ -844,20 +847,21 @@ void InsetText::addToToc(DocIterator const & cdit) const
                if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
                        // insert this into the table of contents
                        docstring tocstring;
+                       int const length = doing_output ? INT_MAX : TOC_ENTRY_LENGTH;
                        if (arginset) {
                                tocstring = par.labelString();
                                if (!tocstring.empty())
                                        tocstring += ' ';
-                               arginset->text().forToc(tocstring, TOC_ENTRY_LENGTH);
+                               arginset->text().forToc(tocstring, length);
                        } else
-                               par.forToc(tocstring, TOC_ENTRY_LENGTH);
+                               par.forToc(tocstring, length);
                        dit.pos() = 0;
                        toc.push_back(TocItem(dit, toclevel - min_toclevel,
-                               tocstring, tocstring));
+                               tocstring, doing_output, tocstring));
                }
                
                // And now the list of changes.
-               par.addChangesToToc(dit, buffer());
+               par.addChangesToToc(dit, buffer(), doing_output);
        }
 }