]> git.lyx.org Git - lyx.git/commitdiff
Detect appropriate delimiter for matrices.
authorRichard Heck <rgheck@comcast.net>
Wed, 16 Dec 2009 17:01:09 +0000 (17:01 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 16 Dec 2009 17:01:09 +0000 (17:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32549 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathAMSArray.h
src/mathed/InsetMathMatrix.cpp
src/mathed/InsetMathMatrix.h
src/mathed/MathExtern.cpp

index 76ca3208fbf4387e6b1520db6eea3dbf9d7b8eb9..2214389c7cc0e792a68441e3ef4c8f2b28f51b9f 100644 (file)
@@ -46,12 +46,12 @@ public:
        void validate(LaTeXFeatures & features) const;
        ///
        InsetCode lyxCode() const { return MATH_AMSARRAY_CODE; }
-private:
-       virtual Inset * clone() const;
        ///
        char const * name_left() const;
        ///
        char const * name_right() const;
+private:
+       virtual Inset * clone() const;
        ///
        docstring name_;
 };
index 0460a9443ffd2dc14e992f596ef5f1b10002dfe5..d368f217b7b1493485c0ebbc652f5bd487824ae4 100644 (file)
@@ -17,8 +17,9 @@
 
 namespace lyx {
 
-InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p)
-       : InsetMathGrid(p)
+InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p, 
+                       docstring const & left, docstring const & right)
+       : InsetMathGrid(p), left_(left), right_(right)
 {}
 
 
@@ -88,15 +89,10 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const
 }
 
 
-// FIXME XHTML
-// We need more information here, so we can output the correct
-// delimiters, which will not always be "[". To do this, we need
-// to make some changes to InsetMathMatrix, adding a member to 
-// record the type of delimiter, and then make the extractMatrices 
-// routine in MathExtern give us this information.
 void InsetMathMatrix::mathmlize(MathStream & os) const
 {
-       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>[</mo>";
+       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << left_ << "</mo>";
        os << MTag("mtable");
        for (row_type row = 0; row < nrows(); ++row) {
                os << MTag("mtr");
@@ -105,7 +101,8 @@ void InsetMathMatrix::mathmlize(MathStream & os) const
                os << ETag("mtr");
        }
        os << ETag("mtable");
-       os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>]</mo>";
+       os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << right_ << "</mo>";
 }
 
 
index 971c30129ed6c772782958554d42f7537165cb59..a62c8ea44b7bfb5a020e962b9810758b20099950 100644 (file)
@@ -13,6 +13,7 @@
 #define MATH_MATRIXINSET_H
 
 #include "InsetMathGrid.h"
+#include "support/strfwd.h"
 
 
 namespace lyx {
@@ -23,9 +24,8 @@ namespace lyx {
 class InsetMathMatrix : public InsetMathGrid {
 public:
        ///
-       explicit InsetMathMatrix(InsetMathGrid const &);
-       ///
-       explicit InsetMathMatrix(Buffer * buf, docstring const & str);
+       explicit InsetMathMatrix(InsetMathGrid const &, 
+                       docstring const & left, docstring const & right);
        /// identifies MatrixInsets
        InsetMathMatrix const * asMatrixInset() const { return this; }
 
@@ -48,6 +48,10 @@ public:
 
 private:
        virtual Inset * clone() const;
+       ///
+       docstring left_;
+       ///
+       docstring right_;
 };
 
 
index 95432cc4b08460f414cdf561e9ca1254d7f33a77..0dd9ecd2303a0dad90fc83dbda40c777c2954991 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "MathExtern.h"
 
+#include "InsetMathAMSArray.h"
 #include "InsetMathArray.h"
 #include "InsetMathChar.h"
 #include "InsetMathDelim.h"
@@ -193,20 +194,31 @@ void extractMatrices(MathData & ar)
        //lyxerr << "\nMatrices from: " << ar << endl;
        // first pass for explicitly delimited stuff
        for (size_t i = 0; i < ar.size(); ++i) {
-               if (!ar[i]->asDelimInset())
+               InsetMathDelim const * const inset = ar[i]->asDelimInset();
+               if (!inset)
                        continue;
-               MathData const & arr = ar[i]->asDelimInset()->cell(0);
+               MathData const & arr = inset->cell(0);
                if (arr.size() != 1)
                        continue;
                if (!arr.front()->asGridInset())
                        continue;
-               ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset())));
+               ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset()), 
+                                inset->left_, inset->right_));
        }
 
        // second pass for AMS "pmatrix" etc
-       for (size_t i = 0; i < ar.size(); ++i)
-               if (ar[i]->asAMSArrayInset())
-                       ar[i] = MathAtom(new InsetMathMatrix(*(ar[i]->asGridInset())));
+       for (size_t i = 0; i < ar.size(); ++i) {
+               InsetMathAMSArray const * const inset = ar[i]->asAMSArrayInset();
+               if (inset) {
+                       string left = inset->name_left();
+                       if (left == "Vert")
+                               left = "[";
+                       string right = inset->name_right();
+                       if (right == "Vert")
+                               right = "]";
+                       ar[i] = MathAtom(new InsetMathMatrix(*inset, from_ascii(left), from_ascii(right)));
+               }
+       }
        //lyxerr << "\nMatrices to: " << ar << endl;
 }