]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExInt.cpp
543a3255a27ef220145600ff20d42626e79cfbd2
[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 void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
66 {
67         lyxerr << "should not happen" << endl;
68 }
69
70
71 void InsetMathExInt::draw(PainterInfo &, int, int) const
72 {
73         lyxerr << "should not happen" << endl;
74 }
75
76
77 void InsetMathExInt::maple(MapleStream & os) const
78 {
79         os << symbol_ << '(';
80         if (cell(0).size())
81                 os << cell(0);
82         else
83                 os << '1';
84         os << ',' << cell(1);
85         if (hasScripts())
86                 os << '=' << cell(2) << ".." << cell(3);
87         os << ')';
88 }
89
90
91 void InsetMathExInt::maxima(MaximaStream & os) const
92 {
93         if ( symbol_ == "int" )
94                 os << "integrate(";
95         else
96                 os << symbol_ << '(';
97
98         if (cell(0).size())
99                 os << cell(0) << ',';
100         else
101                 os << '1' << ',';
102         if (hasScripts())
103                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
104         else
105                 os << cell(1) << ')';
106 }
107
108 void InsetMathExInt::mathematica(MathematicaStream & os) const
109 {
110         if ( symbol_ == "int" )
111                 os << "Integrate[";
112         else if (symbol_ == "sum")
113                 os << "Sum[";
114         else
115                 os << symbol_ << '[';
116
117         if (cell(0).size())
118                 os << cell(0) << ',';
119         else
120                 os << '1' << ',';
121         if (hasScripts())
122                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
123         else
124                 os << cell(1) << ']';
125 }
126
127
128 void InsetMathExInt::mathmlize(MathStream & os) const
129 {
130         boost::scoped_ptr<InsetMathSymbol> sym(new InsetMathSymbol(symbol_));
131         //if (hasScripts())
132         //      mathmlize(sym, os);
133         //else
134                 sym->mathmlize(os);
135         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
136            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
137            << cell(1) << ETag("mrow");
138 }
139
140
141 void InsetMathExInt::write(WriteStream &) const
142 {
143         lyxerr << "should not happen" << endl;
144 }
145
146
147 } // namespace lyx