]> git.lyx.org Git - features.git/commitdiff
Make the generation of children's tocs more robust
authorGuillaume Munch <gm@lyx.org>
Fri, 13 Jan 2017 10:06:48 +0000 (11:06 +0100)
committerGuillaume Munch <gm@lyx.org>
Sat, 14 Jan 2017 22:13:14 +0000 (23:13 +0100)
Let the children directly access the TocBuilders, instead of concatenating
after the fact.

40 files changed:
src/Changes.cpp
src/Changes.h
src/Paragraph.cpp
src/Paragraph.h
src/TocBackend.cpp
src/frontends/qt4/Menus.cpp
src/frontends/qt4/TocModel.cpp
src/insets/Inset.h
src/insets/InsetArgument.cpp
src/insets/InsetArgument.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/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetExternal.cpp
src/insets/InsetExternal.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/InsetNomencl.cpp
src/insets/InsetNomencl.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 5a803c21e843715159ff1c0c81d9d7882093e739..5db28010fa1755deae327cafda4ef0a8e9a5e5cc 100644 (file)
@@ -475,12 +475,12 @@ void Changes::checkAuthors(AuthorList const & authorList)
 
 
 void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer,
-        bool output_active) const
+                       bool output_active, TocBackend & backend) const
 {
        if (table_.empty())
                return;
 
-       shared_ptr<Toc> change_list = buffer.tocBackend().toc("change");
+       shared_ptr<Toc> change_list = backend.toc("change");
        AuthorList const & author_list = buffer.params().authors();
        DocIterator dit = cdit;
 
index f2fa1a4d9f0b9fe7326069d4cd8dc354b8b884f9..5bded171ac5c5d5bce5d2c6596b38610f2629456 100644 (file)
@@ -29,10 +29,11 @@ namespace lyx {
 class AuthorList;
 class Buffer;
 class DocIterator;
+class FontInfo;
 class OutputParams;
 class otexstream;
 class PainterInfo;
-class FontInfo;
+class TocBackend;
 
 
 class Change {
@@ -137,7 +138,7 @@ public:
 
        ///
        void addToToc(DocIterator const & cdit, Buffer const & buffer,
-               bool output_active) const;
+                     bool output_active, TocBackend & backend) const;
 
        ///
        void updateBuffer(Buffer const & buf);
index 6d50f278c45bd577aef0f499863f5f6b2e8dfbe1..425ac39dee9f4be9daa1cd632502c0bd08265749 100644 (file)
@@ -562,10 +562,10 @@ Paragraph::Private::Private(Private const & p, Paragraph * owner,
 }
 
 
-void Paragraph::addChangesToToc(DocIterator const & cdit,
-       Buffer const & buf, bool output_active) const
+void Paragraph::addChangesToToc(DocIterator const & cdit, Buffer const & buf,
+                                bool output_active, TocBackend & backend) const
 {
-       d->changes_.addToToc(cdit, buf, output_active);
+       d->changes_.addToToc(cdit, buf, output_active, backend);
 }
 
 
index 813640e548d5e0aa65594bef4e4cbef961f53498..03a652ec08ced266b8be525ea87677e1c4ccc7b9 100644 (file)
@@ -47,6 +47,7 @@ class MetricsInfo;
 class OutputParams;
 class PainterInfo;
 class ParagraphParameters;
+class TocBackend;
 class WordLangTuple;
 class XHTMLStream;
 class otexstream;
@@ -150,7 +151,7 @@ public:
 
        ///
        void addChangesToToc(DocIterator const & cdit, Buffer const & buf,
-               bool output_active) const;
+                            bool output_active, TocBackend & backend) const;
        /// set the buffer flag if there are changes in the paragraph
        void addChangesToBuffer(Buffer const & buf) const;
        ///
index 4630d85b9deb5da15875c0347a6e0aca6351bd61..c013cca03f7e2f71caa8194d868cc7dfb2dcfa2c 100644 (file)
@@ -217,7 +217,7 @@ void TocBackend::update(bool output_active, UpdateType utype)
        resetOutlinerNames();
        if (!buffer_->isInternal()) {
                DocIterator dit;
-               buffer_->inset().addToToc(dit, output_active, utype);
+               buffer_->inset().addToToc(dit, output_active, utype, *this);
        }
 }
 
index 249d742013cb6d2d5fed90bd59e36c5c2c454c4b..c8682bb08143f4e8045640fa57d26fcbfc1c478e 100644 (file)
@@ -1311,20 +1311,20 @@ void MenuDefinition::expandToc(Buffer const * buf)
        }
 
        MenuDefinition other_lists;
-       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) {
+       // In the navigation menu, only add tocs from this document
+       TocBackend const & backend = buf->tocBackend();
+       TocList const & toc_list = backend.tocs();
+       for (pair<string, shared_ptr<Toc>> const & toc : toc_list) {
                // Handle table of contents later
-               if (cit->first == "tableofcontents" || cit->second->empty())
+               if (toc.first == "tableofcontents" || toc.second->empty())
                        continue;
                MenuDefinition submenu;
-               submenu.expandTocSubmenu(cit->first, *cit->second);
-               docstring const toc_name = buf->tocBackend().outlinerName(cit->first);
+               submenu.expandTocSubmenu(toc.first, *toc.second);
+               docstring const toc_name = backend.outlinerName(toc.first);
                MenuItem item(MenuItem::Submenu, toqstr(toc_name));
                item.setSubmenu(submenu);
                // deserves to be in the main menu?
-               if (!TocBackend::isOther(cit->first))
+               if (!TocBackend::isOther(toc.first))
                        add(item);
                else
                        other_lists.add(item);
@@ -1336,8 +1336,8 @@ void MenuDefinition::expandToc(Buffer const * buf)
        }
        // Handle normal TOC
        add(MenuItem(MenuItem::Separator));
-       cit = toc_list.find("tableofcontents");
-       if (cit == end)
+       TocList::const_iterator cit = toc_list.find("tableofcontents");
+       if (cit == toc_list.end())
                LYXERR(Debug::GUI, "No table of contents.");
        else {
                if (!cit->second->empty())
index 03dbf38671bd867aa7066237ed50c146b8c01b2b..0733c1f6416b82548568c549d2ea189ce0682a54 100644 (file)
@@ -351,21 +351,19 @@ void TocModels::reset(BufferView const * bv)
        names_->blockSignals(true);
        names_->beginResetModel();
        names_->insertColumns(0, 1);
+       // In the outliner, add Tocs from the master document
        TocBackend const & backend = bv->buffer().masterBuffer()->tocBackend();
-       TocList const & tocs = backend.tocs();
-       TocList::const_iterator it = tocs.begin();
-       TocList::const_iterator toc_end = tocs.end();
-       for (; it != toc_end; ++it) {
-               QString const type = toqstr(it->first);
+       for (pair<string, shared_ptr<Toc>> const & toc : backend.tocs()) {
+               QString const type = toqstr(toc.first);
 
                // First, fill in the toc models.
                iterator mod_it = models_.find(type);
                if (mod_it == models_.end())
                        mod_it = models_.insert(type, new TocModel(this));
-               mod_it.value()->reset(it->second);
+               mod_it.value()->reset(toc.second);
 
                // Fill in the names_ model.
-               QString const gui_name = toqstr(backend.outlinerName(it->first));
+               QString const gui_name = toqstr(backend.outlinerName(toc.first));
                int const current_row = names_->rowCount();
                names_->insertRows(current_row, 1);
                QModelIndex const index = names_->index(current_row, 0);
index 0783ec1ffbb0c1dea4d130b1a39358d072e9036f..0b339cc12630e536f7bac596dfe936511f4c7db0 100644 (file)
@@ -57,6 +57,7 @@ class PainterInfo;
 class ParConstIterator;
 class ParIterator;
 class Text;
+class TocBackend;
 class TocList;
 class XHTMLStream;
 class otexstream;
@@ -512,9 +513,12 @@ public:
        ///
        /// \param utype : is the toc being generated for use by the output
        /// routines?
+       ///
+       /// \param tocbackend : where to add the toc information.
        virtual void addToToc(DocIterator const & /* di */,
                                                  bool /* output_active */,
-                                                 UpdateType /* utype*/) const {}
+                             UpdateType /* utype*/,
+                             TocBackend & /* tocbackend */) const {}
        /// Collect BibTeX information
        virtual void collectBibKeys(InsetIterator const &) const {}
        /// Update the counters of this inset and of its contents.
index 605286ca20f76482f8bae5190d12b7870e29eea9..2acf71fa1a756171cc31b9cd0aa211b02200ed15 100644 (file)
@@ -317,17 +317,16 @@ void InsetArgument::latexArgument(otexstream & os,
 }
 
 
-
 void InsetArgument::addToToc(DocIterator const & dit, bool output_active,
-                             UpdateType utype) const
+                             UpdateType utype, TocBackend & backend) const
 {
        if (!caption_of_toc_.empty()) {
                docstring str;
                text().forOutliner(str, TOC_ENTRY_LENGTH);
-               buffer().tocBackend().builder(caption_of_toc_).argumentItem(str);
+               backend.builder(caption_of_toc_).argumentItem(str);
        }
        // Proceed with the rest of the inset.
-       InsetText::addToToc(dit, output_active, utype);
+       InsetText::addToToc(dit, output_active, utype, backend);
 }
 
 
index 0ccdc41bc0b5ddc9f9be620f6dc68f3d30cd4132..3e200e3b1c173bc1dfbecd74b7b35fe8364f42d3 100644 (file)
@@ -83,7 +83,7 @@ public:
        //@}
        ///
        void addToToc(DocIterator const & dit, bool output_active,
-                     UpdateType utype) const; //override
+                     UpdateType utype, TocBackend & backend) const; //override
 
 private:
        ///
index 613249b6b25c28472c2134cbaf795e6ccc58153d..7570fa52fa1ec1cc6bf12e95cd947db6e078c7d8 100644 (file)
@@ -94,7 +94,7 @@ void InsetCaption::setCustomLabel(docstring const & label)
 
 
 void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
-                                                       UpdateType utype) const
+                                                       UpdateType utype, TocBackend & backend) const
 {
        string const & type = floattype_.empty() ? "senseless" : floattype_;
        DocIterator pit = cpit;
@@ -109,9 +109,9 @@ void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
                str = full_label_;
                text().forOutliner(str, length);
        }
-       buffer().tocBackend().builder(type).captionItem(pit, str, output_active);
+       backend.builder(type).captionItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetText::addToToc(cpit, output_active, utype);
+       InsetText::addToToc(cpit, output_active, utype, backend);
 }
 
 
index 461d9ce4f4e0da43ff59c713808f749f352fddd8..a2aca81c4bbfcde30269cb8583521bffe335b519 100644 (file)
@@ -82,7 +82,8 @@ private:
        ///
        void setCustomLabel(docstring const & label);
        ///
-       void addToToc(DocIterator const & di, bool output_active, UpdateType utype) const;
+       void addToToc(DocIterator const & di, bool output_active, UpdateType utype,
+                     TocBackend & backend) const;
        /// 
        virtual bool forcePlainLayout(idx_type = 0) const { return true; }
        /// Captions don't accept alignment, spacing, etc.
index 94326f4c352a6755a18b6a98fd45d2bd38fdda76..0683aa69485b86d0cd2fe8e8fd9087125f6af943 100644 (file)
@@ -97,7 +97,7 @@ docstring InsetCaptionable::getCaptionHTML(OutputParams const & runparams) const
 
 
 void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
-                                                               UpdateType utype) const
+                                                               UpdateType utype, TocBackend & backend) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
@@ -107,10 +107,10 @@ void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
        // non-empty.
        if (utype != OutputUpdate)
                text().forOutliner(str, TOC_ENTRY_LENGTH);
-       TocBuilder & b = buffer().tocBackend().builder(caption_type_);
+       TocBuilder & b = backend.builder(caption_type_);
        b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active, utype);
+       InsetCollapsable::addToToc(cpit, output_active, utype, backend);
        b.pop();
 }
 
index 5e06d77b73134212b0b38590dbffbea942cd419c..005c371ea2b99448cad45ee437b636ff0f3a3260 100644 (file)
@@ -43,7 +43,7 @@ protected:
        virtual bool hasSubCaptions(ParIterator const &) const { return false; }
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
index 29964fb727e9aadd23f3ac94f0bf79e7cd4c9fa3..0a5da5b1192f63a04d4210e7f1489e64e35c461c 100644 (file)
@@ -420,7 +420,7 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
 
 
 void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
-                                                        UpdateType) const
+                                                        UpdateType, TocBackend & backend) const
 {
        // NOTE
        // BiblioInfo::collectCitedEntries() uses the TOC to collect the citations 
@@ -428,7 +428,7 @@ void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
        // by both XHTML and plaintext output. So, if we change what goes into the TOC,
        // then we will also need to change that routine.
        docstring const tocitem = getParam("key");
-       TocBuilder & b = buffer().tocBackend().builder("citation");
+       TocBuilder & b = backend.builder("citation");
        b.pushItem(cpit, tocitem, output_active);
        b.pop();
 }
index cde7bd126ce511f0475029944020dd40e84ae208..38624ed6f58e9d23b918386f24adb0551cd86b51 100644 (file)
@@ -69,7 +69,7 @@ public:
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        std::string contextMenuName() const;
        //@}
index fa9f01056ab685e00ae67280e2faafa1541dec5f..beb9f6d4f151c6cc6a7151a151bdb503761682b3 100644 (file)
@@ -662,19 +662,19 @@ bool InsetCollapsable::canPaintChange(BufferView const & bv) const
 
 
 void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active,
-                                UpdateType utype) const
+                                UpdateType utype, TocBackend & backend) const
 {
        bool doing_output = output_active && producesOutput();
        InsetLayout const & layout = getLayout();
        if (layout.addToToc()) {
-               TocBuilder & b = buffer().tocBackend().builder(layout.tocType());
+               TocBuilder & b = backend.builder(layout.tocType());
                // Cursor inside the inset
                DocIterator pit = cpit;
                pit.push_back(CursorSlice(const_cast<InsetCollapsable &>(*this)));
                docstring const label = getLabel();
                b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
                // Proceed with the rest of the inset.
-               InsetText::addToToc(cpit, doing_output, utype);
+               InsetText::addToToc(cpit, doing_output, utype, backend);
                if (layout.isTocCaption()) {
                        docstring str;
                        text().forOutliner(str, TOC_ENTRY_LENGTH);
@@ -682,7 +682,7 @@ void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active,
                }
                b.pop();
        } else
-               InsetText::addToToc(cpit, doing_output, utype);
+               InsetText::addToToc(cpit, doing_output, utype, backend);
 }
 
 
index 016d73207f8098221576c174dd38a6544d42373e..a426db034ab12903057c96fd01fce67b0bb5d2af 100644 (file)
@@ -152,7 +152,7 @@ public:
        std::string contextMenuName() const;
        ///
        void addToToc(DocIterator const & dit, bool output_active,
-                     UpdateType utype) const; //override
+                     UpdateType utype, TocBackend & backend) const; //override
 
 protected:
        ///
index 6e0baff5d739556fb9437c5f78968c7606938389..8ddd7565d78ca566bcb4699907baf9ec77d51f9b 100644 (file)
@@ -504,10 +504,10 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 
 void InsetExternal::addToToc(DocIterator const & cpit, bool output_active,
-                                                        UpdateType) const
+                                                        UpdateType, TocBackend & backend) const
 {
        docstring str = screenLabel(params_, buffer());
-       TocBuilder & b = buffer().tocBackend().builder("external");
+       TocBuilder & b = backend.builder("external");
        b.pushItem(cpit, str, output_active);
        b.pop();
 }
index 497f1c653a7fa71846f95ee86c7d69124d0dadad..5eca6641cc50c967b743ab8c66ef1e6760f28545 100644 (file)
@@ -121,7 +121,7 @@ public:
        bool clickable(BufferView const &, int, int) const { return true; }
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
 private:
        ///
        InsetExternal(InsetExternal const &);
index d1458c05a3dc8df58e667226a05d7048a06e0ada..b41d72bc70083d132742ee48ef3b851aeb576251 100644 (file)
@@ -1036,11 +1036,11 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
 
 
 void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active,
-                                                        UpdateType) const
+                                                        UpdateType, TocBackend & backend) const
 {
        //FIXME UNICODE
        docstring const str = from_utf8(params_.filename.onlyFileName());
-       TocBuilder & b = buffer().tocBackend().builder("graphics");
+       TocBuilder & b = backend.builder("graphics");
        b.pushItem(cpit, str, output_active);
        b.pop();
 }
index a2fef00a39d68e809a4d49ef117d14404a386710..88ded43e1bb0f9ffe7aac7450deec0c6e4575cf4 100644 (file)
@@ -102,7 +102,7 @@ private:
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        std::string contextMenuName() const;
        /// Force inset into LTR environment if surroundings are RTL
index c39b7d349fb52467f7d6386778fea522e9a5e51f..482fdb2110f434afd9594dfc17d11f1033a40457 100644 (file)
@@ -1141,12 +1141,11 @@ void InsetInclude::addPreview(DocIterator const & /*inset_pos*/,
 
 
 void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
-                                                       UpdateType utype) const
+                            UpdateType utype, TocBackend & backend) const
 {
-       TocBackend & backend = buffer().tocBackend();
        if (isListings(params())) {
                if (label_)
-                       label_->addToToc(cpit, output_active, utype);
+                       label_->addToToc(cpit, output_active, utype, backend);
                TocBuilder & b = backend.builder("listing");
                b.pushItem(cpit, screenLabel(), output_active);
                InsetListingsParams p(to_utf8(params()["lstparams"]));
@@ -1165,13 +1164,7 @@ void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
                        return;
 
                // Include Tocs from children
-               childbuffer->tocBackend().update(output_active, utype);
-               for(auto const & pair : childbuffer->tocBackend().tocs()) {
-                       string const & type = pair.first;
-                       shared_ptr<Toc const> child_toc = pair.second;
-                       shared_ptr<Toc> toc = backend.toc(type);
-                       toc->insert(toc->end(), child_toc->begin(), child_toc->end());
-               }
+               childbuffer->inset().addToToc(cpit, output_active, utype, backend);
                //Copy missing outliner names (though the user has been warned against
                //having different document class and module selection between master
                //and child).
index c844075489f7034c65ae87ab42f912cf93920674..e616f55626de309499834341d357577d30ff2874 100644 (file)
@@ -110,7 +110,7 @@ public:
        void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        void updateBuffer(ParIterator const &, UpdateType);
        ///
index a328d27de635c885b6d978e1fccf0ec81a763e16..d5d487f78e58ff61a68f0379592b8395067c6a80 100644 (file)
@@ -351,7 +351,7 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params)
 
 
 void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
-                                                 UpdateType utype) const
+                                                 UpdateType utype, TocBackend & backend) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
@@ -361,10 +361,10 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
                type += ":" + to_utf8(params_.index);
        // this is unlikely to be terribly long
        text().forOutliner(str, INT_MAX);
-       TocBuilder & b = buffer().tocBackend().builder(type);
+       TocBuilder & b = backend.builder(type);
        b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active, utype);
+       InsetCollapsable::addToToc(cpit, output_active, utype, backend);
        b.pop();
 }
 
index c0e23d8124da8c26396ee90e10a4b011b32ab33b..80d8149bc4cab58a93814baafe6eef8270800343 100644 (file)
@@ -72,7 +72,7 @@ private:
        bool neverIndent() const { return true; }
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
index 553c6d7b969bac5cb09fcf1f26862c4a99509328..b025de31c1621e0558914acabf09f9b6c76eb9ac 100644 (file)
@@ -170,10 +170,10 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
 
 
 void InsetLabel::addToToc(DocIterator const & cpit, bool output_active,
-                                                 UpdateType) const
+                                                 UpdateType, TocBackend & backend) const
 {
        docstring const & label = getParam("name");
-       shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
+       shared_ptr<Toc> toc = backend.toc("label");
        if (buffer().insetLabel(label) != this) {
                toc->push_back(TocItem(cpit, 0, screen_label_, output_active));
        } else {
index 27f445c1af65fd38b80480d83366c0e97cf863f0..65a6d3aa20fa3f5b16a739f1ad52da99021f8b56 100644 (file)
@@ -58,7 +58,7 @@ public:
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        /// Is the content of this inset part of the immediate (visible) text sequence?
        bool isPartOfTextSequence() const { return false; }
        //@}
index fe4f7fb1419a6c833a83fc82dc5cc25c7a573909..1613542db38dad187f9d8e19f321a5be6d8dab10 100644 (file)
@@ -138,10 +138,10 @@ void InsetNomencl::validate(LaTeXFeatures & features) const
 
 
 void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
-                                                       UpdateType) const
+                                                       UpdateType, TocBackend & backend) const
 {
        docstring const str = getParam("symbol");
-       TocBuilder & b = buffer().tocBackend().builder("nomencl");
+       TocBuilder & b = backend.builder("nomencl");
        b.pushItem(cpit, str, output_active);
        b.pop();
 }
index 5e161a6ca5bfe9d117a561c4c24cdeae6d1a98b9..d222c6526646593b46cddea87b2af93e77351774 100644 (file)
@@ -41,7 +41,7 @@ public:
        void validate(LaTeXFeatures & features) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        InsetCode lyxCode() const { return NOMENCL_CODE; }
        ///
index 31c0187cc1cadfeb01035c69f69a777d7ce7782f..32b80589d11e59a46cac544efe58929628931e48 100644 (file)
@@ -356,7 +356,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 
 
 void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
-                                               UpdateType) const
+                                               UpdateType, TocBackend & backend) const
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))
@@ -365,7 +365,7 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
 
        // It seems that this reference does not point to any valid label.
        screen_label_ = _("BROKEN: ") + screen_label_;
-       shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
+       shared_ptr<Toc> toc = backend.toc("label");
        toc->push_back(TocItem(cpit, 0, screen_label_, output_active));
 }
 
index a28d233fc2cb0edc6a35ce567e4e3a79de4ef0c6..80b767814ce81e96476f2a64ee919e9dacacd4c4 100644 (file)
@@ -71,7 +71,7 @@ public:
        void updateBuffer(ParIterator const & it, UpdateType);
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        bool forceLTR() const { return true; }
        //@}
index bf21ae73f148c7b3288663f975186e23b4e02c8d..a6a280551a1e988e02d933a0a97111c564cb3b70 100644 (file)
@@ -3510,9 +3510,9 @@ docstring InsetTableCell::asString(bool intoInsets)
 
 
 void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
-                                                         UpdateType utype) const
+                                                         UpdateType utype, TocBackend & backend) const
 {
-       InsetText::iterateForToc(di, output_active, utype);
+       InsetText::iterateForToc(di, output_active, utype, backend);
 }
 
 
@@ -3981,13 +3981,13 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
 
 
 void InsetTabular::addToToc(DocIterator const & cpit, bool output_active,
-                                                       UpdateType utype) const
+                                                       UpdateType utype, TocBackend & backend) 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, utype);
+               cell(dit.idx())->addToToc(dit, output_active, utype, backend);
 }
 
 
index 1e1379cc7b28df7decf825ef123cd56dcab41faf..bdd21aff4e91c54758ead126e95db3bdbb8f561b 100644 (file)
@@ -71,7 +71,7 @@ public:
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
 private:
        /// unimplemented
        InsetTableCell();
@@ -959,7 +959,7 @@ public:
        void updateBuffer(ParIterator const &, UpdateType);
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
 
        ///
        bool completionSupported(Cursor const &) const;
index db6b744deb833dcc815bb8d6d2c8baddd8409116..471e72c74adbd56b7458e839dbd9ce6cf8fc1589 100644 (file)
@@ -830,20 +830,20 @@ void InsetText::forOutliner(docstring & os, size_t const maxlen,
 
 
 void InsetText::addToToc(DocIterator const & cdit, bool output_active,
-                                                UpdateType utype) const
+                                                UpdateType utype, TocBackend & backend) const
 {
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
-       iterateForToc(dit, output_active, utype);
+       iterateForToc(dit, output_active, utype, backend);
 }
 
 
 void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
-                                                         UpdateType utype) const
+                                                         UpdateType utype, TocBackend & backend) const
 {
        DocIterator dit = cdit;
        // This also ensures that any document has a table of contents
-       shared_ptr<Toc> toc = buffer().tocBackend().toc("tableofcontents");
+       shared_ptr<Toc> toc = backend.toc("tableofcontents");
 
        BufferParams const & bufparams = buffer_->params();
        int const min_toclevel = bufparams.documentClass().min_toclevel();
@@ -870,7 +870,8 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
 
                // Custom AddToToc in paragraph layouts (i.e. theorems)
                if (par.layout().addToToc() && text().isFirstInSequence(pit)) {
-                       pit_type end = openAddToTocForParagraph(pit, dit, output_active);
+                       pit_type end =
+                               openAddToTocForParagraph(pit, dit, output_active, backend);
                        addtotoc_stack.push({pit, end});
                }
 
@@ -882,7 +883,7 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
                        Inset & inset = *it->inset;
                        dit.pos() = it->pos;
                        //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
-                       inset.addToToc(dit, doing_output, utype);
+                       inset.addToToc(dit, doing_output, utype, backend);
                        if (inset.lyxCode() == ARG_CODE)
                                arginset = inset.asInsetText();
                }
@@ -891,7 +892,7 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
                while (!addtotoc_stack.empty() && addtotoc_stack.top().second == pit) {
                        // execute the closing function
                        closeAddToTocForParagraph(addtotoc_stack.top().first,
-                                                 addtotoc_stack.top().second);
+                                                 addtotoc_stack.top().second, backend);
                        addtotoc_stack.pop();
                }
 
@@ -915,27 +916,29 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
                }
 
                // And now the list of changes.
-               par.addChangesToToc(dit, buffer(), doing_output);
+               par.addChangesToToc(dit, buffer(), doing_output, backend);
        }
 }
 
 
 pit_type InsetText::openAddToTocForParagraph(pit_type pit,
                                              DocIterator const & dit,
-                                             bool output_active) const
+                                             bool output_active,
+                                             TocBackend & backend) const
 {
        Paragraph const & par = paragraphs()[pit];
-       TocBuilder & b = buffer().tocBackend().builder(par.layout().tocType());
+       TocBuilder & b = backend.builder(par.layout().tocType());
        docstring const label = par.labelString();
        b.pushItem(dit, label + (label.empty() ? "" : " "), output_active);
        return text().lastInSequence(pit);
 }
 
 
-void InsetText::closeAddToTocForParagraph(pit_type start, pit_type end) const
+void InsetText::closeAddToTocForParagraph(pit_type start, pit_type end,
+                                          TocBackend & backend) const
 {
        Paragraph const & par = paragraphs()[start];
-       TocBuilder & b = buffer().tocBackend().builder(par.layout().tocType());
+       TocBuilder & b = backend.builder(par.layout().tocType());
        if (par.layout().isTocCaption()) {
                docstring str;
                text().forOutliner(str, TOC_ENTRY_LENGTH, start, end);
index 8c647fbff919e5d85bd64fdbf855ea05d01510ac..d8dbc43616dd69804333ddc7abc59d50fa84bb0a 100644 (file)
@@ -25,6 +25,7 @@ class Dimension;
 class ParagraphList;
 class InsetCaption;
 class InsetTabular;
+class TocBuilder;
 
 /**
  A text inset is like a TeX box to write full text
@@ -176,7 +177,7 @@ public:
        void forOutliner(docstring &, size_t const, bool const) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        Inset * clone() const { return new InsetText(*this); }
        ///
@@ -221,15 +222,17 @@ public:
 protected:
        ///
        void iterateForToc(DocIterator const & cdit, bool output_active,
-                                          UpdateType utype) const;
+                                          UpdateType utype, TocBackend & backend) const;
 private:
        /// Open the toc item for paragraph pit. Returns the paragraph index where
        /// it should end.
        pit_type openAddToTocForParagraph(pit_type pit,
                                          DocIterator const & dit,
-                                         bool output_active) const;
+                                         bool output_active,
+                                         TocBackend & backend) const;
        /// Close a toc item opened in start and closed in end
-       void closeAddToTocForParagraph(pit_type start, pit_type end) const;
+       void closeAddToTocForParagraph(pit_type start, pit_type end,
+                                      TocBackend & backend) const;
        ///
        bool drawFrame_;
        ///
index b326aebb5bf5364c3c256c4d24e34455240dc419..e21beb236e98730460d693f68c0aab4705482aaa 100644 (file)
@@ -335,7 +335,7 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
 
 
 void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
-                                                        UpdateType utype) const
+                                                        UpdateType utype, TocBackend & backend) const
 {
        if (!buffer_) {
                //FIXME: buffer_ should be set at creation for this inset! Problem is
@@ -344,7 +344,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
                return;
        }
 
-       TocBuilder & b = buffer().tocBackend().builder("equation");
+       TocBuilder & b = backend.builder("equation");
        // compute first and last item
        row_type first = nrows();
        for (row_type row = 0; row != nrows(); ++row)
@@ -368,7 +368,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
                if (!numbered(row))
                        continue;
                if (label_[row])
-                       label_[row]->addToToc(pit, output_active, utype);
+                       label_[row]->addToToc(pit, output_active, utype, backend);
                docstring label = nicelabel(row);
                if (first == last)
                        // this is the only equation
index f8c04dfe2be2793a44c5b3a641ebeb837a67a373..e04d68e91860caf370a6f709d955ce9a28b0f1ba 100644 (file)
@@ -52,7 +52,7 @@ public:
        void updateBuffer(ParIterator const &, UpdateType);
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        InsetMathHull & operator=(InsetMathHull const &);
        ///
index 6b61af2af8bd036733439d0a4b9995906e268a77..457aea602a6a2a1c72cae26d351f7ba7c86a1227 100644 (file)
@@ -1384,15 +1384,16 @@ string MathMacroTemplate::contextMenuName() const
        return "context-math-macro-definition";
 }
 
+
 void MathMacroTemplate::addToToc(DocIterator const & pit, bool output_active,
-                                                                UpdateType) const
+                                                                UpdateType, TocBackend & backend) const
 {
        docstring str;
        if (!validMacro())
                str = bformat(_("Invalid macro! \\%1$s"), name());
        else
                str = "\\" + name();
-       TocBuilder & b = buffer().tocBackend().builder("math-macro");
+       TocBuilder & b = backend.builder("math-macro");
        b.pushItem(pit, str, output_active);
        b.pop();
 }
index b0c301897761a0caeb9124c91270386b960875a9..56fe0ecb0fc751f2c2c80c59f3dbb20ee6b0e2ad 100644 (file)
@@ -105,7 +105,7 @@ public:
        std::string contextMenuName() const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
 protected:
        ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);