Am 03.04.2013 15:00, schrieb Jean-Marc Lasgouttes:

As I already mentionned (I think)

I missed that.

, there is support for empty length (look for Length::empty()
method) and nothing prevents you from using it. It is already used in several 
places in the code.

What is the problem exactly?

I can use an empty length (see attached patch) but this results in "0pt" as length when the length is read. But "0pt" is a valid length. I can change from 99.9col% to 0pt as length for the case that no length is given if you like. But is this a better solution than mine? The problem I see is that "0pt" is used as length if you want to have a box with the height of its contents but not width, this is a case that I would not allow anymore if I would handle 0pt as no length.

But maybe I only make a mistake and there is a way to prevent that an empty 
length is read as 0pt?

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..da7aa49 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).asString().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..9d8cc72 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 from_ascii(params_.width.asLatexString()) != "";
 }
 
 
@@ -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 (from_ascii(width_string) != "") {
 			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 (from_ascii(width_string) != "") {
 				os << "\\makebox";
 				// FIXME UNICODE
 				// output the width and horizontal position

Reply via email to