mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Introduce InitialValue tag for counters. Fixes bug #8707.
This commit is contained in:
parent
a853132e12
commit
2374229cc6
@ -19388,6 +19388,37 @@ End
|
||||
The following parameters can also be used:
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted 1414654397 1370012684
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1370012589
|
||||
InitialValue
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 1414654397 1370012639
|
||||
number
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
=1] Sets the initial value for the counter, to which it will be reset whenever
|
||||
that happens.
|
||||
Normally, one will want the default, 1.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
@ -160,6 +160,9 @@ import os, re, string, sys
|
||||
# Incremented to format 47, 23 May 2013 by rgh
|
||||
# Add PackageOptions tag
|
||||
|
||||
# Incremented to format 48, 31 May 2013 by rgh
|
||||
# Add InitialValue tag for counters
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
@ -167,7 +170,7 @@ import os, re, string, sys
|
||||
# development/tools/updatelayouts.sh script to update all
|
||||
# layout files to the new format.
|
||||
|
||||
currentFormat = 47
|
||||
currentFormat = 48
|
||||
|
||||
|
||||
def usage(prog_name):
|
||||
@ -384,7 +387,7 @@ def convert(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format >= 44 and format <= 46:
|
||||
if format >= 44 and format <= 47:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
@ -40,7 +40,7 @@ Counter::Counter()
|
||||
|
||||
Counter::Counter(docstring const & mc, docstring const & ls,
|
||||
docstring const & lsa)
|
||||
: master_(mc), labelstring_(ls), labelstringappendix_(lsa)
|
||||
: initial_value_(0), master_(mc), labelstring_(ls), labelstringappendix_(lsa)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@ -53,11 +53,13 @@ bool Counter::read(Lexer & lex)
|
||||
CT_LABELSTRING,
|
||||
CT_LABELSTRING_APPENDIX,
|
||||
CT_PRETTYFORMAT,
|
||||
CT_INITIALVALUE,
|
||||
CT_END
|
||||
};
|
||||
|
||||
LexerKeyword counterTags[] = {
|
||||
{ "end", CT_END },
|
||||
{ "initialvalue", CT_INITIALVALUE},
|
||||
{ "labelstring", CT_LABELSTRING },
|
||||
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
|
||||
{ "prettyformat", CT_PRETTYFORMAT },
|
||||
@ -83,6 +85,18 @@ bool Counter::read(Lexer & lex)
|
||||
if (master_ == "none")
|
||||
master_.erase();
|
||||
break;
|
||||
case CT_INITIALVALUE:
|
||||
lex.next();
|
||||
initial_value_ = lex.getInteger();
|
||||
// getInteger() returns -1 on error, and larger
|
||||
// negative values do not make much sense.
|
||||
// In the other case, we subtract one, since the
|
||||
// counter will be incremented before its first use.
|
||||
if (initial_value_ <= -1)
|
||||
initial_value_ = 0;
|
||||
else
|
||||
initial_value_ -= 1;
|
||||
break;
|
||||
case CT_PRETTYFORMAT:
|
||||
lex.next();
|
||||
prettyformat_ = lex.getDocString();
|
||||
@ -136,7 +150,7 @@ void Counter::step()
|
||||
|
||||
void Counter::reset()
|
||||
{
|
||||
value_ = 0;
|
||||
value_ = initial_value_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,6 +76,9 @@ public:
|
||||
private:
|
||||
///
|
||||
int value_;
|
||||
/// This is actually one less than the initial value, since the
|
||||
/// counter is always stepped before being used.
|
||||
int initial_value_;
|
||||
/// contains master counter name.
|
||||
/** The master counter is the counter that, if stepped
|
||||
* (incremented) zeroes this counter. E.g. "subsection"'s
|
||||
|
@ -61,7 +61,7 @@ namespace lyx {
|
||||
// development/tools/updatelayouts.sh script, to update the format of
|
||||
// all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 47; //rgh: package options
|
||||
int const LAYOUT_FORMAT = 48; //rgh: initial values for counter
|
||||
|
||||
namespace {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user