The attached patch reimplements setDefaultParagraphs in insettabular, as 
described in bug 1953. However, the paragraph merging problem described there 
is not fixed (this is a different problem, independent from 
setDefaultParagraphs; I got that wrong).

There is a remaining problem with setDefaultParagraphs, but that is not a 
regression (cf 1.3): for the paragraphs where setDefaultParagraphs is true, 
the layout is actually not reset to default, only a layout change is blocked. 
This is definitely a bug (copy a list into an ERT, change a fixed width cell 
with a list to non-fixed width etc.).

I propose to put this patch in, though, and address the other problems 
separately.

Jürgen
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.671
diff -p -u -r1.671 lyxfunc.C
--- lyxfunc.C	24 Oct 2005 09:42:18 -0000	1.671
+++ lyxfunc.C	13 Nov 2005 11:28:19 -0000
@@ -430,7 +430,14 @@ FuncStatus LyXFunc::getStatus(FuncReques
 
 	case LFUN_LAYOUT:
 	case LFUN_LAYOUT_PARAGRAPH:
-		enable = !cur.inset().forceDefaultParagraphs(&cur.inset());
+		// in tabulars, we have to check for the cell
+		if (cur.inset().lyxCode() == InsetBase::TABULAR_CODE) {
+			InsetTabular & tabular = static_cast<InsetTabular&>(cur.inset());
+			enable = !cur.inset().forceDefaultParagraphs(
+					tabular.cell(cur.idx()).get());
+		}
+		else
+			enable = !cur.inset().forceDefaultParagraphs(&cur.inset());
 		break;
 
 	case LFUN_VC_REGISTER:
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.317
diff -p -u -r1.317 text3.C
--- text3.C	2 Nov 2005 11:27:08 -0000	1.317
+++ text3.C	13 Nov 2005 11:28:22 -0000
@@ -53,6 +53,7 @@
 #include "insets/insetnewline.h"
 #include "insets/insetquotes.h"
 #include "insets/insetspecialchar.h"
+#include "insets/insettabular.h"
 #include "insets/insettext.h"
 
 #include "support/lstrings.h"
@@ -1415,7 +1416,15 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 		// Will the paragraph accept changes from the dialog?
 		InsetBase & inset = cur.inset();
-		bool const accept = !inset.forceDefaultParagraphs(&inset);
+		bool accept;
+		// in tabulars, we have to check for the cell
+		if (inset.lyxCode() == InsetBase::TABULAR_CODE) {
+			InsetTabular & tabular = static_cast<InsetTabular&>(inset);
+			accept = !inset.forceDefaultParagraphs(
+					tabular.cell(cur.idx()).get());
+		}
+		else
+			accept = !inset.forceDefaultParagraphs(&inset);
 
 		data = "update " + convert<string>(accept) + '\n' + data;
 		bv->owner()->getDialogs().update("paragraph", data);
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.491
diff -p -u -r1.491 insettabular.C
--- insets/insettabular.C	24 Oct 2005 09:42:20 -0000	1.491
+++ insets/insettabular.C	13 Nov 2005 11:28:28 -0000
@@ -1851,27 +1851,10 @@ void InsetTabular::markErased(bool erase
 }
 
 
-bool InsetTabular::forceDefaultParagraphs(InsetBase const *) const
+bool InsetTabular::forceDefaultParagraphs(InsetBase const * in) const
 {
-#if 0
 	idx_type const cell = tabular.getCellFromInset(in);
-	// FIXME: getCellFromInset() returns now always a valid cell, so
-	// the stuff below can be deleted, and instead we have:
 	return tabular.getPWidth(cell).zero();
-
-	if (cell != npos)
-		return tabular.getPWidth(cell).zero();
-
-	// this is a workaround for a crash (New, Insert->Tabular,
-	// Insert->FootNote)
-	if (!owner())
-		return false;
-
-	// well we didn't obviously find it so maybe our owner knows more
-	BOOST_ASSERT(owner());
-	return owner()->forceDefaultParagraphs(in);
-#endif
-	return false;
 }
 
 
Index: insets/insettabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v
retrieving revision 1.208
diff -p -u -r1.208 insettabular.h
--- insets/insettabular.h	7 Sep 2005 10:37:04 -0000	1.208
+++ insets/insettabular.h	13 Nov 2005 11:28:29 -0000
@@ -117,8 +117,9 @@ public:
 	///
 	void markErased(bool);
 
-	// this should return true if we have a "normal" cell, otherwise true.
+	// this should return true if we have a "normal" cell, otherwise false.
 	// "normal" means without width set!
+	/// should all paragraphs be output with "Standard" layout?
 	bool forceDefaultParagraphs(InsetBase const * in) const;
 
 	///

Reply via email to