Am 10.04.2013 11:36, schrieb Jean-Marc Lasgouttes:

Look for some comments below. I am not sure that what I propose will be enough 
to make things work,
but it should be a good first step.

That does not cure the problem. Attached is the updated patch.
The problem is that LyX requires a length. Length() stores
Length::UNIT_NONE
but this is translated during the reading of the buffer to the default unit and this is "pt". As an empty value was stored "0" is used. This is by design but as I said "0pt" is a valid length and not comparable to no length. In case that no length is given, it is automatically calculated by LaTeX so that the box has the minimal width necessary for its content.

I could store another bool so that if the length "0pt" is read _and_ the bool for no width is true, then no explicit width is used. But what is the benefit compared to my solution? In my opinion there is no, only more code ad another variable we have to introduce and to store in the LyX file. Nobody will ever use a length "-9.99\\columnwidth" so it is safe to use this as code for no width. Or have I overseen a fact here?

thanks and regards
Uwe
 src/frontends/qt4/GuiBox.cpp |  8 ++++----
 src/insets/InsetBox.cpp      | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp
index 657896a..f81005a 100644
--- a/src/frontends/qt4/GuiBox.cpp
+++ b/src/frontends/qt4/GuiBox.cpp
@@ -305,8 +305,8 @@ void GuiBox::paramsToDialog(Inset const * inset)
 	// the width can only be selected for makebox or framebox
 	widthCB->setEnabled(inner_type == "makebox" 
 	                    || (type == "Boxed" && !ibox && !pagebreakCB->isChecked()));
-	// "-999col%" is the code for no width
-	if ((params.width).asString() == "-999col%")
+	// an empty length is the code for no width
+	if(params.width.empty())
 		widthCB->setCheckState(Qt::Unchecked);
 	else {
 		if (widthCB->isEnabled())
@@ -378,9 +378,9 @@ docstring GuiBox::dialogToParams() const
 	 }
 	} else {
 		if (widthCB->isEnabled()) {
-			// use the code "-999col%" for the case that no width was selected
+			// use an empty length for the case that no width was selected
 			params.special = "none";
-			params.width = Length("-999col%");
+			params.width = Length();
 		}
 	}
 
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp
index f610263..5ee0a44 100644
--- a/src/insets/InsetBox.cpp
+++ b/src/insets/InsetBox.cpp
@@ -162,7 +162,7 @@ void InsetBox::setButtonLabel()
 
 bool InsetBox::hasFixedWidth() const
 {
-	return from_ascii(params_.width.asLatexString()) != "-9.99\\columnwidth";
+	return !params_.width.empty();
 }
 
 
@@ -316,8 +316,8 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
 		os << "\\begin{framed}%\n";
 		break;
 	case Boxed:
-		// "-999col%" is the code for no width
-		if (from_ascii(width_string) != "-9.99\\columnwidth") {
+		// an empty length is the code for no width
+		if (!params_.width.empty()) {
 			os << "\\framebox";
 			if (!params_.inner_box) {
 				// Special widths, see usrguide §3.5
@@ -358,8 +358,8 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
 		if (params_.use_parbox)
 			os << "\\parbox";
 		else if (params_.use_makebox) {
-			// "-999col%" is the code for no width
-			if (from_ascii(width_string) != "-9.99\\columnwidth") {
+			// an empty length is the code for no width
+			if (!params_.width.empty()) {
 				os << "\\makebox";
 				// FIXME UNICODE
 				// output the width and horizontal position

Reply via email to