2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathExInt.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathExInt.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2009-12-31 03:50:12 +00:00
|
|
|
#include "MathExtern.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "MathStream.h"
|
|
|
|
#include "InsetMathSymbol.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-14 21:57:43 +00:00
|
|
|
#include "support/docstring.h"
|
2001-12-18 03:16:46 +00:00
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
2007-11-28 22:12:03 +00:00
|
|
|
namespace lyx {
|
2001-11-09 14:48:57 +00:00
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathExInt::InsetMathExInt(Buffer * buf, docstring const & name)
|
|
|
|
: InsetMathNest(buf, 4), symbol_(name)
|
2001-11-09 14:48:57 +00:00
|
|
|
{}
|
|
|
|
|
2001-11-15 14:14:37 +00:00
|
|
|
// 0 - core
|
|
|
|
// 1 - diff
|
|
|
|
// 2 - lower
|
|
|
|
// 3 - upper
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathExInt::clone() const
|
2001-11-09 14:48:57 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathExInt(*this);
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathExInt::symbol(docstring const & symbol)
|
2001-11-12 14:37:43 +00:00
|
|
|
{
|
|
|
|
symbol_ = symbol;
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
bool InsetMathExInt::hasScripts() const
|
2001-11-09 16:27:44 +00:00
|
|
|
{
|
2001-11-15 09:51:57 +00:00
|
|
|
// take empty upper bound as "no scripts"
|
2001-11-15 14:14:37 +00:00
|
|
|
return !cell(3).empty();
|
2001-11-09 16:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::normalize(NormalStream & os) const
|
2001-11-09 14:48:57 +00:00
|
|
|
{
|
2002-03-21 17:42:56 +00:00
|
|
|
os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
|
2001-11-15 14:14:37 +00:00
|
|
|
<< cell(2) << ' ' << cell(3) << ']';
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const
|
2001-11-09 14:48:57 +00:00
|
|
|
{
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("should not happen");
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::draw(PainterInfo &, int, int) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("should not happen");
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::maple(MapleStream & os) const
|
2001-11-09 14:48:57 +00:00
|
|
|
{
|
2001-12-05 08:04:20 +00:00
|
|
|
os << symbol_ << '(';
|
2001-11-13 18:33:48 +00:00
|
|
|
if (cell(0).size())
|
|
|
|
os << cell(0);
|
2002-03-21 17:42:56 +00:00
|
|
|
else
|
2001-11-12 13:09:26 +00:00
|
|
|
os << '1';
|
2001-11-13 18:33:48 +00:00
|
|
|
os << ',' << cell(1);
|
2001-11-15 14:14:37 +00:00
|
|
|
if (hasScripts())
|
|
|
|
os << '=' << cell(2) << ".." << cell(3);
|
2001-11-09 16:27:44 +00:00
|
|
|
os << ')';
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-30 17:51:19 +00:00
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::maxima(MaximaStream & os) const
|
2002-10-28 17:15:19 +00:00
|
|
|
{
|
2007-11-14 21:57:43 +00:00
|
|
|
if (symbol_ == "int")
|
2002-10-28 17:15:19 +00:00
|
|
|
os << "integrate(";
|
2002-12-01 22:59:25 +00:00
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
os << symbol_ << '(';
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-28 17:15:19 +00:00
|
|
|
if (cell(0).size())
|
|
|
|
os << cell(0) << ',';
|
|
|
|
else
|
|
|
|
os << '1' << ',';
|
|
|
|
if (hasScripts())
|
|
|
|
os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
|
2002-12-01 22:59:25 +00:00
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
os << cell(1) << ')';
|
|
|
|
}
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
{
|
2007-11-14 21:57:43 +00:00
|
|
|
if (symbol_ == "int")
|
2002-07-01 11:17:14 +00:00
|
|
|
os << "Integrate[";
|
2002-12-01 22:59:25 +00:00
|
|
|
else if (symbol_ == "sum")
|
2002-10-28 17:15:19 +00:00
|
|
|
os << "Sum[";
|
2002-12-01 22:59:25 +00:00
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
os << symbol_ << '[';
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
if (cell(0).size())
|
|
|
|
os << cell(0) << ',';
|
|
|
|
else
|
|
|
|
os << '1' << ',';
|
|
|
|
if (hasScripts())
|
|
|
|
os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
|
2002-12-01 22:59:25 +00:00
|
|
|
else
|
2002-07-01 11:17:14 +00:00
|
|
|
os << cell(1) << ']';
|
|
|
|
}
|
|
|
|
|
2001-11-09 16:27:44 +00:00
|
|
|
|
2009-12-31 03:50:12 +00:00
|
|
|
docstring InsetMathExInt::mathmlize(MathStream & os) const
|
2001-11-09 14:48:57 +00:00
|
|
|
{
|
2009-12-17 17:52:09 +00:00
|
|
|
// At the moment, we are not extracting sums and the like for MathML.
|
|
|
|
// If we should decide to do so later, then we'll need to re-merge
|
|
|
|
// r32566 and r32568.
|
|
|
|
// So right now this only handles integrals.
|
2009-12-17 16:06:00 +00:00
|
|
|
InsetMathSymbol sym(symbol_);
|
|
|
|
bool const lower = !cell(2).empty();
|
|
|
|
bool const upper = !cell(3).empty();
|
|
|
|
if (lower && upper)
|
|
|
|
os << MTag("msubsup");
|
|
|
|
else if (lower)
|
|
|
|
os << MTag("msub");
|
|
|
|
else if (upper)
|
|
|
|
os << MTag("msup");
|
|
|
|
os << MTag("mrow");
|
2009-12-17 15:54:49 +00:00
|
|
|
sym.mathmlize(os);
|
2009-12-17 16:06:00 +00:00
|
|
|
os << ETag("mrow");
|
|
|
|
if (lower)
|
|
|
|
os << MTag("mrow") << cell(2) << ETag("mrow");
|
|
|
|
if (upper)
|
|
|
|
os << MTag("mrow") << cell(3) << ETag("mrow");
|
|
|
|
if (lower && upper)
|
|
|
|
os << ETag("msubsup");
|
|
|
|
else if (lower)
|
|
|
|
os << ETag("msub");
|
|
|
|
else if (upper)
|
|
|
|
os << ETag("msup");
|
2009-12-31 03:50:12 +00:00
|
|
|
docstring rv = lyx::mathmlize(cell(0), os);
|
|
|
|
os << "<mo> ⁢ </mo>"
|
2001-11-09 18:02:20 +00:00
|
|
|
<< MTag("mrow") << "<mo> ⅆ </mo>"
|
2001-11-13 18:33:48 +00:00
|
|
|
<< cell(1) << ETag("mrow");
|
2009-12-31 03:50:12 +00:00
|
|
|
return rv;
|
2001-11-09 14:48:57 +00:00
|
|
|
}
|
2001-11-09 16:27:44 +00:00
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExInt::write(WriteStream &) const
|
2001-11-09 16:27:44 +00:00
|
|
|
{
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("should not happen");
|
2001-11-09 16:27:44 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2009-12-17 17:50:46 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|