]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.C
84277234189a92ac08417b3c2d1c00ef9ca87876
[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 bool InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
69 {
70         lyxerr << "should not happen" << endl;
71         return true;
72 }
73
74
75 void InsetMathExInt::draw(PainterInfo &, int, int) const
76 {
77         lyxerr << "should not happen" << endl;
78 }
79
80
81 void InsetMathExInt::maple(MapleStream & os) const
82 {
83         os << symbol_ << '(';
84         if (cell(0).size())
85                 os << cell(0);
86         else
87                 os << '1';
88         os << ',' << cell(1);
89         if (hasScripts())
90                 os << '=' << cell(2) << ".." << cell(3);
91         os << ')';
92 }
93
94
95 void InsetMathExInt::maxima(MaximaStream & os) const
96 {
97         if ( symbol_ == "int" )
98                 os << "integrate(";
99         else
100                 os << symbol_ << '(';
101
102         if (cell(0).size())
103                 os << cell(0) << ',';
104         else
105                 os << '1' << ',';
106         if (hasScripts())
107                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
108         else
109                 os << cell(1) << ')';
110 }
111
112 void InsetMathExInt::mathematica(MathematicaStream & os) const
113 {
114         if ( symbol_ == "int" )
115                 os << "Integrate[";
116         else if (symbol_ == "sum")
117                 os << "Sum[";
118         else
119                 os << symbol_ << '[';
120
121         if (cell(0).size())
122                 os << cell(0) << ',';
123         else
124                 os << '1' << ',';
125         if (hasScripts())
126                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
127         else
128                 os << cell(1) << ']';
129 }
130
131
132 void InsetMathExInt::mathmlize(MathStream & os) const
133 {
134         boost::scoped_ptr<InsetMathSymbol> sym(new InsetMathSymbol(symbol_));
135         //if (hasScripts())
136         //      mathmlize(sym, os);
137         //else
138                 sym->mathmlize(os);
139         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
140            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
141            << cell(1) << ETag("mrow");
142 }
143
144
145 void InsetMathExInt::write(WriteStream &) const
146 {
147         lyxerr << "should not happen" << endl;
148 }
149
150
151 } // namespace lyx