mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Never, never use a string for something that has 3 values
This commit replaces the string math_number_before by a proper math_number enum.
Note that the _before naming was misleading. It was chosen at a time
when we were not sure whether leqno was always left or could be right
in RtL documents.
Note that the token in LyX document is still \math_number_before and
this should be changed.
Fixup for 19cc4a1f
.
This commit is contained in:
parent
c200e49d67
commit
d4685f2806
@ -385,7 +385,7 @@ BufferParams::BufferParams()
|
||||
makeDocumentClass();
|
||||
paragraph_separation = ParagraphIndentSeparation;
|
||||
is_math_indent = false;
|
||||
math_number_before = "default";
|
||||
math_number = DEFAULT;
|
||||
quotes_style = InsetQuotesParams::EnglishQuotes;
|
||||
dynamic_quotes = false;
|
||||
fontsize = "default";
|
||||
@ -854,7 +854,14 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
lex.next();
|
||||
pimpl_->mathindent = Length(lex.getString());
|
||||
} else if (token == "\\math_number_before") {
|
||||
lex >> math_number_before;
|
||||
string tmp;
|
||||
lex >> tmp;
|
||||
if (tmp == "true")
|
||||
math_number = LEFT;
|
||||
else if (tmp == "false")
|
||||
math_number = RIGHT;
|
||||
else
|
||||
math_number = DEFAULT;
|
||||
} else if (token == "\\quotes_style") {
|
||||
string qstyle;
|
||||
lex >> qstyle;
|
||||
@ -1355,7 +1362,17 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
|
||||
os << "\n\\is_math_indent " << is_math_indent;
|
||||
if (is_math_indent && !getMathIndent().empty())
|
||||
os << "\n\\math_indentation " << getMathIndent().asString();
|
||||
os << "\n\\math_number_before " << math_number_before;
|
||||
os << "\n\\math_number_before ";
|
||||
switch(math_number) {
|
||||
case LEFT:
|
||||
os << "true";
|
||||
break;
|
||||
case RIGHT:
|
||||
os << "false";
|
||||
break;
|
||||
case DEFAULT:
|
||||
os << "default";
|
||||
}
|
||||
os << "\n\\quotes_style "
|
||||
<< string_quotes_style[quotes_style]
|
||||
<< "\n\\dynamic_quotes " << dynamic_quotes
|
||||
@ -1640,11 +1657,16 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
if (is_math_indent)
|
||||
clsoptions << "fleqn,";
|
||||
|
||||
if (math_number_before == "true")
|
||||
switch(math_number) {
|
||||
case LEFT:
|
||||
clsoptions << "leqno,";
|
||||
else if (math_number_before == "false") {
|
||||
break;
|
||||
case RIGHT:
|
||||
clsoptions << "reqno,";
|
||||
features.require("amsmath");
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
}
|
||||
|
||||
// language should be a parameter to \documentclass
|
||||
|
@ -110,8 +110,9 @@ public:
|
||||
bool is_math_indent;
|
||||
|
||||
|
||||
/// number formulas before or not
|
||||
std::string math_number_before;
|
||||
enum MathNumber { DEFAULT, LEFT, RIGHT };
|
||||
/// number formulas on left/right/default
|
||||
MathNumber math_number;
|
||||
|
||||
/** Whether paragraphs are separated by using a indent like in
|
||||
* articles or by using a little skip like in letters.
|
||||
|
@ -2943,17 +2943,17 @@ void GuiDocument::applyView()
|
||||
}
|
||||
switch (mathsModule->MathNumberingPosCO->currentIndex()) {
|
||||
case 0:
|
||||
bp_.math_number_before = "true";
|
||||
bp_.math_number = BufferParams::LEFT;
|
||||
break;
|
||||
case 1:
|
||||
bp_.math_number_before = "default";
|
||||
bp_.math_number = BufferParams::DEFAULT;
|
||||
break;
|
||||
case 2:
|
||||
bp_.math_number_before = "false";
|
||||
bp_.math_number = BufferParams::RIGHT;
|
||||
break;
|
||||
default:
|
||||
// this should never happen
|
||||
bp_.math_number_before = "default";
|
||||
bp_.math_number = BufferParams::DEFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3419,12 +3419,16 @@ void GuiDocument::paramsToDialog()
|
||||
mathsModule->MathIndentCO->setCurrentIndex(indent);
|
||||
enableMathIndent(indent);
|
||||
}
|
||||
if (bp_.math_number_before == "true")
|
||||
switch(bp_.math_number) {
|
||||
case BufferParams::LEFT:
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(0);
|
||||
else if (bp_.math_number_before == "default")
|
||||
break;
|
||||
case BufferParams::DEFAULT:
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(1);
|
||||
else if (bp_.math_number_before == "false")
|
||||
break;
|
||||
case BufferParams::RIGHT:
|
||||
mathsModule->MathNumberingPosCO->setCurrentIndex(2);
|
||||
}
|
||||
|
||||
map<string, string> const & packages = BufferParams::auto_packages();
|
||||
for (map<string, string>::const_iterator it = packages.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user