]> git.lyx.org Git - features.git/commitdiff
Some small counters work
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 11 Aug 2002 20:34:20 +0000 (20:34 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 11 Aug 2002 20:34:20 +0000 (20:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4936 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/counters.C
src/counters.h
src/paragraph.C
src/paragraph.h
src/paragraph_pimpl.h
src/text2.C

index 22d5dda7a17dd61fc67f2545484159ef4933a23b..202865fed5b066e19da20fee113905360e9949f2 100644 (file)
@@ -1,20 +1,33 @@
+2002-08-11  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * paragraph_pimpl.h: remove inclusion of boost/array.hpp, remove
+       unused class variable counter_,
+
+       * paragraph.[Ch] (getFirstCounter): delete unused function 
+
+       * counters.C: include LAssert.h
+       (reset): add a new function with no arg, change other version to
+       not have def. arg and to not allow empty arg.
+
+       * text2.C (setCounter): remove empty arg from call to Counters::reset
+
 2002-08-11  John Levon  <levon@movementarian.org>
 
        * Makefile.am: add WordLangTuple.h
+
 2002-08-11  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * paragraph.C, ToolbarDefaults.h, kbsequence.h, lyx_main.C,
-       lyxfunc.C lyxlex_pimpl.C: ws changes only. 
+       lyxfunc.C lyxlex_pimpl.C: ws changes only.
 
        * insets/insettext.C: InsetList changes
-       
+
        * graphics/GraphicsSupport.C (operator()): InsetList changes
-       
+
        * toc.C (getTocList): InsetList changes
-       
+
        * paragraph_pimpl.[Ch]: InsetList changes
-       
+
        * paragraph.[Ch]: InsetList changes
 
        * buffer.C (inset_iterator): InsetList changes
index c6d5745ad1a62bab49ea9d1211d64fdd970374f3..e9c0ed0455f275ed5ff6b2c481b1a0eb4d5e1a1a 100644 (file)
@@ -18,6 +18,7 @@
 #include "counters.h"
 #include "debug.h"
 #include "support/lstrings.h"
+#include "support/LAssert.h"
 
 using std::endl;
 using std::vector;
@@ -198,12 +199,25 @@ void Counters::step(string const & ctr)
        }
 }
 
+
+void Counters::reset()
+{
+       CounterList::iterator it = counterList.begin();
+       CounterList::iterator end = counterList.end();
+       for (; it != end; ++it) {
+               it->second.reset();
+       }
+}
+
+
 void Counters::reset(string const & match)
 {
+       lyx::Assert(!match.empty());
+
        CounterList::iterator it = counterList.begin();
        CounterList::iterator end = counterList.end();
        for (; it != end; ++it) {
-               if (it->first.find(match) != string::npos || match == "")
+               if (it->first.find(match) != string::npos)
                        it->second.reset();
        }
 }
index 680005962c770c5aaef16663220efcfa03589fbf..69c4983be810e318b611d813671966d9e2bae068 100644 (file)
@@ -45,20 +45,20 @@ public:
 
 private:
        int value_;
-       /// contains master counter name; master counter is the counter 
-       /// that, if stepped (incremented) zeroes this counter. E.g. 
+       /// contains master counter name; master counter is the counter
+       /// that, if stepped (incremented) zeroes this counter. E.g.
        /// "subparagraph"'s master is "paragraph".
        string master_;
 };
 
 
-/// This is a class of (La)TeX type counters. 
+/// This is a class of (La)TeX type counters.
 /// Every instantiation is an array of counters of type Counter.
 class Counters {
 public:
        ///
        Counters();
-       ///     
+       ///
        //~Counters();
        /// Add a new counter to array.
        void newCounter(string const & newc);
@@ -75,30 +75,31 @@ public:
        /// NOTE sub-slaves not zeroed! That happens at slave's
        /// first step 0->1. Seems to be sufficient.
        void step(string const & ctr);
-       /// Reset counters matched by match string. Empty string matches
-       /// all.
-       void reset(string const & match = string());
-       /// Copy counters whose name matches match from the &from to 
+       /// Reset all counters.
+       void reset();
+       /// Reset counters matched by match string.
+       void reset(string const & match);
+       /// Copy counters whose name matches match from the &from to
        /// the &to array of counters. Empty string matches all.
        void copy(Counters & from, Counters & to, string const & match = string());
        /// A numeric label's single item, like .1 for subsection number in
        /// the 2.1.4 subsubsection number label. "first" indicates if this
        /// is the first item to be displayed, usually chapter or section.
        string labelItem(string const & ctr,
-                       string const & labeltype, 
+                       string const & labeltype,
                        string const & langtype = "latin",
                        bool first = false);
        /// A complete numeric label, like 2.1.4 for a subsubsection.
        /// "head" indicates sequence number of first item to be
        /// displayed, e.g. 0 for chapter, 1 for section.
        string numberLabel(string const & ctr,
-                       string const & labeltype, 
+                       string const & labeltype,
                        string const & langtype = "latin",
                        int head = 0);
        /// Maps numbers to enumeration of sectioning counter name strings.
        std::vector<string> enums;
        std::vector<string> sects;
-       
+
 private:
        /// Maps counter (layout) names to actual counters.
        typedef std::map<string, Counter> CounterList;
index 50723296514d60d7e68812d0cfb0807da9611d1e..84822bdf47a532af9c888233849b1600d0e898eb 100644 (file)
@@ -984,12 +984,6 @@ string const & Paragraph::getLabelstring() const
 }
 
 
-int Paragraph::getFirstCounter(int i) const
-{
-       return pimpl_->counter_[i];
-}
-
-
 // the next two functions are for the manual labels
 string const Paragraph::getLabelWidthString() const
 {
index 8550c4ce42d58188fe7cd5571f27b46cd125b85d..10023bf801c10e9d9bf3a8402541376ba03c2453 100644 (file)
@@ -222,8 +222,6 @@ public:
        ///
        void applyLayout(LyXLayout_ptr const & new_layout);
        ///
-       int getFirstCounter(int i) const;
-       ///
        void erase(lyx::pos_type pos);
        /** the flag determines wether the layout should be copied
         */
index 8ccb6e3944fb985b41ca4561858ec282309cf40f..37bb7ebd48fdc26ff567c76bd6fb9efcf12f195a 100644 (file)
@@ -20,8 +20,6 @@
 #include "ParagraphParameters.h"
 #include "counters.h"
 
-#include <boost/array.hpp>
-
 class LyXLayout;
 
 struct Paragraph::Pimpl {
@@ -59,9 +57,7 @@ struct Paragraph::Pimpl {
                                  BufferParams const & bparams) const;
        ///
        Inset * inset_owner;
-       ///
-       boost::array<int, 10> counter_;
-
+       
        /** A font entry covers a range of positions. Notice that the
            entries in the list are inserted in random order.
            I don't think it's worth the effort to implement a more effective
@@ -151,7 +147,6 @@ struct Paragraph::Pimpl {
        ParagraphParameters params;
        ///
        Counters ctrs;
-
 private:
        /// match a string against a particular point in the paragraph
        bool isTextAt(string const & str, lyx::pos_type pos) const;
index 8a75ef37a974c7f965f44319145180de66276f76..a66e3cde4600f6ff10740f642f96534b8c24cbf2 100644 (file)
@@ -1227,12 +1227,12 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                par->params().appendix(par->previous()->params().appendix());
                if (!par->params().appendix() && par->params().startOfAppendix()) {
                        par->params().appendix(true);
-                       par->counters().reset("");
+                       par->counters().reset();
                }
                par->enumdepth = par->previous()->enumdepth;
                par->itemdepth = par->previous()->itemdepth;
        } else {
-               par->counters().reset("");
+               par->counters().reset();
                par->params().appendix(par->params().startOfAppendix());
                par->enumdepth = 0;
                par->itemdepth = 0;