Bo Peng wrote:


Index: src/insets/InsetInclude.cpp
===================================================================
--- src/insets/InsetInclude.cpp    (revision 18451)
+++ src/insets/InsetInclude.cpp    (working copy)
@@ -858,6 +858,22 @@

void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer) const
{
+    if (isListings(params_)) {
+        InsetListingsParams params(params_.getOptions());
+        string caption = params.getParamValue("caption");
+        if (!caption.empty()) {
+ // This *does not* work because pit is not a proper ParConstIterator + // at least pit->id() would crash lyx. Is this because InsetInclude
+            // is not derived from InsetText?

No this is because we don't have access to the containing Paragraph. This is related to the LOF and LOT bug we were talking about some days ago. The proper fix would be to pass the enclosing ParConstIterator in addToToc(). This is because the constructed ParConstIterator contructed below using par_const_iterator_begin() is not complete.

+            ParConstIterator pit = par_const_iterator_begin(*this);
+            Toc & toc = toclist["listing"];
+            docstring const str =
+                convert<docstring>(toc.size() + 1)
+                + ". " +  params_["filename"];
+            toc.push_back(TocItem(pit, 0, str));
+        }
+        return;
+    }
    Buffer const * const childbuffer = getChildBuffer(buffer, params_);
    if (!childbuffer)
        return;

Patch attached.

Bo


Abdel.

Reply via email to