From c567e8312afbd03dc282630d152adecedfd5956b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 8 Aug 2002 17:11:30 +0000 Subject: [PATCH] replace a few more naked MathInset * by MathAtom & git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4907 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formula.C | 2 +- src/mathed/math_data.C | 9 +++---- src/mathed/math_deliminset.C | 10 ++------ src/mathed/math_diminset.C | 13 +++++++--- src/mathed/math_extern.C | 2 +- src/mathed/math_inset.C | 12 +-------- src/mathed/math_inset.h | 1 - src/mathed/math_mathmlstream.C | 47 ++++++++++------------------------ src/mathed/math_mathmlstream.h | 13 +++++----- 9 files changed, 39 insertions(+), 70 deletions(-) diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 441767e649..31f3de6d14 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -175,7 +175,7 @@ int InsetFormula::docbook(Buffer const * buf, ostream & os, bool) const ms << "]]>"; ms << ETag("alt"); ms << MTag("math"); - ms << par_.nucleus(); + ms << par_; ms << ETag("math"); ms << ETag("equation"); return ms.line() + res; diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index b99772041e..3b9a0da49d 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -105,7 +105,7 @@ void MathArray::dump2() const { NormalStream ns(lyxerr); for (const_iterator it = begin(); it != end(); ++it) - ns << it->nucleus() << ' '; + ns << *it << ' '; } @@ -113,15 +113,14 @@ void MathArray::dump() const { NormalStream ns(lyxerr); for (const_iterator it = begin(); it != end(); ++it) - ns << "<" << it->nucleus() << ">"; + ns << "<" << *it << ">"; } void MathArray::validate(LaTeXFeatures & features) const { for (const_iterator it = begin(); it != end(); ++it) - if (it->nucleus()) - it->nucleus()->validate(features); + (*it)->validate(features); } @@ -137,7 +136,7 @@ bool MathArray::matchpart(MathArray const & ar, pos_type pos) const return false; const_iterator it = begin() + pos; for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it) - if (!jt->nucleus()->match(it->nucleus())) + if (!(*jt)->match(it->nucleus())) return false; return true; } diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index ed24aa851d..ba50d54e2c 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -132,10 +132,7 @@ bool MathDelimInset::isAbs() const void MathDelimInset::maplize(MapleStream & os) const { if (isAbs()) { - bool mat = - cell(0).size() == 1 && cell(0).begin()->nucleus() - && cell(0).begin()->nucleus()->asMatrixInset(); - if (mat) + if (cell(0).size() == 1 && cell(0).front()->asMatrixInset()) os << "linalg[det](" << cell(0) << ")"; else os << "abs(" << cell(0) << ")"; @@ -147,10 +144,7 @@ void MathDelimInset::maplize(MapleStream & os) const void MathDelimInset::mathematicize(MathematicaStream & os) const { if (isAbs()) { - bool mat = - cell(0).size() == 1 && cell(0).begin()->nucleus() - && cell(0).begin()->nucleus()->asMatrixInset(); - if (mat) + if (cell(0).size() == 1 && cell(0).front()->asMatrixInset()) os << "Det" << cell(0) << ']'; else os << "Abs[" << cell(0) << ']'; diff --git a/src/mathed/math_diminset.C b/src/mathed/math_diminset.C index 783e41a1d5..88282f0749 100644 --- a/src/mathed/math_diminset.C +++ b/src/mathed/math_diminset.C @@ -5,17 +5,24 @@ void MathDimInset::metricsT(TextMetricsInfo const &) const { +#ifndef WITH_WARNINGS +#warning temporarily disabled +#endif +/* std::ostringstream os; - os << *this; + os << MathAtom(this); dim_.w = int(os.str().size()); dim_.a = 1; dim_.d = 0; +*/ } -void MathDimInset::drawT(TextPainter & pain, int x, int y) const +void MathDimInset::drawT(TextPainter &, int, int) const { +/* std::ostringstream os; - os << *this; + os << MathAtom(this); pain.draw(x, y, os.str().c_str()); +*/ } diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index 6d24d46352..7e32eb9b81 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -865,7 +865,7 @@ void mathmlize(MathArray const & dat, MathMLStream & os) if (ar.size() == 0) os << ""; else if (ar.size() == 1) - os << ar.begin()->nucleus(); + os << ar.front(); else { os << MTag("mrow"); for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it) diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 52bbd38fc5..e3a0f3be58 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -46,19 +46,9 @@ int MathInset::height() const ostream & operator<<(ostream & os, MathAtom const & at) -{ - if (at.nucleus()) - os << *(at.nucleus()); - else - os << "(nil)"; - return os; -} - - -ostream & operator<<(ostream & os, MathInset const & inset) { WriteStream wi(os, false, false); - inset.write(wi); + at->write(wi); return os; } diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index d092e19645..cf01d36ba2 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -293,7 +293,6 @@ public: virtual string name() const; }; -std::ostream & operator<<(std::ostream &, MathInset const &); std::ostream & operator<<(std::ostream &, MathAtom const &); string asString(MathArray const & ar); diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 16f96e8625..d7cf3ab39f 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -3,7 +3,6 @@ #include "math_mathmlstream.h" #include "math_inset.h" #include "math_extern.h" -#include "debug.h" #include "support/lyxalgo.h" @@ -16,12 +15,9 @@ MathMLStream::MathMLStream(ostream & os) {} -MathMLStream & operator<<(MathMLStream & ms, MathInset const * p) +MathMLStream & operator<<(MathMLStream & ms, MathAtom const & at) { - if (p) - p->mathmlize(ms); - else - lyxerr << "operator<<(MathMLStream, NULL) called\n"; + at->mathmlize(ms); return ms; } @@ -78,12 +74,9 @@ void MathMLStream::cr() ////////////////////////////////////////////////////////////////////// -MapleStream & operator<<(MapleStream & ms, MathInset const * p) +MapleStream & operator<<(MapleStream & ms, MathAtom const & at) { - if (p) - p->maplize(ms); - else - lyxerr << "operator<<(MapleStream, NULL) called\n"; + at->maplize(ms); return ms; } @@ -119,12 +112,9 @@ MapleStream & operator<<(MapleStream & ms, int i) ////////////////////////////////////////////////////////////////////// -MathematicaStream & operator<<(MathematicaStream & ms, MathInset const * p) +MathematicaStream & operator<<(MathematicaStream & ms, MathAtom const & at) { - if (p) - p->mathematicize(ms); - else - lyxerr << "operator<<(MathematicaStream, NULL) called\n"; + at->mathematicize(ms); return ms; } @@ -161,12 +151,9 @@ MathematicaStream & operator<<(MathematicaStream & ms, int i) ////////////////////////////////////////////////////////////////////// -OctaveStream & operator<<(OctaveStream & ns, MathInset const * p) +OctaveStream & operator<<(OctaveStream & ns, MathAtom const & at) { - if (p) - p->octavize(ns); - else - lyxerr << "operator<<(OctaveStream, NULL) called\n"; + at->octavize(ns); return ns; } @@ -202,12 +189,9 @@ OctaveStream & operator<<(OctaveStream & ns, int i) ////////////////////////////////////////////////////////////////////// -NormalStream & operator<<(NormalStream & ns, MathInset const * p) +NormalStream & operator<<(NormalStream & ns, MathAtom const & at) { - if (p) - p->normalize(ns); - else - lyxerr << "operator<<(NormalStream, NULL) called\n"; + at->normalize(ns); return ns; } @@ -260,12 +244,9 @@ void WriteStream::addlines(unsigned int n) } -WriteStream & operator<<(WriteStream & ws, MathInset const * p) +WriteStream & operator<<(WriteStream & ws, MathAtom const & at) { - if (p) - p->write(ws); - else - lyxerr << "operator<<(WriteStream, NULL) called\n"; + at->write(ws); return ws; } @@ -288,10 +269,8 @@ WriteStream & operator<<(WriteStream & ws, char const * s) WriteStream & operator<<(WriteStream & ws, char c) { ws.os() << c; - if (c == '\n') { - lyxerr << "writing a newline\n"; + if (c == '\n') ws.addlines(1); - } return ws; } diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index c5e0a31af2..0163b65a09 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -12,6 +12,7 @@ class MathArray; class MathInset; +class MathAtom; // @@ -58,7 +59,7 @@ private: }; /// -MathMLStream & operator<<(MathMLStream &, MathInset const *); +MathMLStream & operator<<(MathMLStream &, MathAtom const &); /// MathMLStream & operator<<(MathMLStream &, MathArray const &); /// @@ -88,7 +89,7 @@ private: }; /// -NormalStream & operator<<(NormalStream &, MathInset const *); +NormalStream & operator<<(NormalStream &, MathAtom const &); /// NormalStream & operator<<(NormalStream &, MathArray const &); /// @@ -119,7 +120,7 @@ private: /// -MapleStream & operator<<(MapleStream &, MathInset const *); +MapleStream & operator<<(MapleStream &, MathAtom const &); /// MapleStream & operator<<(MapleStream &, MathArray const &); /// @@ -148,7 +149,7 @@ private: /// -MathematicaStream & operator<<(MathematicaStream &, MathInset const *); +MathematicaStream & operator<<(MathematicaStream &, MathAtom const &); /// MathematicaStream & operator<<(MathematicaStream &, MathArray const &); /// @@ -176,7 +177,7 @@ private: }; /// -OctaveStream & operator<<(OctaveStream &, MathInset const *); +OctaveStream & operator<<(OctaveStream &, MathAtom const &); /// OctaveStream & operator<<(OctaveStream &, MathArray const &); /// @@ -224,7 +225,7 @@ private: }; /// -WriteStream & operator<<(WriteStream &, MathInset const *); +WriteStream & operator<<(WriteStream &, MathAtom const &); /// WriteStream & operator<<(WriteStream &, MathArray const &); /// -- 2.39.2