From 0daba49b1d7493cbf76658314b7459b51f870081 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 8 Nov 2001 12:06:56 +0000 Subject: [PATCH] don't #include too much stuff in .h git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2984 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/Makefile.am | 2 + src/mathed/array.C | 30 ++--- src/mathed/array.h | 17 ++- src/mathed/formula.C | 22 +++- src/mathed/formula.h | 2 +- src/mathed/formulamacro.C | 1 + src/mathed/math_arrayinset.C | 3 +- src/mathed/math_arrayinset.h | 2 +- src/mathed/math_binaryopinset.C | 9 +- src/mathed/math_binaryopinset.h | 2 +- src/mathed/math_binominset.C | 3 +- src/mathed/math_binominset.h | 2 +- src/mathed/math_boxinset.C | 5 +- src/mathed/math_boxinset.h | 2 +- src/mathed/math_braceinset.C | 8 +- src/mathed/math_braceinset.h | 2 +- src/mathed/math_charinset.C | 5 +- src/mathed/math_charinset.h | 2 +- src/mathed/math_cursor.C | 1 + src/mathed/math_decorationinset.C | 15 +-- src/mathed/math_decorationinset.h | 2 +- src/mathed/math_deliminset.C | 20 ++-- src/mathed/math_deliminset.h | 2 +- src/mathed/math_dotsinset.C | 12 +- src/mathed/math_dotsinset.h | 2 +- src/mathed/math_exfuncinset.C | 15 +-- src/mathed/math_exfuncinset.h | 2 +- src/mathed/math_exintinset.C | 54 +++++++++ src/mathed/math_exintinset.h | 38 +++++++ src/mathed/math_fracbase.C | 1 + src/mathed/math_fracinset.C | 8 +- src/mathed/math_fracinset.h | 2 +- src/mathed/math_funcinset.C | 13 +-- src/mathed/math_funcinset.h | 2 +- src/mathed/math_funcliminset.C | 10 +- src/mathed/math_funcliminset.h | 2 +- src/mathed/math_gridinset.C | 27 ++--- src/mathed/math_gridinset.h | 2 +- src/mathed/math_inset.C | 14 ++- src/mathed/math_inset.h | 45 +------- src/mathed/math_kerninset.C | 27 ++--- src/mathed/math_kerninset.h | 2 +- src/mathed/math_lefteqninset.C | 26 ++--- src/mathed/math_lefteqninset.h | 2 +- src/mathed/math_macro.C | 3 +- src/mathed/math_macro.h | 2 +- src/mathed/math_macroarg.C | 5 +- src/mathed/math_macroarg.h | 2 +- src/mathed/math_macrotable.C | 3 + src/mathed/math_macrotemplate.C | 19 ++-- src/mathed/math_mathmlstream.C | 112 ++++++++++++++++++- src/mathed/math_mathmlstream.h | 80 +++++++++++++- src/mathed/math_matrixinset.C | 64 +++++------ src/mathed/math_matrixinset.h | 2 +- src/mathed/math_nestinset.C | 11 +- src/mathed/math_notinset.C | 6 +- src/mathed/math_notinset.h | 2 +- src/mathed/math_parser.C | 11 +- src/mathed/math_rootinset.C | 4 +- src/mathed/math_rootinset.h | 2 +- src/mathed/math_scriptinset.C | 172 ++++++++++++++--------------- src/mathed/math_scriptinset.h | 22 ++-- src/mathed/math_sizeinset.C | 10 +- src/mathed/math_sizeinset.h | 2 +- src/mathed/math_spaceinset.C | 4 +- src/mathed/math_spaceinset.h | 2 +- src/mathed/math_specialcharinset.C | 4 +- src/mathed/math_specialcharinset.h | 2 +- src/mathed/math_splitinset.C | 2 +- src/mathed/math_sqrtinset.C | 4 +- src/mathed/math_sqrtinset.h | 2 +- src/mathed/math_stackrelinset.C | 6 +- src/mathed/math_stackrelinset.h | 2 +- src/mathed/math_stringinset.C | 10 +- src/mathed/math_stringinset.h | 2 +- src/mathed/math_symbolinset.C | 10 +- src/mathed/math_symbolinset.h | 4 +- src/mathed/support.C | 2 +- src/mathed/xarray.C | 9 +- 79 files changed, 636 insertions(+), 428 deletions(-) create mode 100644 src/mathed/math_exintinset.C create mode 100644 src/mathed/math_exintinset.h diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 10e26703d6..bc7108aaa4 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -45,6 +45,8 @@ libmathed_la_SOURCES = \ math_dotsinset.h \ math_exfuncinset.C \ math_exfuncinset.h \ + math_exintinset.C \ + math_exintinset.h \ math_factory.C \ math_factory.h \ math_fracinset.C \ diff --git a/src/mathed/array.C b/src/mathed/array.C index cc53477b0c..c65e069f9a 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -6,15 +6,12 @@ #include "math_charinset.h" #include "math_scriptinset.h" #include "math_stringinset.h" +#include "math_mathmlstream.h" +#include "support.h" #include "debug.h" #include "array.h" -#include "mathed/support.h" #include "support/LAssert.h" -using std::ostream; -using std::endl; - - MathArray::MathArray() {} @@ -133,24 +130,19 @@ MathAtom & MathArray::back() } -void MathArray::dump2(ostream & os) const +void MathArray::dump2() const { + NormalStream ns(lyxerr); for (const_iterator it = begin(); it != end(); ++it) - os << it->nucleus() << ' '; + ns << it->nucleus() << ' '; } -void MathArray::dump(ostream & os) const +void MathArray::dump() const { + NormalStream ns(lyxerr); for (const_iterator it = begin(); it != end(); ++it) - os << "<" << it->nucleus() << ">"; -} - - -std::ostream & operator<<(std::ostream & os, MathArray const & ar) -{ - ar.dump2(os); - return os; + ns << "<" << it->nucleus() << ">"; } @@ -231,7 +223,7 @@ void MathArray::write(MathWriteInfo & wi) const } -void MathArray::writeNormal(ostream & os) const +void MathArray::writeNormal(NormalStream & os) const { MathArray ar = glueChars(); for (const_iterator it = ar.begin(); it != ar.end(); ++it) { @@ -281,7 +273,7 @@ void MathArray::mathmlize(MathMLStream & os) const else if (ar.size() == 1) os << ar.begin()->nucleus(); else { - os << ""; + 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)) { @@ -290,7 +282,7 @@ void MathArray::mathmlize(MathMLStream & os) const } else p->mathmlize(os); } - os << ""; + os << ETag("mrow"); } } diff --git a/src/mathed/array.h b/src/mathed/array.h index e4d854cbc0..007d75850e 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -17,7 +17,6 @@ #define MATHEDARRAY_H #include -#include #include "math_atom.h" #include "LString.h" @@ -26,10 +25,12 @@ class MathScriptInset; class MathMacro; class MathWriteInfo; class MathMetricsInfo; -class MathMLStream; +class LaTeXFeatures; +class NormalStream; class MapleStream; +class MathMLStream; class OctaveStream; -class LaTeXFeatures; + #ifdef __GNUG__ #pragma interface @@ -93,9 +94,9 @@ public: MathAtom & back(); /// - void dump(std::ostream &) const; + void dump() const; /// - void dump2(std::ostream &) const; + void dump2() const; /// void substitute(MathMacro const &); @@ -106,7 +107,7 @@ public: /// glue chars if necessary void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void validate(LaTeXFeatures &) const; /// @@ -139,8 +140,4 @@ private: buffer_type bf_; }; - -std::ostream & operator<<(std::ostream & os, MathArray const & ar); - - #endif diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 2de2bfd602..59fdb97cc0 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -41,7 +41,8 @@ #include "Painter.h" #include "lyxrc.h" #include "math_matrixinset.h" -#include "mathed/support.h" +#include "support.h" +#include "math_mathmlstream.h" using std::ostream; using std::ifstream; @@ -86,6 +87,12 @@ namespace { "subs(`\\,`=`\\cdot `," "eval(`latex/latex/*`)):\n"; + // replace spurious \\noalign{\\medskip} in table output + header += + "`latex/latex/matrix`:= " + "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`," + "eval(`latex/latex/matrix`)):\n"; + //"#`latex/latex/symbol` " // " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): "; @@ -217,8 +224,9 @@ namespace { // create normalized expression ostringstream os; + NormalStream ns(os); os << "[" << extra << ' '; - ar.writeNormal(os); + ar.writeNormal(ns); os << "]"; string data = os.str().c_str(); @@ -305,10 +313,12 @@ int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const int InsetFormula::docbook(Buffer const * buf, ostream & os) const { MathMLStream ms(os); - ms << ""; + ms << MTag("equation") << MTag("alt"); int res = ascii(buf, ms.os_, 0); - ms << "\n" << par_.nucleus() << ""; - return res + 1; + ms << ETag("alt") << MTag("math"); + ms << par_.nucleus(); + ms << ETag("math") << ETag("equation"); + return ms.line_ + res; } @@ -508,7 +518,7 @@ void InsetFormula::handleExtern(const string & arg) MathArray ar; if (selected) { mathcursor->selGet(ar); - lyxerr << "use selection: " << ar << "\n"; + //lyxerr << "use selection: " << ar << "\n"; } else { mathcursor->end(); mathcursor->stripFromLastEqualSign(); diff --git a/src/mathed/formula.h b/src/mathed/formula.h index 94c6d602b6..38b41cbccb 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -21,7 +21,7 @@ #pragma interface #endif -#include "mathed/formulabase.h" +#include "formulabase.h" #include "math_defs.h" #include "math_atom.h" diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index e2e28577b3..f5a75c4bd3 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -38,6 +38,7 @@ #include "lyxlex.h" #include "lyxtext.h" #include "lyxfont.h" +#include "math_mathmlstream.h" using std::ostream; diff --git a/src/mathed/math_arrayinset.C b/src/mathed/math_arrayinset.C index 4a48f11e84..4b98267d5d 100644 --- a/src/mathed/math_arrayinset.C +++ b/src/mathed/math_arrayinset.C @@ -6,6 +6,7 @@ #include "math_parser.h" #include "support/LOstream.h" #include "Lsstream.h" +#include "math_mathmlstream.h" using std::vector; @@ -73,7 +74,7 @@ void MathArrayInset::write(MathWriteInfo & os) const } -void MathArrayInset::writeNormal(std::ostream & os) const +void MathArrayInset::writeNormal(NormalStream & os) const { os << "[array "; MathGridInset::writeNormal(os); diff --git a/src/mathed/math_arrayinset.h b/src/mathed/math_arrayinset.h index 13f2ee5736..06d092e413 100644 --- a/src/mathed/math_arrayinset.h +++ b/src/mathed/math_arrayinset.h @@ -22,7 +22,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_binaryopinset.C b/src/mathed/math_binaryopinset.C index 4ceb067faa..ff67faf7a9 100644 --- a/src/mathed/math_binaryopinset.C +++ b/src/mathed/math_binaryopinset.C @@ -6,6 +6,7 @@ #include "Painter.h" #include "support/LOstream.h" #include "support.h" +#include "math_mathmlstream.h" MathBinaryOpInset::MathBinaryOpInset(char op) @@ -50,11 +51,7 @@ void MathBinaryOpInset::write(MathWriteInfo & os) const } -void MathBinaryOpInset::writeNormal(std::ostream & os) const +void MathBinaryOpInset::writeNormal(NormalStream & os) const { - os << "[binop " << op_ << ' '; - cell(0).writeNormal(os); - os << " "; - cell(1).writeNormal(os); - os << "]"; + os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']'; } diff --git a/src/mathed/math_binaryopinset.h b/src/mathed/math_binaryopinset.h index ccd5f085f4..2eca9519da 100644 --- a/src/mathed/math_binaryopinset.h +++ b/src/mathed/math_binaryopinset.h @@ -23,7 +23,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; private: diff --git a/src/mathed/math_binominset.C b/src/mathed/math_binominset.C index 85e9de308b..71b32bdb3c 100644 --- a/src/mathed/math_binominset.C +++ b/src/mathed/math_binominset.C @@ -5,6 +5,7 @@ #include "math_binominset.h" #include "support.h" #include "support/LOstream.h" +#include "math_mathmlstream.h" MathBinomInset::MathBinomInset() @@ -56,7 +57,7 @@ void MathBinomInset::write(MathWriteInfo & os) const } -void MathBinomInset::writeNormal(std::ostream & os) const +void MathBinomInset::writeNormal(NormalStream & os) const { os << "[binom "; cell(0).writeNormal(os); diff --git a/src/mathed/math_binominset.h b/src/mathed/math_binominset.h index b991a2700a..35f5933c0b 100644 --- a/src/mathed/math_binominset.h +++ b/src/mathed/math_binominset.h @@ -20,7 +20,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_boxinset.C b/src/mathed/math_boxinset.C index 39b3b1c931..7eb163fe98 100644 --- a/src/mathed/math_boxinset.C +++ b/src/mathed/math_boxinset.C @@ -9,6 +9,7 @@ #include "Painter.h" #include "math_cursor.h" #include "insets/insettext.h" +#include "math_mathmlstream.h" MathBoxInset::MathBoxInset(string const & name) @@ -46,11 +47,11 @@ UpdatableInset * MathBoxInset::asHyperActiveInset() const void MathBoxInset::write(MathWriteInfo & os) const { - os << "\\" << name_ << "{" << cell(0) << "}"; + os << "\\" << name_.c_str() << "{" << cell(0) << "}"; } -void MathBoxInset::writeNormal(std::ostream & os) const +void MathBoxInset::writeNormal(NormalStream & os) const { os << "[mbox "; //text_->write(buffer(), os); diff --git a/src/mathed/math_boxinset.h b/src/mathed/math_boxinset.h index b866bbe5b8..8812296605 100644 --- a/src/mathed/math_boxinset.h +++ b/src/mathed/math_boxinset.h @@ -32,7 +32,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const &) const; /// identifies BoxInsets diff --git a/src/mathed/math_braceinset.C b/src/mathed/math_braceinset.C index 93b37336d6..88fd33a5bd 100644 --- a/src/mathed/math_braceinset.C +++ b/src/mathed/math_braceinset.C @@ -6,10 +6,8 @@ #include "math_braceinset.h" #include "math_parser.h" -#include "mathed/support.h" -#include "support/LOstream.h" - -using std::max; +#include "support.h" +#include "math_mathmlstream.h" MathBraceInset::MathBraceInset() @@ -29,7 +27,7 @@ void MathBraceInset::write(MathWriteInfo & os) const } -void MathBraceInset::writeNormal(std::ostream & os) const +void MathBraceInset::writeNormal(NormalStream & os) const { os << "[block "; cell(0).writeNormal(os); diff --git a/src/mathed/math_braceinset.h b/src/mathed/math_braceinset.h index b7ed9514ff..960f674b82 100644 --- a/src/mathed/math_braceinset.h +++ b/src/mathed/math_braceinset.h @@ -24,7 +24,7 @@ public: /// void write(MathWriteInfo & os) const; /// write normalized content - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index 89c3378a78..0986be73e0 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -8,9 +8,10 @@ #include "LColor.h" #include "Painter.h" #include "support/LOstream.h" -#include "mathed/support.h" +#include "support.h" #include "math_parser.h" #include "debug.h" +#include "math_mathmlstream.h" MathCharInset::MathCharInset(char c) @@ -101,7 +102,7 @@ void MathCharInset::write(MathWriteInfo & os) const } -void MathCharInset::writeNormal(std::ostream & os) const +void MathCharInset::writeNormal(NormalStream & os) const { os << "[char " << char_ << " " << "mathalpha" << "]"; } diff --git a/src/mathed/math_charinset.h b/src/mathed/math_charinset.h index 3d844729ba..790453440a 100644 --- a/src/mathed/math_charinset.h +++ b/src/mathed/math_charinset.h @@ -35,7 +35,7 @@ public: /// void writeRaw(std::ostream &) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// int ascent() const; /// diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index beeb60793e..aa8394ab47 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -40,6 +40,7 @@ #include "math_scriptinset.h" #include "math_spaceinset.h" #include "math_specialcharinset.h" +#include "math_mathmlstream.h" #define FILEDEBUG 0 diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index 7c76cee6eb..33829502e0 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -3,12 +3,9 @@ #endif #include "math_decorationinset.h" -#include "mathed/support.h" +#include "support.h" #include "math_parser.h" -#include "support/LOstream.h" - - -using std::ostream; +#include "math_mathmlstream.h" MathDecorationInset::MathDecorationInset(string const & name) @@ -98,13 +95,11 @@ void MathDecorationInset::write(MathWriteInfo & os) const { if (os.fragile && protect()) os << "\\protect"; - os << '\\' << name_ << '{' << cell(0) << '}'; + os << '\\' << name_.c_str() << '{' << cell(0) << '}'; } -void MathDecorationInset::writeNormal(ostream & os) const +void MathDecorationInset::writeNormal(NormalStream & os) const { - os << "[" << name_ << " "; - cell(0).writeNormal(os); - os << "] "; + os << "[deco " << name_.c_str() << ' ' << cell(0) << ']'; } diff --git a/src/mathed/math_decorationinset.h b/src/mathed/math_decorationinset.h index 1808b2f474..5a18067de5 100644 --- a/src/mathed/math_decorationinset.h +++ b/src/mathed/math_decorationinset.h @@ -26,7 +26,7 @@ public: /// void metrics(MathMetricsInfo const & st) const; /// - void writeNormal(std::ostream & os) const; + void writeNormal(NormalStream & os) const; /// bool isScriptable() const; diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index d0191cc87b..dd4f3ef08b 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -6,10 +6,9 @@ #include "math_deliminset.h" #include "math_parser.h" -#include "mathed/support.h" +#include "support.h" #include "support/LOstream.h" - -using std::max; +#include "math_mathmlstream.h" MathDelimInset::MathDelimInset(string const & l, string const & r) @@ -45,16 +44,15 @@ string MathDelimInset::latexName(string const & name) void MathDelimInset::write(MathWriteInfo & os) const { - os << "\\left" << latexName(left_) << cell(0) - << "\\right" << latexName(right_); + os << "\\left" << latexName(left_).c_str() << cell(0) + << "\\right" << latexName(right_).c_str(); } -void MathDelimInset::writeNormal(std::ostream & os) const +void MathDelimInset::writeNormal(NormalStream & os) const { - os << "[delim " << latexName(left_) << ' ' << latexName(right_) << ' '; - cell(0).writeNormal(os); - os << "]"; + os << "[delim " << latexName(left_).c_str() << ' ' + << latexName(right_).c_str() << ' ' << cell(0) << ']'; } @@ -77,8 +75,8 @@ void MathDelimInset::metrics(MathMetricsInfo const & mi) const int h0 = (a + d) / 2; int a0 = std::max(xcell(0).ascent(), a) - h0; int d0 = std::max(xcell(0).descent(), d) + h0; - ascent_ = max(a0, d0) + h0; - descent_ = max(a0, d0) - h0; + ascent_ = std::max(a0, d0) + h0; + descent_ = std::max(a0, d0) - h0; width_ = xcell(0).width() + 2 * dw() + 4; } diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index e5d5d4aa60..e0a00d9b57 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -24,7 +24,7 @@ public: /// void write(MathWriteInfo & os) const; /// write normalized content - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 47a79a7d4a..1f3aad2314 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -3,10 +3,8 @@ #endif #include "math_dotsinset.h" -#include "mathed/support.h" -#include "support/LOstream.h" - -using std::ostream; +#include "math_mathmlstream.h" +#include "support.h" MathDotsInset::MathDotsInset(string const & name) @@ -46,11 +44,11 @@ void MathDotsInset::metrics(MathMetricsInfo const & mi) const void MathDotsInset::write(MathWriteInfo & os) const { - os << '\\' << name_ << ' '; + os << '\\' << name_.c_str() << ' '; } -void MathDotsInset::writeNormal(ostream & os) const +void MathDotsInset::writeNormal(NormalStream & os) const { - os << "[" << name_ << "] "; + os << "[" << name_.c_str() << "] "; } diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index 2fcc333c25..c13943d5ae 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -21,7 +21,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; protected: diff --git a/src/mathed/math_exfuncinset.C b/src/mathed/math_exfuncinset.C index 3ca79da57f..d1da3f4119 100644 --- a/src/mathed/math_exfuncinset.C +++ b/src/mathed/math_exfuncinset.C @@ -1,7 +1,6 @@ #include "math_exfuncinset.h" #include "support.h" -#include "debug.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" using std::ostream; @@ -20,17 +19,13 @@ MathInset * MathExFuncInset::clone() const void MathExFuncInset::write(MathWriteInfo & os) const { - os << '\\' << name_ << '{'; - cell(0).write(os); - os << '}'; + os << '\\' << name_.c_str() << '{' << cell(0) << '}'; } -void MathExFuncInset::writeNormal(ostream & os) const +void MathExFuncInset::writeNormal(NormalStream & os) const { - os << "[" << name_ << ' '; - cell(0).writeNormal(os); - os << "] "; + os << '[' << name_.c_str() << ' ' << cell(0) << ']'; } @@ -38,14 +33,12 @@ void MathExFuncInset::metrics(MathMetricsInfo const & mi) const { mi_ = mi; mathed_string_dim(LM_TC_TEXTRM, mi_, name_, ascent_, descent_, width_); - lyxerr << "should not happen\n"; } void MathExFuncInset::draw(Painter & pain, int x, int y) const { drawStr(pain, LM_TC_TEXTRM, mi_, x, y, name_); - lyxerr << "should not happen\n"; } diff --git a/src/mathed/math_exfuncinset.h b/src/mathed/math_exfuncinset.h index 7ff103b01d..951449673f 100644 --- a/src/mathed/math_exfuncinset.h +++ b/src/mathed/math_exfuncinset.h @@ -16,7 +16,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_exintinset.C b/src/mathed/math_exintinset.C new file mode 100644 index 0000000000..7ebd2b9ddc --- /dev/null +++ b/src/mathed/math_exintinset.C @@ -0,0 +1,54 @@ +#include "math_exintinset.h" +#include "support.h" +#include "debug.h" +#include "math_mathmlstream.h" +#include "math_symbolinset.h" + + +MathExIntInset::MathExIntInset(MathScriptInset const & scripts, + MathArray const & core, MathArray const & diff) + : int_(new MathSymbolInset("int")), + scripts_(scripts), core_(core), diff_(diff) +{} + + +MathInset * MathExIntInset::clone() const +{ + return new MathExIntInset(*this); +} + + +void MathExIntInset::write(MathWriteInfo & os) const +{ + scripts_.write(int_.nucleus(), os); + os << core_ << "d" << diff_; +} + + +void MathExIntInset::writeNormal(NormalStream & os) const +{ + //os << "[int " << scripts_ << ' ' << core_ << ' ' << diff_ << ']' +} + + +void MathExIntInset::metrics(MathMetricsInfo const &) const +{ + lyxerr << "should not happen\n"; +} + + +void MathExIntInset::draw(Painter &, int, int) const +{ + lyxerr << "should not happen\n"; +} + + +void MathExIntInset::maplize(MapleStream & os) const +{ + //os << name_.c_str() << '(' << cell(0) << ')'; +} + +void MathExIntInset::mathmlize(MathMLStream & os) const +{ + //os << name_.c_str() << '(' << cell(0) << ')'; +} diff --git a/src/mathed/math_exintinset.h b/src/mathed/math_exintinset.h new file mode 100644 index 0000000000..0d1214e985 --- /dev/null +++ b/src/mathed/math_exintinset.h @@ -0,0 +1,38 @@ +// -*- C++ -*- +#ifndef MATH_EXINTINSET_H +#define MATH_EXINTINSET_H + +// /\int_l^u f(x) dxin one block (as opposed to 'f','(','x',')' or 'f','x') +// for interfacing external programs + +#include "math_scriptinset.h" + +class MathExIntInset : public MathInset { +public: + /// + MathExIntInset(MathScriptInset const &, MathArray const &, MathArray const &); + /// + MathInset * clone() const; + /// + void metrics(MathMetricsInfo const & st) const; + /// + void draw(Painter &, int x, int y) const; + /// + void write(MathWriteInfo & os) const; + /// + void writeNormal(NormalStream &) const; + /// + void maplize(MapleStream &) const; + /// + void mathmlize(MathMLStream &) const; +private: + /// + MathAtom int_; + /// + MathScriptInset scripts_; + /// + MathArray core_; + /// + MathArray diff_; +}; +#endif diff --git a/src/mathed/math_fracbase.C b/src/mathed/math_fracbase.C index 0cb0086bb2..5efcc40b26 100644 --- a/src/mathed/math_fracbase.C +++ b/src/mathed/math_fracbase.C @@ -3,6 +3,7 @@ #endif #include "math_fracbase.h" +#include "math_mathmlstream.h" MathFracbaseInset::MathFracbaseInset() diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 22fc7eeb23..455da87e6a 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -3,9 +3,9 @@ #endif #include "math_fracinset.h" -#include "mathed/support.h" +#include "support.h" #include "Painter.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" MathFracInset::MathFracInset(bool atop) @@ -50,7 +50,7 @@ void MathFracInset::write(MathWriteInfo & os) const } -void MathFracInset::writeNormal(std::ostream & os) const +void MathFracInset::writeNormal(NormalStream & os) const { if (atop_) os << "[atop "; @@ -71,5 +71,5 @@ void MathFracInset::maplize(MapleStream & os) const void MathFracInset::mathmlize(MathMLStream & os) const { - os << "" << cell(0) << cell(1) << ""; + os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac"); } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 479e0c8e87..c66e9fb2f4 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -20,7 +20,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index d36c8b4c5f..af1bebebeb 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -5,11 +5,10 @@ #include "math_funcinset.h" #include "font.h" #include "Painter.h" -#include "mathed/support.h" -#include "support/LOstream.h" +#include "support.h" +#include "math_mathmlstream.h" -using std::ostream; extern LyXFont WhichFont(short type, int size); @@ -39,13 +38,13 @@ void MathFuncInset::setName(string const & n) void MathFuncInset::write(MathWriteInfo & os) const { - os << "\\" << name_ << ' '; + os << "\\" << name_.c_str() << ' '; } -void MathFuncInset::writeNormal(std::ostream & os) const +void MathFuncInset::writeNormal(NormalStream & os) const { - os << "[" << name_ << "] "; + os << "[func " << name_.c_str() << ']'; } @@ -70,7 +69,7 @@ void MathFuncInset::maplize(MapleStream & os) const void MathFuncInset::mathmlize(MathMLStream & os) const { - os << "" << name_.c_str() << ""; + os << MTag("mi") << name_.c_str() << ETag("mi"); } diff --git a/src/mathed/math_funcinset.h b/src/mathed/math_funcinset.h index b1468fc37d..4196e73d7b 100644 --- a/src/mathed/math_funcinset.h +++ b/src/mathed/math_funcinset.h @@ -25,7 +25,7 @@ public: /// void write(MathWriteInfo &) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// string const & name() const; /// diff --git a/src/mathed/math_funcliminset.C b/src/mathed/math_funcliminset.C index 472b6e0807..ac3469cb17 100644 --- a/src/mathed/math_funcliminset.C +++ b/src/mathed/math_funcliminset.C @@ -1,10 +1,8 @@ #include "math_funcliminset.h" +#include "math_mathmlstream.h" #include "support.h" -#include "support/LOstream.h" -using std::ostream; - MathFuncLimInset::MathFuncLimInset(string const & name) : name_(name) {} @@ -24,13 +22,13 @@ bool MathFuncLimInset::isScriptable() const void MathFuncLimInset::write(MathWriteInfo & os) const { - os << '\\' << name_ << ' '; + os << '\\' << name_.c_str() << ' '; } -void MathFuncLimInset::writeNormal(ostream & os) const +void MathFuncLimInset::writeNormal(NormalStream & os) const { - os << "[" << name_ << "] "; + os << "[funclim " << name_.c_str() << ']'; } diff --git a/src/mathed/math_funcliminset.h b/src/mathed/math_funcliminset.h index 86736136ac..02c533e853 100644 --- a/src/mathed/math_funcliminset.h +++ b/src/mathed/math_funcliminset.h @@ -16,7 +16,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 75d9e8e200..c9c5546d02 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -3,8 +3,8 @@ #endif #include "math_gridinset.h" +#include "math_mathmlstream.h" #include "lyxfont.h" -#include "support/LOstream.h" #include "debug.h" @@ -266,25 +266,22 @@ void MathGridInset::write(MathWriteInfo & 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); - os << eolString(row); + os << cell(index(row, col)) << eocString(col).c_str(); + os << eolString(row).c_str(); } } -void MathGridInset::writeNormal(std::ostream & os) const +void MathGridInset::writeNormal(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)).writeNormal(os); - os << "]"; - } - os << "]"; + for (col_type col = 0; col < ncols(); ++col) + os << "[cell " << cell(index(row, col)) << ']'; + os << ']'; } - os << "]"; + os << ']'; } @@ -607,14 +604,14 @@ void MathGridInset::maplize(MapleStream & os) const void MathGridInset::mathmlize(MathMLStream & os) const { - os << ""; + os << MTag("mtable"); for (row_type row = 0; row < nrows(); ++row) { - os << ""; + os << MTag("mtr"); for (col_type col = 0; col < ncols(); ++col) os << cell(index(row, col)); - os << ""; + os << ETag("mtr"); } - os << ""; + os << ETag("mtable"); } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index e87a537cf2..cc2414f42e 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -66,7 +66,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 2d73be133a..c5dfea37d9 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -24,6 +24,7 @@ #include "Lsstream.h" #include "math_inset.h" #include "math_scriptinset.h" +#include "math_mathmlstream.h" #include "debug.h" @@ -160,10 +161,10 @@ void MathInset::idxDeleteRange(idx_type, idx_type) {} -void MathInset::writeNormal(std::ostream & os) const +void MathInset::writeNormal(NormalStream & os) const { os << "[unknown "; - MathWriteInfo wi(0, os, false); + MathWriteInfo wi(0, os.os_, false); write(wi); os << "] "; } @@ -219,17 +220,20 @@ void MathInset::write(MathWriteInfo &) const void MathInset::octavize(OctaveStream & os) const { - writeNormal(os.os_); + NormalStream ns(os.os_); + writeNormal(ns); } void MathInset::maplize(MapleStream & os) const { - writeNormal(os.os_); + NormalStream ns(os.os_); + writeNormal(ns); } void MathInset::mathmlize(MathMLStream & os) const { - writeNormal(os.os_); + NormalStream ns(os.os_); + writeNormal(ns); } diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 013fd1e59d..dc9020cc07 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -30,7 +30,6 @@ #include "xarray.h" #include "math_defs.h" -#include "math_mathmlstream.h" /** Abstract base class for all math objects. A math insets is for use of the math editor only, it isn't a @@ -50,44 +49,8 @@ class MathSpaceInset; class MathMacroTemplate; class LaTeXFeatures; -class Buffer; class BufferView; class UpdatableInset; -class MathOctaveInfo; - - -struct MathWriteInfo { - /// - MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_) - : buffer(buffer_), os(os_), fragile(fragile_) - {} - /// - explicit MathWriteInfo(std::ostream & os_) - : buffer(0), os(os_), fragile(false) - {} - - /// - template - MathWriteInfo & operator<<(T const & t) - { - os << t; - return *this; - } - /// - MathWriteInfo & operator<<(MathArray const & ar) - { - ar.write(*this); - return *this; - } - - - /// - Buffer const * buffer; - /// - std::ostream & os; - /// - bool fragile; -}; class MathInset { @@ -112,8 +75,6 @@ public: virtual void draw(Painter &, int x, int y) const; /// write LaTeX and Lyx code virtual void write(MathWriteInfo & os) const; - /// write normalized content - virtual void writeNormal(std::ostream &) const; /// reproduce itself virtual MathInset * clone() const = 0; ///substitutes macro arguments if necessary @@ -254,12 +215,14 @@ public: /// virtual void handleFont(MathTextCodes) {} - /// - virtual void octavize(OctaveStream &) const; + /// write normalized content + virtual void writeNormal(NormalStream &) const; /// virtual void maplize(MapleStream &) const; /// virtual void mathmlize(MathMLStream &) const; + /// + virtual void octavize(OctaveStream &) const; }; std::ostream & operator<<(std::ostream &, MathInset const &); diff --git a/src/mathed/math_kerninset.C b/src/mathed/math_kerninset.C index 6a28235177..ae18d84790 100644 --- a/src/mathed/math_kerninset.C +++ b/src/mathed/math_kerninset.C @@ -3,8 +3,8 @@ #endif #include "math_kerninset.h" +#include "math_mathmlstream.h" #include "support.h" -#include "support/LOstream.h" MathKernInset::MathKernInset() @@ -31,18 +31,6 @@ void MathKernInset::draw(Painter &, int, int) const {} -void MathKernInset::write(MathWriteInfo & os) const -{ - os << "\\kern" << wid_.asLatexString() << " "; -} - - -void MathKernInset::writeNormal(std::ostream & os) const -{ - os << "[kern " << wid_.asLatexString() << "]"; -} - - void MathKernInset::metrics(MathMetricsInfo const &) const { ascent_ = 0; @@ -54,3 +42,16 @@ void MathKernInset::metrics(MathMetricsInfo const &) const width_ = static_cast(wid_.value()); //cerr << "handling kern of width " << wid_.value() << "\n"; } + + +void MathKernInset::write(MathWriteInfo & os) const +{ + os << "\\kern" << wid_.asLatexString().c_str() << " "; +} + + +void MathKernInset::writeNormal(NormalStream & os) const +{ + os << "[kern " << wid_.asLatexString().c_str() << "]"; +} + diff --git a/src/mathed/math_kerninset.h b/src/mathed/math_kerninset.h index 0a707cae7f..d2b7aabe60 100644 --- a/src/mathed/math_kerninset.h +++ b/src/mathed/math_kerninset.h @@ -27,7 +27,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; private: diff --git a/src/mathed/math_lefteqninset.C b/src/mathed/math_lefteqninset.C index 3f4382d8ea..8628abce06 100644 --- a/src/mathed/math_lefteqninset.C +++ b/src/mathed/math_lefteqninset.C @@ -3,10 +3,10 @@ #endif #include "math_lefteqninset.h" -#include "support/LOstream.h" #include "LColor.h" #include "Painter.h" #include "math_cursor.h" +#include "math_mathmlstream.h" MathLefteqnInset::MathLefteqnInset() @@ -20,6 +20,15 @@ MathInset * MathLefteqnInset::clone() const } +void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const +{ + MathNestInset::metrics(mi); + ascent_ = xcell(0).ascent() + 2; + descent_ = xcell(0).descent() + 2; + width_ = 4; +} + + void MathLefteqnInset::draw(Painter & pain, int x, int y) const { xcell(0).draw(pain, x + 2, y); @@ -36,19 +45,10 @@ void MathLefteqnInset::write(MathWriteInfo & os) const } -void MathLefteqnInset::writeNormal(std::ostream & os) const +void MathLefteqnInset::writeNormal(NormalStream & os) const { os << "[lefteqn "; - MathWriteInfo wi(os); + MathWriteInfo wi(os.os_); cell(0).write(wi); - os << "] "; -} - - -void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const -{ - MathNestInset::metrics(mi); - ascent_ = xcell(0).ascent() + 2; - descent_ = xcell(0).descent() + 2; - width_ = 4; + os << "]"; } diff --git a/src/mathed/math_lefteqninset.h b/src/mathed/math_lefteqninset.h index 15c37262a9..78525d8663 100644 --- a/src/mathed/math_lefteqninset.h +++ b/src/mathed/math_lefteqninset.h @@ -21,7 +21,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; }; diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index f65f7c551e..c0c63266d2 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -27,6 +27,7 @@ #include "math_cursor.h" #include "math_macrotable.h" #include "math_macrotemplate.h" +#include "math_mathmlstream.h" #include "Painter.h" #include "LaTeXFeatures.h" @@ -171,7 +172,7 @@ void MathMacro::write(MathWriteInfo & os) const } -void MathMacro::writeNormal(std::ostream & os) const +void MathMacro::writeNormal(NormalStream & os) const { os << "[macro " << name() << " "; for (idx_type i = 0; i < nargs(); ++i) { diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 39fb630aff..ce9e3b928f 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -50,7 +50,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void dump() const; diff --git a/src/mathed/math_macroarg.C b/src/mathed/math_macroarg.C index 77c817305f..6a6a639b43 100644 --- a/src/mathed/math_macroarg.C +++ b/src/mathed/math_macroarg.C @@ -5,7 +5,8 @@ #include "math_macroarg.h" #include "math_macro.h" #include "math_defs.h" -#include "mathed/support.h" +#include "math_mathmlstream.h" +#include "support.h" #include "debug.h" @@ -57,7 +58,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const } -void MathMacroArgument::writeNormal(std::ostream & os) const +void MathMacroArgument::writeNormal(NormalStream & os) const { os << "[macroarg " << number_ << "] "; } diff --git a/src/mathed/math_macroarg.h b/src/mathed/math_macroarg.h index 25755677d0..f001f21b3b 100644 --- a/src/mathed/math_macroarg.h +++ b/src/mathed/math_macroarg.h @@ -24,7 +24,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void substitute(MathMacro const & macro); /// diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 89065350ab..392897de2b 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -10,6 +10,7 @@ #include "math_macro.h" #include "math_macrotemplate.h" #include "math_parser.h" +#include "math_mathmlstream.h" #include "debug.h" #include "support.h" // math_font_available @@ -19,6 +20,7 @@ MathMacroTable::table_type MathMacroTable::macro_table; void MathMacroTable::dump() { +/* lyxerr << "\n------------------------------------------\n"; table_type::const_iterator it; for (it = macro_table.begin(); it != macro_table.end(); ++it) @@ -26,6 +28,7 @@ void MathMacroTable::dump() << " [" << it->second->asMacroTemplate()->nargs() << "] : " << it->second->cell(0) << "\n"; lyxerr << "------------------------------------------\n"; +*/ } diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 2e9c9d2ef1..d179159284 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -3,6 +3,7 @@ #endif #include "math_macrotemplate.h" +#include "math_mathmlstream.h" #include "Painter.h" #include "debug.h" @@ -47,15 +48,6 @@ string const & MathMacroTemplate::name() const } -void MathMacroTemplate::write(MathWriteInfo & os) const -{ - os << "\n\\newcommand{\\" << name_ << '}'; - if (numargs_ > 0) - os << '[' << numargs_ << ']'; - os << '{' << cell(0) << "}\n"; -} - - void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const { xcell(0).metrics(mi); @@ -70,3 +62,12 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y) const xcell(0).draw(pain, x + 2, y + 1); pain.rectangle(x, y - ascent(), width(), height(), LColor::blue); } + + +void MathMacroTemplate::write(MathWriteInfo & os) const +{ + os << "\n\\newcommand{\\" << name_.c_str() << '}'; + if (numargs_ > 0) + os << '[' << ('0' + numargs_) << ']'; + os << '{' << cell(0) << "}\n"; +} diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 2843602c3c..3f87f143b0 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -1,9 +1,13 @@ -#include "support/LOstream.h" #include "math_inset.h" #include "math_mathmlstream.h" +MathMLStream::MathMLStream(std::ostream & os) + : os_(os), tab_(0), line_(0) +{} + + MathMLStream & MathMLStream::operator<<(MathInset const * p) { p->mathmlize(*this); @@ -32,6 +36,35 @@ MathMLStream & MathMLStream::operator<<(char c) } +MathMLStream & MathMLStream::operator<<(MTag const & t) +{ + ++tab_; + cr(); + os_ << '<' << t.tag_ << '>'; + return *this; +} + + +MathMLStream & MathMLStream::operator<<(ETag const & t) +{ + cr(); + if (tab_ > 0) + --tab_; + os_ << "'; + return *this; +} + + +void MathMLStream::cr() +{ + os_ << '\n'; + for (int i = 0; i < tab_; ++i) + os_ << ' '; +} + + + +////////////////////////////////////////////////////////////////////// MapleStream & MapleStream::operator<<(MathInset const * p) @@ -63,6 +96,8 @@ MapleStream & MapleStream::operator<<(char c) +////////////////////////////////////////////////////////////////////// + OctaveStream & OctaveStream::operator<<(MathInset const * p) { @@ -91,3 +126,78 @@ OctaveStream & OctaveStream::operator<<(char c) return *this; } + +////////////////////////////////////////////////////////////////////// + + +NormalStream & NormalStream::operator<<(MathInset const * p) +{ + p->writeNormal(*this); + return *this; +} + + +NormalStream & NormalStream::operator<<(MathArray const & ar) +{ + ar.writeNormal(*this); + return *this; +} + + +NormalStream & NormalStream::operator<<(char const * s) +{ + os_ << s; + return *this; +} + + +NormalStream & NormalStream::operator<<(char c) +{ + os_ << c; + return *this; +} + + + +////////////////////////////////////////////////////////////////////// + + +MathWriteInfo::MathWriteInfo + (Buffer const * buffer_, std::ostream & os_, bool fragile_) + : buffer(buffer_), os(os_), fragile(fragile_) +{} + + +MathWriteInfo::MathWriteInfo(std::ostream & os_) + : buffer(0), os(os_), fragile(false) +{} + + +MathWriteInfo & MathWriteInfo::operator<<(MathInset const * p) +{ + p->write(*this); + return *this; +} + + +MathWriteInfo & MathWriteInfo::operator<<(MathArray const & ar) +{ + ar.write(*this); + return *this; +} + + +MathWriteInfo & MathWriteInfo::operator<<(char const * s) +{ + os << s; + return *this; +} + + +MathWriteInfo & MathWriteInfo::operator<<(char c) +{ + os << c; + return *this; +} + + diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 10d1430119..1d1839359c 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -1,14 +1,30 @@ -#ifndef MATH_MATH_MLSTREAM -#define MATH_MATH_MLSTREAM +#ifndef MATH_MATHMLSTREAM_H +#define MATH_MATHMLSTREAM_H #include +#include "support/LOstream.h" +struct MathArray; +struct MathInset; +struct Buffer; -struct MathMLStream { +struct MTag { /// - explicit MathMLStream(std::ostream & os) : os_(os) {} + MTag(char const * const tag) : tag_(tag) {} /// - std::ostream & os_; + char const * const tag_; +}; + +struct ETag { + /// + ETag(char const * const tag) : tag_(tag) {} + /// + char const * const tag_; +}; + +struct MathMLStream { + /// + explicit MathMLStream(std::ostream & os); /// MathMLStream & operator<<(MathInset const *); /// @@ -17,6 +33,35 @@ struct MathMLStream { MathMLStream & operator<<(char const *); /// MathMLStream & operator<<(char); + /// + MathMLStream & operator<<(MTag const &); + /// + MathMLStream & operator<<(ETag const &); + /// + void cr(); + + /// + std::ostream & os_; + /// + int tab_; + /// + int line_; +}; + + +struct NormalStream { + /// + explicit NormalStream(std::ostream & os) : os_(os) {} + /// + std::ostream & os_; + /// + NormalStream & operator<<(MathInset const *); + /// + NormalStream & operator<<(MathArray const &); + /// + NormalStream & operator<<(char const *); + /// + NormalStream & operator<<(char); }; @@ -51,4 +96,29 @@ struct OctaveStream { OctaveStream & operator<<(char); }; + +struct MathWriteInfo { + /// + MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_); + /// + explicit MathWriteInfo(std::ostream & os_); + + /// + MathWriteInfo & operator<<(MathInset const *); + /// + MathWriteInfo & operator<<(MathArray const &); + /// + MathWriteInfo & operator<<(char const *); + /// + MathWriteInfo & operator<<(char); + + /// + Buffer const * buffer; + /// + std::ostream & os; + /// + bool fragile; +}; + + #endif diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index cfdbb1b1bd..6f84696135 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -7,9 +7,9 @@ #include "math_matrixinset.h" #include "support.h" #include "debug.h" -#include "support/LOstream.h" #include "Painter.h" #include "LaTeXFeatures.h" +#include "math_mathmlstream.h" namespace { @@ -185,36 +185,6 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const } -void MathMatrixInset::write(MathWriteInfo & os) const -{ - header_write(os.os); - - bool n = numberedType(); - - for (row_type row = 0; row < nrows(); ++row) { - for (col_type col = 0; col < ncols(); ++col) - os << cell(index(row, col)) << eocString(col); - if (n) { - if (!label_[row].empty()) - os << "\\label{" << label_[row] << "}"; - if (nonum_[row]) - os << "\\nonumber "; - } - os << eolString(row); - } - - footer_write(os.os); -} - - -void MathMatrixInset::writeNormal(std::ostream & os) const -{ - os << "[formula " << normalName(getType()) << " "; - MathGridInset::writeNormal(os); - os << "] "; -} - - void MathMatrixInset::mathmlize(MathMLStream & os) const { MathGridInset::mathmlize(os); @@ -673,3 +643,35 @@ void MathMatrixInset::mutate(MathInsetTypes newtype) << "' to '" << newtype << "' not implemented\n"; } } + + +void MathMatrixInset::write(MathWriteInfo & os) const +{ + header_write(os.os); + + bool n = numberedType(); + + 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(); + if (n) { + if (!label_[row].empty()) + os << "\\label{" << label_[row].c_str() << "}"; + if (nonum_[row]) + os << "\\nonumber "; + } + os << eolString(row).c_str(); + } + + footer_write(os.os); +} + + +void MathMatrixInset::writeNormal(NormalStream & os) const +{ + os << "[formula " << normalName(getType()).c_str() << " "; + MathGridInset::writeNormal(os); + os << "] "; +} + + diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 2a06385053..3f43597336 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -29,7 +29,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 0a9d8affb4..5738458776 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -3,10 +3,9 @@ #endif #include "math_nestinset.h" +#include "math_mathmlstream.h" #include "debug.h" -using std::max; -using std::min; MathNestInset::MathNestInset(idx_type nargs) : MathDimInset(), cells_(nargs) @@ -172,10 +171,10 @@ bool MathNestInset::covers(int x, int y) const int x1 = xcell(0).xo() + xcell(0).width(); int y1 = xcell(0).yo() + xcell(0).descent(); for (idx_type i = 1; i < nargs(); ++i) { - x0 = min(x0, xcell(i).xo()); - y0 = min(y0, xcell(i).yo() - xcell(i).ascent()); - x1 = max(x1, xcell(i).xo() + xcell(i).width()); - y1 = max(y1, xcell(i).yo() + xcell(i).descent()); + x0 = std::min(x0, xcell(i).xo()); + y0 = std::min(y0, xcell(i).yo() - xcell(i).ascent()); + x1 = std::max(x1, xcell(i).xo() + xcell(i).width()); + y1 = std::max(y1, xcell(i).yo() + xcell(i).descent()); } return x >= x0 && x <= x1 && y >= y0 && y <= y1; } diff --git a/src/mathed/math_notinset.C b/src/mathed/math_notinset.C index da26ba0a3b..9d55ce2f4c 100644 --- a/src/mathed/math_notinset.C +++ b/src/mathed/math_notinset.C @@ -1,11 +1,9 @@ #include "math_notinset.h" #include "math_parser.h" +#include "math_mathmlstream.h" #include "support.h" -#include "support/LOstream.h" -using std::ostream; - MathNotInset::MathNotInset() {} @@ -22,7 +20,7 @@ void MathNotInset::write(MathWriteInfo & os) const } -void MathNotInset::writeNormal(ostream & os) const +void MathNotInset::writeNormal(NormalStream & os) const { os << "[not] "; } diff --git a/src/mathed/math_notinset.h b/src/mathed/math_notinset.h index 0f94542042..faf1e731fb 100644 --- a/src/mathed/math_notinset.h +++ b/src/mathed/math_notinset.h @@ -15,7 +15,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 498daee1d2..4f59e333fe 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -741,12 +741,14 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) else if (t.cat() == catEnd) { if (flags & FLAG_BRACE_LAST) return; - lyxerr << "found '}' unexpectedly, array: '" << array << "'\n"; + //lyxerr << "found '}' unexpectedly, array: '" << array << "'\n"; + lyxerr << "found '}' unexpectedly\n"; add(array, '}', LM_TC_TEX); } else if (t.cat() == catAlign) { - lyxerr << "found tab unexpectedly, array: '" << array << "'\n"; + //lyxerr << "found tab unexpectedly, array: '" << array << "'\n"; + lyxerr << "found tab unexpectedly\n"; add(array, '&', LM_TC_TEX); } @@ -789,7 +791,8 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) else if (t.cs() == "\\") { curr_skip_ = getArg('[', ']'); - lyxerr << "found newline unexpectedly, array: '" << array << "'\n"; + //lyxerr << "found newline unexpectedly, array: '" << array << "'\n"; + lyxerr << "found newline unexpectedly\n"; array.push_back(createMathInset("\\")); } @@ -830,7 +833,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) else if (t.cs() == "right") { if (!(flags & FLAG_RIGHT)) { - lyxerr << "got so far: '" << array << "'\n"; + //lyxerr << "got so far: '" << array << "'\n"; error("Unmatched right delimiter"); } return; diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index 1625545fe9..187a9529e3 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -16,7 +16,7 @@ #endif #include "math_rootinset.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" #include "Painter.h" @@ -64,7 +64,7 @@ void MathRootInset::write(MathWriteInfo & os) const } -void MathRootInset::writeNormal(std::ostream & os) const +void MathRootInset::writeNormal(NormalStream & os) const { os << "[root "; cell(1).writeNormal(os); diff --git a/src/mathed/math_rootinset.h b/src/mathed/math_rootinset.h index 9a1a8bb22a..200ddc7cc7 100644 --- a/src/mathed/math_rootinset.h +++ b/src/mathed/math_rootinset.h @@ -36,7 +36,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index c017deb4e5..feb398f191 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -1,20 +1,12 @@ - -#include -#include "Lsstream.h" - -#include "debug.h" -#include "support.h" -#include "support/LOstream.h" -#include "support/LAssert.h" - #ifdef __GNUG__ #pragma implementation #endif #include "math_scriptinset.h" - -using std::ostream; -using std::ostringstream; +#include "debug.h" +#include "support.h" +#include "math_mathmlstream.h" +#include "support/LAssert.h" MathScriptInset::MathScriptInset() @@ -227,72 +219,6 @@ void MathScriptInset::draw(MathInset const * nuc, Painter & pain, } -void MathScriptInset::write(MathWriteInfo & os) const -{ - //lyxerr << "unexpected call to MathScriptInset::write()\n"; - write(0, os); -} - - -void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const -{ - if (nuc) { - nuc->write(os); - if (nuc->takesLimits()) { - if (limits_ == -1) - os << "\\nolimits "; - if (limits_ == 1) - os << "\\limits "; - } - } - else - os << "{}"; - - if (hasDown() && down().data_.size()) - os << "_{" << down().data_ << '}'; - - if (hasUp() && up().data_.size()) - os << "^{" << up().data_ << '}'; -} - - -void MathScriptInset::writeNormal(ostream & os) const -{ - //lyxerr << "unexpected call to MathScriptInset::writeNormal()\n"; - writeNormal(0, os); -} - - -void MathScriptInset::writeNormal(MathInset const * nuc, ostream & os) const -{ - bool d = hasDown() && down().data_.size(); - bool u = hasUp() && up().data_.size(); - - ostringstream osb; - if (nuc) - nuc->writeNormal(osb); - else - osb << "[par]"; - string base = osb.str(); - - if (u && d) { - os << "[sup [sub " << osb.str() << " "; - down().data_.writeNormal(os); - os << "] "; - up().data_.writeNormal(os); - os << ']'; - } else if (u) { - os << "[sup " << osb.str() << " "; - up().data_.writeNormal(os); - os << ']'; - } else if (d) { - os << "[sub " << osb.str() << " "; - down().data_.writeNormal(os); - os << ']'; - } -} - - bool MathScriptInset::hasLimits(MathInset const * nuc) const { return limits_ == 1 || (limits_ == 0 && nuc && nuc->isScriptable()); @@ -346,18 +272,65 @@ bool MathScriptInset::idxLeft(MathInset::idx_type &, } -void MathScriptInset::maplize(MathInset const * nuc, MapleStream & os) const +void MathScriptInset::write(MathWriteInfo & os) const +{ + //lyxerr << "unexpected call to MathScriptInset::write()\n"; + write(0, os); +} + + +void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const { - if (nuc) + if (nuc) { os << nuc; + if (nuc->takesLimits()) { + if (limits_ == -1) + os << "\\nolimits "; + if (limits_ == 1) + os << "\\limits "; + } + } + else + os << "{}"; + if (hasDown() && down().data_.size()) - os << '[' << down().data_ << ']'; + os << "_{" << down().data_ << '}'; + if (hasUp() && up().data_.size()) - os << "^(" << up().data_ << ')'; + os << "^{" << up().data_ << '}'; } -void MathScriptInset::octavize(MathInset const * nuc, OctaveStream & os) const +void MathScriptInset::writeNormal(NormalStream & os) const +{ + //lyxerr << "unexpected call to MathScriptInset::writeNormal()\n"; + writeNormal(0, os); +} + + +void MathScriptInset::writeNormal(MathInset const * nuc, NormalStream & os) const +{ + bool d = hasDown() && down().data_.size(); + bool u = hasUp() && up().data_.size(); + + if (u) + os << "[sup "; + if (d) + os << "[sub "; + + if (nuc) + os << nuc << ' '; + else + os << "[par]"; + + if (d) + os << down().data_ << ']'; + if (u) + os << up().data_ << ']'; +} + + +void MathScriptInset::maplize(MathInset const * nuc, MapleStream & os) const { if (nuc) os << nuc; @@ -373,20 +346,35 @@ void MathScriptInset::mathmlize(MathInset const * nuc, MathMLStream & os) const bool d = hasDown() && down().data_.size(); bool u = hasUp() && up().data_.size(); - if (u) - os << ""; - - if (d) - os << ""; + if (u && d) + os << MTag("msubsup"); + else if (u) + os << MTag("msup"); + else if (d) + os << MTag("msub"); if (nuc) os << nuc; else os << ""; - if (d) - os << down().data_ << ""; + if (u && d) + os << down().data_ << up().data_ << ETag("msubsup"); + else if (u) + os << up().data_ << ETag("msup"); + else if (d) + os << down().data_ << ETag("msub"); +} + - if (u) - os << up().data_ << ""; +void MathScriptInset::octavize(MathInset const * nuc, OctaveStream & os) const +{ + if (nuc) + os << nuc; + if (hasDown() && down().data_.size()) + os << '[' << down().data_ << ']'; + if (hasUp() && up().data_.size()) + os << "^(" << up().data_ << ')'; } + + diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index fe72988fdc..904cbe0c2e 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -23,26 +23,22 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream & os) const; + void writeNormal(NormalStream & os) const; /// void metrics(MathMetricsInfo const & st) const; /// void draw(Painter &, int x, int y) const; /// - void write(MathInset const *, MathWriteInfo & os) const; + void metrics(MathInset const * nuc, MathMetricsInfo const & st) const; /// - void writeNormal(MathInset const *, std::ostream & os) const; + void draw(MathInset const * nuc, Painter &, int x, int y) const; /// - void metrics(MathInset const * nucleus, MathMetricsInfo const & st) const; + int ascent(MathInset const * nuc) const; /// - void draw(MathInset const * nucleus, Painter &, int x, int y) const; + int descent(MathInset const * nuc) const; /// - int ascent(MathInset const * nucleus) const; - /// - int descent(MathInset const * nucleus) const; - /// - int width(MathInset const * nucleus) const; + int width(MathInset const * nuc) const; /// bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const; @@ -59,7 +55,7 @@ public: /// int limits() const { return limits_; } /// - bool hasLimits(MathInset const * nucleus) const; + bool hasLimits(MathInset const * nuc) const; /// true if we have an "inner" position MathXArray const & up() const; /// returns subscript @@ -81,6 +77,10 @@ public: /// void ensure(bool up); + /// + void write(MathInset const * nuc, MathWriteInfo & os) const; + /// + void writeNormal(MathInset const * nuc, NormalStream & os) const; /// void octavize(MathInset const * nuc, OctaveStream & os) const; /// diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index a06896ba0f..68219334bf 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -4,7 +4,7 @@ #include "math_sizeinset.h" #include "math_parser.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" MathSizeInset::MathSizeInset(latexkeys const * l) @@ -37,13 +37,11 @@ void MathSizeInset::metrics(MathMetricsInfo const & mi) const void MathSizeInset::write(MathWriteInfo & os) const { - os << "{\\" << key_->name << ' ' << cell(0) << '}'; + os << "{\\" << key_->name.c_str() << ' ' << cell(0) << '}'; } -void MathSizeInset::writeNormal(std::ostream & os) const +void MathSizeInset::writeNormal(NormalStream & os) const { - os << "[" << key_->name << " "; - cell(0).writeNormal(os); - os << "]"; + os << "[" << key_->name.c_str() << ' ' << cell(0) << ']'; } diff --git a/src/mathed/math_sizeinset.h b/src/mathed/math_sizeinset.h index b4e25958c7..e1b0e50fcf 100644 --- a/src/mathed/math_sizeinset.h +++ b/src/mathed/math_sizeinset.h @@ -28,7 +28,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; private: /// diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 77be8e3a19..bf640cb4fa 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -6,7 +6,7 @@ #include "support.h" #include "LColor.h" #include "Painter.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" @@ -28,7 +28,7 @@ void MathSpaceInset::write(MathWriteInfo & os) const } -void MathSpaceInset::writeNormal(std::ostream & os) const +void MathSpaceInset::writeNormal(NormalStream & os) const { os << "[space " << space_ << "] "; } diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index fddaed6130..21fee9249c 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -21,7 +21,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_specialcharinset.C b/src/mathed/math_specialcharinset.C index fad43219c7..e108151eab 100644 --- a/src/mathed/math_specialcharinset.C +++ b/src/mathed/math_specialcharinset.C @@ -3,7 +3,7 @@ #endif #include "math_specialcharinset.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" #include "support.h" @@ -54,7 +54,7 @@ void MathSpecialCharInset::write(MathWriteInfo & os) const } -void MathSpecialCharInset::writeNormal(std::ostream & os) const +void MathSpecialCharInset::writeNormal(NormalStream & os) const { os << "\\" << char_; } diff --git a/src/mathed/math_specialcharinset.h b/src/mathed/math_specialcharinset.h index 1fbcc91301..0adb5267ae 100644 --- a/src/mathed/math_specialcharinset.h +++ b/src/mathed/math_specialcharinset.h @@ -26,7 +26,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// int ascent() const; /// diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index 46eab1d065..6f9d9c8e9b 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -3,7 +3,7 @@ #endif #include "math_splitinset.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" MathSplitInset::MathSplitInset(int n) diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index 5e488bba80..65337dc5c6 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -3,9 +3,9 @@ #endif #include "math_sqrtinset.h" +#include "math_mathmlstream.h" #include "LColor.h" #include "Painter.h" -#include "support/LOstream.h" MathSqrtInset::MathSqrtInset() @@ -49,7 +49,7 @@ void MathSqrtInset::write(MathWriteInfo & os) const } -void MathSqrtInset::writeNormal(std::ostream & os) const +void MathSqrtInset::writeNormal(NormalStream & os) const { os << "[sqrt "; cell(0).writeNormal(os); diff --git a/src/mathed/math_sqrtinset.h b/src/mathed/math_sqrtinset.h index 769d085c24..ac774cbe7b 100644 --- a/src/mathed/math_sqrtinset.h +++ b/src/mathed/math_sqrtinset.h @@ -22,7 +22,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_stackrelinset.C b/src/mathed/math_stackrelinset.C index eb19b0ba0f..69cb5105cd 100644 --- a/src/mathed/math_stackrelinset.C +++ b/src/mathed/math_stackrelinset.C @@ -3,8 +3,8 @@ #endif #include "math_stackrelinset.h" -#include "mathed/support.h" -#include "support/LOstream.h" +#include "math_mathmlstream.h" +#include "support.h" MathStackrelInset::MathStackrelInset() @@ -43,7 +43,7 @@ void MathStackrelInset::write(MathWriteInfo & os) const } -void MathStackrelInset::writeNormal(std::ostream & os) const +void MathStackrelInset::writeNormal(NormalStream & os) const { os << "[stackrel "; cell(0).writeNormal(os); diff --git a/src/mathed/math_stackrelinset.h b/src/mathed/math_stackrelinset.h index 5c66bdcb79..e1122bfa81 100644 --- a/src/mathed/math_stackrelinset.h +++ b/src/mathed/math_stackrelinset.h @@ -20,7 +20,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/math_stringinset.C b/src/mathed/math_stringinset.C index 61461a9d65..b3cb376767 100644 --- a/src/mathed/math_stringinset.C +++ b/src/mathed/math_stringinset.C @@ -5,9 +5,9 @@ #include #include "math_stringinset.h" +#include "math_mathmlstream.h" #include "LColor.h" #include "Painter.h" -#include "support/LOstream.h" #include "support.h" #include "math_parser.h" #include "debug.h" @@ -58,15 +58,15 @@ void MathStringInset::draw(Painter & pain, int x, int y) const void MathStringInset::write(MathWriteInfo & os) const { if (math_font_name(code_)) - os << '\\' << math_font_name(code_) << '{' << str_ << '}'; + os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}'; else - os << str_; + os << str_.c_str(); } -void MathStringInset::writeNormal(std::ostream & os) const +void MathStringInset::writeNormal(NormalStream & os) const { - os << "[string " << str_ << " " << "mathalpha" << "]"; + os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]"; } diff --git a/src/mathed/math_stringinset.h b/src/mathed/math_stringinset.h index edcaafe5c6..1d4e28f095 100644 --- a/src/mathed/math_stringinset.h +++ b/src/mathed/math_stringinset.h @@ -25,7 +25,7 @@ public: /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// int ascent() const; /// diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 94d5697be0..1cfb564602 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -1,12 +1,10 @@ #include "math_symbolinset.h" #include "math_parser.h" +#include "math_mathmlstream.h" #include "debug.h" #include "support.h" -#include "support/LOstream.h" -using std::ostream; - MathSymbolInset::MathSymbolInset(const latexkeys * l) : sym_(l), h_(0) {} @@ -20,13 +18,13 @@ MathInset * MathSymbolInset::clone() const void MathSymbolInset::write(MathWriteInfo & os) const { - os << '\\' << sym_->name << ' '; + os << '\\' << sym_->name.c_str() << ' '; } -void MathSymbolInset::writeNormal(ostream & os) const +void MathSymbolInset::writeNormal(NormalStream & os) const { - os << "[symbol " << sym_->name << "]"; + os << "[symbol " << sym_->name.c_str() << "]"; } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index 6a6ea11df5..7514c0a7be 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -14,11 +14,13 @@ public: /// explicit MathSymbolInset(latexkeys const *); /// + explicit MathSymbolInset(char const *); + /// MathInset * clone() const; /// void write(MathWriteInfo & os) const; /// - void writeNormal(std::ostream &) const; + void writeNormal(NormalStream &) const; /// void metrics(MathMetricsInfo const & st) const; /// diff --git a/src/mathed/support.C b/src/mathed/support.C index bf19f55d65..5c474058a9 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -2,7 +2,7 @@ #include -#include "mathed/support.h" +#include "support.h" #include "lyxfont.h" #include "FontLoader.h" #include "font.h" diff --git a/src/mathed/xarray.C b/src/mathed/xarray.C index 54b83322ba..42da38dd0d 100644 --- a/src/mathed/xarray.C +++ b/src/mathed/xarray.C @@ -7,7 +7,7 @@ #include "xarray.h" #include "math_inset.h" #include "math_scriptinset.h" -#include "mathed/support.h" +#include "support.h" #include "math_defs.h" #include "Painter.h" #include "debug.h" @@ -116,10 +116,3 @@ MathArray::size_type MathXArray::x2pos(int targetx) const --it; return it - begin(); } - - -std::ostream & operator<<(std::ostream & os, MathXArray const & ar) -{ - os << ar.data_; - return os; -} -- 2.39.5