]> git.lyx.org Git - features.git/commitdiff
This patch introduces an optional argument to Buffer::updateLabels(), so
authorRichard Heck <rgheck@comcast.net>
Fri, 4 Dec 2009 03:03:38 +0000 (03:03 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 4 Dec 2009 03:03:38 +0000 (03:03 +0000)
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

29 files changed:
src/Buffer.cpp
src/Buffer.h
src/insets/Inset.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibitem.h
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetFoot.cpp
src/insets/InsetFoot.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h
src/insets/InsetListings.cpp
src/insets/InsetListings.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/insets/InsetWrap.cpp
src/insets/InsetWrap.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h

index 075aa5c73d07354120614788f2a9e8a851b79036..15c7553af243061be82ea0e0b2fe3a25234eb869 100644 (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);
                }
        }
 }
index 84dee28eee047b25fbc654a9a0f3248b7dd7397d..3e3dbe02b456ad7a0948b32fcd3c141327a53117 100644 (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
index 798f311f0b840a71cbb99137aaceed0c4ec7f40e..8d2f1f86df1735a62e0444fe43fb5c81ea11c081 100644 (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;
index b236bab7050abe7d588375eb88ce59c5f6f7a121..5eb0d448b4f646ef93430fcf7a3dcbda698eb1f8 100644 (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();
index b69e85f6cdd1b847976db762b15ccbf3766bb450..cdbd857873f84130a8dd306e9e073c8472a9dfb6 100644 (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);
        ///
index b5bfbc36fe71e3201a3266613025b78e1bc23907..9a4af662089ef95a23f3ca2d2a3e1b40bb6bfd5c 100644 (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);
 }
 
 
index 2be6c68fbbe9a05f473bafa27df1f03a018c4829..3686ec21951e569893e19a4cd83aa7779697bd95 100644 (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;
        ///
index 93e79263f6f64f331457a3aee8a2b1611424a5e2..97f7dfac66fd6bf1fad4b2d0791918b15a093d22 100644 (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)
index e85c3b7d0f882aa6ef089b0cb41b8e3fb08317b6..bcecd81994579ea3ccf736e539a7c15c9a7cb63a 100644 (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 &);
 
index 05c60bbc371986c3538160b423ffd61f922d6f3c..f05286edffb8d36c88ac3b6995c6d693d99c4997 100644 (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);
index 0cbf71cf1899781ce7e637776c1a5c96172ce85b..35539ece9de5cce67b1390ce76afdaa84adb841f 100644 (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);
        ///
index 779c06727e6cb20b648393972fe1edaeb8a50e84..f5b3e4a8d78b545a15aa25a90bb2e78bacd7dc8a 100644 (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);
 }
 
 
index 01639bf7444672152d198f7d3c780e8869404ade..3efc7c89e5a825ffda83db9ac4f624936a590388 100644 (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 &);
        ///
index 265b96e7d918180280086675fcb57cf79d91161f..780554db3fe83766996beee9dc44833c689c6b95 100644 (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()) {
index b1973bd6c13a97567fe79f219700dcb7ad561f60..aee16c0043358f64d79744ea7f930c4a8e908321 100644 (file)
@@ -90,7 +90,7 @@ public:
        ///
        void updateCommand();
        ///
-       void updateLabels(ParIterator const &);
+       void updateLabels(ParIterator const &, bool);
        ///
        static ParamInfo const & findInfo(std::string const &);
        ///
index 5ead4901dcef25a9c4684efcb14b185896409179..b4199a2bd6fc72bdeefb1ae78ec9c0d5b7613e2b 100644 (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)) {
index 85a5db6d3011e18211395e1e3dd1f76287362b09..491d8ecef42ce3216ee0d9e02323ff0bc8778258 100644 (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 &);
        ///
index b7baf198290e6d18fd2e0db220ebbfe2543e6a04..0174a977f875511590944fdf1edb944e82121ddd 100644 (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);
index 8883b98343b3738d1a514a8acc3475c0b064f756..4459c9ee14a742cb45c89a0352c4584044e73419 100644 (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;
        ///
index cad59ce4f0e9406e1091848203ff23cfd1236789..ae7f3b3ca7e06e971aa9b854b6da16585083597f 100644 (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.
index 5a90ef1f96f1cc988d7a09c81d5f0f806cab3791..9359d665604e83d93b6c8fbf55c0950bd72839e5 100644 (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:
index 742baece13f7b2497de9683ddd208db076243239..2678cd9d76d50040c2e1a1652790a99a3f122c16 100644 (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)
index 902a1e1f7088b33b3e571dd937bd129b0e69bce2..2a09eaa9e7491fcebca910295f3c169eb9652d53 100644 (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;
index 1dac64d3aa1b47ef40891f7baa58c7e87dbd8e3d..b7dc42bb72b02f0f23b02f37de2eff29bbc7f226 100644 (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;
        }
 }
index 421870b0e6b2705e289e68a76c0dfb81053536e3..f810a06fb1a023596105bd969742a87ddee701a4 100644 (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;
        ///
index f8e2c5ef981d17b456105b18035289e65084a07d..e92fdb76cd8eab8f1d8fa002334282ed9eb65a44 100644 (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);
index cfb80a2ec447591c68d335de13e3c3942f1cc05f..b079997743e48f50adccf2826cde8d49455bbf5e 100644 (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);
        ///
index ac75549e406638ea0af3b74df6cfa5e26f56639b..66848ad9f37851550181278cda95393d671f637b 100644 (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);
        }
 }
 
index 95ae8497b7efb47f985e88642dda9397508cf953..197fd303fbc94f3f94a4dfbe5e44bbebe0010f45 100644 (file)
@@ -36,7 +36,7 @@ public:
        ///
        void setBuffer(Buffer &);
        ///
-       void updateLabels(ParIterator const &);
+       void updateLabels(ParIterator const &, bool);
        ///
        void addToToc(DocIterator const &);
        ///