This patch introduces an optional argument to Buffer::updateLabels(), so

as to allow us to call the routine when we are preparing for output and
so to do certain things we might not want to do every time. 

This is an abuse of updateLabels(), in a way, but updateLabels() long
ago became the general recurse-through-the-Buffer routine, and to
implement the sort of thing I want to do here in validate(), say, much
of the code in updateLabels()---in particular, the counter-update
code---would have to be duplicated. So I believe this is the best, and
easiest, way to go.

Actual use of the new argument will follow.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32318 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-12-04 03:03:38 +00:00
parent 55b61a0c9f
commit 996505c2ae
29 changed files with 48 additions and 46 deletions

View File

@ -3442,7 +3442,7 @@ void Buffer::setBuffersForInsets() const
}
void Buffer::updateLabels(UpdateScope scope) const
void Buffer::updateLabels(bool out, UpdateScope scope) const
{
// Use the master text class also for child documents
Buffer const * const master = masterBuffer();
@ -3456,7 +3456,7 @@ void Buffer::updateLabels(UpdateScope scope) const
// If this is a child document start with the master
if (master != this) {
bufToUpdate.insert(this);
master->updateLabels();
master->updateLabels(out);
// Do this here in case the master has no gui associated with it. Then,
// the TocModel is not updated and TocModel::toc_ is invalid (bug 5699).
if (!master->gui_)
@ -3484,7 +3484,7 @@ void Buffer::updateLabels(UpdateScope scope) const
// do the real work
ParIterator parit = cbuf.par_iterator_begin();
updateLabels(parit);
updateLabels(parit, out);
if (master != this)
// TocBackend update will be done later.
@ -3695,7 +3695,7 @@ void Buffer::setLabel(ParIterator & it) const
}
void Buffer::updateLabels(ParIterator & parit) const
void Buffer::updateLabels(ParIterator & parit, bool out) const
{
LASSERT(parit.pit() == 0, /**/);
@ -3720,7 +3720,7 @@ void Buffer::updateLabels(ParIterator & parit) const
InsetList::const_iterator end = parit->insetList().end();
for (; iit != end; ++iit) {
parit.pos() = iit->pos;
iit->inset->updateLabels(parit);
iit->inset->updateLabels(parit, out);
}
}
}

View File

@ -526,9 +526,9 @@ public:
// clear how to do it just for the individual pieces we need.
void setBuffersForInsets() const;
///
void updateLabels(UpdateScope = UpdateMaster) const;
void updateLabels(bool output = false, UpdateScope = UpdateMaster) const;
///
void updateLabels(ParIterator & parit) const;
void updateLabels(ParIterator & parit, bool output = false) const;
/// Spellcheck starting from \p from.
/// \p from initial position, will then points to the next misspelled

View File

@ -466,8 +466,10 @@ public:
virtual void addToToc(DocIterator const &) {}
/// Fill keys with BibTeX information
virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const {}
/// Update the counters of this inset and of its contents
virtual void updateLabels(ParIterator const &) {}
/// Update the counters of this inset and of its contents.
/// The boolean indicates whether we are preparing for output, e.g.,
/// of XHTML.
virtual void updateLabels(ParIterator const &, bool) {}
/// Updates the inset's dialog
virtual Buffer const * updateFrontend() const;

View File

@ -254,7 +254,7 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
// Update the counters of this inset and of its contents
void InsetBibitem::updateLabels(ParIterator const & it)
void InsetBibitem::updateLabels(ParIterator const & it, bool)
{
BufferParams const & bp = buffer().masterBuffer()->params();
Counters & counters = bp.documentClass().counters();

View File

@ -65,7 +65,7 @@ private:
///
virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
/// Update the counter of this inset
virtual void updateLabels(ParIterator const &);
virtual void updateLabels(ParIterator const &, bool);
///
void updateCommand(docstring const & new_key, bool dummy = false);
///

View File

@ -294,7 +294,7 @@ docstring InsetCaption::getCaptionAsHTML(XHTMLStream & xs,
}
void InsetCaption::updateLabels(ParIterator const & it)
void InsetCaption::updateLabels(ParIterator const & it, bool out)
{
Buffer const & master = *buffer().masterBuffer();
DocumentClass const & tclass = master.params().documentClass();
@ -329,7 +329,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
}
// Do the real work now.
InsetText::updateLabels(it);
InsetText::updateLabels(it, out);
}

View File

@ -61,7 +61,7 @@ private:
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
int latex(odocstream & os, OutputParams const &) const;
///

View File

@ -440,7 +440,7 @@ docstring InsetCitation::screenLabel() const
}
void InsetCitation::updateLabels(ParIterator const &)
void InsetCitation::updateLabels(ParIterator const &, bool)
{
CiteEngine const engine = buffer().params().citeEngine();
if (cache.params == params() && cache.engine == engine)

View File

@ -56,7 +56,7 @@ public:
///
void validate(LaTeXFeatures &) const;
///
void updateLabels(ParIterator const & it);
void updateLabels(ParIterator const & it, bool);
///
void addToToc(DocIterator const &);

View File

@ -195,7 +195,7 @@ bool InsetFloat::getStatus(Cursor & cur, FuncRequest const & cmd,
}
void InsetFloat::updateLabels(ParIterator const & it)
void InsetFloat::updateLabels(ParIterator const & it, bool out)
{
Counters & cnts =
buffer().masterBuffer()->params().documentClass().counters();
@ -213,7 +213,7 @@ void InsetFloat::updateLabels(ParIterator const & it)
cnts.current_float(params().type);
cnts.isSubfloat(subflt);
InsetCollapsable::updateLabels(it);
InsetCollapsable::updateLabels(it, out);
//reset afterwards
cnts.current_float(saveflt);

View File

@ -101,7 +101,7 @@ private:
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///

View File

@ -36,7 +36,7 @@ InsetFoot::InsetFoot(Buffer * buf)
{}
void InsetFoot::updateLabels(ParIterator const & it)
void InsetFoot::updateLabels(ParIterator const & it, bool out)
{
BufferParams const & bp = buffer().masterBuffer()->params();
Counters & cnts = bp.documentClass().counters();
@ -49,7 +49,7 @@ void InsetFoot::updateLabels(ParIterator const & it)
+ ' ' + cnts.theCounter(count, outer.getParLanguage(bp)->code());
setLabel(custom_label_);
}
InsetCollapsable::updateLabels(it);
InsetCollapsable::updateLabels(it, out);
}

View File

@ -38,7 +38,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
/// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
void addToToc(DocIterator const &);
///

View File

@ -1021,18 +1021,18 @@ void InsetInclude::updateCommand()
setParams(p);
}
void InsetInclude::updateLabels(ParIterator const & it)
void InsetInclude::updateLabels(ParIterator const & it, bool out)
{
Buffer const * const childbuffer = getChildBuffer();
if (childbuffer) {
childbuffer->updateLabels(Buffer::UpdateChildOnly);
childbuffer->updateLabels(out, Buffer::UpdateChildOnly);
return;
}
if (!isListings(params()))
return;
if (label_)
label_->updateLabels(it);
label_->updateLabels(it, out);
InsetListingsParams const par(to_utf8(params()["lstparams"]));
if (par.getParamValue("caption").empty()) {

View File

@ -90,7 +90,7 @@ public:
///
void updateCommand();
///
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
static ParamInfo const & findInfo(std::string const &);
///

View File

@ -105,7 +105,7 @@ docstring InsetLabel::screenLabel() const
}
void InsetLabel::updateLabels(ParIterator const &)
void InsetLabel::updateLabels(ParIterator const &, bool)
{
docstring const & label = getParam("name");
if (buffer().insetLabel(label)) {

View File

@ -53,7 +53,7 @@ public:
static bool isCompatibleCommand(std::string const & s)
{ return s == "label"; }
///
void updateLabels(ParIterator const & it);
void updateLabels(ParIterator const & it, bool);
///
void addToToc(DocIterator const &);
///

View File

@ -70,7 +70,7 @@ Inset::DisplayType InsetListings::display() const
}
void InsetListings::updateLabels(ParIterator const & it)
void InsetListings::updateLabels(ParIterator const & it, bool out)
{
Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
string const saveflt = cnts.current_float();
@ -78,7 +78,7 @@ void InsetListings::updateLabels(ParIterator const & it)
// Tell to captions what the current float is
cnts.current_float("listing");
InsetCollapsable::updateLabels(it);
InsetCollapsable::updateLabels(it, out);
//reset afterwards
cnts.current_float(saveflt);

View File

@ -49,7 +49,7 @@ private:
///
docstring name() const { return from_ascii("Listings"); }
// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
void write(std::ostream & os) const;
///

View File

@ -135,7 +135,7 @@ void InsetRef::tocString(odocstream & os) const
}
void InsetRef::updateLabels(ParIterator const & it)
void InsetRef::updateLabels(ParIterator const & it, bool)
{
docstring const & label = getParam("reference");
// register this inset into the buffer reference cache.

View File

@ -67,7 +67,7 @@ public:
///
static bool isCompatibleCommand(std::string const & s);
///
void updateLabels(ParIterator const & it);
void updateLabels(ParIterator const & it, bool);
///
void addToToc(DocIterator const &);
protected:

View File

@ -3320,7 +3320,7 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection)
}
void InsetTabular::updateLabels(ParIterator const & it)
void InsetTabular::updateLabels(ParIterator const & it, bool out)
{
// In a longtable, tell captions what the current float is
Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
@ -3332,7 +3332,7 @@ void InsetTabular::updateLabels(ParIterator const & it)
it2.forwardPos();
size_t const end = it2.nargs();
for ( ; it2.idx() < end; it2.top().forwardIdx())
buffer().updateLabels(it2);
buffer().updateLabels(it2, out);
//reset afterwards
if (tabular.is_long_tabular)

View File

@ -827,7 +827,7 @@ public:
/// can we go further down on mouse click?
bool descendable(BufferView const &) const { return true; }
// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
bool completionSupported(Cursor const &) const;

View File

@ -675,17 +675,17 @@ ParagraphList & InsetText::paragraphs()
}
void InsetText::updateLabels(ParIterator const & it)
void InsetText::updateLabels(ParIterator const & it, bool out)
{
ParIterator it2 = it;
it2.forwardPos();
LASSERT(&it2.inset() == this && it2.pit() == 0, return);
if (producesOutput())
buffer().updateLabels(it2);
buffer().updateLabels(it2, out);
else {
DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
Counters const savecnt = tclass.counters();
buffer().updateLabels(it2);
buffer().updateLabels(it2, out);
tclass.counters() = savecnt;
}
}

View File

@ -167,7 +167,7 @@ public:
{ return getLayout().allowParagraphCustomization(); }
/// Update the counters of this inset and of its contents
virtual void updateLabels(ParIterator const &);
virtual void updateLabels(ParIterator const &, bool);
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -114,7 +114,7 @@ bool InsetWrap::getStatus(Cursor & cur, FuncRequest const & cmd,
}
void InsetWrap::updateLabels(ParIterator const & it)
void InsetWrap::updateLabels(ParIterator const & it, bool out)
{
setLabel(_("wrap: ") + floatName(params_.type));
Counters & cnts =
@ -124,7 +124,7 @@ void InsetWrap::updateLabels(ParIterator const & it)
// Tell to captions what the current float is
cnts.current_float(params().type);
InsetCollapsable::updateLabels(it);
InsetCollapsable::updateLabels(it, out);
// reset afterwards
cnts.current_float(saveflt);

View File

@ -79,7 +79,7 @@ private:
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
/// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///

View File

@ -211,7 +211,7 @@ void InsetMathHull::setBuffer(Buffer & buffer)
}
void InsetMathHull::updateLabels(ParIterator const & it)
void InsetMathHull::updateLabels(ParIterator const & it, bool out)
{
if (!buffer_) {
//FIXME: buffer_ should be set at creation for this inset! Problem is
@ -221,7 +221,7 @@ void InsetMathHull::updateLabels(ParIterator const & it)
}
for (size_t i = 0; i != label_.size(); ++i) {
if (label_[i])
label_[i]->updateLabels(it);
label_[i]->updateLabels(it, out);
}
}

View File

@ -36,7 +36,7 @@ public:
///
void setBuffer(Buffer &);
///
void updateLabels(ParIterator const &);
void updateLabels(ParIterator const &, bool);
///
void addToToc(DocIterator const &);
///