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;
class AuthorList;
class Buffer;
class DocIterator;
+class FontInfo;
class OutputParams;
class otexstream;
class PainterInfo;
-class FontInfo;
+class TocBackend;
class Change {
///
void addToToc(DocIterator const & cdit, Buffer const & buffer,
- bool output_active) const;
+ bool output_active, TocBackend & backend) const;
///
void updateBuffer(Buffer const & buf);
}
-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);
}
class OutputParams;
class PainterInfo;
class ParagraphParameters;
+class TocBackend;
class WordLangTuple;
class XHTMLStream;
class otexstream;
///
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;
///
resetOutlinerNames();
if (!buffer_->isInternal()) {
DocIterator dit;
- buffer_->inset().addToToc(dit, output_active, utype);
+ buffer_->inset().addToToc(dit, output_active, utype, *this);
}
}
}
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);
}
// 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())
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);
class ParConstIterator;
class ParIterator;
class Text;
+class TocBackend;
class TocList;
class XHTMLStream;
class otexstream;
///
/// \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.
}
-
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);
}
//@}
///
void addToToc(DocIterator const & dit, bool output_active,
- UpdateType utype) const; //override
+ UpdateType utype, TocBackend & backend) const; //override
private:
///
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;
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);
}
///
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.
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)));
// 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();
}
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);
///
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
// 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();
}
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;
//@}
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);
}
b.pop();
} else
- InsetText::addToToc(cpit, doing_output, utype);
+ InsetText::addToToc(cpit, doing_output, utype, backend);
}
std::string contextMenuName() const;
///
void addToToc(DocIterator const & dit, bool output_active,
- UpdateType utype) const; //override
+ UpdateType utype, TocBackend & backend) const; //override
protected:
///
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();
}
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 &);
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();
}
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
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"]));
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).
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);
///
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)));
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();
}
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;
///
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 {
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; }
//@}
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();
}
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; }
///
void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
- UpdateType) const
+ UpdateType, TocBackend & backend) const
{
docstring const & label = getParam("reference");
if (buffer().insetLabel(label))
// 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));
}
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; }
//@}
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);
}
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);
}
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();
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;
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();
// 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});
}
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();
}
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();
}
}
// 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);
class ParagraphList;
class InsetCaption;
class InsetTabular;
+class TocBuilder;
/**
A text inset is like a TeX box to write full text
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); }
///
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_;
///
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
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)
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
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 &);
///
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();
}
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);