}
+bool MathAtom::hasNucleus() const
+{
+ return nucleus_;
+}
+
+
MathInset * MathAtom::operator->() const
{
return nucleus();
///
void reset(MathInset * p);
///
+ bool hasNucleus() const;
+ ///
MathInset * nucleus() const;
///
MathInset * operator->() const;
}
+MathAtom & MathArray::front()
+{
+ return bf_.front();
+}
+
+
+MathAtom const & MathArray::front() const
+{
+ return bf_.front();
+}
+
+
void MathArray::dump2() const
{
NormalStream ns(lyxerr);
///
MathAtom & back();
+ ///
+ MathAtom & front();
+ ///
+ MathAtom const & front() const;
+
///
void dump() const;
///
#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)
+MathExIntInset::MathExIntInset()
+ : int_(new MathSymbolInset("int"))
{}
}
-void MathExIntInset::write(WriteStream & os) const
+void MathExIntInset::differential(MathArray const & ar)
{
- scripts_.write(int_.nucleus(), os);
- os << core_ << "d" << diff_;
+ diff_ = ar;
+}
+
+
+void MathExIntInset::core(MathArray const & ar)
+{
+ core_ = ar;
+}
+
+
+void MathExIntInset::scripts(MathAtom const & at)
+{
+ scripts_ = at;
+}
+
+
+void MathExIntInset::symbol(MathAtom const & at)
+{
+ int_ = at;
}
+bool MathExIntInset::hasScripts() const
+{
+ return scripts_.hasNucleus();
+}
+
+
+
void MathExIntInset::normalize(NormalStream & os) const
{
- //os << "[int " << scripts_ << ' ' << core_ << ' ' << diff_ << ']'
+ os << "[int ";
+ if (hasScripts())
+ os << scripts_.nucleus();
+ else
+ os << "{}";
+ os << ' ' << core_ << ' ' << diff_ << ']';
}
void MathExIntInset::maplize(MapleStream & os) const
{
- //os << name_.c_str() << '(' << cell(0) << ')';
+ os << int_.nucleus() << '(' << core_ << ',' << diff_;
+ if (hasScripts()) {
+ MathScriptInset * p = scripts_->asScriptInset();
+ os << '=' << p->down().data_ << ".." << p->up().data_;
+ }
+ os << ')';
}
+
void MathExIntInset::mathmlize(MathMLStream & os) const
{
//os << name_.c_str() << '(' << cell(0) << ')';
}
+
+
+void MathExIntInset::write(WriteStream & os) const
+{
+ if (hasScripts())
+ os << scripts_.nucleus();
+ os << core_ << "d" << diff_;
+}
+
class MathExIntInset : public MathInset {
public:
///
- MathExIntInset(MathScriptInset const &, MathArray const &, MathArray const &);
+ MathExIntInset();
///
MathInset * clone() const;
///
+ void differential(MathArray const &);
+ ///
+ void core(MathArray const &);
+ ///
+ void scripts(MathAtom const &);
+ ///
+ void symbol(MathAtom const &);
+ ///
+ bool hasScripts() 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;
///
void mathmlize(MathMLStream &) const;
+ ///
+ void write(WriteStream & os) const;
private:
///
MathAtom int_;
///
- MathScriptInset scripts_;
+ MathAtom scripts_;
///
MathArray core_;
///
}
-MathInset * intReplacement(const MathArray & ar)
-{
- MathDelimInset * del = new MathDelimInset("(", ")");
- del->cell(0) = ar;
- return del;
-}
-
-
// replace '\int' ['_^'] x 'd''x'(...)' sequences by a real MathExIntInset
// assume 'extractDelims' ran before
void extractIntegrals(MathArray & ar)
endNestSearch(it, ar.end(), intSymbolTest, differentialTest);
// create a proper inset as replacement
- MathInset * p = intReplacement(MathArray(it + 1, jt));
+ MathExIntInset * p = new MathExIntInset;
- // replace the original stuff by the new inset
- ar.erase(it + 1, jt + 1);
+ // collect scripts
+ MathArray::iterator st = it + 1;
+ if ((*st)->asScriptInset()) {
+ p->scripts(*st);
+ p->core(MathArray(st + 1, jt));
+ } else {
+ p->core(MathArray(st, jt));
+ }
+
+ // is the differential just 'd' oder 'dsomething'?
+ // and replace the original stuff by the new inset
+ string s = extractString(jt->nucleus());
+ MathArray diff;
+ if (s.size() == 1 && jt + 1 != ar.end()) {
+ // use the next atom as differential
+ diff.push_back(*(jt + 1));
+ ar.erase(it + 1, jt + 2);
+ } else {
+ diff.push_back(MathAtom(new MathStringInset(s.substr(1))));
+ ar.erase(it + 1, jt + 1);
+ }
+ p->differential(diff);
(*it).reset(p);
}
+ lyxerr << "\nIntegrals to: " << ar << "\n";
}
#include "math_inset.h"
#include "math_mathmlstream.h"
#include "math_extern.h"
+#include "debug.h"
MathMLStream::MathMLStream(std::ostream & os)
MathMLStream & MathMLStream::operator<<(MathInset const * p)
{
- p->mathmlize(*this);
+ if (p)
+ p->mathmlize(*this);
+ else
+ lyxerr << "MathMLStream::operator<<(NULL) called\n";
return *this;
}
MapleStream & MapleStream::operator<<(MathInset const * p)
{
- p->maplize(*this);
+ if (p)
+ p->maplize(*this);
+ else
+ lyxerr << "MathMLStream::operator<<(NULL) called\n";
return *this;
}
OctaveStream & OctaveStream::operator<<(MathInset const * p)
{
- p->octavize(*this);
+ if (p)
+ p->octavize(*this);
+ else
+ lyxerr << "MathMLStream::operator<<(NULL) called\n";
return *this;
}
NormalStream & NormalStream::operator<<(MathInset const * p)
{
- p->normalize(*this);
+ if (p)
+ p->normalize(*this);
+ else
+ lyxerr << "MathMLStream::operator<<(NULL) called\n";
return *this;
}
WriteStream & WriteStream::operator<<(MathInset const * p)
{
- p->write(*this);
+ if (p)
+ p->write(*this);
+ else
+ lyxerr << "MathMLStream::operator<<(NULL) called\n";
return *this;
}
class MathStringInset : public MathInset {
public:
///
- MathStringInset(string const & s, MathTextCodes t);
+ MathStringInset(string const & s, MathTextCodes t = LM_TC_TEXTRM);
///
MathInset * clone() const;
///
{}
+MathSymbolInset::MathSymbolInset(const char * name)
+ : sym_(in_word_set(name)), h_(0)
+{}
+
+
+
MathInset * MathSymbolInset::clone() const
{
return new MathSymbolInset(*this);