InsetList::const_iterator end = pit->insetlist.end();
for (; it != end; ++it) {
Inset & inset = *it->inset;
- inset.addToToc(tocs_, *buffer_);
+ inset.addToToc(tocs_, *buffer_, pit);
switch (inset.lyxCode()) {
case Inset::OPTARG_CODE: {
if (!tocstring.empty())
class Buffer;
class BufferParams;
class BufferView;
+class ParConstIterator;
class CursorSlice;
class FuncRequest;
class FuncStatus;
*/
virtual void addPreview(graphics::PreviewLoader &) const {}
/// Add an entry to the TocList
- virtual void addToToc(TocList &, Buffer const &) const {}
+ /// pit is the ParConstIterator of the paragraph containing the inset
+ virtual void addToToc(TocList &, Buffer const &, ParConstIterator & pit) const {}
public:
/// returns LyX code associated with the inset. Used for TOC, ...)
}
-void InsetCaption::addToToc(TocList & toclist, Buffer const & buf) const
+void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstIterator &) const
{
if (type_.empty())
return;
///
void setCustomLabel(docstring const & label);
///
- void addToToc(TocList &, Buffer const &) const;
+ void addToToc(TocList &, Buffer const &, ParConstIterator &) const;
/// Captions don't accept alignment, spacing, etc.
bool forceDefaultParagraphs(idx_type) const { return true; }
}
-void InsetFloat::addToToc(TocList & toclist, Buffer const & buf) const
-{
- // Is there a need to provide a list of float insets?
- return;
-
- // Abdel (01/02/2006): I'll let this code for reference in case
- // there's a need to do something similar for another kind of
- // inset.
- ParConstIterator pit = par_const_iterator_begin(*this);
- ParConstIterator end = par_const_iterator_end(*this);
-
- // Find a caption layout in one of the (child inset's) pars
- for (; pit != end; ++pit) {
- if (pit->layout()->labeltype == LABEL_SENSITIVE) {
- Toc & toc = toclist[params_.type];
- docstring const str =
- convert<docstring>(toc.size() + 1)
- + ". " + pit->asString(buf, false);
- toc.push_back(TocItem(pit, 0, str));
- return;
- }
- }
-}
-
-
string const InsetFloatMailer::name_("float");
InsetFloatMailer::InsetFloatMailer(InsetFloat & inset)
///
void sideways(bool s, BufferParams const &);
///
- void addToToc(TocList &, Buffer const &) const;
- ///
bool showInsetDialog(BufferView *) const;
///
InsetFloatParams const & params() const { return params_; }
}
-void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer) const
+void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer, ParConstIterator & pit) const
{
+ if (isListings(params_)) {
+ InsetListingsParams params(params_.getOptions());
+ string caption = params.getParamValue("caption");
+ if (!caption.empty()) {
+ Toc & toc = toclist["listing"];
+ docstring const str = convert<docstring>(toc.size() + 1)
+ + ". " + params_["filename"];
+ // This inset does not have a valid ParConstIterator
+ // so it has to use the iterator of its parent paragraph
+ toc.push_back(TocItem(pit, 0, str));
+ }
+ return;
+ }
Buffer const * const childbuffer = getChildBuffer(buffer, params_);
if (!childbuffer)
return;
///
void addPreview(graphics::PreviewLoader &) const;
///
- void addToToc(TocList &, Buffer const &) const;
+ void addToToc(TocList &, Buffer const &, ParConstIterator &) const;
///
void updateLabels(Buffer const & buffer) const;
///
}
-void InsetWrap::addToToc(TocList & toclist, Buffer const & buf) const
-{
- // Is there a need to provide a list of wrap insets?
- return;
-}
-
-
string const InsetWrapMailer::name_("wrap");
InsetWrapMailer::InsetWrapMailer(InsetWrap & inset)
///
bool insetAllowed(Inset::Code) const;
///
- void addToToc(TocList &, Buffer const &) const;
- ///
bool showInsetDialog(BufferView *) const;
///
InsetWrapParams const & params() const { return params_; }