]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.C
a349946a7e3704e86df41be646a0f6cb8c0d9a42
[lyx.git] / src / mathed / InsetMathExInt.C
1 /**
2  * \file InsetMathExInt.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathExInt.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "MathStream.h"
17 #include "InsetMathSymbol.h"
18 #include "debug.h"
19
20 #include <boost/scoped_ptr.hpp>
21
22
23 namespace lyx {
24
25
26 using std::string;
27 using std::auto_ptr;
28 using std::endl;
29
30
31 InsetMathExInt::InsetMathExInt(docstring const & name)
32         : InsetMathNest(4), symbol_(name)
33 {}
34
35 // 0 - core
36 // 1 - diff
37 // 2 - lower
38 // 3 - upper
39
40
41 auto_ptr<InsetBase> InsetMathExInt::doClone() const
42 {
43         return auto_ptr<InsetBase>(new InsetMathExInt(*this));
44 }
45
46
47 void InsetMathExInt::symbol(docstring const & symbol)
48 {
49         symbol_ = symbol;
50 }
51
52
53 bool InsetMathExInt::hasScripts() const
54 {
55         // take empty upper bound as "no scripts"
56         return !cell(3).empty();
57 }
58
59
60
61 void InsetMathExInt::normalize(NormalStream & os) const
62 {
63         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
64            << cell(2) << ' ' << cell(3) << ']';
65 }
66
67
68 void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
69 {
70         lyxerr << "should not happen" << endl;
71 }
72
73
74 void InsetMathExInt::draw(PainterInfo &, int, int) const
75 {
76         lyxerr << "should not happen" << endl;
77 }
78
79
80 void InsetMathExInt::maple(MapleStream & os) const
81 {
82         os << symbol_ << '(';
83         if (cell(0).size())
84                 os << cell(0);
85         else
86                 os << '1';
87         os << ',' << cell(1);
88         if (hasScripts())
89                 os << '=' << cell(2) << ".." << cell(3);
90         os << ')';
91 }
92
93
94 void InsetMathExInt::maxima(MaximaStream & os) const
95 {
96         if ( symbol_ == "int" )
97                 os << "integrate(";
98         else
99                 os << symbol_ << '(';
100
101         if (cell(0).size())
102                 os << cell(0) << ',';
103         else
104                 os << '1' << ',';
105         if (hasScripts())
106                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
107         else
108                 os << cell(1) << ')';
109 }
110
111 void InsetMathExInt::mathematica(MathematicaStream & os) const
112 {
113         if ( symbol_ == "int" )
114                 os << "Integrate[";
115         else if (symbol_ == "sum")
116                 os << "Sum[";
117         else
118                 os << symbol_ << '[';
119
120         if (cell(0).size())
121                 os << cell(0) << ',';
122         else
123                 os << '1' << ',';
124         if (hasScripts())
125                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
126         else
127                 os << cell(1) << ']';
128 }
129
130
131 void InsetMathExInt::mathmlize(MathStream & os) const
132 {
133         boost::scoped_ptr<InsetMathSymbol> sym(new InsetMathSymbol(symbol_));
134         //if (hasScripts())
135         //      mathmlize(sym, os);
136         //else
137                 sym->mathmlize(os);
138         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
139            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
140            << cell(1) << ETag("mrow");
141 }
142
143
144 void InsetMathExInt::write(WriteStream &) const
145 {
146         lyxerr << "should not happen" << endl;
147 }
148
149
150 } // namespace lyx