]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
Fix math cursor positioning bug
[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_data.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
23 using std::string;
24 using std::auto_ptr;
25 using std::endl;
26
27
28 MathExIntInset::MathExIntInset(string const & name)
29         : MathNestInset(4), symbol_(name)
30 {}
31
32 // 0 - core
33 // 1 - diff
34 // 2 - lower
35 // 3 - upper
36
37
38 auto_ptr<InsetBase> MathExIntInset::doClone() const
39 {
40         return auto_ptr<InsetBase>(new MathExIntInset(*this));
41 }
42
43
44 void MathExIntInset::symbol(string const & symbol)
45 {
46         symbol_ = symbol;
47 }
48
49
50 bool MathExIntInset::hasScripts() const
51 {
52         // take empty upper bound as "no scripts"
53         return !cell(3).empty();
54 }
55
56
57
58 void MathExIntInset::normalize(NormalStream & os) const
59 {
60         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
61            << cell(2) << ' ' << cell(3) << ']';
62 }
63
64
65 void MathExIntInset::metrics(MetricsInfo &, Dimension &) const
66 {
67         lyxerr << "should not happen" << endl;
68 }
69
70
71 void MathExIntInset::draw(PainterInfo &, int, int) const
72 {
73         lyxerr << "should not happen" << endl;
74 }
75
76
77 void MathExIntInset::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 MathExIntInset::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 MathExIntInset::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 MathExIntInset::mathmlize(MathMLStream & os) const
129 {
130         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(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 MathExIntInset::write(WriteStream &) const
142 {
143         lyxerr << "should not happen" << endl;
144 }