From: Richard Heck Date: Wed, 20 Jan 2010 19:42:12 +0000 (+0000) Subject: Get rid of some magic booleans in updateLabels() and related routines. X-Git-Tag: 2.0.0~4312 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=caa4e94bf02b9d3131bc280390fae44683fd5e9a;p=features.git Get rid of some magic booleans in updateLabels() and related routines. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33110 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 6568fab364..e60ffd0d04 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1498,7 +1498,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os, { LaTeXFeatures features(*this, params(), runparams); validate(features); - updateLabels(UpdateMaster, true); + updateLabels(UpdateMaster, OutputUpdate); checkBibInfoCache(); d->bibinfo_.makeCitationLabels(*this); updateMacros(); @@ -3500,7 +3500,7 @@ void Buffer::setBuffersForInsets() const } -void Buffer::updateLabels(UpdateScope scope, bool out) const +void Buffer::updateLabels(UpdateScope scope, UpdateType utype) const { // Use the master text class also for child documents Buffer const * const master = masterBuffer(); @@ -3518,7 +3518,7 @@ void Buffer::updateLabels(UpdateScope scope, bool out) const // If this is a child document start with the master if (master != this) { bufToUpdate.insert(this); - master->updateLabels(UpdateMaster, out); + master->updateLabels(UpdateMaster, utype); // 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_) @@ -3546,7 +3546,7 @@ void Buffer::updateLabels(UpdateScope scope, bool out) const // do the real work ParIterator parit = cbuf.par_iterator_begin(); - updateLabels(parit, out); + updateLabels(parit, utype); if (master != this) // TocBackend update will be done later. @@ -3628,7 +3628,7 @@ static bool needEnumCounterReset(ParIterator const & it) // set the label of a paragraph. This includes the counters. -void Buffer::setLabel(ParIterator & it, bool for_output) const +void Buffer::setLabel(ParIterator & it, UpdateType utype) const { BufferParams const & bp = this->masterBuffer()->params(); DocumentClass const & textclass = bp.documentClass(); @@ -3660,7 +3660,7 @@ void Buffer::setLabel(ParIterator & it, bool for_output) const if (layout.toclevel <= bp.secnumdepth && (layout.latextype != LATEX_ENVIRONMENT || it.text()->isFirstInSequence(it.pit()))) { - counters.step(layout.counter, for_output); + counters.step(layout.counter, utype); par.params().labelString( par.expandLabel(layout, bp)); } else @@ -3714,7 +3714,7 @@ void Buffer::setLabel(ParIterator & it, bool for_output) const // Maybe we have to reset the enumeration counter. if (needEnumCounterReset(it)) counters.reset(enumcounter); - counters.step(enumcounter, for_output); + counters.step(enumcounter, utype); string const & lang = par.getParLanguage(bp)->code(); par.params().labelString(counters.theCounter(enumcounter, lang)); @@ -3731,7 +3731,7 @@ void Buffer::setLabel(ParIterator & it, bool for_output) const docstring name = this->B_(textclass.floats().getType(type).name()); if (counters.hasCounter(from_utf8(type))) { string const & lang = par.getParLanguage(bp)->code(); - counters.step(from_utf8(type), for_output); + counters.step(from_utf8(type), utype); full_label = bformat(from_ascii("%1$s %2$s:"), name, counters.theCounter(from_utf8(type), lang)); @@ -3757,7 +3757,7 @@ void Buffer::setLabel(ParIterator & it, bool for_output) const } -void Buffer::updateLabels(ParIterator & parit, bool out) const +void Buffer::updateLabels(ParIterator & parit, UpdateType utype) const { LASSERT(parit.pit() == 0, /**/); @@ -3774,7 +3774,7 @@ void Buffer::updateLabels(ParIterator & parit, bool out) const parit->params().depth(min(parit->params().depth(), maxdepth)); maxdepth = parit->getMaxDepthAfter(); - if (out) { + if (utype == OutputUpdate) { // track the active counters // we have to do this for the master buffer, since the local // buffer isn't tracking anything. @@ -3783,14 +3783,14 @@ void Buffer::updateLabels(ParIterator & parit, bool out) const } // set the counter for this paragraph - setLabel(parit, out); + setLabel(parit, utype); // now the insets InsetList::const_iterator iit = parit->insetList().begin(); InsetList::const_iterator end = parit->insetList().end(); for (; iit != end; ++iit) { parit.pos() = iit->pos; - iit->inset->updateLabels(parit, out); + iit->inset->updateLabels(parit, utype); } } } diff --git a/src/Buffer.h b/src/Buffer.h index 297e63208c..deca3a49db 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -12,6 +12,7 @@ #ifndef BUFFER_H #define BUFFER_H +#include "OutputEnums.h" #include "update_flags.h" #include "insets/InsetCode.h" @@ -552,13 +553,13 @@ public: /// Updates screen labels and some other information associated with /// insets and paragraphs. Actually, it's more like a general "recurse /// through the Buffer" routine, that visits all the insets and paragraphs. - void updateLabels() const { updateLabels(UpdateMaster, false); } + void updateLabels() const { updateLabels(UpdateMaster, InternalUpdate); } /// \param scope: whether to start with the master document or just /// do this one. /// \param output: whether we are preparing for output. - void updateLabels(UpdateScope scope, bool output) const; + void updateLabels(UpdateScope scope, UpdateType utype) const; /// - void updateLabels(ParIterator & parit, bool output) const; + void updateLabels(ParIterator & parit, UpdateType utype) const; /// Spellcheck starting from \p from. /// \p from initial position, will then points to the next misspelled @@ -579,7 +580,7 @@ private: void updateMacros(DocIterator & it, DocIterator & scope) const; /// - void setLabel(ParIterator & it) const; + void setLabel(ParIterator & it, UpdateType utype) const; /// void collectRelatives(BufferSet & bufs) const; diff --git a/src/Counters.cpp b/src/Counters.cpp index fff4ac7d92..626596a833 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -227,7 +227,7 @@ int Counters::value(docstring const & ctr) const } -void Counters::step(docstring const & ctr, bool track_counters) +void Counters::step(docstring const & ctr, UpdateType utype) { CounterList::iterator it = counterList_.find(ctr); if (it == counterList_.end()) { @@ -237,7 +237,7 @@ void Counters::step(docstring const & ctr, bool track_counters) } it->second.step(); - if (track_counters) { + if (utype == OutputUpdate) { LASSERT(!counter_stack_.empty(), /* */); counter_stack_.pop_back(); counter_stack_.push_back(ctr); diff --git a/src/Counters.h b/src/Counters.h index d32f477ea8..16f1d98184 100644 --- a/src/Counters.h +++ b/src/Counters.h @@ -15,6 +15,8 @@ #ifndef COUNTERS_H #define COUNTERS_H +#include "OutputEnums.h" + #include "support/docstring.h" #include @@ -116,7 +118,7 @@ public: /// Sub-slaves are not zeroed! That happens at slave's first /// step 0->1. Seems to be sufficient. /// \param for_output: whether to track the counters - void step(docstring const & ctr, bool track_counters = false); + void step(docstring const & ctr, UpdateType = InternalUpdate); /// Reset all counters. void reset(); /// Reset counters matched by match string. diff --git a/src/insets/Inset.h b/src/insets/Inset.h index ec69809bd8..8b56f802cd 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -18,6 +18,7 @@ #include "ColorCode.h" #include "InsetCode.h" #include "Layout.h" +#include "OutputEnums.h" #include "support/strfwd.h" #include "support/types.h" @@ -472,7 +473,7 @@ public: /// 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) {} + virtual void updateLabels(ParIterator const &, UpdateType) {} /// Updates the inset's dialog virtual Buffer const * updateFrontend() const; diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 123c639a62..ded2b8b9cc 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -254,13 +254,13 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) // Update the counters of this inset and of its contents -void InsetBibitem::updateLabels(ParIterator const & it, bool) +void InsetBibitem::updateLabels(ParIterator const & it, UpdateType utype) { BufferParams const & bp = buffer().masterBuffer()->params(); Counters & counters = bp.documentClass().counters(); docstring const bibitem = from_ascii("bibitem"); if (counters.hasCounter(bibitem) && getParam("label").empty()) { - counters.step(bibitem); + counters.step(bibitem, utype); string const & lang = it.paragraph().getParLanguage(bp)->code(); autolabel_ = counters.theCounter(bibitem, lang); } else { diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index cdbd857873..98fdf9ff8e 100644 --- a/src/insets/InsetBibitem.h +++ b/src/insets/InsetBibitem.h @@ -65,7 +65,7 @@ private: /// virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const; /// Update the counter of this inset - virtual void updateLabels(ParIterator const &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void updateCommand(docstring const & new_key, bool dummy = false); /// diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 4b84a8190f..b9ed6029dd 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -307,14 +307,14 @@ docstring InsetCaption::getCaptionAsHTML(XHTMLStream & xs, } -void InsetCaption::updateLabels(ParIterator const & it, bool out) +void InsetCaption::updateLabels(ParIterator const & it, UpdateType utype) { Buffer const & master = *buffer().masterBuffer(); DocumentClass const & tclass = master.params().documentClass(); string const & lang = it.paragraph().getParLanguage(master.params())->code(); Counters & cnts = tclass.counters(); string const & type = cnts.current_float(); - if (out) { + if (utype == OutputUpdate) { // counters are local to the caption cnts.saveLastCounter(); } @@ -337,7 +337,7 @@ void InsetCaption::updateLabels(ParIterator const & it, bool out) master.B_(tclass.floats().getType(type).name())); } if (cnts.hasCounter(counter)) { - cnts.step(counter, out); + cnts.step(counter, utype); full_label_ = bformat(from_ascii("%1$s %2$s:"), name, cnts.theCounter(counter, lang)); @@ -346,8 +346,8 @@ void InsetCaption::updateLabels(ParIterator const & it, bool out) } // Do the real work now. - InsetText::updateLabels(it, out); - if (out) + InsetText::updateLabels(it, utype); + if (utype == OutputUpdate) cnts.restoreLastCounter(); } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index 81eee6ee12..e24808e853 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -64,7 +64,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 &, bool); + void updateLabels(ParIterator const &, UpdateType); /// int latex(odocstream & os, OutputParams const &) const; /// diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 7c4caa742e..0e59af21f7 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -457,7 +457,7 @@ docstring InsetCitation::screenLabel() const } -void InsetCitation::updateLabels(ParIterator const &, bool) +void InsetCitation::updateLabels(ParIterator const &, UpdateType utype) { CiteEngine const engine = buffer().params().citeEngine(); if (cache.params == params() && cache.engine == engine) diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index aff0894560..64996e7403 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -56,7 +56,7 @@ public: /// void validate(LaTeXFeatures &) const; /// - void updateLabels(ParIterator const & it, bool); + void updateLabels(ParIterator const & it, UpdateType); /// void addToToc(DocIterator const &); diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 97180b3353..00cb7bd723 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -195,11 +195,11 @@ bool InsetFloat::getStatus(Cursor & cur, FuncRequest const & cmd, } -void InsetFloat::updateLabels(ParIterator const & it, bool out) +void InsetFloat::updateLabels(ParIterator const & it, UpdateType utype) { Counters & cnts = buffer().masterBuffer()->params().documentClass().counters(); - if (out) { + if (utype == OutputUpdate) { // counters are local to the float cnts.saveLastCounter(); } @@ -217,11 +217,11 @@ void InsetFloat::updateLabels(ParIterator const & it, bool out) cnts.current_float(params().type); cnts.isSubfloat(subflt); - InsetCollapsable::updateLabels(it, out); + InsetCollapsable::updateLabels(it, utype); //reset afterwards cnts.current_float(saveflt); - if (out) + if (utype == OutputUpdate) cnts.restoreLastCounter(); cnts.isSubfloat(savesubflt); } diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 35539ece9d..3edba34314 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -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 &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index f184e4bc79..48a70817cb 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -36,11 +36,11 @@ InsetFoot::InsetFoot(Buffer * buf) {} -void InsetFoot::updateLabels(ParIterator const & it, bool out) +void InsetFoot::updateLabels(ParIterator const & it, UpdateType utype) { BufferParams const & bp = buffer().masterBuffer()->params(); Counters & cnts = bp.documentClass().counters(); - if (out) { + if (utype == OutputUpdate) { // the footnote counter is local to this inset cnts.saveLastCounter(); } @@ -48,13 +48,13 @@ void InsetFoot::updateLabels(ParIterator const & it, bool out) InsetLayout const & il = getLayout(); docstring const & count = il.counter(); if (!outer.layout().intitle && cnts.hasCounter(count)) { - cnts.step(count, out); + cnts.step(count, utype); custom_label_= translateIfPossible(il.labelstring()) + ' ' + cnts.theCounter(count, outer.getParLanguage(bp)->code()); setLabel(custom_label_); } - InsetCollapsable::updateLabels(it, out); - if (out) + InsetCollapsable::updateLabels(it, utype); + if (utype == OutputUpdate) cnts.restoreLastCounter(); } diff --git a/src/insets/InsetFoot.h b/src/insets/InsetFoot.h index 3efc7c89e5..28aee678b9 100644 --- a/src/insets/InsetFoot.h +++ b/src/insets/InsetFoot.h @@ -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 &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void addToToc(DocIterator const &); /// diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index e65cdd637f..aa1c00fd80 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -1047,18 +1047,18 @@ void InsetInclude::updateCommand() setParams(p); } -void InsetInclude::updateLabels(ParIterator const & it, bool out) +void InsetInclude::updateLabels(ParIterator const & it, UpdateType utype) { Buffer const * const childbuffer = getChildBuffer(); if (childbuffer) { - childbuffer->updateLabels(Buffer::UpdateChildOnly, out); + childbuffer->updateLabels(Buffer::UpdateChildOnly, utype); return; } if (!isListings(params())) return; if (label_) - label_->updateLabels(it, out); + label_->updateLabels(it, utype); InsetListingsParams const par(to_utf8(params()["lstparams"])); if (par.getParamValue("caption").empty()) { @@ -1070,7 +1070,7 @@ void InsetInclude::updateLabels(ParIterator const & it, bool out) docstring const cnt = from_ascii("listing"); listings_label_ = master.B_("Program Listing"); if (counters.hasCounter(cnt)) { - counters.step(cnt); + counters.step(cnt, utype); listings_label_ += " " + convert(counters.value(cnt)); } } diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index d0c5263a21..428a2dd7cc 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -94,7 +94,7 @@ public: /// void updateCommand(); /// - void updateLabels(ParIterator const &, bool); + void updateLabels(ParIterator const &, UpdateType); /// static ParamInfo const & findInfo(std::string const &); /// diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 840a6341d5..edcf5ec742 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -108,7 +108,7 @@ docstring InsetLabel::screenLabel() const } -void InsetLabel::updateLabels(ParIterator const & par, bool out) +void InsetLabel::updateLabels(ParIterator const & par, UpdateType utype) { docstring const & label = getParam("name"); if (buffer().insetLabel(label)) { @@ -119,7 +119,7 @@ void InsetLabel::updateLabels(ParIterator const & par, bool out) buffer().setInsetLabel(label, this); screen_label_ = label; - if (out) { + if (utype) { // save info on the active counter Counters const & cnts = buffer().masterBuffer()->params().documentClass().counters(); diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 8c3f3ae970..1ad8da9b16 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -55,7 +55,7 @@ public: static bool isCompatibleCommand(std::string const & s) { return s == "label"; } /// - void updateLabels(ParIterator const & it, bool); + void updateLabels(ParIterator const & it, UpdateType); /// void addToToc(DocIterator const &); /// diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 78a97b875b..de690f7c19 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -71,7 +71,7 @@ Inset::DisplayType InsetListings::display() const } -void InsetListings::updateLabels(ParIterator const & it, bool out) +void InsetListings::updateLabels(ParIterator const & it, UpdateType utype) { Counters & cnts = buffer().masterBuffer()->params().documentClass().counters(); string const saveflt = cnts.current_float(); @@ -79,7 +79,7 @@ void InsetListings::updateLabels(ParIterator const & it, bool out) // Tell to captions what the current float is cnts.current_float("listing"); - InsetCollapsable::updateLabels(it, out); + InsetCollapsable::updateLabels(it, utype); //reset afterwards cnts.current_float(saveflt); diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 1e4135c3ef..d11612282d 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -48,7 +48,7 @@ private: /// docstring name() const { return from_ascii("Listings"); } // Update the counters of this inset and of its contents - void updateLabels(ParIterator const &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void write(std::ostream & os) const; /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 647347bc8d..f292caf32e 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -161,7 +161,7 @@ void InsetRef::tocString(odocstream & os) const } -void InsetRef::updateLabels(ParIterator const & it, bool) +void InsetRef::updateLabels(ParIterator const & it, UpdateType) { docstring const & label = getParam("reference"); // register this inset into the buffer reference cache. diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 9359d66560..afcaaf4974 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -67,7 +67,7 @@ public: /// static bool isCompatibleCommand(std::string const & s); /// - void updateLabels(ParIterator const & it, bool); + void updateLabels(ParIterator const & it, UpdateType); /// void addToToc(DocIterator const &); protected: diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 390b08eedc..902814a723 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -3398,7 +3398,7 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection) } -void InsetTabular::updateLabels(ParIterator const & it, bool out) +void InsetTabular::updateLabels(ParIterator const & it, UpdateType utype) { // In a longtable, tell captions what the current float is Counters & cnts = buffer().masterBuffer()->params().documentClass().counters(); @@ -3410,7 +3410,7 @@ void InsetTabular::updateLabels(ParIterator const & it, bool out) it2.forwardPos(); size_t const end = it2.nargs(); for ( ; it2.idx() < end; it2.top().forwardIdx()) - buffer().updateLabels(it2, out); + buffer().updateLabels(it2, utype); //reset afterwards if (tabular.is_long_tabular) diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 922e13ae31..bc72937741 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -836,7 +836,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 &, bool); + void updateLabels(ParIterator const &, UpdateType); /// bool completionSupported(Cursor const &) const; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 39fa0937f3..8761c98f75 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -504,7 +504,7 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & runpara if ((opts & WriteLabel) && !il.counter().empty()) { BufferParams const & bp = buffer().masterBuffer()->params(); Counters & cntrs = bp.documentClass().counters(); - cntrs.step(il.counter(), true); + cntrs.step(il.counter(), OutputUpdate); // FIXME: translate to paragraph language if (!il.htmllabel().empty()) { docstring const lbl = @@ -648,23 +648,21 @@ ParagraphList & InsetText::paragraphs() } -void InsetText::updateLabels(ParIterator const & it, bool out) +void InsetText::updateLabels(ParIterator const & it, UpdateType utype) { ParIterator it2 = it; it2.forwardPos(); LASSERT(&it2.inset() == this && it2.pit() == 0, return); if (producesOutput()) { - // FIXME We only want to do this, in fact, for some insets. - // But we'll need layout info for that. InsetLayout const & il = getLayout(); - bool const save_layouts = out && il.htmlisblock(); + bool const save_layouts = utype == OutputUpdate && il.htmlisblock(); Counters & cnt = buffer().masterBuffer()->params().documentClass().counters(); if (save_layouts) { // LYXERR0("Entering " << name()); cnt.clearLastLayout(); // FIXME cnt.saveLastCounter()? } - buffer().updateLabels(it2, out); + buffer().updateLabels(it2, utype); if (save_layouts) { // LYXERR0("Exiting " << name()); cnt.restoreLastLayout(); @@ -676,7 +674,7 @@ void InsetText::updateLabels(ParIterator const & it, bool out) // tclass.counters().clearLastLayout() // since we are saving and restoring the existing counters, etc. Counters const savecnt = tclass.counters(); - buffer().updateLabels(it2, out); + buffer().updateLabels(it2, utype); tclass.counters() = savecnt; } } diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 43ef3f717d..8c1f6842e7 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -164,7 +164,7 @@ public: { return getLayout().allowParagraphCustomization(); } /// Update the counters of this inset and of its contents - virtual void updateLabels(ParIterator const &, bool); + virtual void updateLabels(ParIterator const &, UpdateType); /// the string that is passed to the TOC void tocString(odocstream &) const; /// diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index c12628b61f..03d5ed528f 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -114,12 +114,12 @@ bool InsetWrap::getStatus(Cursor & cur, FuncRequest const & cmd, } -void InsetWrap::updateLabels(ParIterator const & it, bool out) +void InsetWrap::updateLabels(ParIterator const & it, UpdateType utype) { setLabel(_("wrap: ") + floatName(params_.type)); Counters & cnts = buffer().masterBuffer()->params().documentClass().counters(); - if (out) { + if (utype == OutputUpdate) { // counters are local to the wrap cnts.saveLastCounter(); } @@ -128,11 +128,11 @@ void InsetWrap::updateLabels(ParIterator const & it, bool out) // Tell to captions what the current float is cnts.current_float(params().type); - InsetCollapsable::updateLabels(it, out); + InsetCollapsable::updateLabels(it, utype); // reset afterwards cnts.current_float(saveflt); - if (out) + if (utype == OutputUpdate) cnts.restoreLastCounter(); } diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index b079997743..5c601c894a 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -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 &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index cf21d152f5..79ac46e52f 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -213,7 +213,7 @@ void InsetMathHull::setBuffer(Buffer & buffer) } -void InsetMathHull::updateLabels(ParIterator const & it, bool out) +void InsetMathHull::updateLabels(ParIterator const & it, UpdateType utype) { if (!buffer_) { //FIXME: buffer_ should be set at creation for this inset! Problem is @@ -223,7 +223,7 @@ void InsetMathHull::updateLabels(ParIterator const & it, bool out) } for (size_t i = 0; i != label_.size(); ++i) { if (label_[i]) - label_[i]->updateLabels(it, out); + label_[i]->updateLabels(it, utype); } } diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index db4d2ff89c..1e94d6badc 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -14,6 +14,8 @@ #include "InsetMathGrid.h" +#include "OutputEnums.h" + #include @@ -36,7 +38,7 @@ public: /// void setBuffer(Buffer &); /// - void updateLabels(ParIterator const &, bool); + void updateLabels(ParIterator const &, UpdateType); /// void addToToc(DocIterator const &); /// diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 212d1f6eab..85b58774fc 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -573,7 +573,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf, for (; par != pend; ++par) { Layout const & lay = par->layout(); if (!lay.counter.empty()) - buf.params().documentClass().counters().step(lay.counter); + buf.params().documentClass().counters().step(lay.counter, OutputUpdate); // FIXME We should see if there's a label to be output and // do something with it. if (par != pbegin) @@ -674,7 +674,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf, && (par == pbegin || !isNormalEnv(style)) && cnts.hasCounter(cntr) ) - cnts.step(cntr); + cnts.step(cntr, OutputUpdate); ParagraphList::const_iterator send; // this will be positive, if we want to skip the initial word // (if it's been taken for the label). @@ -786,7 +786,7 @@ void makeCommand(Buffer const & buf, { Layout const & style = pbegin->layout(); if (!style.counter.empty()) - buf.params().documentClass().counters().step(style.counter); + buf.params().documentClass().counters().step(style.counter, OutputUpdate); openTag(xs, style); diff --git a/src/sgml.cpp b/src/sgml.cpp index 7b899f223c..f895287195 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -220,6 +220,7 @@ void sgml::openTag(Buffer const & buf, odocstream & os, if (param.find('#') != string::npos) { // FIXME UNICODE if (!style.counter.empty()) + // NOTE This could use OutputUpdate and track the counters. counters.step(style.counter); else counters.step(from_ascii(name));