mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
IfStyle and IfCounter tags for layout. Docs to follow.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30989 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9b8549f5da
commit
1f8bf874aa
@ -67,7 +67,7 @@ import os, re, string, sys
|
|||||||
# Do not forget to document format change in Customization
|
# Do not forget to document format change in Customization
|
||||||
# Manual (section "Declaring a new text class").
|
# Manual (section "Declaring a new text class").
|
||||||
|
|
||||||
currentFormat = 16
|
currentFormat = 17
|
||||||
|
|
||||||
|
|
||||||
def usage(prog_name):
|
def usage(prog_name):
|
||||||
@ -256,7 +256,7 @@ def convert(lines):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# This just involved new features, not any changes to old ones
|
# This just involved new features, not any changes to old ones
|
||||||
if format == 14 or format == 15:
|
if format == 14 or format == 15 or format == 16:
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -171,18 +171,20 @@ bool Counters::hasCounter(docstring const & c) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Counters::read(Lexer & lex, docstring const & name)
|
bool Counters::read(Lexer & lex, docstring const & name, bool makenew)
|
||||||
{
|
{
|
||||||
if (hasCounter(name)) {
|
if (hasCounter(name)) {
|
||||||
LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name));
|
LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name));
|
||||||
return counterList_[name].read(lex);
|
return counterList_[name].read(lex);
|
||||||
}
|
}
|
||||||
|
|
||||||
LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name));
|
LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name));
|
||||||
Counter cnt;
|
Counter cnt;
|
||||||
bool success = cnt.read(lex);
|
bool success = cnt.read(lex);
|
||||||
if (success)
|
// if makenew is false, we will just discard what we read
|
||||||
|
if (success && makenew)
|
||||||
counterList_[name] = cnt;
|
counterList_[name] = cnt;
|
||||||
else
|
else if (!success)
|
||||||
LYXERR0("Error reading counter `" << name << "'!");
|
LYXERR0("Error reading counter `" << name << "'!");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,10 @@ public:
|
|||||||
/// Checks whether the given counter exists.
|
/// Checks whether the given counter exists.
|
||||||
bool hasCounter(docstring const & c) const;
|
bool hasCounter(docstring const & c) const;
|
||||||
/// reads the counter name
|
/// reads the counter name
|
||||||
|
/// \param makeNew whether to make a new counter if one
|
||||||
|
/// doesn't already exist
|
||||||
/// \return true on success
|
/// \return true on success
|
||||||
bool read(Lexer & lex, docstring const & name);
|
bool read(Lexer & lex, docstring const & name, bool makenew);
|
||||||
///
|
///
|
||||||
void set(docstring const & ctr, int val);
|
void set(docstring const & ctr, int val);
|
||||||
///
|
///
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Keep the changes documented in the Customization manual.
|
// Keep the changes documented in the Customization manual.
|
||||||
int const FORMAT = 16;
|
int const FORMAT = 17;
|
||||||
|
|
||||||
|
|
||||||
bool layout2layout(FileName const & filename, FileName const & tempfile)
|
bool layout2layout(FileName const & filename, FileName const & tempfile)
|
||||||
@ -164,6 +164,7 @@ enum TextClassTags {
|
|||||||
TC_OUTPUTFORMAT,
|
TC_OUTPUTFORMAT,
|
||||||
TC_INPUT,
|
TC_INPUT,
|
||||||
TC_STYLE,
|
TC_STYLE,
|
||||||
|
TC_IFSTYLE,
|
||||||
TC_DEFAULTSTYLE,
|
TC_DEFAULTSTYLE,
|
||||||
TC_INSETLAYOUT,
|
TC_INSETLAYOUT,
|
||||||
TC_NOSTYLE,
|
TC_NOSTYLE,
|
||||||
@ -182,6 +183,7 @@ enum TextClassTags {
|
|||||||
TC_RIGHTMARGIN,
|
TC_RIGHTMARGIN,
|
||||||
TC_FLOAT,
|
TC_FLOAT,
|
||||||
TC_COUNTER,
|
TC_COUNTER,
|
||||||
|
TC_IFCOUNTER,
|
||||||
TC_NOFLOAT,
|
TC_NOFLOAT,
|
||||||
TC_TITLELATEXNAME,
|
TC_TITLELATEXNAME,
|
||||||
TC_TITLELATEXTYPE,
|
TC_TITLELATEXTYPE,
|
||||||
@ -209,6 +211,8 @@ namespace {
|
|||||||
{ "float", TC_FLOAT },
|
{ "float", TC_FLOAT },
|
||||||
{ "format", TC_FORMAT },
|
{ "format", TC_FORMAT },
|
||||||
{ "htmlpreamble", TC_HTMLPREAMBLE },
|
{ "htmlpreamble", TC_HTMLPREAMBLE },
|
||||||
|
{ "ifcounter", TC_IFCOUNTER },
|
||||||
|
{ "ifstyle", TC_IFSTYLE },
|
||||||
{ "input", TC_INPUT },
|
{ "input", TC_INPUT },
|
||||||
{ "insetlayout", TC_INSETLAYOUT },
|
{ "insetlayout", TC_INSETLAYOUT },
|
||||||
{ "leftmargin", TC_LEFTMARGIN },
|
{ "leftmargin", TC_LEFTMARGIN },
|
||||||
@ -352,6 +356,10 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used below to track whether we are in an IfStyle or IfCounter tag.
|
||||||
|
bool ifstyle = false;
|
||||||
|
bool ifcounter = false;
|
||||||
|
|
||||||
switch (static_cast<TextClassTags>(le)) {
|
switch (static_cast<TextClassTags>(le)) {
|
||||||
|
|
||||||
case TC_FORMAT:
|
case TC_FORMAT:
|
||||||
@ -404,6 +412,9 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TC_IFSTYLE:
|
||||||
|
ifstyle = true;
|
||||||
|
// fall through
|
||||||
case TC_STYLE: {
|
case TC_STYLE: {
|
||||||
if (!lexrc.next()) {
|
if (!lexrc.next()) {
|
||||||
lexrc.printError("No name given for style: `$$Token'.");
|
lexrc.printError("No name given for style: `$$Token'.");
|
||||||
@ -423,7 +434,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
} else if (hasLayout(name)) {
|
} else if (hasLayout(name)) {
|
||||||
Layout & lay = operator[](name);
|
Layout & lay = operator[](name);
|
||||||
error = !readStyle(lexrc, lay);
|
error = !readStyle(lexrc, lay);
|
||||||
} else {
|
} else if (!ifstyle) {
|
||||||
Layout layout;
|
Layout layout;
|
||||||
layout.setName(name);
|
layout.setName(name);
|
||||||
error = !readStyle(lexrc, layout);
|
error = !readStyle(lexrc, layout);
|
||||||
@ -436,6 +447,15 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
defaultlayout_ = name;
|
defaultlayout_ = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// scan the rest and discard it
|
||||||
|
Layout lay;
|
||||||
|
readStyle(lexrc, lay);
|
||||||
|
error = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset flag
|
||||||
|
ifstyle = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,6 +625,8 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
readFloat(lexrc);
|
readFloat(lexrc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TC_IFCOUNTER:
|
||||||
|
ifcounter = true;
|
||||||
case TC_COUNTER:
|
case TC_COUNTER:
|
||||||
if (lexrc.next()) {
|
if (lexrc.next()) {
|
||||||
docstring const name = lexrc.getDocString();
|
docstring const name = lexrc.getDocString();
|
||||||
@ -617,12 +639,14 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
|||||||
// and discard it.
|
// and discard it.
|
||||||
c.read(lexrc);
|
c.read(lexrc);
|
||||||
} else
|
} else
|
||||||
error = !counters_.read(lexrc, name);
|
error = !counters_.read(lexrc, name, !ifcounter);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lexrc.printError("No name given for style: `$$Token'.");
|
lexrc.printError("No name given for style: `$$Token'.");
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
// reset flag
|
||||||
|
ifcounter = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TC_TITLELATEXTYPE:
|
case TC_TITLELATEXTYPE:
|
||||||
|
Loading…
Reference in New Issue
Block a user