mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
Revert "BufferParams: get rid of the HSpace class for mathindent as requested by JMarc"
This reverts commit d9a2a40268
.
This is not the right way of getting rid of HSpace. We need a proper
Length, not a string.
This commit is contained in:
parent
e7c3354a87
commit
d86954eb81
@ -916,7 +916,7 @@ int Buffer::readHeader(Lexer & lex)
|
||||
params().headheight.erase();
|
||||
params().headsep.erase();
|
||||
params().footskip.erase();
|
||||
params().math_indentation = "default";
|
||||
params().math_indentation.erase();
|
||||
params().columnsep.erase();
|
||||
params().fonts_cjk.erase();
|
||||
params().listings_params.clear();
|
||||
|
@ -342,6 +342,7 @@ public:
|
||||
* and for detached paragraphs in "indented" documents.
|
||||
*/
|
||||
VSpace defskip;
|
||||
HSpace math_indentation;
|
||||
PDFOptions pdfoptions;
|
||||
LayoutFileIndex baseClass_;
|
||||
FormatList exportableFormatList;
|
||||
@ -628,6 +629,18 @@ PDFOptions const & BufferParams::pdfoptions() const
|
||||
}
|
||||
|
||||
|
||||
HSpace const & BufferParams::getMathIndentation() const
|
||||
{
|
||||
return pimpl_->math_indentation;
|
||||
}
|
||||
|
||||
|
||||
void BufferParams::setMathIndentation(HSpace const & indent)
|
||||
{
|
||||
pimpl_->math_indentation = indent;
|
||||
}
|
||||
|
||||
|
||||
Length const & BufferParams::getParIndent() const
|
||||
{
|
||||
return pimpl_->parindent;
|
||||
@ -838,7 +851,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
} else if (token == "\\is_math_indent") {
|
||||
lex >> is_math_indent;
|
||||
} else if (token == "\\math_indentation") {
|
||||
lex >> math_indentation;
|
||||
lex.next();
|
||||
string math_indentation = lex.getString();
|
||||
pimpl_->math_indentation = HSpace(math_indentation);
|
||||
} else if (token == "\\quotes_style") {
|
||||
string qstyle;
|
||||
lex >> qstyle;
|
||||
@ -1337,8 +1352,8 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
|
||||
else
|
||||
os << "\n\\defskip " << getDefSkip().asLyXCommand();
|
||||
os << "\n\\is_math_indent " << is_math_indent;
|
||||
if (is_math_indent && math_indentation != "default")
|
||||
os << "\n\\math_indentation " << math_indentation;
|
||||
if (is_math_indent && getMathIndentation().asLyXCommand() != "default")
|
||||
os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
|
||||
os << "\n\\quotes_style "
|
||||
<< string_quotes_style[quotes_style]
|
||||
<< "\n\\dynamic_quotes " << dynamic_quotes
|
||||
@ -1950,9 +1965,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
if (is_math_indent) {
|
||||
// when formula indentation
|
||||
// only output something when it is not the default
|
||||
if (math_indentation != "default") {
|
||||
if (getMathIndentation().asLyXCommand() != "default") {
|
||||
os << "\\setlength{\\mathindent}{"
|
||||
<< from_utf8(math_indentation)
|
||||
<< from_utf8(getMathIndentation().asLatexCommand())
|
||||
<< "}\n";
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,11 @@ public:
|
||||
///
|
||||
void setDefSkip(VSpace const & vs);
|
||||
|
||||
///
|
||||
HSpace const & getMathIndentation() const;
|
||||
///
|
||||
void setMathIndentation(HSpace const & indent);
|
||||
|
||||
/// Whether formulas are indented
|
||||
bool is_math_indent;
|
||||
|
||||
|
@ -727,8 +727,6 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
|
||||
connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(allowMathIndent()));
|
||||
connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)),
|
||||
@ -1612,22 +1610,6 @@ void GuiDocument::enableSkip(bool skip)
|
||||
setSkip(textLayoutModule->skipCO->currentIndex());
|
||||
}
|
||||
|
||||
void GuiDocument::allowMathIndent()
|
||||
{
|
||||
// only disable when not checked, checked does not always allow enabling
|
||||
if (!textLayoutModule->MathIndentCB->isChecked()) {
|
||||
textLayoutModule->MathIndentLE->setEnabled(false);
|
||||
textLayoutModule->MathIndentLengthCO->setEnabled(false);
|
||||
}
|
||||
if (textLayoutModule->MathIndentCB->isChecked()
|
||||
&& textLayoutModule->MathIndentCO->currentIndex() == 1) {
|
||||
textLayoutModule->MathIndentLE->setEnabled(true);
|
||||
textLayoutModule->MathIndentLengthCO->setEnabled(true);
|
||||
|
||||
}
|
||||
isValid();
|
||||
}
|
||||
|
||||
void GuiDocument::setMathIndent(int item)
|
||||
{
|
||||
bool const enable = (item == 1);
|
||||
@ -2918,7 +2900,16 @@ void GuiDocument::applyView()
|
||||
if (rb->isChecked())
|
||||
bp_.use_package(it->first, BufferParams::package_off);
|
||||
}
|
||||
|
||||
bp_.is_math_indent = textLayoutModule->MathIndentCB->isChecked();
|
||||
// if math is indented
|
||||
if (bp_.is_math_indent) {
|
||||
HSpace MathIndentation = HSpace(
|
||||
widgetsToLength(textLayoutModule->MathIndentLE,
|
||||
textLayoutModule->MathIndentLengthCO)
|
||||
);
|
||||
bp_.setMathIndentation(MathIndentation);
|
||||
}
|
||||
|
||||
// Page Layout
|
||||
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
|
||||
bp_.pagestyle = "default";
|
||||
@ -3006,24 +2997,26 @@ void GuiDocument::applyView()
|
||||
}
|
||||
}
|
||||
|
||||
bp_.is_math_indent = textLayoutModule->MathIndentCB->isChecked();
|
||||
if (bp_.is_math_indent) {
|
||||
// if math is indented
|
||||
if (textLayoutModule->MathIndentCB->isChecked()) {
|
||||
// if formulas are indented
|
||||
switch (textLayoutModule->MathIndentCO->currentIndex()) {
|
||||
case 0:
|
||||
bp_.math_indentation = "default";
|
||||
bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
|
||||
break;
|
||||
case 1:
|
||||
bp_.math_indentation = widgetsToLength(textLayoutModule->MathIndentLE,
|
||||
textLayoutModule->MathIndentLengthCO);
|
||||
case 1: {
|
||||
HSpace MathIndent = HSpace(
|
||||
widgetsToLength(textLayoutModule->MathIndentLE,
|
||||
textLayoutModule->MathIndentLengthCO)
|
||||
);
|
||||
bp_.setMathIndentation(MathIndent);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// this should never happen
|
||||
bp_.math_indentation = "default";
|
||||
bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
|
||||
break;
|
||||
}
|
||||
} else
|
||||
bp_.math_indentation = "default";
|
||||
}
|
||||
|
||||
bp_.options =
|
||||
fromqstr(latexModule->optionsLE->text());
|
||||
@ -3391,11 +3384,12 @@ void GuiDocument::paramsToDialog()
|
||||
// math
|
||||
if (bp_.is_math_indent) {
|
||||
textLayoutModule->MathIndentCB->setChecked(bp_.is_math_indent);
|
||||
string MathIndentation = bp_.getMathIndentation().asLyXCommand();
|
||||
int MathIndent = 0;
|
||||
if (bp_.math_indentation != "default") {
|
||||
if (MathIndentation != "default") {
|
||||
lengthToWidgets(textLayoutModule->MathIndentLE,
|
||||
textLayoutModule->MathIndentLengthCO,
|
||||
bp_.math_indentation, default_unit);
|
||||
MathIndentation, default_unit);
|
||||
MathIndent = 1;
|
||||
}
|
||||
textLayoutModule->MathIndentCO->setCurrentIndex(MathIndent);
|
||||
|
@ -109,7 +109,6 @@ private Q_SLOTS:
|
||||
void enableIndent(bool);
|
||||
void setSkip(int);
|
||||
void enableSkip(bool);
|
||||
void allowMathIndent();
|
||||
void setMathIndent(int);
|
||||
void browseLayout();
|
||||
void browseMaster();
|
||||
|
Loading…
Reference in New Issue
Block a user