commit 6a85db2307d04581b2e6146b399ab863277f53c1
Author: Richard Heck <[email protected]>
Date:   Mon Feb 24 14:36:13 2014 -0500

    Table cells are insets, but not from the point of view of DocIterators
    and Cursors. So just calling InsetText::addToToc for the cells causes
    problems, because InsetText::addToToc then adds the cell inset itself
    as part of the DocIterator. This then leads to assertions, such as bug
    
    The solution is to refactor InsetText::addToToc so that we can call the
    iterating part without adding the inset.

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index f89c34a..60a0157 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3432,6 +3432,12 @@ docstring InsetTableCell::asString(bool intoInsets)
 }
 
 
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+{
+       InsetText::iterateForToc(di, output_active);
+}
+
+
 docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) 
const
 {
        if (!isFixedWidth)
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 1fed9be..4b1cf83 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -70,6 +70,8 @@ public:
        docstring asString(bool intoInsets = true);
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       ///
+       void addToToc(DocIterator const & di, bool output_active) const;
 private:
        /// unimplemented
        InsetTableCell();
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 3dccd74..5f44052 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -815,6 +815,13 @@ void InsetText::addToToc(DocIterator const & cdit, bool 
output_active) const
 {
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
+       iterateForToc(dit, output_active);
+}
+
+
+void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) 
const
+{
+       DocIterator dit = cdit;
        Toc & toc = buffer().tocBackend().toc("tableofcontents");
 
        BufferParams const & bufparams = buffer_->params();
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index d16d41a..7343ee5 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -217,6 +217,8 @@ protected:
        docstring getCaptionText(OutputParams const &) const;
        ///
        docstring getCaptionHTML(OutputParams const &) const;
+       ///
+       void iterateForToc(DocIterator const & cdit, bool output_active) const;
 private:
        ///
        bool drawFrame_;

Reply via email to