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