]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathString.cpp
revert last patch. there's something wrong, possibly unrelated to this
[lyx.git] / src / mathed / InsetMathString.cpp
1 /**
2  * \file InsetMathString.cpp
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 "MathStream.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18
19 namespace lyx {
20
21 InsetMathString::InsetMathString(docstring const & s)
22         : str_(s)
23 {}
24
25
26 Inset * InsetMathString::clone() const
27 {
28         return new InsetMathString(*this);
29 }
30
31
32 void InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const
33 {
34         mathed_string_dim(mi.base.font, str_, dim);
35 }
36
37
38 void InsetMathString::draw(PainterInfo & pi, int x, int y) const
39 {
40         pi.draw(x, y, str_);
41 }
42
43
44 void InsetMathString::normalize(NormalStream & os) const
45 {
46         os << "[string " << str_ << ' ' << "mathalpha" << ']';
47 }
48
49
50 void InsetMathString::maple(MapleStream & os) const
51 {
52         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
53                 os << ' ' << str_ << ' ';
54                 return;
55         }
56
57         // insert '*' between adjacent chars if type is LM_TC_VAR
58         os << str_[0];
59         for (size_t i = 1; i < str_.size(); ++i)
60                 os << str_[i];
61 }
62
63
64 void InsetMathString::mathematica(MathematicaStream & os) const
65 {
66         os << ' ' << str_ << ' ';
67 }
68
69
70 void InsetMathString::octave(OctaveStream & os) const
71 {
72         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
73                 os << ' ' << str_ << ' ';
74                 return;
75         }
76
77         // insert '*' between adjacent chars if type is LM_TC_VAR
78         os << str_[0];
79         for (size_t i = 1; i < str_.size(); ++i)
80                 os << str_[i];
81 }
82
83
84 void InsetMathString::mathmlize(MathStream & os) const
85 {
86 /*
87         if (code_ == LM_TC_VAR)
88                 os << "<mi> " << str_ << " </mi>";
89         else if (code_ == LM_TC_CONST)
90                 os << "<mn> " << str_ << " </mn>";
91         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
92                 os << "<mtext> " << str_ <<  " </mtext>";
93         else
94 */
95                 os << str_;
96 }
97
98
99 void InsetMathString::write(WriteStream & os) const
100 {
101         os << str_;
102 }
103
104
105 } // namespace lyx