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