Georg Baum wrote:
> I see. I would also document the argument of forceDefaultParagraphs in
> insetbase.h so that misunderstandings like in the current code do not
> longer happen:
>
> /// if this inset has paragraphs should they be output all as default
> /// paragraphs with "Standard" layout?
> /// \p in is a cell in case of tables.
> virtual bool forceDefaultParagraphs(InsetBase const * in) const
> { return false; }

Is it worth it to add the argument for documentation purposes?
Attached is a patch with some mor FIXME's and the proposed documentation 
(without having added the argument).

Would this be acceptable for 1.4? If yes, can I apply it?

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	14 Nov 2005 10:33:31 -0000
@@ -430,7 +430,15 @@ 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
+		// FIXME: redesign insettabular/cell to avoid such extra code
+		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	14 Nov 2005 10:33:34 -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,16 @@ 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
+		// FIXME: redesign insettabular/cell to avoid such extra code
+		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/insetbase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v
retrieving revision 1.60
diff -p -u -r1.60 insetbase.h
--- insets/insetbase.h	10 Nov 2005 10:19:05 -0000	1.60
+++ insets/insetbase.h	14 Nov 2005 10:33:37 -0000
@@ -327,6 +327,7 @@ public:
 	virtual bool insetAllowed(Code) const { return false; }
 	/// if this inset has paragraphs should they be output all as default
 	/// paragraphs with "Standard" layout?
+	/// \p in is a cell in case of tables.
 	virtual bool forceDefaultParagraphs(InsetBase const *) const { return false; }
 
 	///
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	14 Nov 2005 10:33:41 -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	14 Nov 2005 10:33:41 -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