mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Make the generation of children's tocs more robust
Let the children directly access the TocBuilders, instead of concatenating after the fact.
This commit is contained in:
parent
461fda9ca9
commit
3391fed36a
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
//@}
|
||||
///
|
||||
void addToToc(DocIterator const & dit, bool output_active,
|
||||
UpdateType utype) const; //override
|
||||
UpdateType utype, TocBackend & backend) const; //override
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
///
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
//@}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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:
|
||||
///
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 &);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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).
|
||||
|
@ -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);
|
||||
///
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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 {
|
||||
|
@ -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; }
|
||||
//@}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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; }
|
||||
///
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
//@}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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_;
|
||||
///
|
||||
|
@ -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
|
||||
|
@ -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 &);
|
||||
///
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user