]> git.lyx.org Git - features.git/commitdiff
Fix caption counter in longtables (see #8993).
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 25 Feb 2014 07:00:43 +0000 (08:00 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 25 Feb 2014 07:00:43 +0000 (08:00 +0100)
src/Counters.h
src/insets/InsetCaption.cpp
src/insets/InsetTabular.cpp

index a195889e313ec0d09986cdf1cdf08792c309f926..ce122c4140ebbf71216cee445dfecc20457b3d58 100644 (file)
@@ -172,6 +172,10 @@ public:
        bool isSubfloat() const { return subfloat_; }
        /// Set the state variable indicating whether we are in a subfloat.
        void isSubfloat(bool s) { subfloat_ = s; }
+       /// Are we in a longtable?
+       bool isLongtable() const { return longtable_; }
+       /// Set the state variable indicating whether we are in a longtable.
+       void isLongtable(bool s) { longtable_ = s; }
        
        /// \name refstepcounter        
        // @{
@@ -225,6 +229,8 @@ private:
        std::string current_float_;
        /// Are we in a subfloat?
        bool subfloat_;
+       /// Are we in a longtable?
+       bool longtable_;
        /// Used to keep track of active counters.
        std::vector<docstring> counter_stack_;
        /// Same, but for last layout.
index 2303a1d82a530eb52620cb0879c0ad9f0187c79f..f1f0983810cc8b0b64c16362f86ad36cbb092b5c 100644 (file)
@@ -404,7 +404,9 @@ void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype)
                docstring const labelstring = isAscii(lstring) ?
                                master.B_(to_ascii(lstring)) : lstring;
                if (cnts.hasCounter(counter)) {
-                       cnts.step(counter, utype);
+                       // for longtables, we step the counter upstream
+                       if (!cnts.isLongtable())
+                               cnts.step(counter, utype);
                        sec = cnts.theCounter(counter, lang);
                }
                if (labelstring != master.B_("standard")) {
index b633c492e1b6175180ea4b82c5517821c375ef50..f89c34a285e62a3c44f389ab56362388d4c44e17 100644 (file)
@@ -3897,8 +3897,12 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
        // In a longtable, tell captions what the current float is
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
        string const saveflt = cnts.current_float();
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float("table");
+               // in longtables, we only step the counter once
+               cnts.step(from_ascii("table"), utype);
+               cnts.isLongtable(true);
+       }
 
        ParIterator it2 = it;
        it2.forwardPos();
@@ -3907,8 +3911,10 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
                buffer().updateBuffer(it2, utype);
 
        //reset afterwards
-       if (tabular.is_long_tabular)
+       if (tabular.is_long_tabular) {
                cnts.current_float(saveflt);
+               cnts.isLongtable(false);
+       }
 }