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