El 15.04.2017 a las 19:07, Jean-Marc Lasgouttes escribió:
Nowadays (with default lengths), the class is basically useless.
OK, attached is a patch that would omit HSpace.
I don't understand why it doesn't work: If the default value is used
math_indentation is not "default" but empty.
Maybe you see my mistake?
In the patch I corrected also the UI enabling logic.
If I could find the problem, I could change the handling of
paragraph_indentation accordingly.
thanks and regards
Uwe
src/BufferParams.cpp | 25 ++++-------------
src/BufferParams.h | 5 ----
src/frontends/qt4/GuiDocument.cpp | 58 +++++++++++++++++++++------------------
src/frontends/qt4/GuiDocument.h | 1 +
4 files changed, 38 insertions(+), 51 deletions(-)
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 1c00dbdd97..35843fa87d 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -342,7 +342,6 @@ public:
*/
HSpace indentation;
VSpace defskip;
- HSpace math_indentation;
PDFOptions pdfoptions;
LayoutFileIndex baseClass_;
FormatList exportableFormatList;
@@ -629,18 +628,6 @@ PDFOptions const & BufferParams::pdfoptions() const
}
-HSpace const & BufferParams::getMathIndentation() const
-{
- return pimpl_->math_indentation;
-}
-
-
-void BufferParams::setMathIndentation(HSpace const & indent)
-{
- pimpl_->math_indentation = indent;
-}
-
-
HSpace const & BufferParams::getIndentation() const
{
return pimpl_->indentation;
@@ -848,9 +835,7 @@ string BufferParams::readToken(Lexer & lex, string const &
token,
} else if (token == "\\is_math_indent") {
lex >> is_math_indent;
} else if (token == "\\math_indentation") {
- lex.next();
- string math_indentation = lex.getString();
- pimpl_->math_indentation = HSpace(math_indentation);
+ lex >> math_indentation;
} else if (token == "\\quotes_style") {
string qstyle;
lex >> qstyle;
@@ -1348,8 +1333,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 && getMathIndentation().asLyXCommand() != "default")
- os << "\n\\math_indentation " <<
getMathIndentation().asLyXCommand();
+ if (is_math_indent && math_indentation != "default")
+ os << "\n\\math_indentation " << math_indentation;
os << "\n\\quotes_style "
<< string_quotes_style[quotes_style]
<< "\n\\dynamic_quotes " << dynamic_quotes
@@ -1961,9 +1946,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 (getMathIndentation().asLyXCommand() != "default") {
+ if (math_indentation != "default") {
os << "\\setlength{\\mathindent}{"
- << from_utf8(getMathIndentation().asLatexCommand())
+ << from_utf8(math_indentation)
<< "}\n";
}
}
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 3b0b8a79de..4f59b7c5b0 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -101,11 +101,6 @@ public:
///
void setDefSkip(VSpace const & vs);
- ///
- HSpace const & getMathIndentation() const;
- ///
- void setMathIndentation(HSpace const & indent);
-
/// Whether formulas are indented
bool is_math_indent;
diff --git a/src/frontends/qt4/GuiDocument.cpp
b/src/frontends/qt4/GuiDocument.cpp
index b1db0e9886..6948948c17 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -727,6 +727,8 @@ 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)),
@@ -1610,6 +1612,22 @@ 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);
@@ -2900,16 +2918,7 @@ 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";
@@ -2997,26 +3006,24 @@ void GuiDocument::applyView()
}
}
- if (textLayoutModule->MathIndentCB->isChecked()) {
- // if formulas are indented
+ bp_.is_math_indent = textLayoutModule->MathIndentCB->isChecked();
+ if (bp_.is_math_indent) {
+ // if math is indented
switch (textLayoutModule->MathIndentCO->currentIndex()) {
case 0:
- bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+ bp_.math_indentation = "default";
break;
- case 1: {
- HSpace MathIndent = HSpace(
- widgetsToLength(textLayoutModule->MathIndentLE,
- textLayoutModule->MathIndentLengthCO)
- );
- bp_.setMathIndentation(MathIndent);
+ case 1:
+ bp_.math_indentation =
widgetsToLength(textLayoutModule->MathIndentLE,
+ textLayoutModule->MathIndentLengthCO);
break;
- }
default:
// this should never happen
- bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+ bp_.math_indentation = "default";
break;
}
- }
+ } else
+ bp_.math_indentation = "default";
bp_.options =
fromqstr(latexModule->optionsLE->text());
@@ -3384,16 +3391,15 @@ 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 (MathIndentation != "default") {
+ if (bp_.math_indentation != "default") {
lengthToWidgets(textLayoutModule->MathIndentLE,
textLayoutModule->MathIndentLengthCO,
- MathIndentation, default_unit);
+ bp_.math_indentation, default_unit);
MathIndent = 1;
}
textLayoutModule->MathIndentCO->setCurrentIndex(MathIndent);
- setMathIndent(MathIndent);
+ allowMathIndent();
}
map<string, string> const & packages = BufferParams::auto_packages();
diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h
index b33fca95f8..7527a59edc 100644
--- a/src/frontends/qt4/GuiDocument.h
+++ b/src/frontends/qt4/GuiDocument.h
@@ -109,6 +109,7 @@ private Q_SLOTS:
void enableIndent(bool);
void setSkip(int);
void enableSkip(bool);
+ void allowMathIndent();
void setMathIndent(int);
void browseLayout();
void browseMaster();