1) Open EmbeddedObject.lyx
2) Open Toc
3) Click on section 7.2.2 which is in the second child document
4) assertion.
This commit adds proper support for multi-part documents. With this each child document has access to the _full_ TOC tree (including LOT and LOF). This enables to switch between master and child document using the TOC.
* buffer_funcs.cpp:
- updateLabels(): do not emit Buffer::structureChanged() signal for child document
- checkBufferStructure(): update the structure of the master document.
* ControlToc.cpp: always use the TocBackend of the master document.
* LyXView::connectBuffer(): connect structureChanged() of master document.
* TocBackend:
- TocItem: get rid of child_ member.
- TocBackend::item(): only compare items from the same document.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18386
a592a061-630c-0410-9148-
cb99ea01b6c8
// TocItem implementation
TocItem::TocItem(ParConstIterator const & par_it, int d,
- docstring const & s, bool child)
- : par_it_(par_it), depth_(d), str_(s), child_(child)
+ docstring const & s)
+ : par_it_(par_it), depth_(d), str_(s)
{
/*
if (!uid_.empty())
BufferParams const & bufparams = buffer_->params();
const int min_toclevel = bufparams.getTextClass().min_toclevel();
- // Is this a child document?
- bool const child_document = buffer_->getMasterBuffer() != buffer_;
-
Toc & toc = tocs_["tableofcontents"];
ParConstIterator pit = buffer_->par_iterator_begin();
ParConstIterator end = buffer_->par_iterator_end();
if (tocstring.empty())
tocstring = pit->asString(*buffer_, true);
toc.push_back(TocItem(pit, toclevel - min_toclevel,
- tocstring, child_document));
+ tocstring));
}
}
}
-TocIterator const TocBackend::item(
- std::string const & type, ParConstIterator const & par_it) const
+TocIterator const TocBackend::item(std::string const & type,
+ ParConstIterator const & par_it) const
{
TocList::const_iterator toclist_it = tocs_.find(type);
// Is the type supported?
par_it_text.backwardPos();
for (; it != last; --it) {
- if (it->child_)
+ // We verify that we don't compare contents of two
+ // different document. This happens when you
+ // have parent and child documents.
+ if (&it->par_it_[0].inset() != &par_it_text[0].inset())
continue;
if (it->par_it_ <= par_it_text)
return it;
///
TocItem(ParConstIterator const & par_it = ParConstIterator(),
int d = -1,
- docstring const & s = docstring(),
- bool child = false
+ docstring const & s = docstring()
);
///
~TocItem() {}
/// Full item string
docstring str_;
-
- /// Set to true if the item comes from a child document.
- bool child_;
};
///
Toc const & toc(std::string const & type) const;
/// Return the first Toc Item before the cursor
- TocIterator const item(std::string const & type, ParConstIterator const &) const;
+ TocIterator const item(
+ std::string const & type, ///< Type of Toc.
+ ParConstIterator const & ///< The cursor location in the document.
+ ) const;
void writePlaintextTocList(std::string const & type, odocstream & os) const;
Buffer & cbuf = const_cast<Buffer &>(buf);
cbuf.tocBackend().update();
- cbuf.structureChanged();
+ if (!childonly)
+ cbuf.structureChanged();
}
{
if (par_it->layout()->labeltype == LABEL_COUNTER
&& par_it->layout()->toclevel != Layout::NOT_IN_TOC) {
- buffer.tocBackend().updateItem(par_it);
- buffer.structureChanged();
+ Buffer * master = buffer.getMasterBuffer();
+ master->tocBackend().updateItem(par_it);
+ master->structureChanged();
}
}
boost::bind(&WorkArea::redraw, work_area_));
bufferStructureChangedConnection_ =
- buf.structureChanged.connect(
+ buf.getMasterBuffer()->structureChanged.connect(
boost::bind(&LyXView::updateToc, this));
errorsConnection_ =
TocList const & ControlToc::tocs() const
{
- return kernel().buffer().tocBackend().tocs();
+ return kernel().buffer().getMasterBuffer()->tocBackend().tocs();
}
types_.clear();
type_names_.clear();
- TocList const & tocs = kernel().buffer().tocBackend().tocs();
+ TocList const & tocs = kernel().buffer().getMasterBuffer()->
+ tocBackend().tocs();
TocList::const_iterator it = tocs.begin();
TocList::const_iterator end = tocs.end();
for (; it != end; ++it) {
void ControlToc::updateBackend()
{
- kernel().buffer().tocBackend().update();
+ kernel().buffer().getMasterBuffer()->tocBackend().update();
kernel().buffer().structureChanged();
}
{
BOOST_ASSERT(kernel().bufferview());
ParConstIterator it(kernel().bufferview()->cursor());
- return kernel().buffer().tocBackend().item(types_[type], it);
+ Buffer const * master = kernel().buffer().getMasterBuffer();
+ return master->tocBackend().item(types_[type], it);
}