2 * \file InsetMathExInt.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathExInt.h"
15 #include "MathStream.h"
16 #include "MathStream.h"
17 #include "InsetMathSymbol.h"
19 #include "support/debug.h"
20 #include "support/docstring.h"
25 InsetMathExInt::InsetMathExInt(Buffer * buf, docstring const & name)
26 : InsetMathNest(buf, 4), symbol_(name)
35 Inset * InsetMathExInt::clone() const
37 return new InsetMathExInt(*this);
41 void InsetMathExInt::symbol(docstring const & symbol)
47 bool InsetMathExInt::hasScripts() const
49 // take empty upper bound as "no scripts"
50 return !cell(3).empty();
55 void InsetMathExInt::normalize(NormalStream & os) const
57 os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
58 << cell(2) << ' ' << cell(3) << ']';
62 void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
64 LYXERR0("should not happen");
68 void InsetMathExInt::draw(PainterInfo &, int, int) const
70 LYXERR0("should not happen");
74 bool InsetMathExInt::isExIntOperator(docstring const & name)
76 std::string const & sname = to_utf8(name);
77 return sname == "sum" || sname == "prod";
81 void InsetMathExInt::maple(MapleStream & os) const
83 // FIXME Products and the like may need special treatment.
91 os << '=' << cell(2) << ".." << cell(3);
96 void InsetMathExInt::maxima(MaximaStream & os) const
98 // FIXME Products and the like may need special treatment.
102 os << symbol_ << '(';
105 os << cell(0) << ',';
109 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
111 os << cell(1) << ')';
115 void InsetMathExInt::mathematica(MathematicaStream & os) const
117 // FIXME Products and the like may need special treatment.
118 if (symbol_ == "int")
120 else if (symbol_ == "sum")
123 os << symbol_ << '[';
126 os << cell(0) << ',';
130 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
132 os << cell(1) << ']';
136 void InsetMathExInt::mathmlize(MathStream & os) const
138 InsetMathSymbol sym(symbol_);
139 if (isExIntOperator(symbol_)) {
140 bool const lower = !cell(1).empty();
141 bool const upper = !cell(3).empty();
143 os << MTag("msubsup");
154 if (!cell(2).empty())
155 os << MTag("mo") << "=" << ETag("mo")
160 os << MTag("mrow") << cell(3) << ETag("mrow");
162 os << ETag("msubsup");
170 // some kind of integral
171 bool const lower = !cell(2).empty();
172 bool const upper = !cell(3).empty();
174 os << MTag("msubsup");
183 os << MTag("mrow") << cell(2) << ETag("mrow");
185 os << MTag("mrow") << cell(3) << ETag("mrow");
187 os << ETag("msubsup");
192 os << cell(0) << "<mo> ⁢ </mo>"
193 << MTag("mrow") << "<mo> ⅆ </mo>"
194 << cell(1) << ETag("mrow");
198 void InsetMathExInt::write(WriteStream &) const
200 LYXERR0("should not happen");