]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
Standardise the header blurb in mathed.
[lyx.git] / src / mathed / math_exintinset.C
1 /**
2  * \file math_exintinset.C
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 "math_exintinset.h"
14 #include "math_support.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17 #include "math_symbolinset.h"
18 #include "debug.h"
19
20 #include <boost/scoped_ptr.hpp>
21
22 using std::auto_ptr;
23 using std::endl;
24
25
26 MathExIntInset::MathExIntInset(string const & name)
27         : MathNestInset(4), symbol_(name)
28 {}
29
30 // 0 - core
31 // 1 - diff
32 // 2 - lower
33 // 3 - upper
34
35
36 auto_ptr<InsetBase> MathExIntInset::clone() const
37 {
38         return auto_ptr<InsetBase>(new MathExIntInset(*this));
39 }
40
41
42 void MathExIntInset::symbol(string const & symbol)
43 {
44         symbol_ = symbol;
45 }
46
47
48 bool MathExIntInset::hasScripts() const
49 {
50         // take empty upper bound as "no scripts"
51         return !cell(3).empty();
52 }
53
54
55
56 void MathExIntInset::normalize(NormalStream & os) const
57 {
58         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
59            << cell(2) << ' ' << cell(3) << ']';
60 }
61
62
63 void MathExIntInset::metrics(MetricsInfo &, Dimension &) const
64 {
65         lyxerr << "should not happen" << endl;
66 }
67
68
69 void MathExIntInset::draw(PainterInfo &, int, int) const
70 {
71         lyxerr << "should not happen" << endl;
72 }
73
74
75 void MathExIntInset::maple(MapleStream & os) const
76 {
77         os << symbol_ << '(';
78         if (cell(0).size())
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 MathExIntInset::maxima(MaximaStream & os) const
90 {
91         if ( symbol_ == "int" )
92                 os << "integrate(";
93         else
94                 os << symbol_ << '(';
95
96         if (cell(0).size())
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 MathExIntInset::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).size())
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 MathExIntInset::mathmlize(MathMLStream & os) const
127 {
128         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
129         //if (hasScripts())
130         //      mathmlize(sym, os);
131         //else
132                 sym->mathmlize(os);
133         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
134            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
135            << cell(1) << ETag("mrow");
136 }
137
138
139 void MathExIntInset::write(WriteStream &) const
140 {
141         lyxerr << "should not happen" << endl;
142 }