> +/// thrown by an inset that does not have a valid ParConstIterator
> +/// so the paragraph containing this inset has to be used
> +class outerTocItem
'OuterTocItem'
Fixed in the attached patch. Jose, OK to apply? (I assume Andre has
tested this patch).
Bo
Index: src/insets/InsetInclude.cpp
===================================================================
--- src/insets/InsetInclude.cpp (revision 18631)
+++ src/insets/InsetInclude.cpp (working copy)
@@ -883,6 +883,18 @@
void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer) const
{
+ if (isListings(params_)) {
+ InsetListingsParams params(params_.getOptions());
+ string caption = params.getParamValue("caption");
+ if (!caption.empty()) {
+ Toc & toc = toclist["listing"];
+ // This inset does not have a valid ParConstIterator
+ // so it has to use the iterator of its parent paragraph
+ throw OuterTocItem("listing", 0, convert<docstring>(toc.size() + 1)
+ + ". " + params_["filename"]);
+ }
+ return;
+ }
Buffer const * const childbuffer = getChildBuffer(buffer, params_);
if (!childbuffer)
return;
Index: src/TocBackend.cpp
===================================================================
--- src/TocBackend.cpp (revision 18631)
+++ src/TocBackend.cpp (working copy)
@@ -184,7 +184,14 @@
InsetList::const_iterator end = pit->insetlist.end();
for (; it != end; ++it) {
Inset & inset = *it->inset;
- inset.addToToc(tocs_, *buffer_);
+ try {
+ inset.addToToc(tocs_, *buffer_);
+ } catch (OuterTocItem const & item) {
+ // if an inset does not have its own ParConstIterator
+ // (e.g. InsetInclude), it can throw an OuterTocItem
+ // to use the ParConstIterator of its parent paragraph.
+ tocs_[item.type()].push_back(TocItem(pit, item.depth(), item.str()));
+ }
switch (inset.lyxCode()) {
case Inset::OPTARG_CODE: {
if (!tocstring.empty())
Index: src/TocBackend.h
===================================================================
--- src/TocBackend.h (revision 18631)
+++ src/TocBackend.h (working copy)
@@ -81,6 +81,30 @@
};
+/// thrown by an inset that does not have a valid ParConstIterator
+/// so the paragraph containing this inset has to be used
+class OuterTocItem
+{
+public:
+ ///
+ OuterTocItem(std::string const & type, int depth, docstring const & str)
+ : type_(type), depth_(depth), str_(str) {}
+ ///
+ std::string const & type() const { return type_; }
+ ///
+ int const depth() const { return depth_; }
+ ///
+ docstring const & str() const { return str_; }
+private:
+ /// Toc type
+ std::string type_;
+ /// nested depth
+ int depth_;
+ /// Full item string
+ docstring str_;
+};
+
+
///
/**
*/