]> git.lyx.org Git - features.git/commitdiff
- backport fix for bug #10466
authorUwe Stöhr <uwestoehr@lyx.org>
Tue, 18 Apr 2017 21:53:27 +0000 (23:53 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Tue, 18 Apr 2017 21:53:27 +0000 (23:53 +0200)
Handle the command \multicolumn correctly in math macros

src/mathed/InsetMathAMSArray.h
src/mathed/InsetMathArray.h
src/mathed/InsetMathCases.h
src/mathed/InsetMathGrid.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathMatrix.h
src/mathed/InsetMathSplit.cpp
src/mathed/InsetMathTabular.h
src/mathed/MathParser.cpp
status.22x

index ceb3069c28190b83d8fb0bad38e461e9a75e3192..e5151f11bb4a2764b8b84a37804d8c2d5b3471a7 100644 (file)
@@ -54,6 +54,9 @@ public:
        char const * name_left() const;
        ///
        char const * name_right() const;
+       /// 
+       bool handlesMulticolumn() const { return true; } //override 
+
 private:
        virtual Inset * clone() const;
        ///
index 79236882c7198ed87f9ed857567aa19704e29130..f01887ca293379444fad681458328ed76830c543 100644 (file)
@@ -51,6 +51,9 @@ public:
        void validate(LaTeXFeatures & features) const;
        ///
        InsetCode lyxCode() const { return MATH_ARRAY_CODE; }
+       /// 
+       bool handlesMulticolumn() const { return true; } //override 
+
 private:
        virtual Inset * clone() const;
        ///
index 7820922f07fd95bc45b023a158389cff8ada6f68..c0d9abfef726aff82a8f22b5eb08313190d728ab 100644 (file)
@@ -54,6 +54,9 @@ public:
        InsetCode lyxCode() const { return MATH_CASES_CODE; }
        ///
        int displayColSpace(col_type) const;
+       /// see e.g. https://tex.stackexchange.com/a/133283/87201 
+       bool handlesMulticolumn() const { return true; } //override
+
 private:
        virtual Inset * clone() const;
 };
index 426d941f19167bfa43be63ac68481575d7a31d45..1ea2e2781c4196719406595bfa4f62a77e0f67f8 100644 (file)
@@ -221,6 +221,8 @@ public:
        virtual int vlinesep() const;
        ///
        virtual int border() const;
+       /// 
+       virtual bool handlesMulticolumn() const { return false; }
 
        ///
        void write(WriteStream & os) const;
index cd069c3da5bd055332b33815d079c158aa692f49..d82e934d179ac4b1d12b96f04af94ed104f9dbaf 100644 (file)
@@ -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"
index 26a854402606476c29b14cb78aa5010f33ff773c..95829ac2394af89e1694b8656f4af1a9ecefe7d8 100644 (file)
@@ -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;
index e385e0a09ac3c3d735592d5bc7e8620278aff5ae..fb2ecbe083148047a843f849c4945571eab2d5ae 100644 (file)
@@ -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")
index a4aa50f1b9137874e4d7f8c7c40dfe686a28e017..8fb06bd2c9fa98ed7321558f4bbdfafbf042ed60 100644 (file)
@@ -47,6 +47,8 @@ public:
        void maple(MapleStream &) const;
        ///
        InsetCode lyxCode() const { return MATH_TABULAR_CODE; }
+       /// 
+       bool handlesMulticolumn() const { return true; } //override
 
 private:
        Inset * clone() const;
index f05af6438d59929aa5324ae24dc10e68e9617249..a2094c920ed262585b82dc8409517a0f0311fa67 100644 (file)
@@ -1361,36 +1361,39 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        }
                }
 
-               else if (t.cs() == "multicolumn") {
-                       // extract column count and insert dummy cells
+               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
                        MathData count;
                        parse(count, FLAG_ITEM, mode);
-                       int cols = 1;
-                       if (!extractNumber(count, cols)) {
-                               success_ = false;
-                               error("can't extract number of multicolumn cells");
-                       }
-                       // resize the table if necessary
-                       size_t first = grid.index(cellrow, cellcol);
-                       for (int i = 1; i < cols; ++i) {
-                               if (addCol(grid, cellcol)) {
-                                       size_t const idx = grid.index(cellrow, cellcol);
-                                       grid.cellinfo(idx).multi_ =
-                                               InsetMathGrid::CELL_PART_OF_MULTICOLUMN;
+                       int cols;
+                       if (extractNumber(count, cols)) {
+                               // resize the table if necessary
+                               size_t first = grid.index(cellrow, cellcol);
+                               for (int i = 1; i < cols; ++i) {
+                                       if (addCol(grid, cellcol)) {
+                                               size_t const idx = grid.index(cellrow, cellcol);
+                                               grid.cellinfo(idx).multi_ = 
+                                                       InsetMathGrid::CELL_PART_OF_MULTICOLUMN;
+                                       }
                                }
-                       }
-
-                       // the first cell is the real thing, not a dummy
-                       cell = &grid.cell(first);
-                       grid.cellinfo(first).multi_ = InsetMathGrid::CELL_BEGIN_OF_MULTICOLUMN;
 
-                       // read special alignment
-                       MathData align;
-                       parse(align, FLAG_ITEM, mode);
-                       grid.cellinfo(first).align_ = asString(align);
-
-                       // parse the remaining contents into the "real" cell
-                       parse(*cell, FLAG_ITEM, mode);
+                               // the first cell is the real thing, not a dummy 
+                               cell = &grid.cell(first); 
+                               grid.cellinfo(first).multi_ =
+                                       InsetMathGrid::CELL_BEGIN_OF_MULTICOLUMN; 
+                               // read special alignment 
+                               MathData align; 
+                               parse(align, FLAG_ITEM, mode); 
+                               grid.cellinfo(first).align_ = asString(align); 
+                               // parse the remaining contents into the "real" cell
+                               parse(*cell, FLAG_ITEM, mode); 
+                       } else {
+                               MathAtom at = MathAtom(new MathMacro(buf, t.cs()));
+                               cell->push_back(at);
+                               cell->push_back(MathAtom(new InsetMathBrace(count)));
+                       }
                }
 
                else if (t.cs() == "limits" || t.cs() == "nolimits") {
index b93ba9369e944cf5a375cb5cafa9178ad7f7cff3..d7a5bb91364368cec52c8bab7aa779aa65780a7f 100644 (file)
@@ -160,7 +160,7 @@ What's new
 
 - Do not convert "--" to "\twohyphens" in formula macros.
 
-- Fix bug in the reversion of colored boxes with special frame settings.
+- Fix bugs in the reversion of colored boxes with special frame settings.
 
 
 * USER INTERFACE
@@ -219,6 +219,8 @@ What's new
 - Fix display and output of math macros with optional arguments appearing
   in the optional argument of another macro.
 
+- Handle the command \multicolumn correctly in math macros (bug 10466).
+
 - Do not prematurely cut selected text when inserting a Hyperref (bug 10306).
 
 - Consider the argument of the hyperref-insert function even if there is a