diff --git a/src/Changes.cpp b/src/Changes.cpp index 5a803c21e8..5db28010fa 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -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 change_list = buffer.tocBackend().toc("change"); + shared_ptr change_list = backend.toc("change"); AuthorList const & author_list = buffer.params().authors(); DocIterator dit = cdit; diff --git a/src/Changes.h b/src/Changes.h index f2fa1a4d9f..5bded171ac 100644 --- a/src/Changes.h +++ b/src/Changes.h @@ -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); diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 6d50f278c4..425ac39dee 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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); } diff --git a/src/Paragraph.h b/src/Paragraph.h index 813640e548..03a652ec08 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -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; /// diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index 4630d85b9d..c013cca03f 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -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); } } diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 249d742013..c8682bb081 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -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> 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()) diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index 03dbf38671..0733c1f641 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -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> 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); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 0783ec1ffb..0b339cc126 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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. diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index 605286ca20..2acf71fa1a 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -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); } diff --git a/src/insets/InsetArgument.h b/src/insets/InsetArgument.h index 0ccdc41bc0..3e200e3b1c 100644 --- a/src/insets/InsetArgument.h +++ b/src/insets/InsetArgument.h @@ -83,7 +83,7 @@ public: //@} /// void addToToc(DocIterator const & dit, bool output_active, - UpdateType utype) const; //override + UpdateType utype, TocBackend & backend) const; //override private: /// diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 613249b6b2..7570fa52fa 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -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); } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index 461d9ce4f4..a2aca81c4b 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -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. diff --git a/src/insets/InsetCaptionable.cpp b/src/insets/InsetCaptionable.cpp index 94326f4c35..0683aa6948 100644 --- a/src/insets/InsetCaptionable.cpp +++ b/src/insets/InsetCaptionable.cpp @@ -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(*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(); } diff --git a/src/insets/InsetCaptionable.h b/src/insets/InsetCaptionable.h index 5e06d77b73..005c371ea2 100644 --- a/src/insets/InsetCaptionable.h +++ b/src/insets/InsetCaptionable.h @@ -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); /// diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 29964fb727..0a5da5b119 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -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(); } diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index cde7bd126c..38624ed6f5 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -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; //@} diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index fa9f01056a..beb9f6d4f1 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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(*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); } diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 016d73207f..a426db034a 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -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: /// diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 6e0baff5d7..8ddd7565d7 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -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(); } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 497f1c653a..5eca6641cc 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -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 &); diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index d1458c05a3..b41d72bc70 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -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(); } diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index a2fef00a39..88ded43e1b 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -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 diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index c39b7d349f..482fdb2110 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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 child_toc = pair.second; - shared_ptr 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). diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index c844075489..e616f55626 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -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); /// diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index a328d27de6..d5d487f78e 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -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(*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(); } diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index c0e23d8124..80d8149bc4 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -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; /// diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 553c6d7b96..b025de31c1 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -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 = buffer().tocBackend().toc("label"); + shared_ptr toc = backend.toc("label"); if (buffer().insetLabel(label) != this) { toc->push_back(TocItem(cpit, 0, screen_label_, output_active)); } else { diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 27f445c1af..65a6d3aa20 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -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; } //@} diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index fe4f7fb141..1613542db3 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -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(); } diff --git a/src/insets/InsetNomencl.h b/src/insets/InsetNomencl.h index 5e161a6ca5..d222c65266 100644 --- a/src/insets/InsetNomencl.h +++ b/src/insets/InsetNomencl.h @@ -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; } /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 31c0187cc1..32b80589d1 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -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 = buffer().tocBackend().toc("label"); + shared_ptr toc = backend.toc("label"); toc->push_back(TocItem(cpit, 0, screen_label_, output_active)); } diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index a28d233fc2..80b767814c 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -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; } //@} diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index bf21ae73f1..a6a280551a 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -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); } diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 1e1379cc7b..bdd21aff4e 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -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; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index db6b744deb..471e72c74a 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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(*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 = buffer().tocBackend().toc("tableofcontents"); + shared_ptr 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); diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 8c647fbff9..d8dbc43616 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -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_; /// diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index b326aebb5b..e21beb236e 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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 diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index f8c04dfe2b..e04d68e918 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -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 &); /// diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 6b61af2af8..457aea602a 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -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(); } diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h index b0c3018977..56fe0ecb0f 100644 --- a/src/mathed/MathMacroTemplate.h +++ b/src/mathed/MathMacroTemplate.h @@ -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);