]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExFunc.C
make it compile again (hopefully)
[lyx.git] / src / mathed / InsetMathExFunc.C
1 /**
2  * \file InsetMathExFunc.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathExFunc.h"
14 #include "MathData.h"
15 #include "MathMLStream.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
18
19
20 using std::string;
21 using std::auto_ptr;
22
23
24 InsetMathExFunc::InsetMathExFunc(string const & name)
25         : InsetMathNest(1), name_(name)
26 {}
27
28
29 InsetMathExFunc::InsetMathExFunc(string const & name, MathArray const & ar)
30         : InsetMathNest(1), name_(name)
31 {
32         cell(0) = ar;
33 }
34
35
36 auto_ptr<InsetBase> InsetMathExFunc::doClone() const
37 {
38         return auto_ptr<InsetBase>(new InsetMathExFunc(*this));
39 }
40
41
42 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
43 {
44         // FIXME UNICODE
45         mathed_string_dim(mi.base.font, lyx::from_utf8(name_), dim_);
46 }
47
48
49 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
50 {
51         // FIXME UNICODE
52         drawStrBlack(pi, x, y, lyx::from_utf8(name_));
53 }
54
55
56 string InsetMathExFunc::name() const
57 {
58         return name_;
59 }
60
61
62 void InsetMathExFunc::maple(MapleStream & os) const
63 {
64         if (name_ == "det")
65                 os << "linalg[det](" << cell(0) << ')';
66         else
67                 os << name_ << '(' << cell(0) << ')';
68 }
69
70
71 void InsetMathExFunc::maxima(MaximaStream & os) const
72 {
73         if (name_ == "det")
74                 os << "determinant(" << cell(0) << ')';
75         else
76                 os << name_ << '(' << cell(0) << ')';
77 }
78
79
80 string asMathematicaName(string const & name)
81 {
82         if (name == "sin")    return "Sin";
83         if (name == "sinh")   return "Sinh";
84         if (name == "arcsin") return "ArcSin";
85         if (name == "asin")   return "ArcSin";
86         if (name == "cos")    return "Cos";
87         if (name == "cosh")   return "Cosh";
88         if (name == "arccos") return "ArcCos";
89         if (name == "acos")   return "ArcCos";
90         if (name == "tan")    return "Tan";
91         if (name == "tanh")   return "Tanh";
92         if (name == "arctan") return "ArcTan";
93         if (name == "atan")   return "ArcTan";
94         if (name == "cot")    return "Cot";
95         if (name == "coth")   return "Coth";
96         if (name == "csc")    return "Csc";
97         if (name == "sec")    return "Sec";
98         if (name == "exp")    return "Exp";
99         if (name == "log")    return "Log";
100         if (name == "ln" )    return "Log";
101         if (name == "arg" )   return "Arg";
102         if (name == "det" )   return "Det";
103         if (name == "gcd" )   return "GCD";
104         if (name == "max" )   return "Max";
105         if (name == "min" )   return "Min";
106         if (name == "erf" )   return "Erf";
107         if (name == "erfc" )  return "Erfc";
108         return name;
109 }
110
111
112 void InsetMathExFunc::mathematica(MathematicaStream & os) const
113 {
114         os << asMathematicaName(name_) << '[' << cell(0) << ']';
115 }
116
117
118 void InsetMathExFunc::mathmlize(MathMLStream & os) const
119 {
120         os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
121 }
122
123
124 void InsetMathExFunc::octave(OctaveStream & os) const
125 {
126         os << name_ << '(' << cell(0) << ')';
127 }