]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
9a0da76e7c29154591ee522ee70e1c41f9cd8d32
[lyx.git] / src / mathed / math_exintinset.C
1
2 #include <config.h>
3
4 #include "math_exintinset.h"
5 #include "math_support.h"
6 #include "math_mathmlstream.h"
7 #include "math_streamstr.h"
8 #include "math_symbolinset.h"
9 #include "debug.h"
10
11 #include <boost/scoped_ptr.hpp>
12
13
14 MathExIntInset::MathExIntInset(string const & name)
15         : MathNestInset(4), symbol_(name)
16 {}
17
18 // 0 - core
19 // 1 - diff
20 // 2 - lower
21 // 3 - upper
22
23
24 MathInset * MathExIntInset::clone() const
25 {
26         return new MathExIntInset(*this);
27 }
28
29
30 void MathExIntInset::symbol(string const & symbol)
31 {
32         symbol_ = symbol;
33 }
34
35
36 bool MathExIntInset::hasScripts() const
37 {
38         // take empty upper bound as "no scripts"
39         return !cell(3).empty();
40 }
41
42
43
44 void MathExIntInset::normalize(NormalStream & os) const
45 {
46         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
47            << cell(2) << ' ' << cell(3) << ']';
48 }
49
50
51 void MathExIntInset::metrics(MathMetricsInfo &) const
52 {
53         lyxerr << "should not happen\n";
54 }
55
56
57 void MathExIntInset::draw(MathPainterInfo &, int, int) const
58 {
59         lyxerr << "should not happen\n";
60 }
61
62
63 void MathExIntInset::maplize(MapleStream & os) const
64 {
65         os << symbol_ << '(';
66         if (cell(0).size())
67                 os << cell(0);
68         else
69                 os << '1';
70         os << ',' << cell(1);
71         if (hasScripts())
72                 os << '=' << cell(2) << ".." << cell(3);
73         os << ')';
74 }
75
76
77 void MathExIntInset::maximize(MaximaStream & os) const
78 {
79         if ( symbol_ == "int" )
80                 os << "integrate(";
81         else
82                 os << symbol_ << '(';
83
84         if (cell(0).size())
85                 os << cell(0) << ',';
86         else
87                 os << '1' << ',';
88         if (hasScripts())
89                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
90         else
91                 os << cell(1) << ')';
92 }
93
94 void MathExIntInset::mathematicize(MathematicaStream & os) const
95 {
96         if ( symbol_ == "int" )
97                 os << "Integrate[";
98         else if (symbol_ == "sum")
99                 os << "Sum[";
100         else
101                 os << symbol_ << '[';
102
103         if (cell(0).size())
104                 os << cell(0) << ',';
105         else
106                 os << '1' << ',';
107         if (hasScripts())
108                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
109         else
110                 os << cell(1) << ']';
111 }
112
113
114 void MathExIntInset::mathmlize(MathMLStream & os) const
115 {
116         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
117         //if (hasScripts())
118         //      mathmlize(sym, os);
119         //else
120                 sym->mathmlize(os);
121         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
122            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
123            << cell(1) << ETag("mrow");
124 }
125
126
127 void MathExIntInset::write(WriteStream &) const
128 {
129         lyxerr << "should not happen\n";
130 }