more mathml stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2979 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-07 18:15:24 +00:00
parent 5e5f64961e
commit f105559752
8 changed files with 73 additions and 38 deletions

View File

@ -276,16 +276,22 @@ void MathArray::maplize(MapleStream & os) const
void MathArray::mathmlize(MathMLStream & os) const
{
MathArray ar = glueChars();
os << "<mrow>";
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 << "<mrow/>";
else if (ar.size() == 1)
os << ar.begin()->nucleus();
else {
os << "<mrow>";
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 << "</mrow>";
}
os << "</mrow>";
}

View File

@ -307,7 +307,7 @@ int InsetFormula::docbook(Buffer const * buf, ostream & os) const
MathMLStream ms(os);
ms << "<equation><alt>";
int res = ascii(buf, ms.os_, 0);
ms << "</alt>\n<mml>" << par_.nucleus() << "<mml></equation>";
ms << "</alt>\n<math>" << par_.nucleus() << "<math></equation>";
return res + 1;
}

View File

@ -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 << "<fenced open=\"" << left_.c_str() << "\" close=\""
<< right_.c_str() << "\">" << cell(0) << "</fenced>";
}
void MathDelimInset::octavize(OctaveStream & os) const
{
if (left_ == "|" && right_ == "|")
os << "det(" << cell(0) << ")";
else
os << left_.c_str() << cell(0) << right_.c_str();
}

View File

@ -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;

View File

@ -587,21 +587,6 @@ std::vector<MathInset::idx_type>
}
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 << "<mtable>";
for (row_type row = 0; row < nrows(); ++row) {
os << "<mtr>";
for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col));
os << "</mtr>";
}
os << "</mtable>";
}
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 << ']';
}

View File

@ -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

View File

@ -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
{

View File

@ -80,6 +80,8 @@ public:
///
MathInsetTypes getType() const;
///
void mathmlize(MathMLStream &) const;
private:
///