}
+bool InsetMathExInt::isExIntOperator(docstring const & name)
+{
+ std::string const & sname = to_utf8(name);
+ return sname == "sum" || sname == "prod";
+}
+
+
void InsetMathExInt::maple(MapleStream & os) const
{
+ // FIXME Products and the like may need special treatment.
os << symbol_ << '(';
if (cell(0).size())
os << cell(0);
void InsetMathExInt::maxima(MaximaStream & os) const
{
+ // FIXME Products and the like may need special treatment.
if (symbol_ == "int")
os << "integrate(";
else
os << cell(1) << ')';
}
+
void InsetMathExInt::mathematica(MathematicaStream & os) const
{
+ // FIXME Products and the like may need special treatment.
if (symbol_ == "int")
os << "Integrate[";
else if (symbol_ == "sum")
void InsetMathExInt::mathmlize(MathStream & os) const
{
InsetMathSymbol sym(symbol_);
- if (symbol_ == "sum") {
+ if (isExIntOperator(symbol_)) {
bool const lower = !cell(1).empty();
bool const upper = !cell(3).empty();
if (lower && upper)
LYXERR0("should not happen");
}
-
} // namespace lyx
// or \sum, \prod... for interfacing external programs
#include "InsetMathNest.h"
-
+#include "support/strfwd.h"
namespace lyx {
void write(WriteStream & os) const;
///
InsetCode lyxCode() const { return MATH_EXINT_CODE; }
+ /// is this a sum, product, or whatever that we can handle?
+ /// note that this does not include integrals.
+ static bool isExIntOperator(docstring const &);
private:
virtual Inset * clone() const;
///
bool hasScripts() const;
-
///
docstring symbol_;
};
typedef MathAtom ReplaceArgumentFunc(const MathData & ar);
-
// try to extract a super/subscript
// modify iterator position to point behind the thing
bool extractScript(MathData & ar,
// leave alone sums and integrals
InsetMathSymbol const * sym =
script->nuc().front()->asSymbolInset();
- if (sym && (sym->name() == "sum" || sym->name() == "int"))
+ if (sym && (InsetMathExInt::isExIntOperator(sym->name()) || sym->name() == "int"))
continue;
}
}
-bool testSumSymbol(MathAtom const & p)
+bool testSumLikeSymbol(MathAtom const & p)
{
- return testSymbol(p, from_ascii("sum"));
+ return InsetMathExInt::isExIntOperator(p->name());
}
-bool testSum(MathAtom const & at)
+docstring testSumLike(MathAtom const & at)
{
- return
- testSumSymbol(at) ||
- ( at->asScriptInset()
+ if (testSumLikeSymbol(at))
+ return at->name();
+ if ( at->asScriptInset()
&& at->asScriptInset()->nuc().size()
- && testSumSymbol(at->asScriptInset()->nuc().back()) );
+ && testSumLikeSymbol(at->asScriptInset()->nuc().back()) )
+ return at->asScriptInset()->nuc().back()->name();
+ return docstring();
}
// replace '\sum' ['_^'] f(x) sequences by a real InsetMathExInt
+// and similar things, like \prod. The things we extract are
+// determined by InsetMathExInt::isExIntOperator().
// assume 'extractDelims' ran before
-void extractSums(MathData & ar)
+void extractSumLike(MathData & ar)
{
// we need at least two items...
if (ar.size() < 2)
MathData::iterator it = ar.begin() + i;
// is this a sum name?
- if (!testSum(ar[i]))
+ docstring const opname = testSumLike(ar[i]);
+ if (opname.empty())
continue;
// create a proper inset as replacement
- auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("sum")));
+ auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, opname));
// collect lower bound and summation index
InsetMathScript const * sub = ar[i]->asScriptInset();
splitScripts(ar);
extractDelims(ar);
extractIntegrals(ar, kind);
- extractSums(ar);
+ extractSumLike(ar);
extractNumbers(ar);
extractMatrices(ar);
extractFunctions(ar, kind);