]> git.lyx.org Git - features.git/commitdiff
some support for matrix operations with maple ('M-x math-extern maple evalm')
authorAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 08:35:57 +0000 (08:35 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 9 Nov 2001 08:35:57 +0000 (08:35 +0000)
further cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2991 a592a061-630c-0410-9148-cb99ea01b6c8

81 files changed:
src/mathed/Makefile.am
src/mathed/formula.C
src/mathed/formulamacro.C
src/mathed/math_arrayinset.C
src/mathed/math_arrayinset.h
src/mathed/math_atom.C
src/mathed/math_atom.h
src/mathed/math_binaryopinset.C
src/mathed/math_binaryopinset.h
src/mathed/math_binominset.C
src/mathed/math_binominset.h
src/mathed/math_boxinset.C
src/mathed/math_boxinset.h
src/mathed/math_braceinset.C
src/mathed/math_braceinset.h
src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_cursor.C
src/mathed/math_data.C
src/mathed/math_data.h
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_dotsinset.C
src/mathed/math_dotsinset.h
src/mathed/math_exfuncinset.C
src/mathed/math_exfuncinset.h
src/mathed/math_exintinset.C
src/mathed/math_exintinset.h
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_funcinset.C
src/mathed/math_funcinset.h
src/mathed/math_funcliminset.C
src/mathed/math_funcliminset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_kerninset.C
src/mathed/math_kerninset.h
src/mathed/math_lefteqninset.C
src/mathed/math_lefteqninset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_macroarg.C
src/mathed/math_macroarg.h
src/mathed/math_macrotemplate.C
src/mathed/math_macrotemplate.h
src/mathed/math_mathmlstream.C
src/mathed/math_mathmlstream.h
src/mathed/math_matrixinset.C [new file with mode: 0644]
src/mathed/math_matrixinset.h [new file with mode: 0644]
src/mathed/math_nestinset.C
src/mathed/math_notinset.C
src/mathed/math_notinset.h
src/mathed/math_parser.C
src/mathed/math_rootinset.C
src/mathed/math_rootinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_sizeinset.C
src/mathed/math_sizeinset.h
src/mathed/math_spaceinset.C
src/mathed/math_spaceinset.h
src/mathed/math_specialcharinset.C
src/mathed/math_specialcharinset.h
src/mathed/math_splitinset.C
src/mathed/math_splitinset.h
src/mathed/math_sqrtinset.C
src/mathed/math_sqrtinset.h
src/mathed/math_stackrelinset.C
src/mathed/math_stackrelinset.h
src/mathed/math_stringinset.C
src/mathed/math_stringinset.h
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h
src/mathed/math_xdata.C

index e3962acf03aff06d12b31814f2cf8487ce9822c1..a1a379d6616e55d31c38b3e5e011a037dc2bf304 100644 (file)
@@ -41,6 +41,8 @@ libmathed_la_SOURCES = \
        math_diminset.h \
        math_dotsinset.C \
        math_dotsinset.h \
+       math_extern.C \
+       math_extern.h \
        math_exfuncinset.C \
        math_exfuncinset.h \
        math_exintinset.C \
@@ -76,6 +78,8 @@ libmathed_la_SOURCES = \
        math_macrotable.h \
        math_mathmlstream.C \
        math_mathmlstream.h \
+       math_matrixinset.C \
+       math_matrixinset.h \
        math_metricsinfo.h \
        math_metricsinfo.C \
        math_nestinset.C \
index d08d0057841795e78138a9c3e933429fdab4cd04..2e808ab513909ef39c1232bb502b167e2aa34d47 100644 (file)
@@ -87,7 +87,7 @@ namespace {
                                "subs(`\\,`=`\\cdot `,"
                                        "eval(`latex/latex/*`)):\n";
 
-               // replace spurious \\noalign{\\medskip} in table output
+               // remove spurious \\noalign{\\medskip} in matrix output
                header += 
                        "`latex/latex/matrix`:= "
                                "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
@@ -226,7 +226,7 @@ namespace {
                ostringstream os;
                NormalStream ns(os);
                os << "[" << extra << ' ';
-               ar.writeNormal(ns); 
+               ns << ar;
                os << "]";
                string data = os.str().c_str();
 
@@ -290,7 +290,7 @@ void InsetFormula::write(Buffer const * buf, ostream & os) const
 int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
        const
 {
-       MathWriteInfo wi(buf, os, fragil);
+       WriteStream wi(buf, os, fragil);
        par_->write(wi);
        return 1;
 }
@@ -298,7 +298,7 @@ int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
 
 int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const
 {
-       MathWriteInfo wi(buf, os, false);
+       WriteStream wi(buf, os, false);
        par_->write(wi);
        return 1;
 }
@@ -539,15 +539,15 @@ bool InsetFormula::display() const
 
 MathHullInset const * InsetFormula::mat() const
 {
-       lyx::Assert(par_->asMatrixInset());
-       return par_->asMatrixInset();
+       lyx::Assert(par_->asHullInset());
+       return par_->asHullInset();
 }
 
 
 MathHullInset * InsetFormula::mat()
 {
-       lyx::Assert(par_->asMatrixInset());
-       return par_->asMatrixInset();
+       lyx::Assert(par_->asHullInset());
+       return par_->asHullInset();
 }
 
 
index bd50d8c087083acb4b334551aaff3563e7ffa2f0..7740c47da690a57a301784cff304f5444b4ed280 100644 (file)
@@ -78,7 +78,7 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
 void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
 {
        os << "FormulaMacro ";
-       MathWriteInfo wi(buf, os, false);
+       WriteStream wi(buf, os, false);
        par()->write(wi);
 }
 
@@ -86,7 +86,7 @@ void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
 int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile, 
                             bool /*free_spacing*/) const
 {
-       MathWriteInfo wi(buf, os, fragile);
+       WriteStream wi(buf, os, fragile);
        par()->write(wi);
        return 2;
 }
@@ -94,7 +94,7 @@ int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile,
 
 int InsetFormulaMacro::ascii(Buffer const * buf, ostream & os, int) const
 {
-       MathWriteInfo wi(buf, os, false);
+       WriteStream wi(buf, os, false);
        par()->write(wi);
        return 0;
 }
index ff252ee435de1844243ea61b88c05a3bca078350..97240cb67c67c35621c44fd2e926b6f593ae439a 100644 (file)
@@ -4,11 +4,11 @@
 
 #include "math_arrayinset.h"
 #include "math_parser.h"
-#include "support/LOstream.h"
-#include "Lsstream.h"
 #include "math_mathmlstream.h"
+#include "Lsstream.h"
 
 using std::vector;
+using std::istringstream;
 
 
 MathArrayInset::MathArrayInset(int m, int n)
@@ -52,7 +52,16 @@ MathInset * MathArrayInset::clone() const
 }
 
 
-void MathArrayInset::write(MathWriteInfo & os) const
+void MathArrayInset::metrics(MathMetricsInfo const & st) const
+{
+       MathMetricsInfo mi = st;
+       if (mi.style == LM_ST_DISPLAY)
+               mi.style = LM_ST_TEXT;
+       MathGridInset::metrics(mi);
+}
+
+
+void MathArrayInset::write(WriteStream & os) const
 {
        if (os.fragile)
                os << "\\protect";
@@ -74,18 +83,17 @@ void MathArrayInset::write(MathWriteInfo & os) const
 }
 
 
-void MathArrayInset::writeNormal(NormalStream & os) const
+void MathArrayInset::normalize(NormalStream & os) const
 {
        os << "[array ";
-       MathGridInset::writeNormal(os);
+       MathGridInset::normalize(os);
        os << "]";
 }
 
 
-void MathArrayInset::metrics(MathMetricsInfo const & st) const
+void MathArrayInset::maplize(MapleStream & os) const
 {
-       MathMetricsInfo mi = st;
-       if (mi.style == LM_ST_DISPLAY)
-               mi.style = LM_ST_TEXT;
-       MathGridInset::metrics(mi);
+       os << "array(";
+       MathGridInset::maplize(os);
+       os << ")";
 }
index 06d092e413b06fd3c5743ce16735382fd52700db..89f34545c3daa16acbf4b7c30fa931fce487ea77 100644 (file)
@@ -20,13 +20,16 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
-       ///
        void metrics(MathMetricsInfo const & st) const;
        ///
        MathArrayInset * asArrayInset() { return this; }
+
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+       ///
+       void maplize(MapleStream &) const;
 };
 
 #endif
index 57acb4a0a7d9b8a113eaeb2c822604f121e6df67..cfb2e9bbff0c9509fcba29d568ed6c68f59750e4 100644 (file)
@@ -55,6 +55,14 @@ MathAtom::~MathAtom()
 }
 
 
+void MathAtom::reset(MathInset * p)
+{
+       done();
+       nucleus_ = p;
+}
+
+
+
 void MathAtom::done()
 {
        delete nucleus_;
index 938d1170ec939382a36f527f1cb1bc273bdd9950..8713c4113b17823d2acd64df1338df8af3a98d44 100644 (file)
@@ -41,6 +41,8 @@ public:
        ///
        void operator=(MathAtom const &);
        ///
+       void reset(MathInset * p);
+       ///
        MathInset * nucleus() const;
        ///
        MathInset * operator->() const;
index e27de8034dcd9948a20f805c835686535da19472..5106d17052505ea1d795cbbdd74927b141914284 100644 (file)
@@ -45,13 +45,13 @@ void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathBinaryOpInset::write(MathWriteInfo & os) const
+void MathBinaryOpInset::write(WriteStream & os) const
 {
        os << '{' << cell(0) << op_ << cell(1) << '}';
 }
 
 
-void MathBinaryOpInset::writeNormal(NormalStream & os) const
+void MathBinaryOpInset::normalize(NormalStream & os) const
 {
        os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
 }
index 2eca9519dacb46736fa9db0e93408f99fdcad4de..cdd4db15730e4eddc4fd3eb929c9fc4edc035039 100644 (file)
@@ -21,9 +21,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
 private:
index 58b1acafa22bfcdd76c9b733cb3615bee8d688e6..342492c8ab470c79e8a06db94f037280960f4b4b 100644 (file)
@@ -51,17 +51,13 @@ void MathBinomInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathBinomInset::write(MathWriteInfo & os) const
+void MathBinomInset::write(WriteStream & os) const
 {
        os << '{' << cell(0) << " \\choose " << cell(1) << '}';
 }
 
 
-void MathBinomInset::writeNormal(NormalStream & os) const
+void MathBinomInset::normalize(NormalStream & os) const
 {
-       os << "[binom ";
-       cell(0).writeNormal(os);
-       os << " ";
-       cell(1).writeNormal(os);
-       os << "] ";
+       os << "[binom " << cell(0) << ' ' << cell(1) << ']';
 }
index 35f5933c0b2b3a31a239c90bf597b750535acee1..213d19a0747a1e9b299b3b2ba456845743a93e59 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index 7eb163fe9895900902ac7870f9ae8b3d6baa1dc7..ba4ab6b2b30e3cb2629c880a7619b6a79224788a 100644 (file)
@@ -45,13 +45,13 @@ UpdatableInset * MathBoxInset::asHyperActiveInset() const
 }
 
 
-void MathBoxInset::write(MathWriteInfo & os) const
+void MathBoxInset::write(WriteStream & os) const
 {
        os << "\\" << name_.c_str() << "{" << cell(0) << "}";
 }
 
 
-void MathBoxInset::writeNormal(NormalStream & os) const
+void MathBoxInset::normalize(NormalStream & os) const
 {
        os << "[mbox ";
        //text_->write(buffer(), os);
index 8812296605840c78cc0cd38cdc9aaffc801a9ff5..f67fa168f687520b938596d2b4734a4986a7a0a3 100644 (file)
@@ -30,9 +30,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const &) const;
        /// identifies BoxInsets
index ff1c46965190bd05fe82307841e951a0d3ddad9c..65970370c4771051979066236077e44977b730ec 100644 (file)
@@ -21,20 +21,6 @@ MathInset * MathBraceInset::clone() const
 }
 
 
-void MathBraceInset::write(MathWriteInfo & os) const
-{
-       os << '{' << cell(0) << '}';
-}
-
-
-void MathBraceInset::writeNormal(NormalStream & os) const
-{
-       os << "[block ";
-       cell(0).writeNormal(os);
-       os << "]";
-}
-
-
 void MathBraceInset::metrics(MathMetricsInfo const & mi) const
 {
        xcell(0).metrics(mi);
@@ -52,3 +38,17 @@ void MathBraceInset::draw(Painter & pain, int x, int y) const
        xcell(0).draw(pain, x + wid_, y);
        drawChar(pain, LM_TC_TEX, mi_, x + width_ - wid_, y, '}');
 }
+
+
+void MathBraceInset::write(WriteStream & os) const
+{
+       os << '{' << cell(0) << '}';
+}
+
+
+void MathBraceInset::normalize(NormalStream & os) const
+{
+       os << "[block " << cell(0) << ']';
+}
+
+
index 960f674b82c3f905cf9efd238548242f691ba884..6a9c08657568127e71639efd1bddc910c7fdfa75 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        /// write normalized content
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
 
index cc3bb1dbb388e96c940ba945b77b0a8711ee1d47..a19d79aef66dd63655b9ef8e3be71328e497fa29 100644 (file)
@@ -94,7 +94,7 @@ void MathCharInset::writeRaw(std::ostream & os) const
 }
 
 
-void MathCharInset::write(MathWriteInfo & os) const
+void MathCharInset::write(WriteStream & os) const
 {
        writeHeader(os.os);
        writeRaw(os.os);
@@ -102,7 +102,7 @@ void MathCharInset::write(MathWriteInfo & os) const
 }
 
 
-void MathCharInset::writeNormal(NormalStream & os) const
+void MathCharInset::normalize(NormalStream & os) const
 {
        os << "[char " << char_ << " " << "mathalpha" << "]";
 }
index 790453440a18f9d4e8bcff864ac7bb2d92ddb980..4f4978793ea249f4c95d2c3b8d99004f7fc18502 100644 (file)
@@ -27,7 +27,7 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
        void writeHeader(std::ostream &) const;
        ///
@@ -35,7 +35,7 @@ public:
        ///
        void writeRaw(std::ostream &) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        /// 
        int ascent() const;
        ///
index a19c1072752b1157eae189883889345171752354..d43f118cb0d26550d4b77103a487378e7b7cb4f3 100644 (file)
@@ -974,7 +974,7 @@ void MathCursor::normalize() const
                lyxerr << "this should not really happen - 2: "
                        << pos() << " " << size() <<  " in idx: " << it->idx()
                        << " in atom: '";
-               MathWriteInfo wi(0, lyxerr, false);
+               WriteStream wi(0, lyxerr, false);
                it->par()->write(wi);
                lyxerr << "\n";
                dump("error 4");
@@ -1091,7 +1091,7 @@ void MathCursor::breakLine()
        while (popRight())
                ;
 
-       MathHullInset * p = formula()->par()->asMatrixInset();
+       MathHullInset * p = formula()->par()->asHullInset();
        if (!p)
                return;
 
@@ -1104,12 +1104,8 @@ void MathCursor::breakLine()
 
                // split line
                const row_type r = row();
-               for (col_type c = col() + 1; c < p->ncols(); ++c) {
-                       const MathHullInset::idx_type i1 = p->index(r, c);
-                       const MathHullInset::idx_type i2 = p->index(r + 1, c);  
-                       //lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
-                       p->cell(i1).swap(p->cell(i2));
-               }
+               for (col_type c = col() + 1; c < p->ncols(); ++c)
+                       p->cell(p->index(r, c)).swap(p->cell(p->index(r + 1, c)));
 
                // split cell
                splitCell();
index 30821404d13192e784b4ccf4851cedf605008927..170ae414918e62b55457839de8a41e21b7d720d5 100644 (file)
@@ -3,9 +3,11 @@
 #endif
 
 #include "math_inset.h"
+#include "math_deliminset.h"
 #include "math_charinset.h"
 #include "math_scriptinset.h"
 #include "math_stringinset.h"
+#include "math_matrixinset.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
 #include "math_data.h"
@@ -29,19 +31,6 @@ void MathArray::substitute(MathMacro const & m)
 }
 
 
-MathScriptInset const * MathArray::asScript(const_iterator it) const
-{
-       if (it->nucleus()->asScriptInset())
-               return 0;
-       const_iterator jt = it + 1;
-       if (jt == end())
-               return 0;
-       if (!jt->nucleus())
-               return 0;
-       return jt->nucleus()->asScriptInset();
-}
-
-
 MathAtom & MathArray::at(size_type pos)
 {
        lyx::Assert(pos < size());
@@ -146,147 +135,6 @@ void MathArray::dump() const
 }
 
 
-// returns sequence of char with same code starting at it up to end
-// it might be less, though...
-string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
-{
-       string s;
-       MathCharInset const * p = it->nucleus()->asCharInset();
-       if (!p)
-               return s;
-
-       for (MathTextCodes c = p->code(); it != end; ++it) {
-               if (!it->nucleus())
-                       break;
-               p = it->nucleus()->asCharInset();
-               if (!p || p->code() != c)
-                       break;
-               s += p->getChar();
-       }
-       return s;
-}
-
-
-MathArray MathArray::glueChars() const
-{
-       MathArray ar;
-       const_iterator it = begin();
-       while (it != end()) {
-               if (it->nucleus() && it->nucleus()->asCharInset()) {
-                       string s = charSequence(it, end());
-                       MathTextCodes c = it->nucleus()->asCharInset()->code();
-                       ar.push_back(MathAtom(new MathStringInset(s, c)));
-                       it += s.size();
-               } else {
-                       ar.push_back(*it);
-                       ++it;
-               }
-       }
-       return ar;
-}
-
-
-bool needAsterisk(MathAtom const &, MathAtom const &)
-{
-       return false;
-}
-
-
-MathArray MathArray::guessAsterisks() const
-{
-       if (size() <= 1)
-               return *this;
-       MathArray ar;
-       ar.push_back(*begin());
-       for (const_iterator it = begin(), jt = begin()+1 ; jt != end(); ++it, ++jt) {
-               if (needAsterisk(*it, *jt))
-                       ar.push_back(MathAtom(new MathCharInset('*')));
-               ar.push_back(*it);
-       }
-       ar.push_back(*end());
-       return ar;
-}
-
-
-void MathArray::write(MathWriteInfo & wi) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->write(p, wi);
-                       ++it;
-               } else {
-                       p->write(wi);
-               }
-       }
-}
-
-
-void MathArray::writeNormal(NormalStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->writeNormal(p, os);
-                       ++it;
-               } else 
-                       p->writeNormal(os);
-       }
-}
-
-
-void MathArray::octavize(OctaveStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->octavize(p, os);
-                       ++it;
-               } else 
-                       p->octavize(os);
-       }
-}
-
-
-void MathArray::maplize(MapleStream & os) const
-{
-       MathArray ar = glueChars();
-       for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
-               MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = ar.asScript(it)) {
-                       q->maplize(p, os);
-                       ++it;
-               } else 
-                       p->maplize(os);
-       }
-}
-
-
-void MathArray::mathmlize(MathMLStream & os) const
-{
-       MathArray ar = glueChars();
-       if (ar.size() == 0)
-               os << "<mrow/>";
-       else if (ar.size() == 1)
-               os << ar.begin()->nucleus();
-       else {
-               os << MTag("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 << ETag("mrow");
-       }
-}
-
-
 void MathArray::validate(LaTeXFeatures & features) const
 {
        for (const_iterator it = begin(); it != end(); ++it)
@@ -327,11 +175,3 @@ MathArray::iterator MathArray::end()
 {
        return bf_.end();
 }
-
-
-bool MathArray::isMatrix() const
-{
-       return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
-}
-
-
index 007d75850ee8ea4bd80f283b878712495aeebfa3..eaca3d61eb57d7d37f7b0de4887faf27719dfd0f 100644 (file)
 
 class MathScriptInset;
 class MathMacro;
-class MathWriteInfo;
-class MathMetricsInfo;
 class LaTeXFeatures;
-class NormalStream;
-class MapleStream;
-class MathMLStream;
-class OctaveStream;
 
 
 #ifdef __GNUG__
@@ -104,10 +98,6 @@ public:
        MathAtom & at(size_type pos);
        ///
        MathAtom const & at(size_type pos) const;
-       /// glue chars if necessary
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
@@ -118,22 +108,6 @@ public:
        iterator begin();
        ///
        iterator end();
-       ///
-       MathScriptInset const * asScript(const_iterator it) const;
-       /// glues chars with the same attributes into MathStringInsets
-       MathArray glueChars() const;
-       /// insert asterisks in "suitable" places
-       MathArray guessAsterisks() const;
-
-       /// interface to Octave
-       void octavize(OctaveStream &) const;
-       /// interface to Maple
-       void maplize(MapleStream &) const;
-       /// interface to MathML
-       void mathmlize(MathMLStream &) const;
-
-       ///
-       bool isMatrix() const;
 
 private:
        /// Buffer
index 49d0f923b9b9d4c4deafe7af69fd187a827a43e7..08762d17b7b61b2083957d85974bcc608d416868 100644 (file)
@@ -91,7 +91,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathDecorationInset::write(MathWriteInfo & os) const
+void MathDecorationInset::write(WriteStream & os) const
 {
        if (os.fragile && protect())
                os << "\\protect";
@@ -99,7 +99,7 @@ void MathDecorationInset::write(MathWriteInfo & os) const
 }
 
 
-void MathDecorationInset::writeNormal(NormalStream & os) const
+void MathDecorationInset::normalize(NormalStream & os) const
 {
        os << "[deco " << name_.c_str() << ' ' <<  cell(0) << ']';
 }
index 5a18067de55798befd7057479be41e43228a82d3..a0ff67b805e545869f940762a12f8e891ada2d21 100644 (file)
@@ -22,11 +22,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
-       void writeNormal(NormalStream & os) const;
+       void normalize(NormalStream & os) const;
        ///
        bool isScriptable() const;
 
index 4ada1f77cc373fd1b5a2d3b0eca47a630bb7024e..435b33f1f0abc074837a3db315c9789d596079af 100644 (file)
@@ -7,8 +7,8 @@
 #include "math_deliminset.h"
 #include "math_parser.h"
 #include "math_support.h"
-#include "support/LOstream.h"
 #include "math_mathmlstream.h"
+#include "math_extern.h"
 
 
 MathDelimInset::MathDelimInset(string const & l, string const & r)
@@ -42,14 +42,14 @@ string MathDelimInset::latexName(string const & name)
 }
 
 
-void MathDelimInset::write(MathWriteInfo & os) const
+void MathDelimInset::write(WriteStream & os) const
 {
        os << "\\left" << latexName(left_).c_str() << cell(0)
           << "\\right" << latexName(right_).c_str();
 }
 
 
-void MathDelimInset::writeNormal(NormalStream & os) const
+void MathDelimInset::normalize(NormalStream & os) const
 {
        os << "[delim " << latexName(left_).c_str() << ' '
                << latexName(right_).c_str() << ' ' << cell(0) << ']';
@@ -91,17 +91,13 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const
 }
 
 
-bool MathDelimInset::isMatrix() const
-{
-       return left_ == "(" && right_ == ")" && cell(0).size() == 1 && 
-               cell(0).begin()->nucleus() && cell(0).begin()->nucleus()->asArrayInset();
-}
-
-
 void MathDelimInset::maplize(MapleStream & os) const
 {
        if (left_ == "|" && right_ == "|") {
-               if (cell(0).isMatrix()) 
+               bool mat =
+                       cell(0).size() == 1 && cell(0).begin()->nucleus()
+                                       && cell(0).begin()->nucleus()->asMatrixInset();
+               if (mat)        
                        os << "linalg[det](" << cell(0) << ")";
                else
                        os << "abs(" << cell(0) << ")";
index e0a00d9b57c0076e5d2270523b0f248ee204172a..c896ee7ca3aa464e93552e0adaa091da95617931 100644 (file)
@@ -20,28 +20,31 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       MathDelimInset * asDelimInset() { return this; }
        ///
-       void write(MathWriteInfo & os) const;
-       /// write normalized content
-       void writeNormal(NormalStream &) const;
+       MathDelimInset const * asDelimInset() const { return this; }
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
-       bool isMatrix() const;
+       void draw(Painter &, int x, int y) const;
+
+       ///
+       void write(WriteStream & os) const;
+       /// write normalized content
+       void normalize(NormalStream &) const;
        ///
        void maplize(MapleStream &) const;
        ///
        void mathmlize(MathMLStream &) const;
        ///
        void octavize(OctaveStream &) const;
-private:
-       ///
-       int dw() const;
        ///
        string left_;
        ///
        string right_;
+private:
+       ///
+       int dw() const;
        ///
        static string latexName(string const & name);
 };
index 2fad8b4082e2c822c828ed399438346cf5ef0291..70e8de37b84461572fb2635c48aec8adb9236952 100644 (file)
@@ -42,13 +42,13 @@ void MathDotsInset::metrics(MathMetricsInfo const & mi) const
 } 
 
 
-void MathDotsInset::write(MathWriteInfo & os) const
+void MathDotsInset::write(WriteStream & os) const
 {
        os << '\\' << name_.c_str() << ' ';
 }
 
 
-void MathDotsInset::writeNormal(NormalStream & os) const
+void MathDotsInset::normalize(NormalStream & os) const
 {
        os << "[" << name_.c_str() << "] ";
 }
index c13943d5ae0457039e39133514adc9feac4e0e8a..87869a842167373507adde050e88f22eb6f302c4 100644 (file)
@@ -19,9 +19,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
 protected:
index 4be96200cbfd427df075b007ed9e37da6badacb9..8b08428c1e291ac0a11dd41325593a6bb0b74112 100644 (file)
@@ -17,13 +17,13 @@ MathInset * MathExFuncInset::clone() const
 }
 
 
-void MathExFuncInset::write(MathWriteInfo & os) const
+void MathExFuncInset::write(WriteStream & os) const
 {
        os << '\\' << name_.c_str() << '{' << cell(0) << '}';
 }
 
 
-void MathExFuncInset::writeNormal(NormalStream & os) const
+void MathExFuncInset::normalize(NormalStream & os) const
 {
        os << '[' << name_.c_str() << ' ' << cell(0) << ']';
 }
index 951449673f27c71905b55566890f37bb21b68abd..0c71ad57ecd6b268e5a1647eba9ef8b02f52282a 100644 (file)
@@ -14,9 +14,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index edd8343c0ba5fb941aada52202b76faac3cc40e5..2ad11b39df7c60a731f24554eb4539426c2b64a2 100644 (file)
@@ -18,14 +18,14 @@ MathInset * MathExIntInset::clone() const
 }
 
 
-void MathExIntInset::write(MathWriteInfo & os) const
+void MathExIntInset::write(WriteStream & os) const
 {
        scripts_.write(int_.nucleus(), os);
        os << core_ << "d" << diff_;
 }
 
 
-void MathExIntInset::writeNormal(NormalStream & os) const
+void MathExIntInset::normalize(NormalStream & os) const
 {
        //os << "[int " << scripts_ << ' ' << core_ << ' ' << diff_ << ']'
 }
index 0d1214e9855b54f756b5c4ed43c56cb5b02d9b8a..c92497a3b920ae129c4f6674cd17c33930995232 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void maplize(MapleStream &) const;
        ///
index 6577510700eb75a13a21d1f6bf664528fab0d8c2..f5c90d775cf8ca08cbcd0d1df8ed36feb4d07190 100644 (file)
@@ -41,7 +41,7 @@ void MathFracInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathFracInset::write(MathWriteInfo & os) const
+void MathFracInset::write(WriteStream & os) const
 {
        if (atop_)
                os << '{' << cell(0) << "\\atop " << cell(1) << '}';
@@ -50,16 +50,13 @@ void MathFracInset::write(MathWriteInfo & os) const
 }
 
 
-void MathFracInset::writeNormal(NormalStream & os) const
+void MathFracInset::normalize(NormalStream & os) const
 {
        if (atop_) 
                os << "[atop ";
        else
                os << "[frac ";
-       cell(0).writeNormal(os);
-       os << " ";
-       cell(1).writeNormal(os);
-       os << "] ";
+       os << cell(0) << ' ' << cell(1) << ']';
 }
 
 
index c66e9fb2f403118747c952b7020afa0364f9d398..2068de0cd9cd6457705ae181eac275b40eaf6d4e 100644 (file)
@@ -18,13 +18,14 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
-       ///
        void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
+
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
        ///
        void maplize(MapleStream &) const;
        ///
index 6318a817b35642a69061ab88210579227b76608e..c2bf78c27795c98b54a77a8e2418bf4cd6ca4e3d 100644 (file)
@@ -36,13 +36,13 @@ void MathFuncInset::setName(string const & n)
 }
 
 
-void MathFuncInset::write(MathWriteInfo & os) const
+void MathFuncInset::write(WriteStream & os) const
 {
        os << "\\" << name_.c_str() << ' ';
 }
 
 
-void MathFuncInset::writeNormal(NormalStream & os) const
+void MathFuncInset::normalize(NormalStream & os) const
 {
        os << "[func " << name_.c_str() << ']';
 }
index 4196e73d7b50ddf05f324285c12cf99741afb458..42d4a2e0553362f6cb2ff2d5b5ebca70b0c0dea0 100644 (file)
@@ -23,9 +23,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo &) const;
+       void write(WriteStream &) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        string const & name() const;
        ///
index 903a7697edb285d79fc375961db382bd293f56e1..79760d029ea09f7b9446c7e31586a5377a528094 100644 (file)
@@ -20,13 +20,13 @@ bool MathFuncLimInset::isScriptable() const
 }
 
 
-void MathFuncLimInset::write(MathWriteInfo & os) const
+void MathFuncLimInset::write(WriteStream & os) const
 {
        os << '\\' << name_.c_str() << ' ';
 }
 
 
-void MathFuncLimInset::writeNormal(NormalStream & os) const
+void MathFuncLimInset::normalize(NormalStream & os) const
 {
        os << "[funclim " << name_.c_str() << ']';
 }
index 02c533e853248a37ae7c915b8ebcb88a2ed89859..e36f4172389096cdc75a54b2fdc35b03d2e21e2d 100644 (file)
@@ -14,9 +14,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index c9c5546d02ca0be9a67258ec78a1f6edc97ff3bd..dac3caa54df9705be741f386eb2b677e7ec1e9f1 100644 (file)
@@ -262,7 +262,7 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathGridInset::write(MathWriteInfo & os) const
+void MathGridInset::write(WriteStream & os) const
 {
        for (row_type row = 0; row < nrows(); ++row) {
                for (col_type col = 0; col < ncols(); ++col) 
@@ -272,7 +272,7 @@ void MathGridInset::write(MathWriteInfo & os) const
 }
 
 
-void MathGridInset::writeNormal(NormalStream & os) const
+void MathGridInset::normalize(NormalStream & os) const
 {
        os << "[grid ";
        for (row_type row = 0; row < nrows(); ++row) {
@@ -583,48 +583,3 @@ std::vector<MathInset::idx_type>
        return res;
 }
 
-
-void MathGridInset::maplize(MapleStream & os) const
-{
-       os << "array([";
-       for (row_type row = 0; row < nrows(); ++row) {
-               if (row)
-                       os << ',';
-               os << '[';
-               for (col_type col = 0; col < ncols(); ++col) {
-                       if (col)
-                               os << ',';
-                       os << 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::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 << ']';
-}
index cc2414f42e9d8ef2ee8924fcac0ad33c47cff0dc..687b3fec030a38bfc005276b414493fa8ab8b6eb 100644 (file)
@@ -64,10 +64,6 @@ public:
        ///
        MathGridInset(int m, int n, char valign, string const & halign);
        ///
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
-       ///
        void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
@@ -149,12 +145,18 @@ public:
        ///
        void setDefaults();
 
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+/*
        ///
        void maplize(MapleStream &) const;
        ///
        void mathmlize(MathMLStream &) const;
        ///
        void octavize(OctaveStream &) const;
+*/
 
 protected:
        /// returns proper 'end of line' code for LaTeX
index d6aea7975a93413a4c1efbaee810e2407c67bf1a..8cb6fc62c3151b5d8b85c03091e3fc468904c9af 100644 (file)
@@ -645,7 +645,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
 }
 
 
-void MathHullInset::write(MathWriteInfo & os) const
+void MathHullInset::write(WriteStream & os) const
 {
   header_write(os.os);
 
@@ -667,10 +667,10 @@ void MathHullInset::write(MathWriteInfo & os) const
 }
 
 
-void MathHullInset::writeNormal(NormalStream & os) const
+void MathHullInset::normalize(NormalStream & os) const
 {
        os << "[formula " << normalName(getType()).c_str() << " ";
-       MathGridInset::writeNormal(os);
+       MathGridInset::normalize(os);
        os << "] ";
 }
 
index 47a6bbeb8d016e0c757788e87eeeac8424dbd50c..af063231ce4a3fa495eee24ec2cbbafd33bdf0a4 100644 (file)
@@ -25,9 +25,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
@@ -51,9 +51,9 @@ public:
        ///
        void validate(LaTeXFeatures & features) const;
        /// identifies MatrixInsets
-       virtual MathHullInset const * asMatrixInset() const { return this; }
-       /// identifies MatrixInsets
-       virtual MathHullInset * asMatrixInset() { return this; }
+       virtual MathHullInset const * asHullInset() const { return this; }
+       /// identifies HullInset
+       virtual MathHullInset * asHullInset() { return this; }
 
        ///
        void addRow(row_type);
index c5dfea37d93f833d1dc7e40b7791ecdffe66cbbe..37000b258379e5ce5670c1b78a4d8802cc19bc3f 100644 (file)
@@ -44,7 +44,7 @@ int MathInset::height() const
 
 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
 {
-       MathWriteInfo wi(0, os, false);
+       WriteStream wi(0, os, false);
        inset.write(wi);
        return os;
 }
@@ -161,10 +161,10 @@ void MathInset::idxDeleteRange(idx_type, idx_type)
 {}
 
 
-void MathInset::writeNormal(NormalStream & os) const
+void MathInset::normalize(NormalStream & os) const
 {
        os << "[unknown ";
-       MathWriteInfo wi(0, os.os_, false);
+       WriteStream wi(0, os.os_, false);
        write(wi);
        os << "] ";
 }
@@ -173,7 +173,7 @@ void MathInset::writeNormal(NormalStream & os) const
 void MathInset::dump() const
 {
        lyxerr << "---------------------------------------------\n";
-       MathWriteInfo wi(0, lyxerr, false);
+       WriteStream wi(0, lyxerr, false);
        write(wi);
        lyxerr << "\n---------------------------------------------\n";
 }
@@ -212,7 +212,7 @@ void MathInset::draw(Painter &, int, int) const
 }
 
 
-void MathInset::write(MathWriteInfo &) const
+void MathInset::write(WriteStream &) const
 {
        lyxerr << "MathInset::write() called directly!\n";
 }
@@ -221,19 +221,19 @@ void MathInset::write(MathWriteInfo &) const
 void MathInset::octavize(OctaveStream & os) const
 {
        NormalStream ns(os.os_);
-       writeNormal(ns);
+       normalize(ns);
 }
 
 
 void MathInset::maplize(MapleStream & os) const
 {
        NormalStream ns(os.os_);
-       writeNormal(ns);
+       normalize(ns);
 }
 
 
 void MathInset::mathmlize(MathMLStream & os) const
 {
        NormalStream ns(os.os_);
-       writeNormal(ns);
+       normalize(ns);
 }
index a710af65d7403973e542abe2d7f593e4e3a04199..315af30e24206bd32f5c4af754174d64bfd1c0f1 100644 (file)
 class MathArrayInset;
 class MathBoxInset;
 class MathCharInset;
+class MathDelimInset;
 class MathGridInset;
-class MathNestInset;
 class MathHullInset;
+class MathMatrixInset;
+class MathNestInset;
 class MathScriptInset;
 class MathSpaceInset;
 class MathMacroTemplate;
 
+class NormalStream;
+class OctaveStream;
+class MapleStream;
+class MathMLStream;
+class WriteStream;
+class MathArray;
+
 class LaTeXFeatures;
 class BufferView;
 class UpdatableInset;
@@ -74,7 +83,7 @@ public:
        /// draw the object
        virtual void draw(Painter &, int x, int y) const;
        /// write LaTeX and Lyx code
-       virtual void write(MathWriteInfo & os) const;
+       virtual void write(WriteStream & os) const;
        /// reproduce itself
        virtual MathInset * clone() const = 0;
        ///substitutes macro arguments if necessary
@@ -168,18 +177,24 @@ public:
        virtual MathScriptInset const * asScriptInset() const { return 0; }
        /// identifies ScriptInsets
        virtual MathScriptInset * asScriptInset() { return 0; }
-       /// identifies MatrixInsets
-       virtual MathHullInset const * asMatrixInset() const { return 0; }
-       /// identifies MatrixInsets
-       virtual MathHullInset * asMatrixInset() { return 0; }
+       /// identifies HullInsets
+       virtual MathHullInset const * asHullInset() const { return 0; }
+       /// identifies HullInsets
+       virtual MathHullInset * asHullInset() { return 0; }
        /// identifies SpaceInset
        virtual MathSpaceInset * asSpaceInset() { return 0; }
        /// identifies GridInset
        virtual MathGridInset * asGridInset() { return 0; }
        /// identifies ArrayInsets
        virtual MathArrayInset * asArrayInset() { return 0; }
+       /// identifies MatrixInsets
+       virtual MathMatrixInset const * asMatrixInset() const { return 0; }
        /// identifies BoxInsets
        virtual MathBoxInset * asBoxInset() { return 0; }
+       /// identifies DelimInsets
+       virtual MathDelimInset * asDelimInset() { return 0; }
+       /// identifies DelimInsets
+       virtual MathDelimInset const * asDelimInset() const { return 0; }
        /// identifies macro templates
        virtual MathMacroTemplate * asMacroTemplate() { return 0; }
        /// identifies hyperactive insets
@@ -195,8 +210,6 @@ public:
        virtual bool isRelOp() const { return false; }
        ///
        virtual bool isMacro() const { return false; }
-       /// is this a matrix or matrix expression?
-       virtual bool isMatrix() const { return false; }
 
        ///
        virtual char getChar() const { return 0; }
@@ -216,7 +229,7 @@ public:
        virtual void handleFont(MathTextCodes) {}
 
        /// write normalized content
-       virtual void writeNormal(NormalStream &) const;
+       virtual void normalize(NormalStream &) const;
        ///
        virtual void maplize(MapleStream &) const;
        ///
index 4df5f78d77f0b1e931ca644ed9fc146d438bb377..cedf71ca34d455d219a9ba1a36b66e2857450325 100644 (file)
@@ -44,13 +44,13 @@ void MathKernInset::metrics(MathMetricsInfo const &) const
 }
 
 
-void MathKernInset::write(MathWriteInfo & os) const
+void MathKernInset::write(WriteStream & os) const
 {
        os << "\\kern" << wid_.asLatexString().c_str() << " ";
 }
 
 
-void MathKernInset::writeNormal(NormalStream & os) const
+void MathKernInset::normalize(NormalStream & os) const
 {
        os << "[kern " << wid_.asLatexString().c_str() << "]";
 }
index d2b7aabe600ad69dd0b74aac233e81e601155041..d6c65e42134aad486e54791b6528a9f0c61c1925 100644 (file)
@@ -25,9 +25,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
 private:
index 8628abce060da9bcad59cc5f5c17889a5785e747..99eb3159a25adb051cb547c46e49c1c690ee7fac 100644 (file)
@@ -39,16 +39,13 @@ void MathLefteqnInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathLefteqnInset::write(MathWriteInfo & os) const
+void MathLefteqnInset::write(WriteStream & os) const
 {
-       os << "\\lefteqn{" << cell(0) << "}";
+       os << "\\lefteqn{" << cell(0) << '}';
 }
 
 
-void MathLefteqnInset::writeNormal(NormalStream & os) const
+void MathLefteqnInset::normalize(NormalStream & os) const
 {
-       os << "[lefteqn ";
-       MathWriteInfo wi(os.os_);
-       cell(0).write(wi);
-       os << "]";
+       os << "[lefteqn " << cell(0) << ']';
 }
index 78525d8663d1b00e39b0d50282c7fc25ef8f2708..3c75e612a8bdfa6aa88eae84fb850bf943b9992c 100644 (file)
@@ -19,9 +19,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
 };
index 707548ec2dec774fb087020886bfeed556b016f5..3d89fbad0b459c1570a879d1cbb69afac6449f60 100644 (file)
@@ -155,13 +155,13 @@ void MathMacro::dump() const
        lyxerr << "\n macro: '" << this << "'\n";
        lyxerr << " name: '" << name() << "'\n";
        lyxerr << " template: '";
-       MathWriteInfo wi(lyxerr);
+       WriteStream wi(lyxerr);
        tmplate_->write(wi);
        lyxerr << "'\n";
 }
 
 
-void MathMacro::write(MathWriteInfo & os) const
+void MathMacro::write(WriteStream & os) const
 {
        os << '\\' << name();
        for (idx_type i = 0; i < nargs(); ++i)
@@ -171,14 +171,12 @@ void MathMacro::write(MathWriteInfo & os) const
 }
 
 
-void MathMacro::writeNormal(NormalStream & os) const
+void MathMacro::normalize(NormalStream & os) const
 {
        os << "[macro " << name() << " ";
-       for (idx_type i = 0; i < nargs(); ++i) {
-               cell(i).writeNormal(os);
-               os << ' ';
-       }
-       os << "] ";
+       for (idx_type i = 0; i < nargs(); ++i) 
+               os << cell(i) << ' ';
+       os << ']';
 }
 
 
index ce9e3b928f8c9782695ef106faac634d23239e4d..f80c18c561fdec268ec99a9a867bc4f75e740833 100644 (file)
@@ -48,9 +48,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void dump() const;
 
index 4a9bf76ce12c0f0160deab6cb8f2e03da4678092..f28b77ab03845e8394bbd39cb9d0327470ae4f75 100644 (file)
@@ -30,7 +30,7 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::write(MathWriteInfo & os) const
+void MathMacroArgument::write(WriteStream & os) const
 {
        os << '#' << number_;
 }
@@ -58,7 +58,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathMacroArgument::writeNormal(NormalStream & os) const
+void MathMacroArgument::normalize(NormalStream & os) const
 {
        os << "[macroarg " << number_ << "] ";
 }
index f001f21b3b9d20563c674085e4717140cdac8ce4..d0b4591966a454be65e4591dbbc33a70766b0687 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void substitute(MathMacro const & macro);
        ///
index d1791592844172484e6901d9b32f63a6cc35ccbd..0f1281f9e9488c79509bc5a9404e3ce2f5f1904e 100644 (file)
@@ -64,7 +64,7 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathMacroTemplate::write(MathWriteInfo & os) const
+void MathMacroTemplate::write(WriteStream & os) const
 {
        os << "\n\\newcommand{\\" << name_.c_str() << '}';
        if (numargs_ > 0)
index 4cbe5106ee3bafbd96631fc3fd615aaf888bb8e7..bab64d1500d92590de82ab93ad511a3c85ad8b5e 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        /// Number of arguments
        int numargs() const;
        ///
index 3f87f143b08ea2d4dc2797cfcca413b413edaeb4..5e5dccd145f16fa23bddf8086eb4111fdfbd0553 100644 (file)
@@ -1,6 +1,7 @@
 
 #include "math_inset.h"
 #include "math_mathmlstream.h"
+#include "math_extern.h"
 
 
 MathMLStream::MathMLStream(std::ostream & os)
@@ -17,7 +18,7 @@ MathMLStream & MathMLStream::operator<<(MathInset const * p)
 
 MathMLStream & MathMLStream::operator<<(MathArray const & ar)
 {
-       ar.mathmlize(*this);
+       mathmlize(ar, *this);
        return *this;           
 }
 
@@ -76,7 +77,7 @@ MapleStream & MapleStream::operator<<(MathInset const * p)
 
 MapleStream & MapleStream::operator<<(MathArray const & ar)
 {
-       ar.maplize(*this);
+       maplize(ar, *this);
        return *this;           
 }
 
@@ -95,6 +96,12 @@ MapleStream & MapleStream::operator<<(char c)
 }
 
 
+MapleStream & MapleStream::operator<<(int i)
+{
+       os_ << i;
+       return *this;           
+}
+
 
 //////////////////////////////////////////////////////////////////////
 
@@ -108,7 +115,7 @@ OctaveStream & OctaveStream::operator<<(MathInset const * p)
 
 OctaveStream & OctaveStream::operator<<(MathArray const & ar)
 {
-       ar.octavize(*this);
+       octavize(ar, *this);
        return *this;           
 }
 
@@ -132,14 +139,14 @@ OctaveStream & OctaveStream::operator<<(char c)
 
 NormalStream & NormalStream::operator<<(MathInset const * p)
 {
-       p->writeNormal(*this);
+       p->normalize(*this);
        return *this;           
 }
 
 
 NormalStream & NormalStream::operator<<(MathArray const & ar)
 {
-       ar.writeNormal(*this);
+       normalize(ar, *this);
        return *this;           
 }
 
@@ -162,39 +169,39 @@ NormalStream & NormalStream::operator<<(char c)
 //////////////////////////////////////////////////////////////////////
 
 
-MathWriteInfo::MathWriteInfo
+WriteStream::WriteStream
                (Buffer const * buffer_, std::ostream & os_, bool fragile_)
        : buffer(buffer_), os(os_), fragile(fragile_)
 {}
 
 
-MathWriteInfo::MathWriteInfo(std::ostream & os_)
+WriteStream::WriteStream(std::ostream & os_)
        : buffer(0), os(os_), fragile(false)
 {}
 
 
-MathWriteInfo & MathWriteInfo::operator<<(MathInset const * p)
+WriteStream & WriteStream::operator<<(MathInset const * p)
 {
        p->write(*this);
        return *this;           
 }
 
 
-MathWriteInfo & MathWriteInfo::operator<<(MathArray const & ar)
+WriteStream & WriteStream::operator<<(MathArray const & ar)
 {
-       ar.write(*this);
+       write(ar, *this);
        return *this;           
 }
 
 
-MathWriteInfo & MathWriteInfo::operator<<(char const * s)
+WriteStream & WriteStream::operator<<(char const * s)
 {
        os << s;
        return *this;           
 }
 
 
-MathWriteInfo & MathWriteInfo::operator<<(char c)
+WriteStream & WriteStream::operator<<(char c)
 {
        os << c;
        return *this;           
index 1d1839359caa5f12be78fa95fa74c1b0c8cb52ee..1af4f9ec77c0ce7ef9c46d91de86a8984099e4bd 100644 (file)
@@ -78,6 +78,8 @@ struct MapleStream {
        MapleStream & operator<<(char const *);
        ///
        MapleStream & operator<<(char);
+       ///
+       MapleStream & operator<<(int);
 };
 
 
@@ -97,20 +99,20 @@ struct OctaveStream {
 };
 
 
-struct MathWriteInfo {
+struct WriteStream {
        ///
-       MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_);
+       WriteStream(Buffer const * buffer_, std::ostream & os_, bool fragile_);
        ///
-       explicit MathWriteInfo(std::ostream & os_);
+       explicit WriteStream(std::ostream & os_);
 
        ///
-       MathWriteInfo & operator<<(MathInset const *);
+       WriteStream & operator<<(MathInset const *);
        ///
-       MathWriteInfo & operator<<(MathArray const &);
+       WriteStream & operator<<(MathArray const &);
        ///
-       MathWriteInfo & operator<<(char const *);
+       WriteStream & operator<<(char const *);
        ///
-       MathWriteInfo & operator<<(char);
+       WriteStream & operator<<(char);
 
        ///
        Buffer const * buffer;
diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C
new file mode 100644 (file)
index 0000000..d8a02da
--- /dev/null
@@ -0,0 +1,71 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_matrixinset.h"
+#include "math_parser.h"
+#include "math_mathmlstream.h"
+#include "Lsstream.h"
+
+
+MathMatrixInset::MathMatrixInset(MathArrayInset const & p)
+       : MathArrayInset(p)
+{}
+
+
+MathInset * MathMatrixInset::clone() const
+{
+       return new MathMatrixInset(*this);
+}
+
+
+void MathMatrixInset::write(WriteStream & os) const
+{
+       MathArrayInset::write(os);
+}
+
+
+void MathMatrixInset::normalize(NormalStream & os) const
+{
+       MathArrayInset::normalize(os);
+}
+
+
+void MathMatrixInset::maplize(MapleStream & os) const
+{
+       os << "matrix(" << int(nrows()) << ',' << int(ncols()) << ",[";
+       for (idx_type idx = 0; idx < nargs(); ++idx) {
+               if (idx)
+                       os << ',';
+               os << cell(idx);
+       }
+       os << "])";
+}
+
+
+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");
+}
+
+
+void MathMatrixInset::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_matrixinset.h b/src/mathed/math_matrixinset.h
new file mode 100644 (file)
index 0000000..f4f2a0a
--- /dev/null
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+#ifndef MATH_MATRIXINSET_H
+#define MATH_MATRIXINSET_H
+
+#include "math_arrayinset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+// "shortcut" for DelimInset("(",ArrayInset,")")
+
+class MathMatrixInset : public MathArrayInset {
+public: 
+       ///
+       MathMatrixInset(MathArrayInset const &);
+       ///
+       MathMatrixInset(string const & str);
+       ///
+       MathInset * clone() const;
+       ///
+       void metrics(MathMetricsInfo const &) const {}
+       /// identifies MatrixInsets
+       MathMatrixInset const * asMatrixInset() const { return this; }
+
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+       ///
+       void maplize(MapleStream &) const;
+       ///
+       void mathmlize(MathMLStream &) const;
+       ///
+       void octavize(OctaveStream &) const;
+};
+
+#endif
index 57384587766241bfa396fcd1537eb9d2cff2d299..03c1c2f04ebc787e77c47b13270ae9a2f475fe3d 100644 (file)
@@ -136,7 +136,7 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
 
 void MathNestInset::dump() const
 {
-       MathWriteInfo os(lyxerr);
+       WriteStream os(lyxerr);
        os << "---------------------------------------------\n";
        write(os);
        os << "\n";
index bedef35dab6f39e24c20355d73bdaddced70215a..1929286e129397e7fb6aa4ed854058cd1768dcda 100644 (file)
@@ -14,13 +14,13 @@ MathInset * MathNotInset::clone() const
 }
 
 
-void MathNotInset::write(MathWriteInfo & os) const
+void MathNotInset::write(WriteStream & os) const
 {
        os << "\\not ";
 }
 
 
-void MathNotInset::writeNormal(NormalStream & os) const
+void MathNotInset::normalize(NormalStream & os) const
 {
        os << "[not] ";
 }
index faf1e731fb99dbb25f04e4ae3a592826fb75e9c0..70470764b3d34b46177a1761bc0cd90efac3d7c8 100644 (file)
@@ -13,9 +13,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index 5384cb5625f07aa53772b18ea37ac1fe0737d78f..b9bc7e43e3540a66e8b05848c3003884adf2bd68 100644 (file)
@@ -492,7 +492,7 @@ bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
                }
 
                if (outmost) {
-                       MathHullInset * m = t->asMatrixInset();
+                       MathHullInset * m = t->asHullInset();
                        if (!m) {
                                lyxerr << "error in Parser::parse_lines() 2\n";
                                return false;
@@ -579,7 +579,7 @@ bool Parser::parse_normal(MathAtom & matrix)
                if (n.cat() == catMath) {
                        // TeX's $$...$$ syntax for displayed math
                        matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-                       MathHullInset * p = matrix->asMatrixInset();
+                       MathHullInset * p = matrix->asHullInset();
                        parse_into(p->cell(0), 0);
                        p->numbered(0, curr_num_);
                        p->label(0, curr_label_);
@@ -603,7 +603,7 @@ bool Parser::parse_normal(MathAtom & matrix)
                curr_num_ = 0;
                curr_label_.erase();
                matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-               MathHullInset * p = matrix->asMatrixInset();
+               MathHullInset * p = matrix->asHullInset();
                parse_into(p->cell(0), 0);
                p->numbered(0, curr_num_);
                p->label(0, curr_label_);
@@ -621,7 +621,7 @@ bool Parser::parse_normal(MathAtom & matrix)
                curr_num_ = (name == "equation");
                curr_label_.erase();
                matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
-               MathHullInset * p = matrix->asMatrixInset();
+               MathHullInset * p = matrix->asHullInset();
                parse_into(p->cell(0), FLAG_END);
                p->numbered(0, curr_num_);
                p->label(0, curr_label_);
index 187a9529e3cb6f1f6d522781832cca3d563e30db..edd10dadf4b9afa6d7d4a6cb3038b213c5fdcacc 100644 (file)
@@ -58,19 +58,15 @@ void MathRootInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathRootInset::write(MathWriteInfo & os) const
+void MathRootInset::write(WriteStream & os) const
 {
        os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
 }
 
 
-void MathRootInset::writeNormal(NormalStream & os) const
+void MathRootInset::normalize(NormalStream & os) const
 {
-       os << "[root ";
-       cell(1).writeNormal(os);  
-       os << " ";
-       cell(0).writeNormal(os);
-       os << "]";
+       os << "[root " << cell(1) << ' ' << cell(1) << ']';
 }
 
 
@@ -102,5 +98,5 @@ void MathRootInset::octavize(OctaveStream & os) const
 
 void MathRootInset::mathmlize(MathMLStream & os) const
 {
-       os << "<mroot>" << cell(1) << cell(0) << "</mroot>";
+       os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot");
 }
index 200ddc7cc72e28db567761432e3979dd64c2f065..209b9720f295dd79364d88c8bee54fa1f695d0cb 100644 (file)
@@ -32,17 +32,18 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
-       ///
-       void write(MathWriteInfo & os) const;
+       bool idxUp(int & idx, int & pos) const;
        ///
-       void writeNormal(NormalStream &) const;
+       bool idxDown(int & idx, int & pos) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
-       bool idxUp(int & idx, int & pos) const;
+       void draw(Painter &, int x, int y) const;
+
        ///
-       bool idxDown(int & idx, int & pos) const;
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
        ///
        void mathmlize(MathMLStream &) const;
        ///
index e675d75a844fc691f6994d3c1c297308bddbc98f..cb7eed1f1cac3e1a71948efe27aa9076978e573e 100644 (file)
@@ -272,14 +272,14 @@ bool MathScriptInset::idxLeft(MathInset::idx_type &,
 }
 
 
-void MathScriptInset::write(MathWriteInfo & os) const
+void MathScriptInset::write(WriteStream & os) const
 {  
        //lyxerr << "unexpected call to MathScriptInset::write()\n";
        write(0, os);
 }
 
 
-void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
+void MathScriptInset::write(MathInset const * nuc, WriteStream & os) const
 {
        if (nuc) {
                os << nuc;
@@ -301,14 +301,14 @@ void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
 }
 
 
-void MathScriptInset::writeNormal(NormalStream & os) const
+void MathScriptInset::normalize(NormalStream & os) const
 {  
-       //lyxerr << "unexpected call to MathScriptInset::writeNormal()\n";
-       writeNormal(0, os);
+       //lyxerr << "unexpected call to MathScriptInset::normalize()\n";
+       normalize(0, os);
 }
 
 
-void MathScriptInset::writeNormal(MathInset const * nuc, NormalStream & os) const
+void MathScriptInset::normalize(MathInset const * nuc, NormalStream & os) const
 {
        bool d = hasDown() && down().data_.size();
        bool u = hasUp() && up().data_.size();
index 904cbe0c2ed9850fad685c6c011961960de847c5..fe9630a518a76fd606037adf0256e63adfb39a7f 100644 (file)
@@ -21,9 +21,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream & os) const;
+       void normalize(NormalStream & os) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
@@ -78,9 +78,9 @@ public:
        void ensure(bool up);
 
        ///
-       void write(MathInset const * nuc, MathWriteInfo & os) const;
+       void write(MathInset const * nuc, WriteStream & os) const;
        ///
-       void writeNormal(MathInset const * nuc, NormalStream & os) const;
+       void normalize(MathInset const * nuc, NormalStream & os) const;
        ///
        void octavize(MathInset const * nuc, OctaveStream & os) const;
        ///
index 68219334bf7a0b7dfb8961f069ce45b7537f01e0..86edc28163e9fb01c0da549a52950121aa5bfefc 100644 (file)
@@ -35,13 +35,13 @@ void MathSizeInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathSizeInset::write(MathWriteInfo & os) const
+void MathSizeInset::write(WriteStream & os) const
 {
        os << "{\\" << key_->name.c_str() << ' ' << cell(0) << '}';
 }
 
 
-void MathSizeInset::writeNormal(NormalStream & os) const
+void MathSizeInset::normalize(NormalStream & os) const
 {
        os << "[" << key_->name.c_str() << ' ' << cell(0) << ']';
 }
index e1b0e50fcf0424db040224c6bc1fc56728b34e54..9fefc55db01cc0962719f0b98e5688a8cfc483a5 100644 (file)
@@ -26,9 +26,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
 
 private:
        /// 
index 2355e3c05b748d7c9bfa9347e5bbee4ab9a998fb..8e32f7c8b3ce03d65a5f40650dea7f894e02811b 100644 (file)
@@ -21,14 +21,14 @@ MathInset * MathSpaceInset::clone() const
 }
 
 
-void MathSpaceInset::write(MathWriteInfo & os) const
+void MathSpaceInset::write(WriteStream & os) const
 {
        if (space_ >= 0 && space_ < 6)
                os << '\\' << latex_mathspace[space_] << ' ';
 }
 
 
-void MathSpaceInset::writeNormal(NormalStream & os) const
+void MathSpaceInset::normalize(NormalStream & os) const
 {
        os << "[space " << space_ << "] ";
 }
index 21fee9249c13371ae2177c6061db7758edf97fd0..b9554ee4d40ba272dcb223f78b04d9d194d32f91 100644 (file)
@@ -19,9 +19,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index 0dbe004b4135a41a0689c7dfcd64b9d79901fe5d..fe66cfa69b9d6f4e5fd28eccb41f16adbd6ee0c9 100644 (file)
@@ -48,13 +48,13 @@ void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathSpecialCharInset::write(MathWriteInfo & os) const
+void MathSpecialCharInset::write(WriteStream & os) const
 {
        os << "\\" << char_;
 }
 
 
-void MathSpecialCharInset::writeNormal(NormalStream & os) const
+void MathSpecialCharInset::normalize(NormalStream & os) const
 {
        os << "\\" << char_;
 }
index 0adb5267ae1f1ede835d5fa5f78b3f6372c3ee59..0b5a72be42aa39a7d9285b12d281f3f4babbe1d0 100644 (file)
@@ -24,9 +24,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        /// 
        int ascent() const;
        ///
index 6f9d9c8e9bfbdf9030ceee100c3b840e52642e8c..02a0d567b5404cae4adbdce429bc34e7c2c9bb03 100644 (file)
@@ -19,7 +19,7 @@ MathInset * MathSplitInset::clone() const
 }
 
 
-void MathSplitInset::write(MathWriteInfo & os) const
+void MathSplitInset::write(WriteStream & os) const
 {
        if (os.fragile)
                os << "\\protect";
index 7c188eca937f2e8183e42a4d90f0c0e1aba47cc4..8704d37429a3343d976d770c981f7c5fc46ead8f 100644 (file)
@@ -16,7 +16,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
        int defaultColSpace(int) { return 0; }
        ///
index 65337dc5c63284a8083be01a4f4e01568aeccaf6..65023a12b400cdd9bb317c8d9456aeeb152c5687 100644 (file)
@@ -43,17 +43,15 @@ void MathSqrtInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathSqrtInset::write(MathWriteInfo & os) const
+void MathSqrtInset::write(WriteStream & os) const
 {
        os << "\\sqrt{" << cell(0) << '}';
 }
 
 
-void MathSqrtInset::writeNormal(NormalStream & os) const
+void MathSqrtInset::normalize(NormalStream & os) const
 {
-       os << "[sqrt ";
-       cell(0).writeNormal(os); 
-       os << "]";
+       os << "[sqrt " << cell(0) << ']';
 }
 
 
@@ -65,5 +63,5 @@ void MathSqrtInset::maplize(MapleStream & os) const
 
 void MathSqrtInset::mathmlize(MathMLStream & os) const
 {
-       os << "<msqrt>" << cell(0) << "</msqrt>";
+       os << MTag("msqrt") << cell(0) << ETag("msqrt");
 }
index ac774cbe7b7d0fafee4798551e154f9ed7082275..57517e49595d74c7ae9c93f104205e6757f37940 100644 (file)
@@ -20,11 +20,12 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void metrics(MathMetricsInfo const & st) const;
+
        ///
-       void writeNormal(NormalStream &) const;
+       void write(WriteStream & os) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void normalize(NormalStream &) const;
        ///
        void maplize(MapleStream &) const;
        ///
index 72f7b981b7cec943b6069f9a6ae2692606107e4f..75ccb8710aec5892bf07e114eb7235e2940f4663 100644 (file)
@@ -37,17 +37,13 @@ void MathStackrelInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathStackrelInset::write(MathWriteInfo & os) const
+void MathStackrelInset::write(WriteStream & os) const
 {
        os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
 }
 
 
-void MathStackrelInset::writeNormal(NormalStream & os) const
+void MathStackrelInset::normalize(NormalStream & os) const
 {
-       os << "[stackrel ";
-       cell(0).writeNormal(os);
-       os << " ";
-       cell(1).writeNormal(os);
-       os << "] ";
+       os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
 }
index e1122bfa816a0af08bde9d35fc48a64aa3d8fcb5..699dffe402d6833346bc6123efebf4f4413c3657 100644 (file)
@@ -18,13 +18,14 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
-       ///
-       void writeNormal(NormalStream &) const;
-       ///
        void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
+
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
 };
 
 #endif
index 68c4dab16e1c6e9e40d52ecaa1b4be5f6bf8ea05..b36639e0ba30493c634bb9640baa14582de81309 100644 (file)
@@ -55,7 +55,7 @@ void MathStringInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathStringInset::write(MathWriteInfo & os) const
+void MathStringInset::write(WriteStream & os) const
 {
        if (math_font_name(code_)) 
                os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}';
@@ -64,7 +64,7 @@ void MathStringInset::write(MathWriteInfo & os) const
 }
 
 
-void MathStringInset::writeNormal(NormalStream & os) const
+void MathStringInset::normalize(NormalStream & os) const
 {
        os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]";
 }
index 1d4e28f095dc2f1d7faede6c216b4394b833f29a..79774ff7577a615f5fe1d3ad76877c4b9931ee0b 100644 (file)
@@ -23,9 +23,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        /// 
        int ascent() const;
        ///
index b9e84c9c8071f3a0cef2e8732a20fc095308441d..e7f000f64c960b30f938ebefa958935f48739d7f 100644 (file)
@@ -16,13 +16,13 @@ MathInset * MathSymbolInset::clone() const
 }
 
 
-void MathSymbolInset::write(MathWriteInfo & os) const
+void MathSymbolInset::write(WriteStream & os) const
 {
        os << '\\' << sym_->name.c_str() << ' ';
 }
 
 
-void MathSymbolInset::writeNormal(NormalStream & os) const
+void MathSymbolInset::normalize(NormalStream & os) const
 {
        os << "[symbol " << sym_->name.c_str() << "]";
 }
index 7514c0a7bead8ed99fa8170b242a0ecbc6339331..5c1a6a348db8343a914a3856cae1ee0f83dc6d66 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(MathWriteInfo & os) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(NormalStream &) const;
+       void normalize(NormalStream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
index f0deef476e50a067b0d3f95b65a5ddf927d47f45..cffec88712d762a48e5ac119cf2a6443e7b90bd0 100644 (file)
@@ -4,14 +4,15 @@
 #pragma implementation
 #endif
 
-#include "math_inset.h"
 #include "math_scriptinset.h"
 #include "math_support.h"
-#include "math_defs.h"
 #include "Painter.h"
 #include "debug.h"
 
 
+extern MathScriptInset const * asScript(MathArray::const_iterator it);
+
+
 MathXArray::MathXArray()
        : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
 {}
@@ -32,7 +33,8 @@ void MathXArray::metrics(MathMetricsInfo const & st) const
        
        for (const_iterator it = begin(); it != end(); ++it) {
                MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
+               MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+               if (q) {
                        q->metrics(p, st);
                        ascent_  = std::max(ascent_,  q->ascent(p));
                        descent_ = std::max(descent_, q->descent(p));
@@ -62,7 +64,8 @@ void MathXArray::draw(Painter & pain, int x, int y) const
 
        for (const_iterator it = begin(); it != end(); ++it) {
                MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
+               MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+               if (q) {
                        q->draw(p, pain, x, y);
                        x += q->width(p);
                        ++it;
@@ -80,7 +83,8 @@ int MathXArray::pos2x(size_type targetpos) const
        const_iterator target = std::min(begin() + targetpos, end());
        for (const_iterator it = begin(); it < target; ++it) {
                MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
+               MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+               if (q) {
                        ++it;
                        if (it < target)
                                x += q->width(p);
@@ -103,7 +107,10 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
 
                int wid = 0;
                MathInset const * p = it->nucleus();
-               if (MathScriptInset const * q = data_.asScript(it)) {
+               MathScriptInset const * q = 0;
+               if (it + 1 != end())
+                       q = asScript(it);
+               if (q) {
                        wid = q->width(p);
                        ++it;
                } else