From 1c84d0ca821f847eb34a848dc7150007f2c8c46b Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Thu, 3 Nov 2016 23:23:11 +0100 Subject: [PATCH] Don't parse multicolumn if the grid does not support it Fixes #10466 and visual/compilation bugs with InsetMathSplit, InsetMathDiagram, InsetMathHull, InsetMathSubstack and InsetMathXYMatrix. --- src/mathed/InsetMathAMSArray.h | 2 ++ src/mathed/InsetMathArray.h | 2 ++ src/mathed/InsetMathCases.h | 2 ++ src/mathed/InsetMathGrid.h | 2 ++ src/mathed/InsetMathHull.cpp | 1 - src/mathed/InsetMathMatrix.h | 2 ++ src/mathed/InsetMathSplit.cpp | 5 ----- src/mathed/InsetMathTabular.h | 2 ++ src/mathed/MathParser.cpp | 2 +- 9 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mathed/InsetMathAMSArray.h b/src/mathed/InsetMathAMSArray.h index 584397302d..c337c781a0 100644 --- a/src/mathed/InsetMathAMSArray.h +++ b/src/mathed/InsetMathAMSArray.h @@ -58,6 +58,8 @@ public: int leftMargin() const { return 6; } //override /// int rightMargin() const { return 8; } //override + /// + bool handlesMulticolumn() const { return true; } //override private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathArray.h b/src/mathed/InsetMathArray.h index a3875e58b7..b1cc3110ab 100644 --- a/src/mathed/InsetMathArray.h +++ b/src/mathed/InsetMathArray.h @@ -53,6 +53,8 @@ public: int leftMargin() const { return 4; } //override /// int rightMargin() const { return 2; } //override + /// + bool handlesMulticolumn() const { return true; } //override private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathCases.h b/src/mathed/InsetMathCases.h index 3b44b823ca..84e13979e8 100644 --- a/src/mathed/InsetMathCases.h +++ b/src/mathed/InsetMathCases.h @@ -56,6 +56,8 @@ public: int leftMargin() const { return 8; } //override /// int rightMargin() const { return 0; } //override + /// see e.g. https://tex.stackexchange.com/a/133283/87201 + bool handlesMulticolumn() const { return true; } //override private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h index 61e7e235c8..4300dc3188 100644 --- a/src/mathed/InsetMathGrid.h +++ b/src/mathed/InsetMathGrid.h @@ -211,6 +211,8 @@ public: virtual int vlinesep() const; /// virtual int border() const; + /// + virtual bool handlesMulticolumn() const { return false; } /// void write(WriteStream & os) const; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 2bb8822acc..e2ceb5c903 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -15,7 +15,6 @@ #include "InsetMathChar.h" #include "InsetMathColor.h" #include "InsetMathFrac.h" -#include "InsetMathGrid.h" #include "InsetMathNest.h" #include "InsetMathScript.h" #include "MathExtern.h" diff --git a/src/mathed/InsetMathMatrix.h b/src/mathed/InsetMathMatrix.h index 26a8544026..d64ba3006c 100644 --- a/src/mathed/InsetMathMatrix.h +++ b/src/mathed/InsetMathMatrix.h @@ -47,6 +47,8 @@ public: void octave(OctaveStream &) const; /// InsetCode lyxCode() const { return MATH_MATRIX_CODE; } + /// + bool handlesMulticolumn() const { return true; } //override private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathSplit.cpp b/src/mathed/InsetMathSplit.cpp index e385e0a09a..fb2ecbe083 100644 --- a/src/mathed/InsetMathSplit.cpp +++ b/src/mathed/InsetMathSplit.cpp @@ -48,11 +48,6 @@ Inset * InsetMathSplit::clone() const } -// FIXME: InsetMathGrid should be changed to let the real column alignment be -// given by a virtual method like displayColAlign, because the values produced -// by defaultColAlign can be invalidated by lfuns such as add-column. I suspect -// that for the moment the values produced by defaultColAlign are not used, -// notably because alignment is not implemented in the LyXHTML output. char InsetMathSplit::defaultColAlign(col_type col) { if (name_ == "gathered") diff --git a/src/mathed/InsetMathTabular.h b/src/mathed/InsetMathTabular.h index ed88bd633f..481d28ef0e 100644 --- a/src/mathed/InsetMathTabular.h +++ b/src/mathed/InsetMathTabular.h @@ -49,6 +49,8 @@ public: int leftMargin() const { return 4; } //override /// int rightMargin() const { return 2; } //override + /// + bool handlesMulticolumn() const { return true; } //override private: Inset * clone() const; diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 4504a13a26..ffb828361c 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -1363,7 +1363,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, } } - else if (t.cs() == "multicolumn") { + else if (t.cs() == "multicolumn" && grid.handlesMulticolumn()) { // if the columns are specified numerically, // extract column count and insert dummy cells, // otherwise parse it as an user macro