Le 18/04/2017 à 15:54, Jean-Marc Lasgouttes a écrit :
Getting rid of the proper length in favor of the weird string version
was definitely not what I had in mind. What I meant is that the HSpace
class is not useful and that a simple Length class would have been a
better choice.

I'll see what I can do. I will propose a patch that reverts your this
commit and does something similar to what I did for parindent.

The attached patches (1) revert your patch and (2) use a Length object instead of HSpace (as well as rename variables with the shorter mathindent name).

If it is OK with you I will commit these, and then commit a change to make the indentation visible on screen.

JMarc



From d86954eb815b8018eb216bfbc1ab344c45e18ebe Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Wed, 19 Apr 2017 16:19:18 +0200
Subject: [PATCH 1/2] Revert "BufferParams: get rid of the HSpace class for
 mathindent as requested by JMarc"

This reverts commit d9a2a4026800865b15da186620ffab4c6b409765.

This is not the right way of getting rid of HSpace. We need a proper
Length, not a string.
---
 src/Buffer.cpp                    |    2 +-
 src/BufferParams.cpp              |   25 +++++++++++++----
 src/BufferParams.h                |    5 ++++
 src/frontends/qt4/GuiDocument.cpp |   56 +++++++++++++++++--------------------
 src/frontends/qt4/GuiDocument.h   |    1 -
 5 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 36fb8d2..4795892 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -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();
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 9f05fe8..863e802 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -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";
 		}
 	}
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 437d00b..14935a9 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -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;
 
diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp
index 691bb2c..64975fe 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -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);
diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h
index 7527a59..b33fca9 100644
--- a/src/frontends/qt4/GuiDocument.h
+++ b/src/frontends/qt4/GuiDocument.h
@@ -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();
-- 
1.7.9.5

From df6b2f447085bb390ef74d0f6bcdd21b6d633204 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Wed, 19 Apr 2017 17:49:11 +0200
Subject: [PATCH 2/2] Rewrite mathindent without HSpace class

Use Length instead of HSpace for math_indentation and rename it to mathindent.
Get rid of the string version.

Rename (g|s)etMathIndentation() to (g|s)etMathIndent().

Remove the HSpace class altogether.

Some cleanups to parindent support to look like mathindent.
---
 src/Buffer.cpp                    |    1 -
 src/BufferParams.cpp              |   26 +++---
 src/BufferParams.h                |    8 +-
 src/HSpace.cpp                    |  159 -------------------------------------
 src/HSpace.h                      |   78 ------------------
 src/Makefile.am                   |    2 -
 src/TextMetrics.cpp               |    1 -
 src/frontends/qt4/GuiDocument.cpp |   54 ++++++-------
 8 files changed, 37 insertions(+), 292 deletions(-)
 delete mode 100644 src/HSpace.cpp
 delete mode 100644 src/HSpace.h

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 4795892..58de3b5 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -916,7 +916,6 @@ int Buffer::readHeader(Lexer & lex)
 	params().headheight.erase();
 	params().headsep.erase();
 	params().footskip.erase();
-	params().math_indentation.erase();
 	params().columnsep.erase();
 	params().fonts_cjk.erase();
 	params().listings_params.clear();
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 863e802..9ef1fdb 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -28,11 +28,11 @@
 #include "ColorSet.h"
 #include "Converter.h"
 #include "Encoding.h"
-#include "HSpace.h"
 #include "IndicesList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "LaTeXFonts.h"
+#include "Length.h"
 #include "ModuleList.h"
 #include "Font.h"
 #include "Lexer.h"
@@ -338,11 +338,11 @@ public:
 	IndicesList indiceslist;
 	Spacing spacing;
 	Length parindent;
+	Length mathindent;
 	/** This is the amount of space used for paragraph_separation "skip",
 	 * and for detached paragraphs in "indented" documents.
 	 */
 	VSpace defskip;
-	HSpace math_indentation;
 	PDFOptions pdfoptions;
 	LayoutFileIndex baseClass_;
 	FormatList exportableFormatList;
@@ -385,7 +385,6 @@ BufferParams::BufferParams()
 	makeDocumentClass();
 	paragraph_separation = ParagraphIndentSeparation;
 	is_math_indent = false;
-	math_indentation = "default";
 	quotes_style = InsetQuotesParams::EnglishQuotes;
 	dynamic_quotes = false;
 	fontsize = "default";
@@ -629,15 +628,15 @@ PDFOptions const & BufferParams::pdfoptions() const
 }
 
 
-HSpace const & BufferParams::getMathIndentation() const
+Length const & BufferParams::getMathIndent() const
 {
-	return pimpl_->math_indentation;
+	return pimpl_->mathindent;
 }
 
 
-void BufferParams::setMathIndentation(HSpace const & indent)
+void BufferParams::setMathIndent(Length const & indent)
 {
-	pimpl_->math_indentation = indent;
+	pimpl_->mathindent = indent;
 }
 
 
@@ -852,8 +851,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
 		lex >> is_math_indent;
 	} else if (token == "\\math_indentation") {
 		lex.next();
-		string math_indentation = lex.getString();
-		pimpl_->math_indentation = HSpace(math_indentation);
+		pimpl_->mathindent = Length(lex.getString());
 	} else if (token == "\\quotes_style") {
 		string qstyle;
 		lex >> qstyle;
@@ -1348,12 +1346,12 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
 	   << string_paragraph_separation[paragraph_separation];
 	if (!paragraph_separation)
 		os << "\n\\paragraph_indentation "
-		   << (pimpl_->parindent.empty() ? "default" : pimpl_->parindent.asString());
+		   << (getParIndent().empty() ? "default" : getParIndent().asString());
 	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 && !getMathIndent().empty())
+		os << "\n\\math_indentation " << getMathIndent().asString();
 	os << "\n\\quotes_style "
 	   << string_quotes_style[quotes_style]
 	   << "\n\\dynamic_quotes " << dynamic_quotes
@@ -1965,9 +1963,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 (!getMathIndent().empty()) {
 			os << "\\setlength{\\mathindent}{"
-			   << from_utf8(getMathIndentation().asLatexCommand())
+			   << from_utf8(getMathIndent().asString())
 			   << "}\n";
 		}
 	}
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 14935a9..3b4724d 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -39,7 +39,6 @@ class Bullet;
 class DocumentClass;
 class Encoding;
 class Font;
-class HSpace;
 class IndicesList;
 class Language;
 class LayoutFile;
@@ -103,16 +102,13 @@ public:
 	void setDefSkip(VSpace const & vs);
 
 	///
-	HSpace const & getMathIndentation() const;
+	Length const & getMathIndent() const;
 	///
-	void setMathIndentation(HSpace const & indent);
+	void setMathIndent(Length const & indent);
 
 	/// Whether formulas are indented
 	bool is_math_indent;
 
-	/// the indentation of formulas
-	std::string math_indentation;
-
 	/** Whether paragraphs are separated by using a indent like in
 	 *  articles or by using a little skip like in letters.
 	 */
diff --git a/src/HSpace.cpp b/src/HSpace.cpp
deleted file mode 100644
index 8a56899..0000000
--- a/src/HSpace.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * \file HSpace.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- * \author Uwe Stöhr
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "HSpace.h"
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "BufferView.h"
-#include "support/gettext.h"
-#include "Length.h"
-#include "Text.h"
-
-#include "support/lstrings.h"
-
-#include "support/lassert.h"
-
-using namespace std;
-using namespace lyx::support;
-
-
-namespace lyx {
-
-
-HSpace::HSpace()
-	: kind_(DEFAULT), len_()
-{}
-
-
-HSpace::HSpace(HSpaceKind k)
-	: kind_(k), len_()
-{}
-
-
-HSpace::HSpace(Length const & l)
-	: kind_(LENGTH), len_(l)
-{}
-
-
-HSpace::HSpace(GlueLength const & l)
-	: kind_(LENGTH), len_(l)
-{}
-
-
-HSpace::HSpace(string const & data)
-	: kind_(DEFAULT), len_()
-{
-	if (data.empty())
-		return;
-
-	string input = rtrim(data);
-
-	if (prefixIs(input, "default"))
-		kind_ = DEFAULT;
-	else if (isValidGlueLength(input, &len_))
-		kind_ = LENGTH;
-}
-
-
-bool HSpace::operator==(HSpace const & other) const
-{
-	if (kind_ != other.kind_)
-		return false;
-	if (len_ != other.len_)
-		return false;
-	return true;
-}
-
-
-string const HSpace::asLyXCommand() const
-{
-	string result;
-	switch (kind_) {
-	case DEFAULT:
-		result = "default";
-		break;
-	case LENGTH:
-		result = len_.asString();
-		break;
-	}
-	return result;
-}
-
-
-string const HSpace::asLatexCommand() const
-{
-	switch (kind_) {
-	case DEFAULT:
-		return string();
-	case LENGTH:
-		return len_.asLatexString();
-	default:
-		LATTEST(false);
-		// fall through in release mode
-	}
-	return string();
-}
-
-
-docstring const HSpace::asGUIName() const
-{
-	docstring result;
-	switch (kind_) {
-	case DEFAULT:
-		result = _("Default");
-		break;
-	case LENGTH:
-		result = from_ascii(len_.asString());
-		break;
-	}
-	return result;
-}
-
-
-string HSpace::asHTMLLength() const 
-{
-	string result;
-	switch (kind_) {
-	case DEFAULT:
-		// 30pt are LaTeX's default
-		result = "30pt";
-		break;
-	case LENGTH: {
-		Length tmp = len_.len();
-		if (tmp.value() > 0)
-			result = tmp.asHTMLString();
-		break;
-		}
-	}
-	return result;
-}
-
-
-int HSpace::inPixels(BufferView const & bv) const
-{
-	switch (kind_) {
-	case DEFAULT:
-		// FIXME: replace by correct length
-		return bv.buffer().params().getParIndent().inPixels(bv.workWidth());
-	case LENGTH:
-		return len_.len().inPixels(bv.workWidth());
-	default:
-		LATTEST(false);
-		// fall through in release mode
-	}
-	return 0;
-}
-
-
-} // namespace lyx
diff --git a/src/HSpace.h b/src/HSpace.h
deleted file mode 100644
index 7c01f37..0000000
--- a/src/HSpace.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// -*- C++ -*-
-/**
- * \file HSpace.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- * \author Uwe Stöhr
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef HSPACE_H
-#define HSPACE_H
-
-#include "Length.h"
-
-
-namespace lyx {
-
-
-class BufferParams;
-class BufferView;
-
-
-/// A class representing latex horizontal spacing
-class HSpace {
-public:
-	/// The different kinds of spaces.
-	enum HSpaceKind {
-		DEFAULT,
-		LENGTH ///< user-defined length
-	};
-
-	///
-	HSpace();
-	///
-	explicit HSpace(HSpaceKind k);
-	///
-	explicit HSpace(Length const & l);
-	///
-	explicit HSpace(GlueLength const & l);
-
-	/// Constructor for reading from a .lyx file
-	explicit HSpace(std::string const & data);
-
-	/// return the type of vertical space
-	HSpaceKind kind() const { return kind_; }
-	/// return the length of this space
-	GlueLength const & length() const { return len_; }
-
-	///
-	bool operator==(HSpace const &) const;
-
-	// conversion
-
-	/// how it goes into the LyX file
-	std::string const asLyXCommand() const;
-	/// the latex representation
-	std::string const asLatexCommand() const;
-	///
-	std::string asHTMLLength() const;
-	/// how it is seen in the LyX window
-	docstring const asGUIName() const;
-	/// the size of the space on-screen
-	int inPixels(BufferView const & bv) const;
-
-private:
-	/// This HSpace kind
-	HSpaceKind kind_;
-	/// the specified length
-	GlueLength len_;
-};
-
-
-} // namespace lyx
-
-#endif // HSPACE_H
diff --git a/src/Makefile.am b/src/Makefile.am
index a0b2ebe..5bf8f3b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -134,7 +134,6 @@ SOURCEFILESCORE = \
 	FuncRequest.cpp \
 	FuncStatus.cpp \
 	Graph.cpp \
-	HSpace.cpp \
 	IndicesList.cpp \
 	InsetIterator.cpp \
 	InsetList.cpp \
@@ -237,7 +236,6 @@ HEADERFILESCORE = \
 	FuncRequest.h \
 	FuncStatus.h \
 	Graph.h \
-	HSpace.h \
 	IndicesList.h \
 	InsetIterator.h \
 	InsetList.h \
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index bb38914..475b809 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -26,7 +26,6 @@
 #include "CoordCache.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
-#include "HSpace.h"
 #include "InsetList.h"
 #include "Language.h"
 #include "Layout.h"
diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp
index 64975fe..8469447 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -38,7 +38,6 @@
 #include "FloatPlacement.h"
 #include "Format.h"
 #include "FuncRequest.h"
-#include "HSpace.h"
 #include "IndicesList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
@@ -2903,13 +2902,10 @@ void GuiDocument::applyView()
 	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);
+		Length mathindent(widgetsToLength(textLayoutModule->MathIndentLE,
+		                                  textLayoutModule->MathIndentLengthCO));
+		bp_.setMathIndent(mathindent);
 	}
-
 	// Page Layout
 	if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
 		bp_.pagestyle = "default";
@@ -2955,14 +2951,12 @@ void GuiDocument::applyView()
 		case 0:
 			bp_.setParIndent(Length());
 			break;
-		case 1:	{
-			Length indent(
-				widgetsToLength(textLayoutModule->indentLE,
-				textLayoutModule->indentLengthCO)
-				);
-			bp_.setParIndent(indent);
+		case 1: {
+			Length parindent(widgetsToLength(textLayoutModule->indentLE,
+			                                 textLayoutModule->indentLengthCO));
+			bp_.setParIndent(parindent);
 			break;
-			}
+		}
 		default:
 			// this should never happen
 			bp_.setParIndent(Length());
@@ -3001,19 +2995,17 @@ void GuiDocument::applyView()
 		// if formulas are indented
 		switch (textLayoutModule->MathIndentCO->currentIndex()) {
 		case 0:
-			bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+			bp_.setMathIndent(Length());
 			break;
-		case 1:	{
-			HSpace MathIndent = HSpace(
-				widgetsToLength(textLayoutModule->MathIndentLE,
-				textLayoutModule->MathIndentLengthCO)
-				);
-			bp_.setMathIndentation(MathIndent);
+		case 1: {
+			Length mathindent(widgetsToLength(textLayoutModule->MathIndentLE,
+			                                  textLayoutModule->MathIndentLengthCO));
+			bp_.setMathIndent(mathindent);
 			break;
-			}
+		}
 		default:
 			// this should never happen
-			bp_.setMathIndentation(HSpace(HSpace::DEFAULT));
+			bp_.setMathIndent(Length());
 			break;
 		}
 	}
@@ -3384,16 +3376,16 @@ 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") {
+		Length const mathindent = bp_.getMathIndent();
+		int indent = 0;
+		if (!mathindent.empty()) {
 			lengthToWidgets(textLayoutModule->MathIndentLE,
-			textLayoutModule->MathIndentLengthCO,
-			MathIndentation, default_unit);
-			MathIndent = 1;
+			                textLayoutModule->MathIndentLengthCO,
+			                mathindent, default_unit);
+			indent = 1;
 		}
-		textLayoutModule->MathIndentCO->setCurrentIndex(MathIndent);
-		setMathIndent(MathIndent);
+		textLayoutModule->MathIndentCO->setCurrentIndex(indent);
+		setMathIndent(indent);
 	}
 
 	map<string, string> const & packages = BufferParams::auto_packages();
-- 
1.7.9.5

Reply via email to