From f10555975235c3062d0fee9fe97a607edc33bf31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 7 Nov 2001 18:15:24 +0000 Subject: [PATCH] more mathml stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2979 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/array.C | 24 ++++++++++++-------- src/mathed/formula.C | 2 +- src/mathed/math_deliminset.C | 24 ++++++++++++-------- src/mathed/math_deliminset.h | 6 +++-- src/mathed/math_gridinset.C | 42 ++++++++++++++++++++++------------- src/mathed/math_gridinset.h | 6 +++-- src/mathed/math_matrixinset.C | 5 +++++ src/mathed/math_matrixinset.h | 2 ++ 8 files changed, 73 insertions(+), 38 deletions(-) diff --git a/src/mathed/array.C b/src/mathed/array.C index 7a3af65925..cc53477b0c 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -276,16 +276,22 @@ void MathArray::maplize(MapleStream & os) const void MathArray::mathmlize(MathMLStream & os) const { MathArray ar = glueChars(); - os << ""; - for (const_iterator it = ar.begin(); it != ar.end(); ++it) { - MathInset const * p = it->nucleus(); - if (MathScriptInset const * q = ar.asScript(it)) { - q->mathmlize(p, os); - ++it; - } else - p->mathmlize(os); + if (ar.size() == 0) + os << ""; + else if (ar.size() == 1) + os << ar.begin()->nucleus(); + else { + os << ""; + for (const_iterator it = ar.begin(); it != ar.end(); ++it) { + MathInset const * p = it->nucleus(); + if (MathScriptInset const * q = ar.asScript(it)) { + q->mathmlize(p, os); + ++it; + } else + p->mathmlize(os); + } + os << ""; } - os << ""; } diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 506928cd7b..2de2bfd602 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -307,7 +307,7 @@ int InsetFormula::docbook(Buffer const * buf, ostream & os) const MathMLStream ms(os); ms << ""; int res = ascii(buf, ms.os_, 0); - ms << "\n" << par_.nucleus() << ""; + ms << "\n" << par_.nucleus() << ""; return res + 1; } diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 50e86abd29..d0191cc87b 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -100,15 +100,6 @@ bool MathDelimInset::isMatrix() const } -void MathDelimInset::octavize(OctaveStream & os) const -{ - if (left_ == "|" && right_ == "|") - os << "det(" << cell(0) << ")"; - else - os << left_.c_str() << cell(0) << right_.c_str(); -} - - void MathDelimInset::maplize(MapleStream & os) const { if (left_ == "|" && right_ == "|") { @@ -121,3 +112,18 @@ void MathDelimInset::maplize(MapleStream & os) const os << left_.c_str() << cell(0) << right_.c_str(); } + +void MathDelimInset::mathmlize(MathMLStream & os) const +{ + os << "" << cell(0) << ""; +} + + +void MathDelimInset::octavize(OctaveStream & os) const +{ + if (left_ == "|" && right_ == "|") + os << "det(" << cell(0) << ")"; + else + os << left_.c_str() << cell(0) << right_.c_str(); +} diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 88f0fcce44..e5d5d4aa60 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -30,9 +30,11 @@ public: /// bool isMatrix() const; /// - void octavize(OctaveStream &) const; - /// void maplize(MapleStream &) const; + /// + void mathmlize(MathMLStream &) const; + /// + void octavize(OctaveStream &) const; private: /// int dw() const; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 40cca94d6f..75d9e8e200 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -587,21 +587,6 @@ std::vector } -void MathGridInset::octavize(OctaveStream & os) const -{ - os << '['; - for (row_type row = 0; row < nrows(); ++row) { - if (row) - os << ';'; - os << '['; - for (col_type col = 0; col < ncols(); ++col) - os << cell(index(row, col)) << ' '; - os <<']'; - } - os <<']'; -} - - void MathGridInset::maplize(MapleStream & os) const { os << "array(["; @@ -619,3 +604,30 @@ void MathGridInset::maplize(MapleStream & os) const os << "])"; } + +void MathGridInset::mathmlize(MathMLStream & os) const +{ + os << ""; + for (row_type row = 0; row < nrows(); ++row) { + os << ""; + for (col_type col = 0; col < ncols(); ++col) + os << cell(index(row, col)); + os << ""; + } + os << ""; +} + + +void MathGridInset::octavize(OctaveStream & os) const +{ + os << '['; + for (row_type row = 0; row < nrows(); ++row) { + if (row) + os << ';'; + os << '['; + for (col_type col = 0; col < ncols(); ++col) + os << cell(index(row, col)) << ' '; + os << ']'; + } + os << ']'; +} diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index c6de00adcf..e87a537cf2 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -149,10 +149,12 @@ public: /// void setDefaults(); - /// - void octavize(OctaveStream &) const; /// void maplize(MapleStream &) const; + /// + void mathmlize(MathMLStream &) const; + /// + void octavize(OctaveStream &) const; protected: /// returns proper 'end of line' code for LaTeX diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 4fa1ebd1f1..cfdbb1b1bd 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -215,6 +215,11 @@ void MathMatrixInset::writeNormal(std::ostream & os) const } +void MathMatrixInset::mathmlize(MathMLStream & os) const +{ + MathGridInset::mathmlize(os); +} + string MathMatrixInset::label(row_type row) const { diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index c6cdaab385..2a06385053 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -80,6 +80,8 @@ public: /// MathInsetTypes getType() const; + /// + void mathmlize(MathMLStream &) const; private: /// -- 2.39.2