From: Richard Heck Date: Thu, 31 Dec 2009 03:50:12 +0000 (+0000) Subject: Introduce a return value for mathmlize(). We will need this to be able X-Git-Tag: 2.0.0~4669 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8a0134cc8ce7de41d6d6911a1c4219ca958f2b71;p=features.git Introduce a return value for mathmlize(). We will need this to be able to defer labels. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32684 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/HTML/HTML.notes b/development/HTML/HTML.notes index 9c80dbae46..b9750e3043 100644 --- a/development/HTML/HTML.notes +++ b/development/HTML/HTML.notes @@ -52,37 +52,36 @@ These insets work but still need work: Math We have a fair bit of math now working via MathML output, but there are still some isues, and not all the insets work. Here are the ones I know still need work: - - AMSArray - - Array - - Big: Not sure if we can actually do anything here. Probably they should - just be treated as delimiters. - - BoldSymbol: Should be easy. - - Box - - Cases - - Diff: Code exists, but I do not know if it is right. - - Font - - Binom (in Frac): None of these tags exist in MathML 2.0. We'll - just output a fraction with delimiters. - - Lefteqn - - MBox: Use . - - Overset: Use . - - Par? - - Phantom: There is some support for this in MathML.... - - Ref: Probably needs to be deferred somehow, which is a hassle, because it - means the whole MathML output business needs a new argument. - - Size: Unclear if we want to do anything here, though we could. See - lib/symbols for the commands supported, of course. - - Space: Needs checking. - - SpecialChar: Needs checking. - - Split - - Stackrel: Use , probably. - - Substack: This is a stack of however many cells, all in a smaller style. - Probably do something with , again. - - Tabular: This is more or less a text-like table in math. Probably output it - as a table, but set the font. - - Underset: Use . - - XArrow: Contents above and below an arrow. Use...? - - XYMatrix: Not sure how this differs from ordinary ones. + - AMSArray + - Array + - Big: Not sure if we can actually do anything here. Probably they should + just be treated as delimiters. + - BoldSymbol: Should be easy. + - Box + - Cases + - Diff: Code exists, but I do not know if it is right. + - Font + - Binom (in Frac): None of these tags exist in MathML 2.0. We'll + just output a fraction with delimiters. + - Lefteqn + - MBox: Use . + - Overset: Use . + - Par? + - Phantom: There is some support for this in MathML.... + - Ref: Needs to be deferred. + - Size: Unclear if we want to do anything here, though we could. See + lib/symbols for the commands supported, of course. + - Space: Needs checking. + - SpecialChar: Needs checking. + - Split + - Stackrel: Use , probably. + - Substack: This is a stack of however many cells, all in a smaller style. + Probably do something with , again. + - Tabular: This is more or less a text-like table in math. Probably output it + as a table, but set the font. + - Underset: Use . + - XArrow: Contents above and below an arrow. Use...? + - XYMatrix: Not sure how this differs from ordinary ones. These insets do not work and are not yet scheduled to work: diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp index 0a9772c676..a5cd28a284 100644 --- a/src/mathed/InsetMath.cpp +++ b/src/mathed/InsetMath.cpp @@ -120,12 +120,13 @@ void InsetMath::mathematica(MathematicaStream & os) const } -void InsetMath::mathmlize(MathStream & os) const +docstring InsetMath::mathmlize(MathStream & os) const { os << MTag("mi"); NormalStream ns(os.os()); normalize(ns); os << ETag("mi"); + return docstring(); } diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index 555762c8c7..12ea7ab06c 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -187,7 +187,7 @@ public: /// write content as something readable by Mathematica virtual void mathematica(MathematicaStream &) const; /// write content as something resembling MathML - virtual void mathmlize(MathStream &) const; + virtual docstring mathmlize(MathStream &) const; /// write content as something readable by Octave virtual void octave(OctaveStream &) const; diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index d432794fc0..701a0bb634 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -52,7 +52,7 @@ void InsetMathBox::normalize(NormalStream & os) const } -void InsetMathBox::mathmlize(MathStream & ms) const +docstring InsetMathBox::mathmlize(MathStream & ms) const { // FIXME This doesn't actually work yet. We need to be able to signal // that we are in text mode and then just call ms << cell(0). So we @@ -60,6 +60,7 @@ void InsetMathBox::mathmlize(MathStream & ms) const ms << MTag("mtext"); ms.os() << cell(0); ms << ETag("mtext"); + return docstring(); } diff --git a/src/mathed/InsetMathBox.h b/src/mathed/InsetMathBox.h index 4ef299401d..03d2da9f9e 100644 --- a/src/mathed/InsetMathBox.h +++ b/src/mathed/InsetMathBox.h @@ -35,7 +35,7 @@ public: /// void normalize(NormalStream & ns) const; /// - void mathmlize(MathStream & ms) const; + docstring mathmlize(MathStream & ms) const; /// void infoize(odocstream & os) const; /// @@ -66,7 +66,7 @@ public: /// write normalized content void normalize(NormalStream & ns) const; /// - //void mathmlize(MathStream & ms) const; + //docstring mathmlize(MathStream & ms) const; /// void infoize(odocstream & os) const; private: @@ -89,7 +89,7 @@ public: /// write normalized content void normalize(NormalStream & ns) const; /// - //void mathmlize(MathStream & ms) const; + //docstring mathmlize(MathStream & ms) const; /// mode_type currentMode() const { return TEXT_MODE; } /// @@ -116,7 +116,7 @@ public: /// void write(WriteStream & os) const; /// - //void mathmlize(MathStream & ms) const; + //docstring mathmlize(MathStream & ms) const; /// write normalized content void normalize(NormalStream & ns) const; /// diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp index c1034c9aee..4bf24dfb81 100644 --- a/src/mathed/InsetMathBrace.cpp +++ b/src/mathed/InsetMathBrace.cpp @@ -13,6 +13,7 @@ #include "InsetMathBrace.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" @@ -94,9 +95,12 @@ void InsetMathBrace::octave(OctaveStream & os) const } -void InsetMathBrace::mathmlize(MathStream & os) const +docstring InsetMathBrace::mathmlize(MathStream & os) const { - os << MTag("mrow") << cell(0) << ETag("mrow"); + os << MTag("mrow"); + docstring const rv = lyx::mathmlize(cell(0), os); + os << ETag("mrow"); + return rv; } diff --git a/src/mathed/InsetMathBrace.h b/src/mathed/InsetMathBrace.h index e8e3ea9557..6af0ca32b0 100644 --- a/src/mathed/InsetMathBrace.h +++ b/src/mathed/InsetMathBrace.h @@ -46,7 +46,7 @@ public: /// void octave(OctaveStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void infoize(odocstream & os) const; /// diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 8e02c6a92c..27093e8504 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -165,12 +165,12 @@ void InsetMathChar::octave(OctaveStream & os) const // mathalpha, then we'll treat it as an identifier, otherwise as an // operator. // Worst case: We get bad spacing, or bad italics. -void InsetMathChar::mathmlize(MathStream & ms) const +docstring InsetMathChar::mathmlize(MathStream & ms) const { switch (char_) { - case '<': ms << "<"; return; - case '>': ms << ">"; return; - case '&': ms << "&"; return; + case '<': ms << "<"; return docstring(); + case '>': ms << ">"; return docstring(); + case '&': ms << "&"; return docstring(); default: break; } @@ -179,6 +179,7 @@ void InsetMathChar::mathmlize(MathStream & ms) const ? "mi" : "mo"; // we don't use MTag and ETag because we do not want the spacing ms << "<" << type << ">" << char(char_) << ""; + return docstring(); } diff --git a/src/mathed/InsetMathChar.h b/src/mathed/InsetMathChar.h index 6dba328c4e..d1a865fc15 100644 --- a/src/mathed/InsetMathChar.h +++ b/src/mathed/InsetMathChar.h @@ -41,7 +41,7 @@ public: /// void octave(OctaveStream & os) const; /// - void mathmlize(MathStream & ms) const; + docstring mathmlize(MathStream & ms) const; /// identifies Charinsets InsetMathChar const * asCharInset() const { return this; } /// diff --git a/src/mathed/InsetMathComment.cpp b/src/mathed/InsetMathComment.cpp index ebfba7a859..92693a2c7e 100644 --- a/src/mathed/InsetMathComment.cpp +++ b/src/mathed/InsetMathComment.cpp @@ -86,9 +86,10 @@ void InsetMathComment::octave(OctaveStream &) const {} -void InsetMathComment::mathmlize(MathStream & os) const +docstring InsetMathComment::mathmlize(MathStream & os) const { os << MTag("comment") << cell(0) << cell(1) << ETag("comment"); + return docstring(); } diff --git a/src/mathed/InsetMathComment.h b/src/mathed/InsetMathComment.h index bb775a74cb..2ab35c2805 100644 --- a/src/mathed/InsetMathComment.h +++ b/src/mathed/InsetMathComment.h @@ -44,7 +44,7 @@ public: /// void octave(OctaveStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void infoize(odocstream & os) const; /// diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index 629a440abf..825b212c9d 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -14,6 +14,7 @@ #include "InsetMathDecoration.h" #include "MathData.h" +#include "MathExtern.h" #include "MathParser.h" #include "MathSupport.h" #include "MathStream.h" @@ -205,16 +206,18 @@ namespace { } } -void InsetMathDecoration::mathmlize(MathStream & os) const +docstring InsetMathDecoration::mathmlize(MathStream & os) const { Translator const & t = translator(); Translator::const_iterator cur = t.find(to_utf8(key_->name)); - LASSERT(cur != t.end(), return); + LASSERT(cur != t.end(), return docstring()); char const * const outag = cur->second.over ? "mover" : "munder"; - os << MTag(outag) - << MTag("mrow") << cell(0) << ETag("mrow") + os << MTag(outag) << MTag("mrow"); + docstring const rv = lyx::mathmlize(cell(0), os); + os << ETag("mrow") << from_ascii("" + cur->second.tag + "") << ETag(outag); + return rv; } diff --git a/src/mathed/InsetMathDecoration.h b/src/mathed/InsetMathDecoration.h index 22c9f9bed3..7d77b49ae3 100644 --- a/src/mathed/InsetMathDecoration.h +++ b/src/mathed/InsetMathDecoration.h @@ -42,7 +42,7 @@ public: /// InsetCode lyxCode() const { return MATH_DECORATION_CODE; } /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp index 459866c924..6da49562eb 100644 --- a/src/mathed/InsetMathDelim.cpp +++ b/src/mathed/InsetMathDelim.cpp @@ -14,6 +14,7 @@ #include "InsetMathDelim.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" @@ -161,10 +162,12 @@ void InsetMathDelim::mathematica(MathematicaStream & os) const } -void InsetMathDelim::mathmlize(MathStream & os) const +docstring InsetMathDelim::mathmlize(MathStream & os) const { - os << "" << left_ << "" - << cell(0) << "" << right_ << ""; + os << "" << left_ << ""; + docstring const rv = lyx::mathmlize(cell(0),os); + os << "" << right_ << ""; + return rv; } diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h index 67e1db0906..fb70f24927 100644 --- a/src/mathed/InsetMathDelim.h +++ b/src/mathed/InsetMathDelim.h @@ -56,7 +56,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; /// diff --git a/src/mathed/InsetMathDiff.cpp b/src/mathed/InsetMathDiff.cpp index 1e990d7ffb..f044ab8f15 100644 --- a/src/mathed/InsetMathDiff.cpp +++ b/src/mathed/InsetMathDiff.cpp @@ -12,6 +12,7 @@ #include "InsetMathDiff.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "support/debug.h" @@ -95,15 +96,17 @@ void InsetMathDiff::mathematica(MathematicaStream & os) const } -void InsetMathDiff::mathmlize(MathStream & os) const +docstring InsetMathDiff::mathmlize(MathStream & os) const { os << "diff("; + docstring rv; for (idx_type idx = 0; idx < nargs(); ++idx) { if (idx != 0) os << ','; - os << cell(idx); + rv += lyx::mathmlize(cell(idx), os); } os << ')'; + return rv; } diff --git a/src/mathed/InsetMathDiff.h b/src/mathed/InsetMathDiff.h index 6253168397..f9f1aba088 100644 --- a/src/mathed/InsetMathDiff.h +++ b/src/mathed/InsetMathDiff.h @@ -39,7 +39,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void maxima(MaximaStream &) const; /// diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp index 8ca2a1e469..d1b18fa9b4 100644 --- a/src/mathed/InsetMathDots.cpp +++ b/src/mathed/InsetMathDots.cpp @@ -85,7 +85,7 @@ void InsetMathDots::validate(LaTeXFeatures & features) const } -void InsetMathDots::mathmlize(MathStream & os) const +docstring InsetMathDots::mathmlize(MathStream & os) const { // which symbols we support is decided by what is listed in // lib/symbols as generating a dots inset @@ -106,6 +106,7 @@ void InsetMathDots::mathmlize(MathStream & os) const else LASSERT(false, ent = "…"); os << MTag("mi") << from_ascii(ent) << ETag("mi"); + return docstring(); } } // namespace lyx diff --git a/src/mathed/InsetMathDots.h b/src/mathed/InsetMathDots.h index 4f2428712c..4ba13351e9 100644 --- a/src/mathed/InsetMathDots.h +++ b/src/mathed/InsetMathDots.h @@ -35,7 +35,7 @@ public: /// InsetCode lyxCode() const { return MATH_DOTS_CODE; } /// - void mathmlize(MathStream & os) const; + docstring mathmlize(MathStream & os) const; protected: /// cache for the thing's height mutable int dh_; diff --git a/src/mathed/InsetMathEnsureMath.cpp b/src/mathed/InsetMathEnsureMath.cpp index 8f738a8dae..149bae7d2c 100644 --- a/src/mathed/InsetMathEnsureMath.cpp +++ b/src/mathed/InsetMathEnsureMath.cpp @@ -13,8 +13,9 @@ #include "InsetMathEnsureMath.h" -#include "MathStream.h" +#include "MathExtern.h" #include "MathData.h" +#include "MathStream.h" #include @@ -67,9 +68,9 @@ void InsetMathEnsureMath::write(WriteStream & os) const } -void InsetMathEnsureMath::mathmlize(MathStream & os) const +docstring InsetMathEnsureMath::mathmlize(MathStream & os) const { - os << cell(0); + return lyx::mathmlize(cell(0), os); } diff --git a/src/mathed/InsetMathEnsureMath.h b/src/mathed/InsetMathEnsureMath.h index ccc136a157..c8e58bbe97 100644 --- a/src/mathed/InsetMathEnsureMath.h +++ b/src/mathed/InsetMathEnsureMath.h @@ -36,7 +36,7 @@ public: /// void write(WriteStream & os) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void infoize(odocstream & os) const; /// diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp index 25c8dcbaf9..173436eb61 100644 --- a/src/mathed/InsetMathExFunc.cpp +++ b/src/mathed/InsetMathExFunc.cpp @@ -13,6 +13,7 @@ #include "InsetMathExFunc.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" @@ -122,10 +123,10 @@ void InsetMathExFunc::mathematica(MathematicaStream & os) const } -void InsetMathExFunc::mathmlize(MathStream & os) const +docstring InsetMathExFunc::mathmlize(MathStream & os) const { os << "" << name_ << ""; - os << cell(0); + return lyx::mathmlize(cell(0), os); } diff --git a/src/mathed/InsetMathExFunc.h b/src/mathed/InsetMathExFunc.h index fb6dda8b36..0517484f38 100644 --- a/src/mathed/InsetMathExFunc.h +++ b/src/mathed/InsetMathExFunc.h @@ -43,7 +43,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; /// diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp index 88970e0e96..5277b6cde8 100644 --- a/src/mathed/InsetMathExInt.cpp +++ b/src/mathed/InsetMathExInt.cpp @@ -12,6 +12,7 @@ #include "InsetMathExInt.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathStream.h" #include "InsetMathSymbol.h" @@ -122,7 +123,7 @@ void InsetMathExInt::mathematica(MathematicaStream & os) const } -void InsetMathExInt::mathmlize(MathStream & os) const +docstring InsetMathExInt::mathmlize(MathStream & os) const { // At the moment, we are not extracting sums and the like for MathML. // If we should decide to do so later, then we'll need to re-merge @@ -150,9 +151,11 @@ void InsetMathExInt::mathmlize(MathStream & os) const os << ETag("msub"); else if (upper) os << ETag("msup"); - os << cell(0) << "" + docstring rv = lyx::mathmlize(cell(0), os); + os << "" << MTag("mrow") << "" << cell(1) << ETag("mrow"); + return rv; } diff --git a/src/mathed/InsetMathExInt.h b/src/mathed/InsetMathExInt.h index ced825b890..55aa1f78f2 100644 --- a/src/mathed/InsetMathExInt.h +++ b/src/mathed/InsetMathExInt.h @@ -52,7 +52,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void write(WriteStream & os) const; /// diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index 11d24469db..3fbd56d8fd 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -17,6 +17,7 @@ #include "Cursor.h" #include "LaTeXFeatures.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" @@ -384,12 +385,14 @@ void InsetMathFrac::octave(OctaveStream & os) const } -void InsetMathFrac::mathmlize(MathStream & os) const +docstring InsetMathFrac::mathmlize(MathStream & os) const { - os << MTag("mfrac") - << MTag("mrow") << cell(0) << ETag("mrow") - << MTag("mrow") << cell(1) << ETag("mrow") - << ETag("mfrac"); + os << MTag("mfrac") << MTag("mrow"); + docstring rv = lyx::mathmlize(cell(0), os); + os << ETag("mrow") << MTag("mrow"); + rv += lyx::mathmlize(cell(1), os); + os << ETag("mrow") << ETag("mfrac"); + return rv; } @@ -533,8 +536,9 @@ void InsetMathBinom::normalize(NormalStream & os) const } -void InsetMathBinom::mathmlize(MathStream & os) const +docstring InsetMathBinom::mathmlize(MathStream & os) const { + // FIXME This all needs fixing switch (kind_) { case BINOM: os << MTag("mbinom") << cell(0) << cell(1) << ETag("mbinom"); @@ -547,6 +551,7 @@ void InsetMathBinom::mathmlize(MathStream & os) const os << MTag("mdbinom") << cell(0) << cell(1) << ETag("mdbinom"); break; } + return docstring(); } diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h index 36e7ba363b..14af2f8be3 100644 --- a/src/mathed/InsetMathFrac.h +++ b/src/mathed/InsetMathFrac.h @@ -82,7 +82,7 @@ public: /// void octave(OctaveStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void validate(LaTeXFeatures & features) const; public: @@ -121,7 +121,7 @@ public: /// bool extraBraces() const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void validate(LaTeXFeatures & features) const; /// diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 432a39a2f2..c4fa241857 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -14,6 +14,7 @@ #include "InsetMathGrid.h" #include "MathData.h" +#include "MathExtern.h" #include "MathParser.h" #include "MathStream.h" #include "MetricsInfo.h" @@ -967,19 +968,21 @@ void InsetMathGrid::normalize(NormalStream & os) const } -void InsetMathGrid::mathmlize(MathStream & os) const +docstring InsetMathGrid::mathmlize(MathStream & os) const { bool const havetable = nrows() > 1; if (havetable) os << MTag("mtable"); + docstring rv; for (row_type row = 0; row < nrows(); ++row) { os << MTag("mrow"); for (col_type col = 0; col < ncols(); ++col) - os << cell(index(row, col)); + rv += lyx::mathmlize(cell(index(row, col)), os); os << ETag("mrow"); } if (havetable) os << ETag("mtable"); + return rv; } diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h index 926216ea1c..aaef2aaa21 100644 --- a/src/mathed/InsetMathGrid.h +++ b/src/mathed/InsetMathGrid.h @@ -219,7 +219,7 @@ public: /// //void maple(MapleStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// //void octave(OctaveStream &) const; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 57137db2f2..492e748d79 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1092,9 +1092,9 @@ void InsetMathHull::normalize(NormalStream & os) const } -void InsetMathHull::mathmlize(MathStream & os) const +docstring InsetMathHull::mathmlize(MathStream & os) const { - InsetMathGrid::mathmlize(os); + return InsetMathGrid::mathmlize(os); } @@ -1782,9 +1782,9 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const &) const xs << StartTag("math", "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); MathStream ms(xs.os()); - InsetMathGrid::mathmlize(ms); + docstring const rv = InsetMathGrid::mathmlize(ms); xs << EndTag("math"); - return docstring(); + return rv; } diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index db4d2ff89c..a48edd1da5 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -102,7 +102,7 @@ public: /// void write(WriteStream & os) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void normalize(NormalStream &) const; /// diff --git a/src/mathed/InsetMathKern.cpp b/src/mathed/InsetMathKern.cpp index 7f990f9968..fddecfe58e 100644 --- a/src/mathed/InsetMathKern.cpp +++ b/src/mathed/InsetMathKern.cpp @@ -73,4 +73,10 @@ void InsetMathKern::normalize(NormalStream & os) const } +docstring InsetMathKern::mathmlize(MathStream &) const +{ + return docstring(); +} + + } // namespace lyx diff --git a/src/mathed/InsetMathKern.h b/src/mathed/InsetMathKern.h index bd26e4e021..db701cf158 100644 --- a/src/mathed/InsetMathKern.h +++ b/src/mathed/InsetMathKern.h @@ -39,7 +39,7 @@ public: /// void normalize(NormalStream & ns) const; /// - void mathmlize(MathStream &) const { } + docstring mathmlize(MathStream &) const; /// InsetCode lyxCode() const { return MATH_KERN_CODE; } diff --git a/src/mathed/InsetMathLim.cpp b/src/mathed/InsetMathLim.cpp index a5eae28bb7..91335f3c3b 100644 --- a/src/mathed/InsetMathLim.cpp +++ b/src/mathed/InsetMathLim.cpp @@ -12,6 +12,7 @@ #include "InsetMathLim.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "support/debug.h" @@ -71,13 +72,16 @@ void InsetMathLim::mathematica(MathematicaStream & os) const } -void InsetMathLim::mathmlize(MathStream & os) const +docstring InsetMathLim::mathmlize(MathStream & os) const { // FIXME XHTML We need a form of MTag that takes attributes. os << "" << "" << "lim" << "" - << "" << cell(1) << "" << cell(2) << "" - << "(" << cell(0) << ")" ; + << "" << cell(1) << "" << cell(2) + << "" << "("; + docstring const rv = lyx::mathmlize(cell(0), os); + os << ")"; + return rv; } diff --git a/src/mathed/InsetMathLim.h b/src/mathed/InsetMathLim.h index 11d18dc06e..5d1f1a4c6a 100644 --- a/src/mathed/InsetMathLim.h +++ b/src/mathed/InsetMathLim.h @@ -40,7 +40,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void write(WriteStream & os) const; /// diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp index d368f217b7..7b73d3803e 100644 --- a/src/mathed/InsetMathMatrix.cpp +++ b/src/mathed/InsetMathMatrix.cpp @@ -12,6 +12,7 @@ #include "InsetMathMatrix.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" @@ -89,20 +90,25 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const } -void InsetMathMatrix::mathmlize(MathStream & os) const +docstring InsetMathMatrix::mathmlize(MathStream & os) const { os << "" << left_ << ""; os << MTag("mtable"); + docstring rv; for (row_type row = 0; row < nrows(); ++row) { os << MTag("mtr"); - for (col_type col = 0; col < ncols(); ++col) - os << MTag("mtd") << cell(index(row, col)) << ETag("mtd"); + for (col_type col = 0; col < ncols(); ++col) { + os << MTag("mtd"); + rv += lyx::mathmlize(cell(index(row, col)), os); + os << ETag("mtd"); + } os << ETag("mtr"); } os << ETag("mtable"); os << "" << right_ << ""; + return rv; } diff --git a/src/mathed/InsetMathMatrix.h b/src/mathed/InsetMathMatrix.h index a62c8ea44b..e9639811c8 100644 --- a/src/mathed/InsetMathMatrix.h +++ b/src/mathed/InsetMathMatrix.h @@ -40,7 +40,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; /// diff --git a/src/mathed/InsetMathNumber.cpp b/src/mathed/InsetMathNumber.cpp index fdacf0c7bc..eb2e85bdc7 100644 --- a/src/mathed/InsetMathNumber.cpp +++ b/src/mathed/InsetMathNumber.cpp @@ -67,9 +67,10 @@ void InsetMathNumber::octave(OctaveStream & os) const } -void InsetMathNumber::mathmlize(MathStream & os) const +docstring InsetMathNumber::mathmlize(MathStream & os) const { os << " " << str_ << " "; + return docstring(); } diff --git a/src/mathed/InsetMathNumber.h b/src/mathed/InsetMathNumber.h index a6ca9dae29..ed9e95ffcb 100644 --- a/src/mathed/InsetMathNumber.h +++ b/src/mathed/InsetMathNumber.h @@ -43,7 +43,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void write(WriteStream & os) const; /// diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp index 38c09469c9..7ca7706ba0 100644 --- a/src/mathed/InsetMathRoot.cpp +++ b/src/mathed/InsetMathRoot.cpp @@ -13,6 +13,7 @@ #include "InsetMathRoot.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "Cursor.h" @@ -112,9 +113,13 @@ void InsetMathRoot::octave(OctaveStream & os) const } -void InsetMathRoot::mathmlize(MathStream & os) const +docstring InsetMathRoot::mathmlize(MathStream & os) const { - os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot"); + os << MTag("mroot"); + docstring rv = lyx::mathmlize(cell(1), os); + rv += lyx::mathmlize(cell(0), os); + os << ETag("mroot"); + return rv; } diff --git a/src/mathed/InsetMathRoot.h b/src/mathed/InsetMathRoot.h index cfcac0a7f3..e05cc807a3 100644 --- a/src/mathed/InsetMathRoot.h +++ b/src/mathed/InsetMathRoot.h @@ -36,7 +36,7 @@ public: /// void normalize(NormalStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void maple(MapleStream &) const; /// diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index 1af0e57345..74420279cb 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -18,6 +18,7 @@ #include "InsetMathScript.h" #include "InsetMathSymbol.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "MathSupport.h" @@ -616,7 +617,7 @@ void InsetMathScript::mathematica(MathematicaStream & os) const // It may be worth trying to output munder, mover, and munderover // in certain cases, e.g., for display formulas. But then we would // need to know if we're in a display formula. -void InsetMathScript::mathmlize(MathStream & os) const +docstring InsetMathScript::mathmlize(MathStream & os) const { bool d = hasDown() && down().size(); bool u = hasUp() && up().size(); @@ -628,9 +629,12 @@ void InsetMathScript::mathmlize(MathStream & os) const else if (d) os << MTag("msub"); - if (nuc().size()) - os << MTag("mrow") << nuc() << ETag("mrow"); - else + docstring rv; + if (nuc().size()) { + os << MTag("mrow"); + rv = lyx::mathmlize(nuc(), os); + os << ETag("mrow"); + } else os << ""; if (u && d) @@ -641,6 +645,7 @@ void InsetMathScript::mathmlize(MathStream & os) const os << MTag("mrow") << up() << ETag("mrow") << ETag("msup"); else if (d) os << MTag("mrow") << down() << ETag("mrow") << ETag("msub"); + return rv; } diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index 569bc79f35..8d704dca9f 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -61,7 +61,7 @@ public: /// write content as something readable by Mathematica void mathematica(MathematicaStream &) const; /// write content as something resembling MathML - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// write content as something readable by Octave void octave(OctaveStream &) const; diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp index c771d2595b..b2a321234d 100644 --- a/src/mathed/InsetMathSpace.cpp +++ b/src/mathed/InsetMathSpace.cpp @@ -192,11 +192,11 @@ void InsetMathSpace::octave(OctaveStream & os) const } -void InsetMathSpace::mathmlize(MathStream & ms) const +docstring InsetMathSpace::mathmlize(MathStream & ms) const { SpaceInfo const & si = space_info[space_]; if (si.negative || !si.visible) - return; + return docstring(); string l; if (si.custom) l = length_.asHTMLString(); @@ -210,6 +210,7 @@ void InsetMathSpace::mathmlize(MathStream & ms) const if (!l.empty()) ms << " width=\"" << from_ascii(l) << "\""; ms << " />"; + return docstring(); } diff --git a/src/mathed/InsetMathSpace.h b/src/mathed/InsetMathSpace.h index 3e60b41c12..442fe2e799 100644 --- a/src/mathed/InsetMathSpace.h +++ b/src/mathed/InsetMathSpace.h @@ -52,7 +52,7 @@ public: /// void octave(OctaveStream &) const; /// - void mathmlize(MathStream & ms) const; + docstring mathmlize(MathStream & ms) const; /// void write(WriteStream & os) const; /// generate something that will be understood by the Dialogs. diff --git a/src/mathed/InsetMathSpecialChar.cpp b/src/mathed/InsetMathSpecialChar.cpp index 2c600d0c2b..b32c2e2302 100644 --- a/src/mathed/InsetMathSpecialChar.cpp +++ b/src/mathed/InsetMathSpecialChar.cpp @@ -147,7 +147,7 @@ void InsetMathSpecialChar::octave(OctaveStream & os) const } -void InsetMathSpecialChar::mathmlize(MathStream & ms) const +docstring InsetMathSpecialChar::mathmlize(MathStream & ms) const { switch (char_) { case '&': @@ -157,6 +157,7 @@ void InsetMathSpecialChar::mathmlize(MathStream & ms) const ms.os().put(char_); break; } + return docstring(); } diff --git a/src/mathed/InsetMathSpecialChar.h b/src/mathed/InsetMathSpecialChar.h index c672b504f6..5dcc012801 100644 --- a/src/mathed/InsetMathSpecialChar.h +++ b/src/mathed/InsetMathSpecialChar.h @@ -45,7 +45,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream & ms) const; + docstring mathmlize(MathStream & ms) const; /// identifies SpecialChar insets InsetMathSpecialChar const * asSpecialCharInset() const { return this; } /// diff --git a/src/mathed/InsetMathSqrt.cpp b/src/mathed/InsetMathSqrt.cpp index f738e2c17b..dc154f8f6b 100644 --- a/src/mathed/InsetMathSqrt.cpp +++ b/src/mathed/InsetMathSqrt.cpp @@ -12,6 +12,7 @@ #include "InsetMathSqrt.h" #include "MathData.h" +#include "MathExtern.h" #include "MathStream.h" #include "TextPainter.h" #include "frontends/Painter.h" @@ -107,9 +108,12 @@ void InsetMathSqrt::octave(OctaveStream & os) const } -void InsetMathSqrt::mathmlize(MathStream & os) const +docstring InsetMathSqrt::mathmlize(MathStream & os) const { - os << MTag("msqrt") << cell(0) << ETag("msqrt"); + os << MTag("msqrt"); + docstring const rv = lyx::mathmlize(cell(0), os); + os << ETag("msqrt"); + return rv; } diff --git a/src/mathed/InsetMathSqrt.h b/src/mathed/InsetMathSqrt.h index 485f66a574..2cdc0e5a37 100644 --- a/src/mathed/InsetMathSqrt.h +++ b/src/mathed/InsetMathSqrt.h @@ -44,7 +44,7 @@ public: /// void octave(OctaveStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// InsetCode lyxCode() const { return MATH_SQRT_CODE; } diff --git a/src/mathed/InsetMathString.cpp b/src/mathed/InsetMathString.cpp index ac951a1838..28069ca6ad 100644 --- a/src/mathed/InsetMathString.cpp +++ b/src/mathed/InsetMathString.cpp @@ -89,13 +89,6 @@ void InsetMathString::octave(OctaveStream & os) const } -void InsetMathString::mathmlize(MathStream & /*os*/) const -{ - // useless, no doubt, but we should not be here - LASSERT(false, /* */); -} - - void InsetMathString::write(WriteStream & os) const { if (!os.latex() || os.lockedMode()) { diff --git a/src/mathed/InsetMathString.h b/src/mathed/InsetMathString.h index 9f94a7457f..95b2937c1c 100644 --- a/src/mathed/InsetMathString.h +++ b/src/mathed/InsetMathString.h @@ -47,8 +47,6 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; - /// void write(WriteStream & os) const; /// InsetCode lyxCode() const { return MATH_STRING_CODE; } diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index a4a761171f..d09d40b02c 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -184,7 +184,7 @@ char const * MathMLtype(docstring const & s) } -void InsetMathSymbol::mathmlize(MathStream & os) const +docstring InsetMathSymbol::mathmlize(MathStream & os) const { // FIXME To get this working properly, we need to do add the // XML entity definitions to lib/symbols. And probably do more @@ -197,6 +197,7 @@ void InsetMathSymbol::mathmlize(MathStream & os) const else os << sym_->xmlname; os << " '; + return docstring(); } diff --git a/src/mathed/InsetMathSymbol.h b/src/mathed/InsetMathSymbol.h index 5382f72e85..a9b96fc4b5 100644 --- a/src/mathed/InsetMathSymbol.h +++ b/src/mathed/InsetMathSymbol.h @@ -61,7 +61,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; /// diff --git a/src/mathed/InsetMathUnknown.cpp b/src/mathed/InsetMathUnknown.cpp index 2cd11c2a86..ae6f8ce005 100644 --- a/src/mathed/InsetMathUnknown.cpp +++ b/src/mathed/InsetMathUnknown.cpp @@ -86,9 +86,10 @@ void InsetMathUnknown::mathematica(MathematicaStream & os) const } -void InsetMathUnknown::mathmlize(MathStream & os) const +docstring InsetMathUnknown::mathmlize(MathStream & os) const { os << MTag("mi") << name_ << ETag("mi"); + return docstring(); } diff --git a/src/mathed/InsetMathUnknown.h b/src/mathed/InsetMathUnknown.h index b43bcfd672..9493ecfc28 100644 --- a/src/mathed/InsetMathUnknown.h +++ b/src/mathed/InsetMathUnknown.h @@ -50,7 +50,7 @@ public: /// void mathematica(MathematicaStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; /// diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index f9b9f42af2..ee7ceebe4f 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -1413,20 +1413,22 @@ void mathematica(MathData const & dat, MathematicaStream & os) } -void mathmlize(MathData const & dat, MathStream & os) +docstring mathmlize(MathData const & dat, MathStream & os) { MathData ar = dat; extractStructure(ar, MATHML); + docstring retval; if (ar.size() == 0) os << ""; else if (ar.size() == 1) - os << ar.front(); + retval = ar.front()->mathmlize(os); else { os << MTag("mrow"); for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it) - (*it)->mathmlize(os); + retval += (*it)->mathmlize(os); os << ETag("mrow"); } + return retval; } // convert this inset somehow to a number diff --git a/src/mathed/MathExtern.h b/src/mathed/MathExtern.h index 199295ae96..d367b1e901 100644 --- a/src/mathed/MathExtern.h +++ b/src/mathed/MathExtern.h @@ -30,7 +30,7 @@ void normalize(MathData const &, NormalStream &); void maple(MathData const &, MapleStream &); void maxima(MathData const &, MaximaStream &); void mathematica(MathData const &, MathematicaStream &); -void mathmlize(MathData const &, MathStream &); +docstring mathmlize(MathData const &, MathStream &); void octave(MathData const &, OctaveStream &); bool extractNumber(MathData const & ar, int & i); diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 5564600d06..dd7ccf3e71 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -73,7 +73,10 @@ public: } // FIXME Other external things need similar treatment. /// - void mathmlize(MathStream & ms) const { ms << mathMacro_.cell(idx_); } + docstring mathmlize(MathStream & ms) const { + ms << mathMacro_.cell(idx_); + return docstring(); + } /// void draw(PainterInfo & pi, int x, int y) const { if (mathMacro_.editMetrics(pi.base.bv)) { @@ -740,9 +743,10 @@ void MathMacro::maple(MapleStream & os) const } -void MathMacro::mathmlize(MathStream & os) const +docstring MathMacro::mathmlize(MathStream & os) const { os << expanded_.cell(0); + return docstring(); } diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h index b431a9a9a5..bb9ed723ca 100644 --- a/src/mathed/MathMacro.h +++ b/src/mathed/MathMacro.h @@ -71,7 +71,7 @@ public: /// void maple(MapleStream &) const; /// - void mathmlize(MathStream &) const; + docstring mathmlize(MathStream &) const; /// void octave(OctaveStream &) const; ///