]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exfuncinset.C
Fix reading of math macros
[lyx.git] / src / mathed / math_exfuncinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include <config.h>
6
7 #include "math_exfuncinset.h"
8 #include "math_support.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11
12
13 MathExFuncInset::MathExFuncInset(string const & name)
14         : MathNestInset(1), name_(name)
15 {}
16
17
18 MathExFuncInset::MathExFuncInset(string const & name, MathArray const & ar)
19         : MathNestInset(1), name_(name)
20 {
21         cell(0) = ar;
22 }
23
24
25 MathInset * MathExFuncInset::clone() const
26 {
27         return new MathExFuncInset(*this);
28 }
29
30
31 void MathExFuncInset::metrics(MathMetricsInfo & mi) const
32 {
33         mathed_string_dim(mi.base.font, name_, dim_);
34 }
35
36
37 void MathExFuncInset::draw(MathPainterInfo & pi, int x, int y) const
38 {
39         drawStrBlack(pi, x, y, name_);
40 }
41
42
43 string MathExFuncInset::name() const
44 {
45         return name_;
46 }
47
48
49 void MathExFuncInset::maplize(MapleStream & os) const
50 {
51         if (name_ == "det")
52                 os << "linalg[det](" << cell(0) << ')';
53         else
54                 os << name_ << '(' << cell(0) << ')';
55 }
56
57
58 void MathExFuncInset::maximize(MaximaStream & os) const
59 {
60         if (name_ == "det")
61                 os << "determinant(" << cell(0) << ')';
62         else
63                 os << name_ << '(' << cell(0) << ')';
64 }
65
66
67 string asMathematicaName(string const & name)
68 {
69         if (name == "sin")    return "Sin";
70         if (name == "sinh")   return "Sinh";
71         if (name == "arcsin") return "ArcSin";
72         if (name == "cos")    return "Cos";
73         if (name == "cosh")   return "Cosh";
74         if (name == "arcos")  return "ArcCos";
75         if (name == "tan")    return "Tan";
76         if (name == "tanh")   return "Tanh";
77         if (name == "arctan") return "ArcTan";
78         if (name == "cot")    return "Cot";
79         if (name == "coth")   return "Coth";
80         if (name == "csc")    return "Csc";
81         if (name == "sec")    return "Sec";
82         if (name == "exp")    return "Exp";
83         if (name == "log")    return "Log";
84         if (name == "ln" )    return "Log";
85         return name;
86 }
87
88
89 void MathExFuncInset::mathematicize(MathematicaStream & os) const
90 {
91         os << asMathematicaName(name_) << '[' << cell(0) << ']';
92 }
93
94
95 void MathExFuncInset::mathmlize(MathMLStream & os) const
96 {
97         os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
98 }
99
100
101 void MathExFuncInset::octavize(OctaveStream & os) const
102 {
103         os << name_ << '(' << cell(0) << ')';
104 }