}
+// FIXME: buf should should be const because updateLabels() modifies
+// the contents of the paragraphs.
+void Buffer::updateLabels(bool childonly) const
+{
+ // Use the master text class also for child documents
+ Buffer const * const master = masterBuffer();
+ DocumentClass const & textclass = master->params().documentClass();
+
+ // keep the buffers to be children in this set. If the call from the
+ // master comes back we can see which of them were actually seen (i.e.
+ // via an InsetInclude). The remaining ones in the set need still be updated.
+ static std::set<Buffer const *> bufToUpdate;
+ if (!childonly) {
+ // If this is a child document start with the master
+ if (master != this) {
+ bufToUpdate.insert(this);
+ master->updateLabels(false);
+
+ // was buf referenced from the master (i.e. not in bufToUpdate anymore)?
+ if (bufToUpdate.find(this) == bufToUpdate.end())
+ return;
+ }
+
+ // start over the counters in the master
+ textclass.counters().reset();
+ }
+
+ // update will be done below for this buffer
+ bufToUpdate.erase(this);
+
+ // update all caches
+ clearReferenceCache();
+ inset().setBuffer(const_cast<Buffer &>(*this));
+ updateMacros();
+
+ Buffer & cbuf = const_cast<Buffer &>(*this);
+
+ LASSERT(!text().paragraphs().empty(), /**/);
+
+ // do the real work
+ ParIterator parit = cbuf.par_iterator_begin();
+ lyx::updateLabels(*this, parit);
+
+ if (master != this)
+ // TocBackend update will be done later.
+ return;
+
+ cbuf.tocBackend().update();
+ if (!childonly)
+ cbuf.structureChanged();
+}
+
} // namespace lyx
void setInsetLabel(docstring const & label, InsetLabel const * il);
InsetLabel const * insetLabel(docstring const & label) const;
+ // FIXME: buf should should be const because updateLabels() modifies
+ // the contents of the paragraphs.
+ void updateLabels(bool childonly = false) const;
+
private:
/// search for macro in local (buffer) table or in children
MacroData const * getBufferMacro(docstring const & name,
d->cursor_ = cur;
- updateLabels(buffer_);
+ buffer_.updateLabels();
updateMetrics();
buffer_.changed();
// need a valid cursor. (Lgb)
cur.clearSelection();
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
// tell tabular that a recent copy happened
dirtyTabularStack(false);
boost::tie(ppp, endpit) =
pasteSelectionHelper(cur, parlist, docclass, errorList);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second);
}
makeDisplayPath(fname.absFilename())));
Buffer * buf = lyx_view_->loadDocument(fname, false);
if (buf) {
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
buf->errors("Parse");
}
break;
}
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
view()->setCursorFromRow(row);
if (loaded)
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
child->setParent(buffer);
- updateLabels(*child->masterBuffer());
+ child->masterBuffer()->updateLabels();
lyx_view_->setBuffer(child);
if (parsed)
child->errors("Parse");
docstring const disp_fn = makeDisplayPath(filename.absFilename());
docstring str;
if (buf) {
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
buf->errors("Parse");
str = bformat(_("Document %1$s reloaded."), disp_fn);
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
buffer->errors("Class Switch");
- updateLabels(*buffer);
+ buffer->updateLabels();
}
break; // the character couldn't be deleted physically due to change tracking
}
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
// A singlePar update is not enough in this case.
cur.updateFlags(Update::Force);
cur.clearSelection();
setCursorIntern(cur, begPit, begPos);
cur.updateFlags(Update::Force);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
}
cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
mergeParagraph(bufparams, cur.text()->paragraphs(),
prevcur.pit());
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
cur.updateFlags(Update::Force);
return true;
cur.top().forwardPos();
if (was_inset)
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
else
cur.checkBufferStructure();
needsUpdate = true;
}
if (needsUpdate) {
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
}
bool const was_inset = cur.paragraph().isInset(cur.pos());
cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges);
if (was_inset)
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
else
cur.checkBufferStructure();
}
pit_type undopit = undoSpan(end - 1);
recUndo(cur, start, undopit - 1);
setLayout(cur.buffer(), start, end, layout);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
}
}
// this handles the counter labels, and also fixes up
// depth values for follow-on (child) paragraphs
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
}
/**
- * \file text3.cpp
+ * \file Text3.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
recUndo(cur, pit, pit + 1);
cur.finishUndo();
swap(pars_[pit], pars_[pit + 1]);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
++cur.pit();
break;
recUndo(cur, pit - 1, pit);
cur.finishUndo();
swap(pars_[pit], pars_[pit - 1]);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
--cur.pit();
needsUpdate = true;
break;
par.params().startOfAppendix(start);
// we can set the refreshing parameters now
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
break;
}
case LFUN_WORD_DELETE_FORWARD:
- if (cur.selection()) {
+ if (cur.selection())
cutSelection(cur, true, false);
- } else
+ else
deleteWordForward(cur);
finishChange(cur, false);
break;
cur.posForward();
// Some insets are numbered, others are shown in the outline pane so
// let's update the labels and the toc backend.
- updateLabels(bv->buffer());
+ bv->buffer().updateLabels();
break;
case LFUN_TABULAR_INSERT:
// date metrics.
FuncRequest cmd_caption(LFUN_CAPTION_INSERT);
doInsertInset(cur, cur.text(), cmd_caption, true, false);
- updateLabels(bv->buffer());
+ bv->buffer().updateLabels();
cur.updateFlags(Update::Force);
// FIXME: When leaving the Float (or Wrap) inset we should
// delete any empty paragraph left above or below the
case LFUN_OUTLINE_UP:
outline(OutlineUp, cur);
setCursor(cur, cur.pit(), 0);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_DOWN:
outline(OutlineDown, cur);
setCursor(cur, cur.pit(), 0);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_IN:
outline(OutlineIn, cur);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_OUT:
outline(OutlineOut, cur);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
LYXERR(Debug::INFO, "MacroContext not initialised!"
<< " Going through the buffer again and hope"
<< " the context is better then.");
- updateLabels(bv_->buffer());
+ bv_->buffer().updateLabels();
parPos = text_->macrocontextPosition();
LASSERT(!parPos.empty(), /**/);
parPos.pit() = pit;
doTextUndoOrRedo(cur, stack, otherstack);
// Addapt the new material to current buffer.
- updateLabels(buffer_);
+ buffer_.updateLabels();
return true;
}
}
}
-
-// FIXME: buf should should be const because updateLabels() modifies
-// the contents of the paragraphs.
-void updateLabels(Buffer const & buf, bool childonly)
-{
- // Use the master text class also for child documents
- Buffer const * const master = buf.masterBuffer();
- DocumentClass const & textclass = master->params().documentClass();
-
- // keep the buffers to be children in this set. If the call from the
- // master comes back we can see which of them were actually seen (i.e.
- // via an InsetInclude). The remaining ones in the set need still be updated.
- static std::set<Buffer const *> bufToUpdate;
- if (!childonly) {
- // If this is a child document start with the master
- if (master != &buf) {
- bufToUpdate.insert(&buf);
- updateLabels(*master);
-
- // was buf referenced from the master (i.e. not in bufToUpdate anymore)?
- if (bufToUpdate.find(&buf) == bufToUpdate.end())
- return;
- }
-
- // start over the counters in the master
- textclass.counters().reset();
- }
-
- // update will be done below for buf
- bufToUpdate.erase(&buf);
-
- // update all caches
- buf.clearReferenceCache();
- buf.inset().setBuffer(const_cast<Buffer &>(buf));
- buf.updateMacros();
-
- Buffer & cbuf = const_cast<Buffer &>(buf);
-
- BOOST_ASSERT(!buf.text().paragraphs().empty());
-
- // do the real work
- ParIterator parit = par_iterator_begin(buf.inset());
- updateLabels(buf, parit);
-
- if (master != &buf)
- // TocBackend update will be done later.
- return;
-
- cbuf.tocBackend().update();
- if (!childonly)
- cbuf.structureChanged();
-}
-
-
} // namespace lyx
/// Count the number of chars in the text between these two iterators
int countChars(DocIterator const & from, DocIterator const & to, bool with_blanks);
-/// updates all counters
-void updateLabels(Buffer const &, bool childonly = false);
-
///
void updateLabels(Buffer const &, ParIterator &);
dispatch(FuncRequest(LFUN_INSET_MODIFY, argument));
// FIXME: update the inset contents
- updateLabels(bufferview()->buffer());
+ bufferview()->buffer().updateLabels(false);
BufferView * bv = const_cast<BufferView *>(bufferview());
bv->updateMetrics();
bv->buffer().changed();
GuiWorkArea * wa = workArea(*newBuffer);
if (wa == 0) {
- updateLabels(*newBuffer->masterBuffer());
+ newBuffer->masterBuffer()->updateLabels();
wa = addWorkArea(*newBuffer);
} else {
//Disconnect the old buffer...there's no new one.
docstring str2;
Buffer * buf = loadDocument(fullname);
if (buf) {
- updateLabels(*buf);
-
+ buf->updateLabels();
setBuffer(buf);
buf->errors("Parse");
str2 = bformat(_("Document %1$s opened."), disp_fn);
Buffer * buf = lv->loadDocument(lyxfile);
if (!buf)
return false;
- updateLabels(*buf);
+ buf->updateLabels();
lv->setBuffer(buf);
buf->errors("Parse");
} else {
void Inset::initView()
{
if (isLabeled())
- lyx::updateLabels(buffer());
+ buffer().updateLabels();
}
}
setParam("key", key);
- lyx::updateLabels(buffer());
+ buffer().updateLabels();
}
{
Buffer const * const childbuffer = getChildBuffer(buffer(), params());
if (childbuffer) {
- lyx::updateLabels(*childbuffer, true);
+ childbuffer->updateLabels(true);
return;
}
if (!isListings(params()))
buffer().undo().endUndoGroup();
// We need an update of the Buffer reference cache. This is achieved by
- // updateLabel().
- lyx::updateLabels(buffer());
+ // updateLabels().
+ buffer().updateLabels();
}
ParamInfo const & InsetLabel::findInfo(string const & /* cmdName */)
{
static ParamInfo param_info_;
- if (param_info_.empty()) {
+ if (param_info_.empty())
param_info_.add("name", ParamInfo::LATEX_REQUIRED);
- }
return param_info_;
}
++num;
}
- updateLabels(buf);
+ buf.updateLabels();
bv->putSelectionAt(doc_iterator_begin(buf.inset()), 0, false);
if (num)
buf.markDirty();
label_[row] = dummy_pointer;
// We need an update of the Buffer reference cache.
// This is achieved by updateLabels().
- lyx::updateLabels(buffer());
- } else
+ buffer().updateLabels();
+ } else {
label_[row]->updateCommand(label);
+ }
return;
}
InsetCommandParams p(LABEL_CODE);
label_[row] = 0;
// We need an update of the Buffer reference cache.
// This is achieved by updateLabels().
- lyx::updateLabels(buffer());
+ buffer().updateLabels();
}
}