]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.cpp
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[lyx.git] / src / mathed / InsetMathExInt.cpp
1 /**
2  * \file InsetMathExInt.cpp
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 using std::endl;
26
27
28 InsetMathExInt::InsetMathExInt(docstring const & name)
29         : InsetMathNest(4), symbol_(name)
30 {}
31
32 // 0 - core
33 // 1 - diff
34 // 2 - lower
35 // 3 - upper
36
37
38 Inset * InsetMathExInt::clone() const
39 {
40         return new InsetMathExInt(*this);
41 }
42
43
44 void InsetMathExInt::symbol(docstring const & symbol)
45 {
46         symbol_ = symbol;
47 }
48
49
50 bool InsetMathExInt::hasScripts() const
51 {
52         // take empty upper bound as "no scripts"
53         return !cell(3).empty();
54 }
55
56
57
58 void InsetMathExInt::normalize(NormalStream & os) const
59 {
60         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
61            << cell(2) << ' ' << cell(3) << ']';
62 }
63
64
65 bool InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
66 {
67         lyxerr << "should not happen" << endl;
68         return true;
69 }
70
71
72 void InsetMathExInt::draw(PainterInfo &, int, int) const
73 {
74         lyxerr << "should not happen" << endl;
75 }
76
77
78 void InsetMathExInt::maple(MapleStream & os) const
79 {
80         os << symbol_ << '(';
81         if (cell(0).size())
82                 os << cell(0);
83         else
84                 os << '1';
85         os << ',' << cell(1);
86         if (hasScripts())
87                 os << '=' << cell(2) << ".." << cell(3);
88         os << ')';
89 }
90
91
92 void InsetMathExInt::maxima(MaximaStream & os) const
93 {
94         if ( symbol_ == "int" )
95                 os << "integrate(";
96         else
97                 os << symbol_ << '(';
98
99         if (cell(0).size())
100                 os << cell(0) << ',';
101         else
102                 os << '1' << ',';
103         if (hasScripts())
104                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
105         else
106                 os << cell(1) << ')';
107 }
108
109 void InsetMathExInt::mathematica(MathematicaStream & os) const
110 {
111         if ( symbol_ == "int" )
112                 os << "Integrate[";
113         else if (symbol_ == "sum")
114                 os << "Sum[";
115         else
116                 os << symbol_ << '[';
117
118         if (cell(0).size())
119                 os << cell(0) << ',';
120         else
121                 os << '1' << ',';
122         if (hasScripts())
123                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
124         else
125                 os << cell(1) << ']';
126 }
127
128
129 void InsetMathExInt::mathmlize(MathStream & os) const
130 {
131         boost::scoped_ptr<InsetMathSymbol> sym(new InsetMathSymbol(symbol_));
132         //if (hasScripts())
133         //      mathmlize(sym, os);
134         //else
135                 sym->mathmlize(os);
136         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
137            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
138            << cell(1) << ETag("mrow");
139 }
140
141
142 void InsetMathExInt::write(WriteStream &) const
143 {
144         lyxerr << "should not happen" << endl;
145 }
146
147
148 } // namespace lyx