From: Richard Heck Date: Fri, 4 Dec 2009 03:03:38 +0000 (+0000) Subject: This patch introduces an optional argument to Buffer::updateLabels(), so X-Git-Tag: 2.0.0~4927 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=996505c2ae981187d34580633fca410972c2493d;p=features.git 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 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 075aa5c73d..15c7553af2 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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); } } } diff --git a/src/Buffer.h b/src/Buffer.h index 84dee28eee..3e3dbe02b4 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -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 diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 798f311f0b..8d2f1f86df 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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; diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index b236bab705..5eb0d448b4 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -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(); diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index b69e85f6cd..cdbd857873 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 &); + virtual void updateLabels(ParIterator const &, bool); /// void updateCommand(docstring const & new_key, bool dummy = false); /// diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index b5bfbc36fe..9a4af66208 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -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); } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index 2be6c68fbb..3686ec2195 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -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; /// diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 93e79263f6..97f7dfac66 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -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) diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index e85c3b7d0f..bcecd81994 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); + void updateLabels(ParIterator const & it, bool); /// void addToToc(DocIterator const &); diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 05c60bbc37..f05286edff 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -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); diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 0cbf71cf18..35539ece9d 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 &); + void updateLabels(ParIterator const &, bool); /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 779c06727e..f5b3e4a8d7 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -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); } diff --git a/src/insets/InsetFoot.h b/src/insets/InsetFoot.h index 01639bf744..3efc7c89e5 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 &); + void updateLabels(ParIterator const &, bool); /// void addToToc(DocIterator const &); /// diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 265b96e7d9..780554db3f 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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()) { diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index b1973bd6c1..aee16c0043 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -90,7 +90,7 @@ public: /// void updateCommand(); /// - void updateLabels(ParIterator const &); + void updateLabels(ParIterator const &, bool); /// static ParamInfo const & findInfo(std::string const &); /// diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 5ead4901dc..b4199a2bd6 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -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)) { diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 85a5db6d30..491d8ecef4 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -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 &); /// diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index b7baf19829..0174a977f8 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -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); diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 8883b98343..4459c9ee14 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -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; /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index cad59ce4f0..ae7f3b3ca7 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -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. diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 5a90ef1f96..9359d66560 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); + void updateLabels(ParIterator const & it, bool); /// void addToToc(DocIterator const &); protected: diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 742baece13..2678cd9d76 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -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) diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 902a1e1f70..2a09eaa9e7 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -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; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 1dac64d3aa..b7dc42bb72 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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; } } diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 421870b0e6..f810a06fb1 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -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; /// diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index f8e2c5ef98..e92fdb76cd 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -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); diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index cfb80a2ec4..b079997743 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 &); + void updateLabels(ParIterator const &, bool); /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index ac75549e40..66848ad9f3 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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); } } diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 95ae8497b7..197fd303fb 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -36,7 +36,7 @@ public: /// void setBuffer(Buffer &); /// - void updateLabels(ParIterator const &); + void updateLabels(ParIterator const &, bool); /// void addToToc(DocIterator const &); ///