]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
Geof Piroux's patch for Mathematica support
[lyx.git] / src / mathed / math_exintinset.C
1 #include <config.h>
2
3 #include "math_exintinset.h"
4 #include "math_support.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7 #include "math_symbolinset.h"
8 #include "debug.h"
9
10 #include <boost/scoped_ptr.hpp>
11
12 using std::endl;
13
14
15 MathExIntInset::MathExIntInset(string const & name)
16         : MathNestInset(4), symbol_(name)
17 {}
18
19 // 0 - core
20 // 1 - diff
21 // 2 - lower
22 // 3 - upper
23
24
25 MathInset * MathExIntInset::clone() const
26 {
27         return new MathExIntInset(*this);
28 }
29
30
31 void MathExIntInset::symbol(string const & symbol)
32 {
33         symbol_ = symbol;
34 }
35
36
37 bool MathExIntInset::hasScripts() const
38 {
39         // take empty upper bound as "no scripts"
40         return !cell(3).empty();
41 }
42
43
44
45 void MathExIntInset::normalize(NormalStream & os) const
46 {
47         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
48            << cell(2) << ' ' << cell(3) << ']';
49 }
50
51
52 void MathExIntInset::metrics(MathMetricsInfo &) const
53 {
54         lyxerr << "should not happen" << endl;
55 }
56
57
58 void MathExIntInset::draw(MathPainterInfo &, int, int) const
59 {
60         lyxerr << "should not happen" << endl;
61 }
62
63
64 void MathExIntInset::maplize(MapleStream & os) const
65 {
66         os << symbol_ << '(';
67         if (cell(0).size())
68                 os << cell(0);
69         else
70                 os << '1';
71         os << ',' << cell(1);
72         if (hasScripts())
73                 os << '=' << cell(2) << ".." << cell(3);
74         os << ')';
75 }
76
77 void MathExIntInset::mathematicize(MathematicaStream & os) const
78 {
79         if ( symbol_ == "int" ) 
80                 os << "Integrate[";
81         else 
82                 if (symbol_ == "sum") 
83                         os << "Sum[";
84                 else 
85                         os << symbol_ << '[';
86         
87         if (cell(0).size())
88                 os << cell(0) << ',';
89         else
90                 os << '1' << ',';
91         if (hasScripts())
92                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
93         else 
94                 os << cell(1) << ']';
95 }
96
97
98 void MathExIntInset::mathmlize(MathMLStream & os) const
99 {
100         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
101         //if (hasScripts())
102         //      mathmlize(sym, os);
103         //else
104                 sym->mathmlize(os);
105         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
106            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
107            << cell(1) << ETag("mrow");
108 }
109
110
111 void MathExIntInset::write(WriteStream &) const
112 {
113         lyxerr << "should not happen" << endl;
114 }