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.
This commit is contained in:
Richard Heck 2014-02-24 14:36:13 -05:00
parent 214f7ed262
commit 6a85db2307
4 changed files with 17 additions and 0 deletions

View File

@ -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 docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const
{ {
if (!isFixedWidth) if (!isFixedWidth)

View File

@ -70,6 +70,8 @@ public:
docstring asString(bool intoInsets = true); docstring asString(bool intoInsets = true);
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
void addToToc(DocIterator const & di, bool output_active) const;
private: private:
/// unimplemented /// unimplemented
InsetTableCell(); InsetTableCell();

View File

@ -815,6 +815,13 @@ void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
{ {
DocIterator dit = cdit; DocIterator dit = cdit;
dit.push_back(CursorSlice(const_cast<InsetText &>(*this))); 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"); Toc & toc = buffer().tocBackend().toc("tableofcontents");
BufferParams const & bufparams = buffer_->params(); BufferParams const & bufparams = buffer_->params();

View File

@ -217,6 +217,8 @@ protected:
docstring getCaptionText(OutputParams const &) const; docstring getCaptionText(OutputParams const &) const;
/// ///
docstring getCaptionHTML(OutputParams const &) const; docstring getCaptionHTML(OutputParams const &) const;
///
void iterateForToc(DocIterator const & cdit, bool output_active) const;
private: private:
/// ///
bool drawFrame_; bool drawFrame_;