Second iteration of the floatflt->wrapfig transition patch,
for lyx-1.6 only  due to the format change.

The format is now increased from 282 to 283, because the
exported latex is different.

I hope someone can have a look at the lyx2lyx stuff, as I don't
know that part very well.  I tried to add a do-nothing conversion,
as the .lyx format itself doesn't change. This seems to work
in a simple test.

My test of the format change:
I opened a older document with the patched LyX, this worked.
Opening old documents containing wrapped figures also works.

My test of the wrapfig feature:
Wrapped figures works, even in a case where floatflt would
drop the figure.

Helge Hafting
Index: src/insets/InsetWrap.cpp
===================================================================
--- src/insets/InsetWrap.cpp	(revisjon 20137)
+++ src/insets/InsetWrap.cpp	(arbeidskopi)
@@ -175,7 +175,7 @@
 
 void InsetWrap::validate(LaTeXFeatures & features) const
 {
-	features.require("floatflt");
+	features.require("wrapfig");
 	InsetCollapsable::validate(features);
 }
 
@@ -195,12 +195,13 @@
 int InsetWrap::latex(Buffer const & buf, odocstream & os,
 		     OutputParams const & runparams) const
 {
-	os << "\\begin{floating" << from_ascii(params_.type) << '}';
+	os << "\\begin{wrap" << from_ascii(params_.type) << '}';
 	if (!params_.placement.empty())
-		os << '[' << from_ascii(params_.placement) << ']';
+		os << '{' << from_ascii(params_.placement) << '}';
+		else os << "{o}"; //Outer is default in the current UI
 	os << '{' << from_ascii(params_.width.asLatexString()) << "}%\n";
 	int const i = InsetText::latex(buf, os, runparams);
-	os << "\\end{floating" << from_ascii(params_.type) << "}%\n";
+	os << "\\end{wrap" << from_ascii(params_.type) << "}%\n";
 	return i + 2;
 }
 
Index: src/frontends/qt4/GuiWrap.cpp
===================================================================
--- src/frontends/qt4/GuiWrap.cpp	(revisjon 20137)
+++ src/frontends/qt4/GuiWrap.cpp	(arbeidskopi)
@@ -103,7 +103,7 @@
 		params.placement = "r";
 		break;
 	case 3:
-		params.placement = "p";
+		params.placement = "o";
 		break;
 	}
 }
@@ -112,10 +112,9 @@
 static string const numtostr(double val)
 {
 	string a = convert<string>(val);
-	// FIXME: Will this test ever trigger? (Lgb)
-	if (a == "0")
-		a.erase();
 	return a;
+	//0pt is a legal width now, it yields a
+	//wrapfloat just wide enough for the contents.
 }
 
 
@@ -132,7 +131,7 @@
 		item = 1;
 	else if (params.placement == "r")
 		item = 2;
-	else if (params.placement == "p")
+	else if (params.placement == "o")
 		item = 3;
 
 	valignCO->setCurrentIndex(item);
Index: src/factory.cpp
===================================================================
--- src/factory.cpp	(revisjon 20137)
+++ src/factory.cpp	(arbeidskopi)
@@ -173,7 +173,7 @@
 			string const argument = to_utf8(cmd.argument());
 			if (argument == "figure")
 				return new InsetWrap(params, argument);
-			lyxerr << "Non-existent floatflt type: " << argument << endl;
+			lyxerr << "Non-existent wrapfig type: " << argument << endl;
 			return 0;
 		}
 
Index: src/LaTeXFeatures.cpp
===================================================================
--- src/LaTeXFeatures.cpp	(revisjon 20137)
+++ src/LaTeXFeatures.cpp	(arbeidskopi)
@@ -397,7 +397,7 @@
 	"latexsym",
 	"pifont",
 	"subfigure",
-	"floatflt",
+	"wrapfig",
 	"varioref",
 	"prettyref",
 	"float",
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revisjon 20137)
+++ src/Buffer.cpp	(arbeidskopi)
@@ -142,7 +142,7 @@
 
 namespace {
 
-int const LYX_FORMAT = 282;
+int const LYX_FORMAT = 283;
 
 } // namespace anon
 
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py	(revisjon 20137)
+++ lib/lyx2lyx/LyX.py	(arbeidskopi)
@@ -78,7 +78,7 @@
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 5)),
                    ("1_5", range(246,277), generate_minor_versions("1.5" , 1)),
-                   ("1_6", range(277,283), generate_minor_versions("1.6" , 0))]
+                   ("1_6", range(277,284), generate_minor_versions("1.6" , 0))]
 
 
 def formats_list():
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py	(revisjon 20137)
+++ lib/lyx2lyx/lyx_1_6.py	(arbeidskopi)
@@ -167,7 +167,8 @@
            [279, [long_charstyle_names]],
            [280, [axe_show_label]],
            [281, []],
-           [282, []]
+           [282, []],
+	   [283, []]
           ]
 
 revert =  [
Index: lib/chkconfig.ltx
===================================================================
--- lib/chkconfig.ltx	(revisjon 20137)
+++ lib/chkconfig.ltx	(arbeidskopi)
@@ -230,7 +230,7 @@
 \TestPackage{esint}
 \TestPackage{fancybox}
 \TestPackage{fancyhdr}
-\TestPackage{floatflt}
+\TestPackage{wrapfig}
 \TestPackage{framed}
 \TestPackage{geometry}
 \TestPackage{jurabib}
Index: development/FORMAT
===================================================================
--- development/FORMAT	(revisjon 20137)
+++ development/FORMAT	(arbeidskopi)
@@ -1,6 +1,14 @@
 LyX file-format changes
 -----------------------
 
+2007-09-08 Helge Hafting
+	* Format incremented to 283: LyX now implements wrapped figures
+	  using wrapfig.sty instead of floatflt.sty. The latter
+	  is rather buggy, the former also has more options.
+	  No conversion as the .lyx doesn't change.
+	  The .tex export is slightly different, necessitating the
+	  format increase.
+
 2007-08-31 Bo Peng
 
 	* format incremented to 282: lyx files can be zipfiles with

Reply via email to