X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCollapsable.cpp;h=fa9f01056ab685e00ae67280e2faafa1541dec5f;hb=239b9919ffe28338d789e6dc9122228f77ab77a7;hp=bcf96cc06999f222bd2e8a7fc971ee3e61e2706d;hpb=28dfc48fb2e24bb8c9d913535b955437b73ca9af;p=lyx.git diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index bcf96cc069..fa9f01056a 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -24,6 +24,7 @@ #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" +#include "TocBackend.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -660,4 +661,30 @@ bool InsetCollapsable::canPaintChange(BufferView const & bv) const } +void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active, + UpdateType utype) const +{ + bool doing_output = output_active && producesOutput(); + InsetLayout const & layout = getLayout(); + if (layout.addToToc()) { + TocBuilder & b = buffer().tocBackend().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); + if (layout.isTocCaption()) { + docstring str; + text().forOutliner(str, TOC_ENTRY_LENGTH); + b.argumentItem(str); + } + b.pop(); + } else + InsetText::addToToc(cpit, doing_output, utype); +} + + + } // namespace lyx