]> git.lyx.org Git - features.git/blobdiff - src/Counters.h
Improved character count statistics for letter based insets (e.g. the LyX logo).
[features.git] / src / Counters.h
index 536dcc17a6a9321b3226e747dbae9c77aed57ac7..ffc091b2adfcc4a889b26f930ad658e8c919aaa9 100644 (file)
@@ -35,7 +35,7 @@ public:
        Counter();
        ///
        Counter(docstring const & mc, docstring const & ls,
-               docstring const & lsa);
+               docstring const & lsa, docstring const & guiname);
        /// \return true on success
        bool read(Lexer & lex);
        ///
@@ -45,6 +45,10 @@ public:
        ///
        int value() const;
        ///
+       void saveValue();
+       ///
+       void restoreValue();
+       ///
        void step();
        ///
        void reset();
@@ -63,6 +67,8 @@ public:
        /// Similar, but used for formatted references in XHTML output.
        /// E.g., for a section counter it might be "section \thesection"
        docstring const & prettyFormat() const { return prettyformat_; }
+       ///
+       docstring const & guiName() const { return guiname_; }
 
        /// Returns a map of LaTeX-like strings to format the counter.
        /** For each language, the string is similar to what one gets
@@ -79,6 +85,8 @@ private:
        /// This is actually one less than the initial value, since the
        /// counter is always stepped before being used.
        int initial_value_;
+       ///
+       int saved_value_;
        /// contains master counter name.
        /** The master counter is the counter that, if stepped
         *  (incremented) zeroes this counter. E.g. "subsection"'s
@@ -91,6 +99,8 @@ private:
        docstring labelstringappendix_;
        /// Similar, but used for formatted references in XHTML output
        docstring prettyformat_;
+       ///
+       docstring guiname_;
        /// Cache of the labelstring with \\the<counter> expressions expanded,
        /// indexed by language
        mutable StringMap flatlabelstring_;
@@ -114,7 +124,8 @@ public:
        void newCounter(docstring const & newc,
                        docstring const & masterc,
                        docstring const & ls,
-                       docstring const & lsa);
+                       docstring const & lsa,
+                       docstring const & guiname);
        /// Checks whether the given counter exists.
        bool hasCounter(docstring const & c) const;
        /// reads the counter name
@@ -128,6 +139,10 @@ public:
        void addto(docstring const & ctr, int val);
        ///
        int value(docstring const & ctr) const;
+       ///
+       void saveValue(docstring const & ctr) const;
+       ///
+       void restoreValue(docstring const & ctr) const;
        /// Reset recursively all the counters that are slaves of the one named by \c ctr.
        void resetSlaves(docstring const & ctr);
        /// Increment by one master of counter named by \c ctr.
@@ -164,6 +179,8 @@ public:
        /// format given by Counter::prettyFormat().
        docstring prettyCounter(docstring const & cntr,
                               std::string const & lang) const;
+       ///
+       docstring const & guiName(docstring const & cntr) const;
        /// Are we in appendix?
        bool appendix() const { return appendix_; }
        /// Set the state variable indicating whether we are in appendix.
@@ -193,7 +210,7 @@ public:
        /// Also for updateBuffer().
        /// Call this when entering things like footnotes, where there is now
        /// no "last layout" and we want to restore the "last layout" on exit.
-       void clearLastLayout() { layout_stack_.push_back(0); }
+       void clearLastLayout() { layout_stack_.push_back(nullptr); }
        /// Call this when exiting things like footnotes.
        void restoreLastLayout() { layout_stack_.pop_back(); }
        ///
@@ -202,6 +219,8 @@ public:
        ///
        void restoreLastCounter() { counter_stack_.pop_back(); }
        // @}
+       ///
+       std::vector<docstring> listOfCounters() const;
 private:
        /** expands recursively any \\the<counter> macro in the
         *  labelstring of \c counter.  The \c lang code is used to