]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.cpp
Special handing of space characters during text output.
[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         // At the moment, we are not extracting sums and the like for MathML.
128         // If we should decide to do so later, then we'll need to re-merge
129         // r32566 and r32568.
130         // So right now this only handles integrals.
131         InsetMathSymbol sym(symbol_);
132         bool const lower = !cell(2).empty();
133         bool const upper = !cell(3).empty();
134         if (lower && upper)
135                 os << MTag("msubsup");
136         else if (lower)
137                 os << MTag("msub");
138         else if (upper)
139                 os << MTag("msup");
140         os << MTag("mrow");
141         sym.mathmlize(os);
142         os << ETag("mrow");
143         if (lower)
144                 os << MTag("mrow") << cell(2) << ETag("mrow");
145         if (upper)
146                 os << MTag("mrow") << cell(3) << ETag("mrow");
147         if (lower && upper)
148                 os << ETag("msubsup");
149         else if (lower)
150                 os << ETag("msub");
151         else if (upper)
152                 os << ETag("msup");
153         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
154            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
155            << cell(1) << ETag("mrow");
156 }
157
158
159 void InsetMathExInt::write(WriteStream &) const
160 {
161         LYXERR0("should not happen");
162 }
163
164
165 } // namespace lyx