Author: vfr
Date: Fri Dec  3 03:44:16 2010
New Revision: 36673
URL: http://www.lyx.org/trac/changeset/36673

Log:
Fix bug #2100: No display equations allowed in a non-fixed width tabular cell.

Modified:
   lyx-devel/trunk/src/insets/InsetTabular.cpp
   lyx-devel/trunk/src/mathed/InsetMathHull.cpp

Modified: lyx-devel/trunk/src/insets/InsetTabular.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetTabular.cpp Fri Dec  3 03:42:25 2010        
(r36672)
+++ lyx-devel/trunk/src/insets/InsetTabular.cpp Fri Dec  3 03:44:16 2010        
(r36673)
@@ -3226,7 +3226,7 @@
 bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd,
        FuncStatus & status) const
 {
-       bool enabled;
+       bool enabled = true;
        switch (cmd.action()) {
        case LFUN_LAYOUT:
                enabled = !forcePlainLayout();
@@ -3234,6 +3234,12 @@
        case LFUN_LAYOUT_PARAGRAPH:
                enabled = allowParagraphCustomization();
                break;
+
+       case LFUN_MATH_DISPLAY:
+               if (!hasFixedWidth()) {
+                       enabled = false;
+                       break;
+               } //fall-through
        default:
                return InsetText::getStatus(cur, cmd, status);
        }

Modified: lyx-devel/trunk/src/mathed/InsetMathHull.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathHull.cpp        Fri Dec  3 03:42:25 
2010        (r36672)
+++ lyx-devel/trunk/src/mathed/InsetMathHull.cpp        Fri Dec  3 03:44:16 
2010        (r36673)
@@ -1480,9 +1480,25 @@
                return true;
 
        case LFUN_MATH_MUTATE: {
-               HullType ht = hullType(cmd.argument());
+               HullType const ht = hullType(cmd.argument());
                status.setOnOff(type_ == ht);
-               // fall through
+               status.setEnabled(true);
+
+               if (ht != hullSimple) {
+                       Cursor tmpcur = cur;
+                       while (!tmpcur.empty()) {
+                               InsetCode code = tmpcur.inset().lyxCode();
+                               if (code == BOX_CODE) {
+                                       return true;
+                               } else if (code == TABULAR_CODE) {
+                                       FuncRequest tmpcmd(LFUN_MATH_DISPLAY);
+                                       if (tmpcur.getStatus(tmpcmd, status) && 
!status.enabled())
+                                               return true;
+                               }
+                               tmpcur.pop_back();
+                       }
+               }
+               return true;
        }
        case LFUN_MATH_DISPLAY: {
                bool enable = true;

Reply via email to