]> git.lyx.org Git - features.git/commitdiff
simple MathML output for integrals
authorAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 18:02:20 +0000 (18:02 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 18:02:20 +0000 (18:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3000 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/mathed/math_defs.h
src/mathed/math_exintinset.C
src/mathed/math_extern.C
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hash.C
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_mathmlstream.C
src/mathed/math_mathmlstream.h
src/mathed/math_matrixinset.C
src/mathed/math_parser.h
src/mathed/math_stringinset.C
src/mathed/math_symbolinset.C

index 64b62b65503dabb4d3c4b4731bea7a04f314097f..a787878d851359c93a168626cf5ca6208ea62460 100644 (file)
@@ -118,15 +118,4 @@ enum MathInsetTypes  {
        LM_OT_MAX
 };
 
-
-///
-enum MathSymbolTypes {
-       ///
-       LMB_NONE = 0,
-       ///
-       LMB_RELATION,
-       ///
-       LMB_OPERATOR
-};
-
 #endif
index 0168fd9cb31a64e2249f014286510f99edce875d..2002a6fdd1db3a24c80a2f89147254d8fc577a15 100644 (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");
 }
 
 
index b966b5ac03f16dd67f8a4e6d548d081fe2f6ff27..6a9d3023130bb542f03032038ffb5eb354ef7e06 100644 (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;
 
index dac3caa54df9705be741f386eb2b677e7ec1e9f1..f6eaa1144b4ef594ed1383098e99666da0a6576c 100644 (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();
+       }
+}
+
+
index 687b3fec030a38bfc005276b414493fa8ab8b6eb..9567068798c1ecb5a8ec968cfb10b75482590449 100644 (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
index df468ddb2986d102af38e33802305a3d584e3218..dc1de913e526a21c6f9962f277682bc12eec70a8 100644 (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;
        }
index 08c8dc19267bea92bfc8c90fbfa50a3b873437e6..9ab4bf1223c4bea65afc0960bfa6241edd0ac529 100644 (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);
+}
+
+
index af063231ce4a3fa495eee24ec2cbbafd33bdf0a4..d3e4dea56a90c437e8b39d4bd0c90dd9008027ab 100644 (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:
        ///
index eb697eaaa0ca131342c08b838b53d78eece2cdaa..0ea5e316da073d52e069c910a8258a2869c92cfc 100644 (file)
@@ -6,7 +6,7 @@
 
 
 MathMLStream::MathMLStream(std::ostream & os)
-       : os_(os), tab_(0), line_(0)
+       : os_(os), tab_(0), line_(0), lastchar_(0)
 {}
 
 
index 1af4f9ec77c0ce7ef9c46d91de86a8984099e4bd..245d6dc0848d8dcf6321b176eef57cad1e5941a3 100644 (file)
@@ -46,6 +46,8 @@ struct MathMLStream {
        int tab_;
        ///
        int line_;
+       ///
+       char lastchar_;
 };
 
 
index d8a02da555b5d13a930e0d3c52990c7bb35ed0f3..1f43e5a9b09aa7134c7cd51d08ca570d9de5e278 100644 (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);
 }
 
 
index 8fe33a3a11d490fa7a5cfb909d6c94cb7bd1a253..44420f370b3f04061a835e5ba6c9502198df7665 100644 (file)
@@ -129,7 +129,7 @@ struct latexkeys {
        ///
        unsigned char latex_font_id;
        ///
-       MathSymbolTypes type;
+       string type;
 };
 
 
index b36639e0ba30493c634bb9640baa14582de81309..9f896fd289bbf88fb44b2ed5e92f16c2cd5d66db 100644 (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();
 }
index 4d731c6bfab2347dc7e0ae5f19befb6976cc414d..b2855ac9f2b739d28b3fb5274f8ee8f78f6772cd 100644 (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 << '>';
 }