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