]> git.lyx.org Git - features.git/commitdiff
Enhancements and bugfixes to the TOCs
authorGuillaume Munch <gm@lyx.org>
Sun, 27 Sep 2015 06:05:00 +0000 (07:05 +0100)
committerGuillaume Munch <gm@lyx.org>
Thu, 1 Oct 2015 20:44:22 +0000 (21:44 +0100)
* New TOC "math-macro". This means that math macros can now be accessed in the
  outline pane in their order of appearance or in alphabetical order, and can be
  searched using the filter.

* Lists of floats now show subfloats deeper in the navigation menu

* The arbitrary 30 element cut-off after which nothing is shown except "Open
  Navigator..." is removed. Menus now have no limit in size, so Qt may display
  them scrollable. In exchange, we always show "Open outliner..." at the
  beginning. I tested for performance issues with a rather complex document and
  it is fine; but this does not exclude corner cases with lots of TOC entries of
  a certain kind. If necessary, populating the navigation sub-menu should be
  delayed like the main menu.

* Elements that do not contribute to the output (e.g. in a note, a disabled
  branch) are now preceded with a symbol indicating this status. (The machinery
  was already there; I wonder why it was not implemented already.) I have chosen
  U+274E NEGATIVE SQUARED CROSS MARK.

* Fix the contextual menus in the outliner (bug introduced at 94e992c5).

* Toc item now move to the caption when present, but first center on the float,
  to prevent the situation where the caption is at the top of the screen and the
  contents of the float is off-screen above the caption.
  (Internally, the action of the toc items can now be customised)

* Fix the LyXHTML output. Disabled captions no longer appear in the list of
  figures.

43 files changed:
src/Buffer.cpp
src/TocBackend.cpp
src/TocBackend.h
src/frontends/qt4/Menus.cpp
src/frontends/qt4/TocModel.cpp
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/qt_helpers.cpp
src/insets/Inset.h
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h
src/insets/InsetCaptionable.cpp
src/insets/InsetCaptionable.h
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetFloatList.cpp
src/insets/InsetFoot.cpp
src/insets/InsetFoot.h
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h
src/insets/InsetMarginal.cpp
src/insets/InsetMarginal.h
src/insets/InsetNomencl.cpp
src/insets/InsetNomencl.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h
src/mathed/MathMacroTemplate.cpp
src/mathed/MathMacroTemplate.h

index 0f37edd9dcb1868dbad7bce1159a87a1172b8e60..6eea29a112ee19ba9b755f3edb43c439c2519b13 100644 (file)
@@ -4462,7 +4462,7 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
        d->bibinfo_cache_valid_ = true;
        d->cite_labels_valid_ = true;
        /// FIXME: Perf
-       cbuf.tocBackend().update(utype == OutputUpdate);
+       cbuf.tocBackend().update(true, utype);
        if (scope == UpdateMaster)
                cbuf.structureChanged();
 }
index 1eb8f8098c09937c3d4f430567021c4f754a915c..f0750c61bda9ac16a2a84a73ce3158ebf5b366d9 100644 (file)
@@ -39,6 +39,7 @@ using namespace std;
 
 namespace lyx {
 
+
 ///////////////////////////////////////////////////////////////////////////
 //
 // TocItem implementation
@@ -46,8 +47,9 @@ namespace lyx {
 ///////////////////////////////////////////////////////////////////////////
 
 TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
-       bool output_active, docstring const & t) :
-  dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active)
+                       bool output_active, docstring const & t, FuncRequest action) :
+       dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active),
+       action_(action)
 {
 }
 
@@ -66,15 +68,32 @@ docstring const & TocItem::tooltip() const
 
 docstring const TocItem::asString() const
 {
-       return docstring(4 * depth_, ' ') + str_;
+       // U+2327 X IN A RECTANGLE BOX
+       // char_type const cross = 0x2327;
+       // U+274E NEGATIVE SQUARED CROSS MARK
+       char_type const cross = 0x274e;
+       docstring prefix;
+       if (!output_) {
+               prefix += cross;
+               prefix += " ";
+       }
+       return prefix + str_;
 }
 
+// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO 
+docstring paragraph_goto_arg(DocIterator const & dit)
+{
+       CursorSlice const & s = dit.innerTextSlice();
+       return convert<docstring>(s.paragraph().id()) + ' ' +
+               convert<docstring>(s.pos());
+}
 
 FuncRequest TocItem::action() const
 {
-       string const arg = convert<string>(dit_.paragraph().id())
-               + ' ' + convert<string>(dit_.pos());
-       return FuncRequest(LFUN_PARAGRAPH_GOTO, arg);
+       if (action_.action() == LFUN_UNKNOWN_ACTION) {
+               return FuncRequest(LFUN_PARAGRAPH_GOTO, paragraph_goto_arg(dit_));
+       } else
+               return action_;
 }
 
 
@@ -156,15 +175,29 @@ void TocBuilder::pushItem(DocIterator const & dit, docstring const & s,
 void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
                                                         bool output_active)
 {
+       // first show the float before moving to the caption
+       docstring arg = "paragraph-goto " + paragraph_goto_arg(dit);
+       if (!stack_.empty())
+               arg = "paragraph-goto " +
+                       paragraph_goto_arg((*toc_)[stack_.top().pos].dit_) + ";" + arg;
+       FuncRequest func(LFUN_COMMAND_SEQUENCE, arg);
+       
        if (!stack_.empty() && !stack_.top().is_captioned) {
                // The float we entered has not yet been assigned a caption.
                // Assign the caption string to it.
-               (*toc_)[stack_.top().pos].str(s);
+               TocItem & captionable = (*toc_)[stack_.top().pos];
+               captionable.str(s);
+               captionable.setAction(func);
                stack_.top().is_captioned = true;
        } else {
                // This is a new entry.
                pop();
-               pushItem(dit, s, output_active, true);
+               // the dit is at the float's level, e.g. for the contextual menu of
+               // outliner entries
+               DocIterator captionable_dit = dit;
+               captionable_dit.pop_back();
+               pushItem(captionable_dit, s, output_active, true);
+               (*toc_)[stack_.top().pos].setAction(func);
        }
 }
 
@@ -269,14 +302,14 @@ bool TocBackend::updateItem(DocIterator const & dit)
                && tocstring.empty())
                        tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
 
-       const_cast<TocItem &>(*toc_item).str_ = tocstring;
+       const_cast<TocItem &>(*toc_item).str(tocstring);
 
        buffer_->updateTocItem("tableofcontents", dit);
        return true;
 }
 
 
-void TocBackend::update(bool output_active)
+void TocBackend::update(bool output_active, UpdateType utype)
 {
        for (TocList::iterator it = tocs_.begin(); it != tocs_.end(); ++it)
                it->second->clear();
@@ -284,7 +317,7 @@ void TocBackend::update(bool output_active)
        builders_.clear();
        if (!buffer_->isInternal()) {
                DocIterator dit;
-               buffer_->inset().addToToc(dit, output_active);
+               buffer_->inset().addToToc(dit, output_active, utype);
        }
 }
 
index 176175d7f385d054784071292a90055d9c745d2d..2668eb0643335cf04b3ddfa507a7f18f8e003a7b 100644 (file)
@@ -16,6 +16,8 @@
 #define TOC_BACKEND_H
 
 #include "DocIterator.h"
+#include "FuncRequest.h"
+#include "OutputEnums.h"
 
 #include "support/shared_ptr.h"
 #include "support/strfwd.h"
@@ -29,7 +31,6 @@
 namespace lyx {
 
 class Buffer;
-class FuncRequest;
 
 
 /* FIXME: toc types are currently identified by strings. It cannot be converted
@@ -66,6 +67,7 @@ class TocItem
 {
        friend class Toc;
        friend class TocBackend;
+       friend class TocBuilder;
 
 public:
        /// Default constructor for STL containers.
@@ -75,7 +77,8 @@ public:
                int depth,
                docstring const & s,
                bool output_active,
-               docstring const & t = docstring()
+               docstring const & t = docstring(),
+               FuncRequest action = FuncRequest(LFUN_UNKNOWN_ACTION)
                );
        ///
        ~TocItem() {}
@@ -89,19 +92,22 @@ public:
        void str(docstring const & s) { str_ = s; }
        ///
        docstring const & tooltip() const;
-       ///
+       /// String for display, e.g. it has a mark if output is inactive
        docstring const asString() const;
        ///
        DocIterator const & dit() const { return dit_; }
        ///
        bool isOutput() const { return output_; }
-
-       /// the action corresponding to the goTo above
+       ///
+       void setAction(FuncRequest a) { action_ = a; }
+       /// custom action, or the default one (paragraph-goto) if not customised
        FuncRequest action() const;
 
 protected:
        /// Current position of item.
        DocIterator dit_;
+
+private:
        /// nesting depth
        int depth_;
        /// Full item string
@@ -110,6 +116,8 @@ protected:
        docstring tooltip_;
        /// Is this item in a note, inactive branch, etc?
        bool output_;
+       /// Custom action
+       FuncRequest action_;
 };
 
 
@@ -192,7 +200,7 @@ public:
        ///
        void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
        ///
-       void update(bool output_active);
+       void update(bool output_active, UpdateType utype);
        /// \return true if the item was updated.
        bool updateItem(DocIterator const & pit);
        ///
index c336542378a245ae357007f49ae28698dad24d6a..592a66a8165dc412908edd6002d775f757a9cd3b 100644 (file)
@@ -1219,7 +1219,7 @@ void MenuDefinition::expandFlexInsert(
 }
 
 
-size_t const max_number_of_items = 25;
+size_t const max_number_of_items = 30;
 
 void MenuDefinition::expandToc2(Toc const & toc_list,
                size_t from, size_t to, int depth)
@@ -1236,7 +1236,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
        if (to - from <= max_number_of_items) {
                for (size_t i = from; i < to; ++i) {
                        QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
-                       label += limitStringLength(toc_list[i].str());
+                       label += limitStringLength(toc_list[i].asString());
                        if (toc_list[i].depth() == depth) {
                                label += '|';
                            if (shortcut_count < 9) {
@@ -1246,6 +1246,9 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
                        }
                        add(MenuItem(MenuItem::Command, label,
                                            FuncRequest(toc_list[i].action())));
+                       // separator after the menu heading
+                       if (toc_list[i].depth() < depth)
+                               add(MenuItem(MenuItem::Separator));
                }
        } else {
                size_t pos = from;
@@ -1255,7 +1258,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
                                ++new_pos;
 
                        QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
-                       label += limitStringLength(toc_list[pos].str());
+                       label += limitStringLength(toc_list[pos].asString());
                        if (toc_list[pos].depth() == depth) {
                                label += '|';
                            if (shortcut_count < 9) {
@@ -1285,12 +1288,10 @@ void MenuDefinition::expandToc(Buffer const * buf)
        // all MenuItem constructors and to expandToc2. However, we
        // know that all the entries in a TOC will be have status_ ==
        // OK, so we avoid this unnecessary overhead (JMarc)
-
        if (!buf) {
-               add(MenuItem(MenuItem::Info, qt_("<No Document Open>")));
+               add(MenuItem(MenuItem::Info, qt_("(No Document Open)")));
                return;
        }
-
        // Add an entry for the master doc if this is a child doc
        Buffer const * const master = buf->masterBuffer();
        if (buf != master) {
@@ -1301,68 +1302,36 @@ void MenuDefinition::expandToc(Buffer const * buf)
        }
 
        MenuDefinition other_lists;
-
        FloatList const & floatlist = buf->params().documentClass().floats();
        TocList const & toc_list = buf->tocBackend().tocs();
        TocList::const_iterator cit = toc_list.begin();
        TocList::const_iterator end = toc_list.end();
        for (; cit != end; ++cit) {
-               // Handle this later
-               if (cit->first == "tableofcontents")
+               // Handle table of contents later
+               if (cit->first == "tableofcontents" || cit->second->empty())
                        continue;
-
                MenuDefinition submenu;
-               if (floatlist.typeExist(cit->first)) {
-                       TocIterator ccit = cit->second->begin();
-                       TocIterator eend = cit->second->end();
-                       for (; ccit != eend; ++ccit) {
-                               if (0 == ccit->depth()) {// omit subfloats
-                                       submenu.add(MenuItem(MenuItem::Command,
-                                                                                limitStringLength(ccit->str()) + '|',
-                                                                                FuncRequest(ccit->action())));
-                               }
-                       }
-
-                       FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
-                       submenu.add(MenuItem(MenuItem::Separator));
-                       submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
-                       MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
-                       // deserves to be in the main menu.
-                       item.setSubmenu(submenu);
+               // "Open outliner..." entry
+               FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
+               submenu.add(MenuItem(MenuItem::Command, qt_("Open outliner..."), f));
+               submenu.add(MenuItem(MenuItem::Separator));
+               // add entries
+               submenu.expandToc2(* cit->second, 0, cit->second->size(), 0);
+               MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
+               item.setSubmenu(submenu);
+               // deserves to be in the main menu?
+               if (floatlist.typeExist(cit->first) || cit->first == "child")
                        add(item);
-               } else {
-                       if (cit->second->size() >= 30) {
-                               // FIXME: the behaviour of the interface should not change
-                               // arbitrarily. Each type should be audited to see if the list
-                               // can be optimised like for floats above.
-                               FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
-                               submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
-                       } else {
-                               TocIterator ccit = cit->second->begin();
-                               TocIterator eend = cit->second->end();
-                               for (; ccit != eend; ++ccit) {
-                                       submenu.add(MenuItem(MenuItem::Command,
-                                                                                limitStringLength(ccit->str()) + '|',
-                                                                                FuncRequest(ccit->action())));
-                               }
-                       }
-
-                       MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
-                       item.setSubmenu(submenu);
-                       if (cit->first == "child") {
-                               // deserves to be in the main menu.
-                               add(item);
-                       } else
-                               other_lists.add(item);
-               }
+               else
+                       other_lists.add(item);
        }
        if (!other_lists.empty()) {
                MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
                item.setSubmenu(other_lists);
                add(item);
        }
-
        // Handle normal TOC
+       add(MenuItem(MenuItem::Separator));
        cit = toc_list.find("tableofcontents");
        if (cit == end)
                LYXERR(Debug::GUI, "No table of contents.");
@@ -1370,7 +1339,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
                if (!cit->second->empty())
                        expandToc2(* cit->second, 0, cit->second->size(), 0);
                else
-                       add(MenuItem(MenuItem::Info, qt_("<Empty Table of Contents>")));
+                       add(MenuItem(MenuItem::Info, qt_("(Empty Table of Contents)")));
        }
 }
 
index 8f0e3178b231b28edf96c6b3ec25b5088fa544ec..53475e19bb446aaf820c0c79411b51932ecf0159 100644 (file)
@@ -154,7 +154,7 @@ void TocModel::updateItem(DocIterator const & dit)
 {
        QModelIndex index = modelIndex(dit);
        TocItem const & toc_item = tocItem(index);
-       model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
+       model_->setData(index, toqstr(toc_item.asString()), Qt::DisplayRole);
        model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
 }
 
@@ -183,12 +183,12 @@ void TocModel::reset(shared_ptr<Toc const> toc)
                int current_row = model_->rowCount();
                model_->insertRows(current_row, 1);
                QModelIndex top_level_item = model_->index(current_row, 0);
-               model_->setData(top_level_item, toqstr(item.str()), Qt::DisplayRole);
+               model_->setData(top_level_item, toqstr(item.asString()), Qt::DisplayRole);
                model_->setData(top_level_item, index, Qt::UserRole);
                model_->setData(top_level_item, toqstr(item.tooltip()), Qt::ToolTipRole);
 
                LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
-                       << ", added item " << item.str());
+                       << ", added item " << item.asString());
 
                populate(index, top_level_item);
                if (index >= end)
@@ -224,7 +224,7 @@ void TocModel::populate(unsigned int & index, QModelIndex const & parent)
                int current_row = model_->rowCount(parent);
                model_->insertRows(current_row, 1, parent);
                child_item = model_->index(current_row, 0, parent);
-               model_->setData(child_item, toqstr(item.str()), Qt::DisplayRole);
+               model_->setData(child_item, toqstr(item.asString()), Qt::DisplayRole);
                model_->setData(child_item, index, Qt::UserRole);
                model_->setData(child_item, toqstr(item.tooltip()), Qt::ToolTipRole);
                populate(index, child_item);
@@ -315,7 +315,7 @@ void TocModels::goTo(QString const & type, QModelIndex const & index) const
        }
        LASSERT(index.model() == it.value()->model(), return);
        TocItem const item = it.value()->tocItem(index);
-       LYXERR(Debug::GUI, "TocModels::goTo " << item.str());
+       LYXERR(Debug::GUI, "TocModels::goTo " << item.asString());
        dispatch(item.action());
 }
 
index 86fa16b0c4258d3ee75ab3512f9fd97f1e1c578a..bb15f31e2b71bf9ca7dca027c130aa4267856c0f 100644 (file)
@@ -119,16 +119,12 @@ Inset * TocWidget::itemInset() const
 
        else if (current_type_ == "branch"
                         || current_type_ == "index"
-                        || current_type_ == "change")
+                        || current_type_ == "change"
+                        || current_type_ == "table" 
+                    || current_type_ == "listing"
+                    || current_type_ == "figure")
                inset = &dit.inset();
 
-       else if (current_type_ == "table" 
-                    || current_type_ == "listing"
-                    || current_type_ == "figure") {
-               DocIterator tmp_dit(dit);
-               tmp_dit.pop_back();
-               inset = &tmp_dit.inset();
-       }
        return inset;
 }
 
@@ -157,7 +153,7 @@ bool TocWidget::getStatus(Cursor & cur, FuncRequest const & cmd,
 
        case LFUN_LABEL_COPY_AS_REFERENCE: {
                // For labels in math, we need to supply the label as a string
-               FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
+               FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
                if (inset)
                        return inset->getStatus(cur, label_copy, status);
                break;
@@ -202,7 +198,7 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
 
        case LFUN_LABEL_COPY_AS_REFERENCE: {
                // For labels in math, we need to supply the label as a string
-               FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
+               FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
                if (inset)
                        inset->dispatch(cur, label_copy);
                break;
index 593aa3b2ce28ed9c54358e2adefb63973c35b2e4..075a00562a1c8989666c56f2aa91b6712bf8618d 100644 (file)
@@ -616,6 +616,8 @@ QString guiName(string const & type, BufferParams const & bp)
                return qt_("Index Entries");
        if (type == "marginalnote")
                return qt_("Marginal notes");
+       if (type == "math-macro")
+               return qt_("Math macros");
        if (type == "nomencl")
                return qt_("Nomenclature Entries");
        if (type == "note")
index c582ea168f8ab512657eef897db7a897722e6c71..2cc7091a364bcc8c70d0dd57430950ab595a9ba6 100644 (file)
@@ -74,7 +74,7 @@ std::string insetName(InsetCode);
 /// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
 docstring insetDisplayName(InsetCode);
 ///
-static int const TOC_ENTRY_LENGTH = 40;
+static int const TOC_ENTRY_LENGTH = 80;
 
 /// Common base class to all insets
 
@@ -493,7 +493,15 @@ public:
        /// Add an entry to the TocList
        /// Pass a DocIterator that points at the paragraph containing
        /// the inset
-       virtual void addToToc(DocIterator const & /* di */, bool /* output_active */) const {}
+       ///
+       /// \param output_active : is the inset active or is it in an inactive
+       /// branch or a note?
+       ///
+       /// \param utype : is the toc being generated for use by the output
+       /// routines?
+       virtual void addToToc(DocIterator const & /* di */,
+                                                 bool /* output_active */,
+                                                 UpdateType /* utype*/) const {}
        /// Collect BibTeX information
        virtual void collectBibKeys(InsetIterator const &) const {}
        /// Update the counters of this inset and of its contents.
index 98e5c4c5cb81899818a6dfdfefd25b9b34a63ecb..0ed3bc49e6678e1d6c25e72b30ff8c8d68b4fc1e 100644 (file)
@@ -348,7 +348,8 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
 }
 
 
-void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
+                                                  UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
@@ -359,7 +360,7 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
        toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
        // Proceed with the rest of the inset.
        bool const doing_output = output_active && isBranchSelected();
-       InsetCollapsable::addToToc(cpit, doing_output);
+       InsetCollapsable::addToToc(cpit, doing_output, utype);
 }
 
 
index ecd2f7d7e2b5ffdeec15201629240705ead56043..f4ba3f5d9496d42bb17ce441e5de14f0ea872990 100644 (file)
@@ -82,7 +82,8 @@ private:
        ///
        std::string contextMenuName() const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        InsetBranchParams const & params() const { return params_; }
        ///
index 415c3ad316305e50f2f31a1418bc7da3b1686e8d..93abfe47ee8ee2cb9b25a411bb0948b4bdb8e732 100644 (file)
@@ -90,17 +90,25 @@ void InsetCaption::setCustomLabel(docstring const & label)
 }
 
 
-void InsetCaption::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
+                                                       UpdateType utype) const
 {
        string const & type = floattype_.empty() ? "senseless" : floattype_;
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
-       docstring str = full_label_;
-       int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
-       text().forOutliner(str, length);
+       int length = (utype == OutputUpdate) ?
+               // For output (e.g. xhtml) all (bug #8603) or nothing
+               (output_active ? INT_MAX : 0) :
+               // TOC for LyX interface
+               TOC_ENTRY_LENGTH;
+       docstring str;
+       if (length > 0) {
+               str = full_label_;
+               text().forOutliner(str, length);
+       }
        buffer().tocBackend().builder(type)->captionItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetText::addToToc(cpit, output_active);
+       InsetText::addToToc(cpit, output_active, utype);
 }
 
 
index 97f2691629f863bbe44e19a7ecb5bf7db20449d5..1d8775e8ed39e7544afbacdf2bd6568913ff31f8 100644 (file)
@@ -79,9 +79,8 @@ private:
        docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
        ///
        void setCustomLabel(docstring const & label);
-       /// \param output_active : is the toc being generated for use by the
-       /// output routines?
-       void addToToc(DocIterator const & di, bool output_active) const;
+       ///
+       void addToToc(DocIterator const & di, bool output_active, UpdateType utype) const;
        /// 
        virtual bool forcePlainLayout(idx_type = 0) const { return true; }
        /// Captions don't accept alignment, spacing, etc.
index f90776ab0408541f1dd672470239359efbd7ac97..cbdcc0ab152a84218ab1d61c52541d9c22beca81 100644 (file)
@@ -45,17 +45,21 @@ docstring InsetCaptionable::floatName(string const & type) const
 }
 
 
-void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
+                                                               UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
        docstring str;
-       int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
-       text().forOutliner(str, length);
+       // Leave str empty if we generate for output (e.g. xhtml lists of figures).
+       // This ensures that there is a caption if and only if the string is
+       // non-empty.
+       if (utype != OutputUpdate)
+               text().forOutliner(str, TOC_ENTRY_LENGTH);
        shared_ptr<TocBuilder> b = buffer().tocBackend().builder(caption_type_);
        b->pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active);
+       InsetCollapsable::addToToc(cpit, output_active, utype);
        b->pop();
 }
 
index 9e85f67f5ee0a7e3553f0b20f8f03eddd0b58676..94202e4e6cb46214813c8edf247c111860552674 100644 (file)
@@ -38,7 +38,8 @@ protected:
        /// are our captions subcaptions?
        virtual bool hasSubCaptions(ParIterator const &) const { return false; }
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
index 293b0a12391637898a45b1182ce87ffaf06da1da..b455c8654ec9302c09514ba94c26bdeb1ea064e8 100644 (file)
@@ -331,7 +331,8 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
 }
 
 
-void InsetCitation::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
+                                                        UpdateType) const
 {
        // NOTE
        // BiblioInfo::collectCitedEntries() uses the TOC to collect the citations 
index 8d7bb7940b1ce596cdca7ff078e09cca331cf71a..4b4b5ed69c3aab4a1c8ddfd8e06c06c82bc318a3 100644 (file)
@@ -65,7 +65,8 @@ public:
        ///
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        std::string contextMenuName() const;
        //@}
index 9c84314f133f5a9803e2108d9a64462e42082d9f..6deb46ce2d1cff77a86285692994f69a0d0fe8a0 100644 (file)
@@ -209,8 +209,6 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
                                               op.local_font->language()->lang());
        }
 
-       // FIXME Do we need to check if it exists? If so, we need a new
-       // routine in TocBackend to do that.
        shared_ptr<Toc const> toc = buffer().tocBackend().toc(toctype);
        if (toc->empty())
                return docstring();
@@ -252,6 +250,8 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
        Toc::const_iterator it = toc->begin();
        Toc::const_iterator const en = toc->end();
        for (; it != en; ++it) {
+               if (it->str().empty())
+                       continue;
                Paragraph const & par = it->dit().innerParagraph();
                string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
                xs << html::StartTag("div", attr);
index e941f4aa011d78f730a20403b212d6d1561f191d..d1b753d52fc661ef923e322427425b4a358b45f3 100644 (file)
@@ -74,7 +74,8 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
 }
 
 
-void InsetFoot::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
+                                                UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
@@ -84,7 +85,7 @@ void InsetFoot::addToToc(DocIterator const & cpit, bool output_active) const
        text().forOutliner(str, TOC_ENTRY_LENGTH);
        toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
        // Proceed with the rest of the inset.
-       InsetFootlike::addToToc(cpit, output_active);
+       InsetFootlike::addToToc(cpit, output_active, utype);
 }
 
 
index 165a7cf2b42427b721f62d6f6f60feb30a663f04..f145d5ce1678da22a01e401e13c66206509d91b0 100644 (file)
@@ -39,7 +39,8 @@ private:
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
index 83cd84ddf06f6a6fc81056463e0ba1d2933fd542..c20f0314abd27ca559e244a2be56d4960fa32431 100644 (file)
@@ -1027,7 +1027,8 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
 }
 
 
-void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active,
+                                                        UpdateType) const
 {
        //FIXME UNICODE
        docstring const str = from_utf8(params_.filename.onlyFileName());
index d6ccfe2331ab6b42ddd4097f01b431d0029275c8..3cf296fc8db71be2ce34525d138c9bf90749c543 100644 (file)
@@ -99,7 +99,8 @@ private:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        std::string contextMenuName() const;
        /// Force inset into LTR environment if surroundings are RTL
index 3883d2267de8085c57a80317e90c03fa3e56ce5f..20e077976dece98b262ae481230c628367da1bd6 100644 (file)
@@ -1125,13 +1125,14 @@ void InsetInclude::addPreview(DocIterator const & /*inset_pos*/,
 }
 
 
-void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
+                                                       UpdateType utype) const
 {
        TocBackend & backend = buffer().tocBackend();
 
        if (isListings(params())) {
                if (label_)
-                       label_->addToToc(cpit, output_active);
+                       label_->addToToc(cpit, output_active, utype);
 
                InsetListingsParams p(to_utf8(params()["lstparams"]));
                string caption = p.getParamValue("caption");
@@ -1151,8 +1152,7 @@ void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
                docstring str = childbuffer->fileName().displayName();
                toc->push_back(TocItem(cpit, 0, str, output_active));
 
-               //TocList & toclist = backend.tocs();
-               childbuffer->tocBackend().update(output_active);
+               childbuffer->tocBackend().update(output_active, utype);
                TocList const & childtoclist = childbuffer->tocBackend().tocs();
                TocList::const_iterator it = childtoclist.begin();
                TocList::const_iterator const end = childtoclist.end();
index bee2089d9407beb2a4e921ec69decde18977b90c..ce93c7104c0eb321eec2f4e2f2ae789ad788933c 100644 (file)
@@ -104,7 +104,8 @@ public:
        ///
        void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        void updateBuffer(ParIterator const &, UpdateType);
        ///
index cb2704f2f91f508a60cdc026c9bc5ad892054e9a..aff40805d4c360002b2093bb1797d6bdece57e77 100644 (file)
@@ -348,7 +348,8 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params)
 }
 
 
-void InsetIndex::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
+                                                 UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
@@ -360,7 +361,7 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active) const
        text().forOutliner(str, INT_MAX);
        buffer().tocBackend().toc(type)->push_back(TocItem(pit, 0, str, output_active));
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active);
+       InsetCollapsable::addToToc(cpit, output_active, utype);
 }
 
 
index a980a4278143b75fa63966044ac88f87374d7413..b1aa9b4c5f6ee473c1247a96b9a272e75667ca74 100644 (file)
@@ -71,7 +71,8 @@ private:
        /// should paragraph indendation be omitted in any case?
        bool neverIndent() const { return true; }
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
index 82923fff57622345de53df53dd621853e3b5cfa1..9171cd1e362a96fd08d21be87b05cefa6b9e76db 100644 (file)
@@ -169,7 +169,8 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
 }
 
 
-void InsetLabel::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetLabel::addToToc(DocIterator const & cpit, bool output_active,
+                                                 UpdateType) const
 {
        docstring const & label = getParam("name");
        shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
index 3c9bbd05f6b25257c855bbf60fc2ff30cd0d6752..a5e5e3ef1e407a1bac8f7f27952d239bc79585f1 100644 (file)
@@ -57,7 +57,8 @@ public:
        ///
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived classes
index 2970fcb185f4442b128e492e206ce1a2e47c944f..40ff30aaba21028a56c7fc2ecd0242e3183bd531 100644 (file)
@@ -51,7 +51,8 @@ int InsetMarginal::docbook(odocstream & os,
 }
 
 
-void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
+                                 UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
@@ -61,7 +62,7 @@ void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active) const
        text().forOutliner(str, TOC_ENTRY_LENGTH);
        toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
        // Proceed with the rest of the inset.
-       InsetFootlike::addToToc(cpit, output_active);
+       InsetFootlike::addToToc(cpit, output_active, utype);
 }
 
 } // namespace lyx
index 38e1a9c50a067590c3f53ebfe10c726acb9cda7c..237beeeef8550542e9f519de44d9a82d8c7491ed 100644 (file)
@@ -36,7 +36,8 @@ public:
        ///
        int docbook(odocstream &, OutputParams const & runparams) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
 private:
        ///
        Inset * clone() const { return new InsetMarginal(*this); }
index 953eeea7227c3ebef376ee32e0ec990b2ff7edd8..227976623bbb637fcc38fb4b3096519acc7b9de0 100644 (file)
@@ -132,7 +132,8 @@ void InsetNomencl::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
+                                                       UpdateType) const
 {
        docstring const str = getParam("symbol");
        buffer().tocBackend().toc("nomencl")->push_back(TocItem(cpit, 0, str, output_active));
index c58500f6f82d610afacb6c01fc4b9012897e81a4..14507b66ce3cd163b7c0b8b9110e70531d2bba93 100644 (file)
@@ -40,7 +40,8 @@ public:
        /// Updates needed features for this inset.
        void validate(LaTeXFeatures & features) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        InsetCode lyxCode() const { return NOMENCL_CODE; }
        ///
index c1bb07aef4a5db8b4f804ef4698b2fac72c4fcd5..6fcf2794bb649d81f1dee8622df22dcc9cab769a 100644 (file)
@@ -207,7 +207,8 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-void InsetNote::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
+                                                UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
@@ -220,7 +221,7 @@ void InsetNote::addToToc(DocIterator const & cpit, bool output_active) const
 
        // Proceed with the rest of the inset.
        bool doing_output = output_active && producesOutput();
-       InsetCollapsable::addToToc(cpit, doing_output);
+       InsetCollapsable::addToToc(cpit, doing_output, utype);
 }
 
 
index dd580da8a024b8895e1a8933bfddb3bab8df7e4a..c80d61b27df1e6e7edccf455b440690b176dbf7b 100644 (file)
@@ -96,7 +96,8 @@ private:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
index c0de3baf0d5e121c28ec120b51d31faf4adaef14..4489270d4e4812e480f3b9fb432b669f0716b3ec 100644 (file)
@@ -303,7 +303,8 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 }
 
 
-void InsetRef::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
+                                               UpdateType) const
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))
index 002fa64d10ab656287fa10324064def6c6863f9d..5836d2ecfb219a71ab85b63880bce2b018ccdee1 100644 (file)
@@ -70,7 +70,8 @@ public:
        ///
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        bool forceLTR() const { return true; }
        //@}
index 94d2f8e4c5abfbc1b43c6f9db5812c80db10fff7..6a138cc18d6e5c7ebcf480a1bfe85e9907ba9c85 100644 (file)
@@ -3439,9 +3439,10 @@ docstring InsetTableCell::asString(bool intoInsets)
 }
 
 
-void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
+                                                         UpdateType utype) const
 {
-       InsetText::iterateForToc(di, output_active);
+       InsetText::iterateForToc(di, output_active, utype);
 }
 
 
@@ -3927,13 +3928,14 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
 }
 
 
-void InsetTabular::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetTabular::addToToc(DocIterator const & cpit, bool output_active,
+                                                       UpdateType utype) const
 {
        DocIterator dit = cpit;
        dit.forwardPos();
        size_t const end = dit.nargs();
        for ( ; dit.idx() < end; dit.top().forwardIdx())
-               cell(dit.idx())->addToToc(dit, output_active);
+               cell(dit.idx())->addToToc(dit, output_active, utype);
 }
 
 
index f27df2ae3a040470e06713e3facf45a0942f8ddd..a3c2b86c504f755cbccd63bb6e804119c30f893c 100644 (file)
@@ -71,7 +71,8 @@ public:
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
 private:
        /// unimplemented
        InsetTableCell();
@@ -942,7 +943,8 @@ public:
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
 
        ///
        bool completionSupported(Cursor const &) const;
index c4d4f244b203d0c6b6a31ef00ab02415e9b9a891..204df961380cbb8f5bc00e4deea56e777b16018a 100644 (file)
@@ -797,18 +797,20 @@ void InsetText::forOutliner(docstring & os, size_t maxlen) const
 }
 
 
-void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
+void InsetText::addToToc(DocIterator const & cdit, bool output_active,
+                                                UpdateType utype) const
 {
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
-       iterateForToc(dit, output_active);
+       iterateForToc(dit, output_active, utype);
 }
 
 
-void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) const
+void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
+                                                         UpdateType utype) const
 {
        DocIterator dit = cdit;
-       // Ensure that any document has a table of contents
+       // This also ensures that any document has a table of contents
        shared_ptr<Toc> toc = buffer().tocBackend().toc("tableofcontents");
 
        BufferParams const & bufparams = buffer_->params();
@@ -832,7 +834,7 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) cons
                        Inset & inset = *it->inset;
                        dit.pos() = it->pos;
                        //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
-                       inset.addToToc(dit, doing_output);
+                       inset.addToToc(dit, doing_output, utype);
                        if (inset.lyxCode() == ARG_CODE)
                                arginset = inset.asInsetText();
                }
@@ -841,7 +843,8 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) cons
                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;
+                       int const length = (doing_output && utype == OutputUpdate) ?
+                               INT_MAX : TOC_ENTRY_LENGTH;
                        if (arginset) {
                                tocstring = par.labelString();
                                if (!tocstring.empty())
index 64b62357ff26f3d6ec27888912d7b4b9b13c549f..77dcfa9616c4ab502e24e915f104d3a0b436d823 100644 (file)
@@ -171,7 +171,8 @@ public:
        ///
        void forOutliner(docstring &, size_t) const;
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        Inset * clone() const { return new InsetText(*this); }
        ///
@@ -217,7 +218,8 @@ protected:
        ///
        docstring getCaptionHTML(OutputParams const &) const;
        ///
-       void iterateForToc(DocIterator const & cdit, bool output_active) const;
+       void iterateForToc(DocIterator const & cdit, bool output_active,
+                                          UpdateType utype) const;
 private:
        ///
        bool drawFrame_;
index 485d62b33ed388b11913c0f301e38b6895143fb3..08bbe414a966285b35c687d3cb73fc3278bcab11 100644 (file)
@@ -292,7 +292,8 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
 }
 
 
-void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
+void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
+                                                        UpdateType utype) const
 {
        if (!buffer_) {
                //FIXME: buffer_ should be set at creation for this inset! Problem is
@@ -307,7 +308,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
                if (!numbered(row))
                        continue;
                if (label_[row])
-                       label_[row]->addToToc(pit, output_active);
+                       label_[row]->addToToc(pit, output_active, utype);
                toc->push_back(TocItem(pit, 0, nicelabel(row), output_active));
        }
 }
index 5462acd8ef9ab961ddf053569743e4da0dd00961..b4a5be06c2b9ae6040e7c7dd740003afc4b5f60d 100644 (file)
@@ -51,7 +51,8 @@ public:
        ///
        void updateBuffer(ParIterator const &, UpdateType);
        ///
-       void addToToc(DocIterator const & di, bool output_active) const;
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
        ///
        InsetMathHull & operator=(InsetMathHull const &);
        ///
index d2d3cbafab90d9178957f664425af7c341c25aaa..f3ba2b480f0a41ca6de1c2482180fce44ebf32ba 100644 (file)
@@ -34,6 +34,7 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "Lexer.h"
+#include "TocBackend.h"
 
 #include "frontends/Painter.h"
 
@@ -1383,4 +1384,17 @@ string MathMacroTemplate::contextMenuName() const
        return "context-math-macro-definition";
 }
 
+void MathMacroTemplate::addToToc(DocIterator const & pit, bool output_active,
+                                                                UpdateType) const
+{
+       shared_ptr<Toc> toc = buffer().tocBackend().toc("math-macro");
+       docstring str;
+       if (!validMacro())
+               str = bformat(_("Invalid macro! \\%1$s"), name());
+       else
+               str = "\\" + name();
+       toc->push_back(TocItem(pit, 0, str, output_active));
+}
+
+
 } // namespace lyx
index 366c654a03f560a8bb7fdcf381bfc59f0565884d..b0c301897761a0caeb9124c91270386b960875a9 100644 (file)
@@ -103,6 +103,9 @@ public:
        void infoize(odocstream & os) const;
        ///
        std::string contextMenuName() const;
+       ///
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype) const;
 protected:
        ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);