This fixes a bug reported by Helge: changing the paragraph style needlessly resets all the paragraph parameters. This is important to fix in the context of the recently committed fixes to paragraph settings.

I'd appreciate it if someone could commit this for me, once we get the OK. I'll be on vacation starting tomorrow. Here's a log message:

Fix bug 3939. Don't reset all the parameters when the layout is changed,
but instead: Check if the alignment is permitted; if not, issue a warning,
and reset to LYX_ALIGN_LAYOUT.

Richard

--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Index: Paragraph.cpp
===================================================================
--- Paragraph.cpp	(revision 18922)
+++ Paragraph.cpp	(working copy)
@@ -42,6 +42,7 @@
 #include "TexRow.h"
 #include "VSpace.h"
 
+#include "frontends/alert.h"
 #include "frontends/FontMetrics.h"
 
 #include "insets/InsetBibitem.h"
@@ -1641,9 +1642,15 @@
 void Paragraph::applyLayout(Layout_ptr const & new_layout)
 {
 	layout(new_layout);
-	params().labelWidthString(docstring());
-	params().align(LYX_ALIGN_LAYOUT);
-	params().spacing(Spacing(Spacing::Default));
+	LyXAlignment const oldAlign = params().align();
+	// FIXME The first check is due to the fact that LYX_ALIGN_LAYOUT
+	// is not required to be possible. A fix is on the way.
+	if ((oldAlign != LYX_ALIGN_LAYOUT) && 
+	    !(oldAlign & layout()->alignpossible)) {
+		frontend::Alert::warning(_("Alignment not permitted"), 
+			_("The new layout does not permit the alignment previously used.\nSetting to default."));
+		params().align(LYX_ALIGN_LAYOUT);
+	}
 }
 
 

Reply via email to