simple MathML output for integrals

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3000 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-09 18:02:20 +00:00
parent 86c2cf6f65
commit 4da1f8e66f
14 changed files with 82 additions and 77 deletions

View File

@ -118,15 +118,4 @@ enum MathInsetTypes {
LM_OT_MAX
};
///
enum MathSymbolTypes {
///
LMB_NONE = 0,
///
LMB_RELATION,
///
LMB_OPERATOR
};
#endif

View File

@ -83,7 +83,13 @@ void MathExIntInset::maplize(MapleStream & os) const
void MathExIntInset::mathmlize(MathMLStream & os) const
{
//os << name_.c_str() << '(' << cell(0) << ')';
if (hasScripts())
scripts_->asScriptInset()->mathmlize(int_.nucleus(), os);
else
int_->mathmlize(os);
os << core_ << "<mo> &InvisibleTimes; </mo>"
<< MTag("mrow") << "<mo> &DifferentialD; </mo>"
<< diff_ << ETag("mrow");
}

View File

@ -289,6 +289,10 @@ void extractIntegrals(MathArray & ar)
MathArray::iterator jt =
endNestSearch(it, ar.end(), intSymbolTest, differentialTest);
// something sensible found?
if (jt == ar.end())
continue;
// create a proper inset as replacement
MathExIntInset * p = new MathExIntInset;

View File

@ -262,29 +262,6 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
}
void MathGridInset::write(WriteStream & os) const
{
for (row_type row = 0; row < nrows(); ++row) {
for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col)) << eocString(col).c_str();
os << eolString(row).c_str();
}
}
void MathGridInset::normalize(NormalStream & os) const
{
os << "[grid ";
for (row_type row = 0; row < nrows(); ++row) {
os << "[row ";
for (col_type col = 0; col < ncols(); ++col)
os << "[cell " << cell(index(row, col)) << ']';
os << ']';
}
os << ']';
}
string MathGridInset::eolString(row_type row) const
{
if (row + 1 == nrows())
@ -583,3 +560,41 @@ std::vector<MathInset::idx_type>
return res;
}
void MathGridInset::normalize(NormalStream & os) const
{
os << "[grid ";
for (row_type row = 0; row < nrows(); ++row) {
os << "[row ";
for (col_type col = 0; col < ncols(); ++col)
os << "[cell " << cell(index(row, col)) << ']';
os << ']';
}
os << ']';
}
void MathGridInset::mathmlize(MathMLStream & os) const
{
os << MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) {
os << MTag("mtr");
for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col));
os << ETag("mtr");
}
os << ETag("mtable");
}
void MathGridInset::write(WriteStream & os) const
{
for (row_type row = 0; row < nrows(); ++row) {
for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col)) << eocString(col).c_str();
os << eolString(row).c_str();
}
}

View File

@ -149,14 +149,12 @@ public:
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
/*
///
void maplize(MapleStream &) const;
//void maplize(MapleStream &) const;
///
void mathmlize(MathMLStream &) const;
///
void octavize(OctaveStream &) const;
*/
//void octavize(OctaveStream &) const;
protected:
/// returns proper 'end of line' code for LaTeX

View File

@ -160,16 +160,6 @@ MathTokenEnum tokenEnum(const string & font)
}
MathSymbolTypes symbolType(const string & type)
{
if (type == "mathrel")
return LMB_RELATION;
if (type == "mathbin")
return LMB_OPERATOR;
return LMB_NONE;
}
void readSymbols(string const & filename)
{
LyXLex lex(0, 0);
@ -184,7 +174,7 @@ void readSymbols(string const & filename)
if (lex.next())
tmp.id = lex.getInteger();
if (lex.next())
tmp.type = symbolType(lex.getString());
tmp.type = lex.getString();
if (theWordList.find(tmp.name) != theWordList.end())
lyxerr << "readSymbols: token " << tmp.name
<< " already exists.\n";
@ -201,7 +191,6 @@ void initSymbols()
tmp.name = p->name;
tmp.token = p->token;
tmp.id = p->id;
tmp.type = LMB_NONE;
tmp.latex_font_id = 0;
theWordList[p->name] = tmp;
}

View File

@ -185,12 +185,6 @@ void MathHullInset::draw(Painter & pain, int x, int y) const
}
void MathHullInset::mathmlize(MathMLStream & os) const
{
MathGridInset::mathmlize(os);
}
string MathHullInset::label(row_type row) const
{
return label_[row];
@ -673,3 +667,9 @@ void MathHullInset::normalize(NormalStream & os) const
}
void MathHullInset::mathmlize(MathMLStream & os) const
{
MathGridInset::mathmlize(os);
}

View File

@ -25,10 +25,6 @@ public:
///
MathInset * clone() const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
@ -79,7 +75,11 @@ public:
///
MathInsetTypes getType() const;
///
void write(WriteStream & os) const;
///
void mathmlize(MathMLStream &) const;
///
void normalize(NormalStream &) const;
private:
///

View File

@ -6,7 +6,7 @@
MathMLStream::MathMLStream(std::ostream & os)
: os_(os), tab_(0), line_(0)
: os_(os), tab_(0), line_(0), lastchar_(0)
{}

View File

@ -46,6 +46,8 @@ struct MathMLStream {
int tab_;
///
int line_;
///
char lastchar_;
};

View File

@ -45,14 +45,7 @@ void MathMatrixInset::maplize(MapleStream & os) const
void MathMatrixInset::mathmlize(MathMLStream & os) const
{
os << MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) {
os << MTag("mtr");
for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col));
os << ETag("mtr");
}
os << ETag("mtable");
MathGridInset::mathmlize(os);
}

View File

@ -129,7 +129,7 @@ struct latexkeys {
///
unsigned char latex_font_id;
///
MathSymbolTypes type;
string type;
};

View File

@ -101,11 +101,11 @@ void MathStringInset::octavize(OctaveStream & os) const
void MathStringInset::mathmlize(MathMLStream & os) const
{
if (code_ == LM_TC_VAR)
os << "<mi>" << str_.c_str() << "</mi>";
os << "<mi> " << str_.c_str() << " </mi>";
else if (code_ == LM_TC_CONST)
os << "<mn>" << str_.c_str() << "</mn>";
os << "<mn> " << str_.c_str() << " </mn>";
else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
os << "<mtext>" << str_.c_str() << "</mtext>";
os << "<mtext> " << str_.c_str() << " </mtext>";
else
os << str_.c_str();
}

View File

@ -1,7 +1,7 @@
#include "math_symbolinset.h"
#include "math_parser.h"
#include "math_mathmlstream.h"
#include "math_support.h"
#include "math_parser.h"
#include "debug.h"
@ -96,7 +96,7 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const
bool MathSymbolInset::isRelOp() const
{
return sym_->type == LMB_RELATION;
return sym_->type == "mathrel";
}
@ -127,9 +127,18 @@ void MathSymbolInset::maplize(MapleStream & os) const
}
char const * MathMLtype(string const & s)
{
if (s == "mathop")
return "mo";
return "mi";
}
void MathSymbolInset::mathmlize(MathMLStream & os) const
{
os << name().c_str();
char const * type = MathMLtype(sym_->type);
os << '<' << type << "> " << name().c_str() << " </" << type << '>';
}