From: Richard Heck Date: Wed, 16 Dec 2009 17:01:09 +0000 (+0000) Subject: Detect appropriate delimiter for matrices. X-Git-Tag: 2.0.0~4798 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=05f1f323de8c11c1d4b56568a650dc4878a3749a;p=features.git Detect appropriate delimiter for matrices. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32549 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathAMSArray.h b/src/mathed/InsetMathAMSArray.h index 76ca3208fb..2214389c7c 100644 --- a/src/mathed/InsetMathAMSArray.h +++ b/src/mathed/InsetMathAMSArray.h @@ -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_; }; diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp index 0460a9443f..d368f217b7 100644 --- a/src/mathed/InsetMathMatrix.cpp +++ b/src/mathed/InsetMathMatrix.cpp @@ -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 << "["; + os << "" + << left_ << ""; 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 << "]"; + os << "" + << right_ << ""; } diff --git a/src/mathed/InsetMathMatrix.h b/src/mathed/InsetMathMatrix.h index 971c30129e..a62c8ea44b 100644 --- a/src/mathed/InsetMathMatrix.h +++ b/src/mathed/InsetMathMatrix.h @@ -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_; }; diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index 95432cc4b0..0dd9ecd230 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -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; }