2 * \file InsetMathExFunc.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 "InsetMathExFunc.h"
16 #include "MathExtern.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19 #include "MetricsInfo.h"
21 #include "support/docstream.h"
28 InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name)
29 : InsetMathNest(buf, 1), name_(name)
33 InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar)
34 : InsetMathNest(buf, 1), name_(name)
40 Inset * InsetMathExFunc::clone() const
42 return new InsetMathExFunc(*this);
46 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
48 mathed_string_dim(mi.base.font, name_, dim);
52 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
54 drawStrBlack(pi, x, y, name_);
58 docstring InsetMathExFunc::name() const
64 void InsetMathExFunc::maple(MapleStream & os) const
67 os << "linalg[det](" << cell(0) << ')';
69 os << name_ << '(' << cell(0) << ')';
73 void InsetMathExFunc::maxima(MaximaStream & os) const
76 os << "determinant(" << cell(0) << ')';
78 os << name_ << '(' << cell(0) << ')';
82 static string asMathematicaName(string const & name)
84 if (name == "sin") return "Sin";
85 if (name == "sinh") return "Sinh";
86 if (name == "arcsin") return "ArcSin";
87 if (name == "asin") return "ArcSin";
88 if (name == "cos") return "Cos";
89 if (name == "cosh") return "Cosh";
90 if (name == "arccos") return "ArcCos";
91 if (name == "acos") return "ArcCos";
92 if (name == "tan") return "Tan";
93 if (name == "tanh") return "Tanh";
94 if (name == "arctan") return "ArcTan";
95 if (name == "atan") return "ArcTan";
96 if (name == "cot") return "Cot";
97 if (name == "coth") return "Coth";
98 if (name == "csc") return "Csc";
99 if (name == "sec") return "Sec";
100 if (name == "exp") return "Exp";
101 if (name == "log") return "Log";
102 if (name == "ln" ) return "Log";
103 if (name == "arg" ) return "Arg";
104 if (name == "det" ) return "Det";
105 if (name == "gcd" ) return "GCD";
106 if (name == "max" ) return "Max";
107 if (name == "min" ) return "Min";
108 if (name == "erf" ) return "Erf";
109 if (name == "erfc" ) return "Erfc";
114 static docstring asMathematicaName(docstring const & name)
116 return from_utf8(asMathematicaName(to_utf8(name)));
120 void InsetMathExFunc::mathematica(MathematicaStream & os) const
122 os << asMathematicaName(name_) << '[' << cell(0) << ']';
126 docstring InsetMathExFunc::mathmlize(MathStream & os) const
128 os << "<mi>" << name_ << "</mi><mo>⁡</mo>";
129 return lyx::mathmlize(cell(0), os);
133 void InsetMathExFunc::octave(OctaveStream & os) const
135 os << name_ << '(' << cell(0) << ')';