]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.cpp
Remove profiling.py
[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
15 #include "LaTeXFeatures.h"
16 #include "MathData.h"
17 #include "MathStream.h"
18 #include "InsetMathSymbol.h"
19
20 #include "support/debug.h"
21 #include "support/docstring.h"
22
23
24 namespace lyx {
25
26 InsetMathExInt::InsetMathExInt(Buffer * buf, docstring const & name)
27         : InsetMathNest(buf, 4), symbol_(name)
28 {}
29
30 // 0 - core
31 // 1 - diff
32 // 2 - lower
33 // 3 - upper
34
35
36 Inset * InsetMathExInt::clone() const
37 {
38         return new InsetMathExInt(*this);
39 }
40
41
42 void InsetMathExInt::symbol(docstring const & symbol)
43 {
44         symbol_ = symbol;
45 }
46
47
48 bool InsetMathExInt::hasScripts() const
49 {
50         // take empty upper bound as "no scripts"
51         return !cell(3).empty();
52 }
53
54
55
56 void InsetMathExInt::normalize(NormalStream & os) const
57 {
58         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
59            << cell(2) << ' ' << cell(3) << ']';
60 }
61
62
63 void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
64 {
65         LYXERR0("should not happen");
66 }
67
68
69 void InsetMathExInt::draw(PainterInfo &, int, int) const
70 {
71         LYXERR0("should not happen");
72 }
73
74
75 void InsetMathExInt::maple(MapleStream & os) const
76 {
77         os << symbol_ << '(';
78         if (!cell(0).empty())
79                 os << cell(0);
80         else
81                 os << '1';
82         os << ',' << cell(1);
83         if (hasScripts())
84                 os << '=' << cell(2) << ".." << cell(3);
85         os << ')';
86 }
87
88
89 void InsetMathExInt::maxima(MaximaStream & os) const
90 {
91         if (symbol_ == "int")
92                 os << "integrate(";
93         else
94                 os << symbol_ << '(';
95
96         if (!cell(0).empty())
97                 os << cell(0) << ',';
98         else
99                 os << '1' << ',';
100         if (hasScripts())
101                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
102         else
103                 os << cell(1) << ')';
104 }
105
106 void InsetMathExInt::mathematica(MathematicaStream & os) const
107 {
108         if (symbol_ == "int")
109                 os << "Integrate[";
110         else if (symbol_ == "sum")
111                 os << "Sum[";
112         else
113                 os << symbol_ << '[';
114
115         if (!cell(0).empty())
116                 os << cell(0) << ',';
117         else
118                 os << '1' << ',';
119         if (hasScripts())
120                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
121         else
122                 os << cell(1) << ']';
123 }
124
125
126 void InsetMathExInt::mathmlize(MathMLStream & ms) const
127 {
128         // At the moment, we are not extracting sums and the like for MathML.
129         // If we should decide to do so later, then we'll need to re-merge
130         // r32566 and r32568.
131         // So right now this only handles integrals.
132         InsetMathSymbol sym(buffer_, symbol_);
133         bool const lower = !cell(2).empty();
134         bool const upper = !cell(3).empty();
135         if (lower && upper)
136                 ms << MTag("msubsup");
137         else if (lower)
138                 ms << MTag("msub");
139         else if (upper)
140                 ms << MTag("msup");
141         ms << MTag("mrow");
142         sym.mathmlize(ms);
143         ms << ETag("mrow");
144         if (lower)
145                 ms << cell(2);
146         if (upper)
147                 ms << cell(3);
148         if (lower && upper)
149                 ms << ETag("msubsup");
150         else if (lower)
151                 ms << ETag("msub");
152         else if (upper)
153                 ms << ETag("msup");
154         ms << cell(0)
155            << MTagInline("mo") << "&#8290;" << ETagInline("mo") // &InvisibleTimes;
156            << MTag("mrow")
157            << MTagInline("mo") << "&#8518;" << ETagInline("mo") // &DifferentialD;
158            << cell(1)
159            << ETag("mrow");
160 }
161
162
163 void InsetMathExInt::htmlize(HtmlStream & os) const
164 {
165         // At the moment, we are not extracting sums and the like for HTML.
166         // So right now this only handles integrals.
167         InsetMathSymbol sym(buffer_, symbol_);
168         bool const lower = !cell(2).empty();
169         bool const upper = !cell(3).empty();
170
171         os << MTag("span", "class='integral'")
172            << MTag("span", "class='intsym'");
173         sym.htmlize(os, false);
174         os << ETag("span");
175
176         if (lower && upper) {
177                 os << MTag("span", "class='limits'")
178                    << MTag("span") << cell(2) << ETag("span")
179                          << MTag("span") << cell(3) << ETag("span")
180                          << ETag("span");
181         } else if (lower)
182                 os << MTag("sub", "class='limit'") << cell(2) << ETag("sub");
183         else if (upper)
184                 os << MTag("sup", "class='limit'") << cell(3) << ETag("sup");
185         os << cell(0) << "<b>d</b>" << cell(1) << ETag("span");
186 }
187
188
189 void InsetMathExInt::write(TeXMathStream &) const
190 {
191         LYXERR0("should not happen");
192 }
193
194 } // namespace lyx