]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExFunc.C
Fix some unicode conversion problems, more work needed.
[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 namespace lyx {
21
22
23 using std::string;
24 using std::auto_ptr;
25 using std::vector;
26
27
28 InsetMathExFunc::InsetMathExFunc(string const & name)
29         : InsetMathNest(1), name_(name)
30 {}
31
32
33 InsetMathExFunc::InsetMathExFunc(string const & name, MathArray const & ar)
34         : InsetMathNest(1), name_(name)
35 {
36         cell(0) = ar;
37 }
38
39
40 auto_ptr<InsetBase> InsetMathExFunc::doClone() const
41 {
42         return auto_ptr<InsetBase>(new InsetMathExFunc(*this));
43 }
44
45
46 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
47 {
48         // FIXME UNICODE
49         vector<char_type> n(name_.begin(), name_.end());
50         mathed_string_dim(mi.base.font, n, dim_);
51 }
52
53
54 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
55 {
56         // FIXME UNICODE
57         drawStrBlack(pi, x, y, from_utf8(name_));
58 }
59
60
61 string InsetMathExFunc::name() const
62 {
63         return name_;
64 }
65
66
67 void InsetMathExFunc::maple(MapleStream & os) const
68 {
69         if (name_ == "det")
70                 os << "linalg[det](" << cell(0) << ')';
71         else
72                 os << name_ << '(' << cell(0) << ')';
73 }
74
75
76 void InsetMathExFunc::maxima(MaximaStream & os) const
77 {
78         if (name_ == "det")
79                 os << "determinant(" << cell(0) << ')';
80         else
81                 os << name_ << '(' << cell(0) << ')';
82 }
83
84
85 string asMathematicaName(string const & name)
86 {
87         if (name == "sin")    return "Sin";
88         if (name == "sinh")   return "Sinh";
89         if (name == "arcsin") return "ArcSin";
90         if (name == "asin")   return "ArcSin";
91         if (name == "cos")    return "Cos";
92         if (name == "cosh")   return "Cosh";
93         if (name == "arccos") return "ArcCos";
94         if (name == "acos")   return "ArcCos";
95         if (name == "tan")    return "Tan";
96         if (name == "tanh")   return "Tanh";
97         if (name == "arctan") return "ArcTan";
98         if (name == "atan")   return "ArcTan";
99         if (name == "cot")    return "Cot";
100         if (name == "coth")   return "Coth";
101         if (name == "csc")    return "Csc";
102         if (name == "sec")    return "Sec";
103         if (name == "exp")    return "Exp";
104         if (name == "log")    return "Log";
105         if (name == "ln" )    return "Log";
106         if (name == "arg" )   return "Arg";
107         if (name == "det" )   return "Det";
108         if (name == "gcd" )   return "GCD";
109         if (name == "max" )   return "Max";
110         if (name == "min" )   return "Min";
111         if (name == "erf" )   return "Erf";
112         if (name == "erfc" )  return "Erfc";
113         return name;
114 }
115
116
117 void InsetMathExFunc::mathematica(MathematicaStream & os) const
118 {
119         os << asMathematicaName(name_) << '[' << cell(0) << ']';
120 }
121
122
123 void InsetMathExFunc::mathmlize(MathMLStream & os) const
124 {
125         os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
126 }
127
128
129 void InsetMathExFunc::octave(OctaveStream & os) const
130 {
131         os << name_ << '(' << cell(0) << ')';
132 }
133
134
135 } // namespace lyx