From fc1b3149985a0f94cceaa502e86072c0984e362e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 24 Apr 2002 17:07:42 +0000 Subject: [PATCH] fix crash due to wrong export of AMS's pmatrix etc in math-extern git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4060 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_amsarrayinset.C | 7 ------- src/mathed/math_amsarrayinset.h | 2 -- src/mathed/math_extern.C | 14 ++++++++++++-- src/mathed/math_inset.h | 2 ++ src/mathed/math_mathmlstream.C | 7 +++++++ src/mathed/math_mathmlstream.h | 2 ++ src/mathed/math_matrixinset.C | 8 ++++---- src/mathed/math_matrixinset.h | 6 +++--- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index efd88cf89f..367c44669d 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -90,10 +90,3 @@ void MathAMSArrayInset::normalize(NormalStream & os) const os << "]"; } - -void MathAMSArrayInset::maplize(MapleStream & os) const -{ - os << name_ << "("; - MathGridInset::maplize(os); - os << ")"; -} diff --git a/src/mathed/math_amsarrayinset.h b/src/mathed/math_amsarrayinset.h index 27154a99be..6f9d39809f 100644 --- a/src/mathed/math_amsarrayinset.h +++ b/src/mathed/math_amsarrayinset.h @@ -28,8 +28,6 @@ public: void write(WriteStream & os) const; /// void normalize(NormalStream &) const; - /// - void maplize(MapleStream &) const; private: /// diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index 1f9e516752..0e0a528012 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -4,6 +4,7 @@ #include +#include "math_amsarrayinset.h" #include "math_charinset.h" #include "math_deliminset.h" #include "math_diffinset.h" @@ -164,14 +165,23 @@ MathInset * singleItem(MathArray & ar) void extractMatrices(MathArray & ar) { //lyxerr << "\nMatrices from: " << ar << "\n"; + // first pass for explicitly delimited stuff for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) { MathDelimInset * del = (*it)->asDelimInset(); if (!del) continue; MathInset * arr = singleItem(del->cell(0)); - if (!arr || !arr->asArrayInset()) + if (!arr || !arr->asGridInset()) continue; - *it = MathAtom(new MathMatrixInset(*(arr->asArrayInset()))); + *it = MathAtom(new MathMatrixInset(*(arr->asGridInset()))); + } + + // second pass for AMS "pmatrix" etc + for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) { + MathAMSArrayInset * ams = (*it)->asAMSArrayInset(); + if (!ams) + continue; + *it = MathAtom(new MathMatrixInset(*ams)); } //lyxerr << "\nMatrices to: " << ar << "\n"; } diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 20662bdb85..3bdff2dbbf 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -47,6 +47,7 @@ inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset. class MathArrayInset; +class MathAMSArrayInset; class MathBraceInset; class MathBoxInset; class MathCharInset; @@ -182,6 +183,7 @@ public: virtual bool validCell(idx_type) const { return true; } /// identifies certain types of insets + virtual MathAMSArrayInset * asAMSArrayInset() { return 0; } virtual MathArrayInset * asArrayInset() { return 0; } virtual MathBraceInset * asBraceInset() { return 0; } virtual MathBoxInset * asBoxInset() { return 0; } diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 9f9c1dc7d5..a10691ea1b 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -149,6 +149,13 @@ OctaveStream & operator<<(OctaveStream & ns, char c) } +OctaveStream & operator<<(OctaveStream & ns, int i) +{ + ns.os() << i; + return ns; +} + + ////////////////////////////////////////////////////////////////////// diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 364e5c1077..744156946e 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -150,6 +150,8 @@ OctaveStream & operator<<(OctaveStream &, MathArray const &); OctaveStream & operator<<(OctaveStream &, char const *); /// OctaveStream & operator<<(OctaveStream &, char); +/// +OctaveStream & operator<<(OctaveStream &, int); diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 25cece5aa9..330c3cef62 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -8,8 +8,8 @@ #include "Lsstream.h" -MathMatrixInset::MathMatrixInset(MathArrayInset const & p) - : MathArrayInset(p) +MathMatrixInset::MathMatrixInset(MathGridInset const & p) + : MathGridInset(p) {} @@ -21,13 +21,13 @@ MathInset * MathMatrixInset::clone() const void MathMatrixInset::write(WriteStream & os) const { - MathArrayInset::write(os); + MathGridInset::write(os); } void MathMatrixInset::normalize(NormalStream & os) const { - MathArrayInset::normalize(os); + MathGridInset::normalize(os); } diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index dd1636131b..57d45d61ea 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -2,7 +2,7 @@ #ifndef MATH_MATRIXINSET_H #define MATH_MATRIXINSET_H -#include "math_arrayinset.h" +#include "math_gridinset.h" #ifdef __GNUG__ #pragma interface @@ -10,10 +10,10 @@ // "shortcut" for DelimInset("(",ArrayInset,")") -class MathMatrixInset : public MathArrayInset { +class MathMatrixInset : public MathGridInset { public: /// - MathMatrixInset(MathArrayInset const &); + MathMatrixInset(MathGridInset const &); /// MathMatrixInset(string const & str); /// -- 2.39.2