On Wed, 2005-10-19 at 17:03 +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> This is the generalized patch. I believe it works always --
> Martin> except when copying/pasting a display math inset from the
> Martin> outside. I see no easy fix to that.
> 
> Actually, this problem should be handled IMO at the insettext level.
> There two kind of texts in latex: paragraph mode and LR mode. In LR
> mode there is no line breaking and things like display math are not
> allowed. So instead of looking whether we are in a tabular (we should
> aim at getting rid of direct testing against inset codes IMO), we
> could have yet another insettext virtual method that tells whether
> this text is in LR mode. The same happens also in an mbox for example.
> 
> But frankly, I do not think that we should care about it right now.
> This is post-1.4.0 stuff.

I agree on both counts. But this is a point fix for this release that
keeps latex-naive users out of trouble. Why not put it in, perhaps with
a FIXME?

Attached again, after Angus' and Georg's critique.

- Martin

Index: math_hullinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v
retrieving revision 1.179
diff -u -p -r1.179 math_hullinset.C
--- math_hullinset.C	18 Jul 2005 17:12:28 -0000	1.179
+++ math_hullinset.C	20 Oct 2005 07:22:24 -0000
@@ -561,6 +561,27 @@ bool MathHullInset::colChangeOK() const
 }
 
 
+namespace {
+
+bool inTable(LCursor & cur)
+{
+	bool ret = false;
+	lyx::size_type n = cur.depth() - 1;
+	// If at any level a tabular, display math is not allowed:
+	for (int i = 0; i != n; ++i)
+		if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
+			ret = true;
+			break;
+		}
+	// ... unless contained in a box.
+	if (cur[cur.depth() - 2].inset().lyxCode() == InsetBase::BOX_CODE)
+	    	ret = false;
+	return ret;
+}
+
+} // end anon namespace
+
+
 void MathHullInset::addRow(row_type row)
 {
 	if (!rowChangeOK())
@@ -1129,7 +1150,7 @@ bool MathHullInset::getStatus(LCursor & 
 	case LFUN_MATH_MUTATE:
 	case LFUN_MATH_DISPLAY:
 		// we handle these
-		status.enabled(true);
+		status.enabled(!inTable(cur) || type_ != "simple");
 		return true;
 	case LFUN_INSERT_LABEL:
 		status.enabled(type_ != "simple");

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to