]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathString.C
Fix some unicode conversion problems, more work needed.
[lyx.git] / src / mathed / InsetMathString.C
1 /**
2  * \file InsetMathString.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 "InsetMathString.h"
14 #include "MathMLStream.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18
19 namespace lyx {
20
21 using std::string;
22 using std::auto_ptr;
23 using std::vector;
24
25
26 InsetMathString::InsetMathString(string const & s)
27         : str_(s)
28 {}
29
30
31 auto_ptr<InsetBase> InsetMathString::doClone() const
32 {
33         return auto_ptr<InsetBase>(new InsetMathString(*this));
34 }
35
36
37 void InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         // FIXME UNICODE
40         vector<char_type> n(str_.begin(), str_.end());
41         mathed_string_dim(mi.base.font, n, dim);
42 }
43
44
45 void InsetMathString::draw(PainterInfo & pi, int x, int y) const
46 {
47         //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
48         // FIXME UNICODE
49         docstring dstr = from_utf8(str_);
50         pi.draw(x, y, dstr);
51 }
52
53
54 void InsetMathString::normalize(NormalStream & os) const
55 {
56         os << "[string " << str_ << ' ' << "mathalpha" << ']';
57 }
58
59
60 void InsetMathString::maple(MapleStream & os) const
61 {
62         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
63                 os << ' ' << str_ << ' ';
64                 return;
65         }
66
67         // insert '*' between adjacent chars if type is LM_TC_VAR
68         os << str_[0];
69         for (string::size_type i = 1; i < str_.size(); ++i)
70                 os << str_[i];
71 }
72
73
74 void InsetMathString::mathematica(MathematicaStream & os) const
75 {
76         os << ' ' << str_ << ' ';
77 }
78
79
80 void InsetMathString::octave(OctaveStream & os) const
81 {
82         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
83                 os << ' ' << str_ << ' ';
84                 return;
85         }
86
87         // insert '*' between adjacent chars if type is LM_TC_VAR
88         os << str_[0];
89         for (string::size_type i = 1; i < str_.size(); ++i)
90                 os << str_[i];
91 }
92
93
94 void InsetMathString::mathmlize(MathMLStream & os) const
95 {
96 /*
97         if (code_ == LM_TC_VAR)
98                 os << "<mi> " << str_ << " </mi>";
99         else if (code_ == LM_TC_CONST)
100                 os << "<mn> " << str_ << " </mn>";
101         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
102                 os << "<mtext> " << str_ <<  " </mtext>";
103         else
104 */
105                 os << str_;
106 }
107
108
109 void InsetMathString::write(WriteStream & os) const
110 {
111         os << str_;
112 }
113
114
115 } // namespace lyx