]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
math-extern: enable handling of simple sums
[lyx.git] / src / mathed / math_exintinset.C
1 #include "math_exintinset.h"
2 #include "math_support.h"
3 #include "debug.h"
4 #include "math_mathmlstream.h"
5 #include "math_symbolinset.h"
6
7
8 MathExIntInset::MathExIntInset(string const & name)
9         : symbol_(name)
10 {}
11
12
13 MathInset * MathExIntInset::clone() const
14 {
15         return new MathExIntInset(*this);
16 }
17
18
19 void MathExIntInset::index(MathArray const & ar)
20 {
21         index_ = ar;
22 }
23
24
25 void MathExIntInset::core(MathArray const & ar)
26 {
27         core_ = ar;
28 }
29
30
31 void MathExIntInset::scripts(MathAtom const & at)
32 {
33         scripts_ = at;
34 }
35
36
37 MathAtom & MathExIntInset::scripts()
38 {
39         return scripts_;
40 }
41
42
43 void MathExIntInset::symbol(string const & symbol)
44 {
45         symbol_ = symbol;
46 }
47
48
49 bool MathExIntInset::hasScripts() const
50 {
51         return scripts_.hasNucleus();
52 }
53
54
55
56 void MathExIntInset::normalize(NormalStream & os) const
57 {
58         os << '[' << symbol_.c_str() << ' ';
59         if (hasScripts())
60                 os << scripts_.nucleus();
61         else 
62                 os << "{}";
63         os << ' ' << core_ << ' ' << index_ << ']';
64 }
65
66
67 void MathExIntInset::metrics(MathMetricsInfo const &) const
68 {
69         lyxerr << "should not happen\n";
70 }
71
72
73 void MathExIntInset::draw(Painter &, int, int) const
74 {  
75         lyxerr << "should not happen\n";
76 }
77
78
79 void MathExIntInset::maplize(MapleStream & os) const
80 {
81         os << symbol_.c_str() << '(';
82         if (core_.size())
83                 os << core_;
84         else 
85                 os << '1';
86         os << ',' << index_;
87         if (hasScripts()) {
88                 MathScriptInset * p = scripts_->asScriptInset();
89                 os << '=' << p->down().data_ << ".." << p->up().data_;
90         }
91         os << ')';
92 }
93
94
95 void MathExIntInset::mathmlize(MathMLStream & os) const
96 {
97         MathSymbolInset * sym = new MathSymbolInset(symbol_.c_str());
98         if (hasScripts())
99                 scripts_->asScriptInset()->mathmlize(sym, os);
100         else 
101                 sym->mathmlize(os);
102         delete sym;
103         os << core_ << "<mo> &InvisibleTimes; </mo>"
104            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
105            << index_ << ETag("mrow");
106 }
107
108
109 void MathExIntInset::write(WriteStream &) const
110 {
111         lyxerr << "should not happen\n";
112 }
113