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