Small cleanup in order to improve toc change detection within insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26574 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-09-26 10:37:24 +00:00
parent 42693547f7
commit 5731e7faae
3 changed files with 11 additions and 8 deletions

View File

@ -2192,11 +2192,9 @@ void Cursor::recordUndoSelection() const
void Cursor::checkBufferStructure()
{
if (paragraph().layout().toclevel == Layout::NOT_IN_TOC)
return;
Buffer const * master = buffer().masterBuffer();
master->tocBackend().updateItem(ParConstIterator(*this));
master->structureChanged();
if (master->tocBackend().updateItem(*this))
master->structureChanged();
}

View File

@ -104,13 +104,16 @@ Toc & TocBackend::toc(string const & type)
}
void TocBackend::updateItem(DocIterator const & dit)
bool TocBackend::updateItem(DocIterator const & dit)
{
if (dit.paragraph().layout().toclevel == Layout::NOT_IN_TOC)
return false;
if (toc("tableofcontents").empty()) {
// FIXME: should not happen,
// a call to TocBackend::update() is missing somewhere
LYXERR0("TocBackend::updateItem called but the TOC is empty!");
return;
return false;
}
BufferParams const & bufparams = buffer_->params();
@ -145,6 +148,8 @@ void TocBackend::updateItem(DocIterator const & dit)
tocstring = par.asString(AS_STR_LABEL);
const_cast<TocItem &>(*toc_item).str_ = tocstring;
return true;
}

View File

@ -97,8 +97,8 @@ public:
void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
///
void update();
///
void updateItem(DocIterator const & pit);
/// \return true if the item was updated.
bool updateItem(DocIterator const & pit);
///
TocList const & tocs() const { return tocs_; }