7 #include "math_stringinset.h"
8 #include "math_mathmlstream.h"
9 #include "math_streamstr.h"
12 #include "math_support.h"
13 #include "math_parser.h"
14 #include "LaTeXFeatures.h"
20 MathStringInset::MathStringInset()
21 : str_(), code_(LM_TC_MIN)
24 MathStringInset::MathStringInset(string const & s, MathTextCodes t)
29 MathInset * MathStringInset::clone() const
31 return new MathStringInset(*this);
35 int MathStringInset::ascent() const
37 return mathed_string_ascent(code_, mi_, str_);
41 int MathStringInset::descent() const
43 return mathed_string_descent(code_, mi_, str_);
47 int MathStringInset::width() const
49 return mathed_string_width(code_, mi_, str_);
52 void MathStringInset::validate(LaTeXFeatures & features) const
54 //lyxerr << "stringinset amssymb" << endl;
55 if (code_ == LM_TC_MSA || code_ == LM_TC_MSB)
56 features.require("amssymb");
59 void MathStringInset::metrics(MathMetricsInfo const & mi) const
65 void MathStringInset::draw(Painter & pain, int x, int y) const
67 //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
68 drawStr(pain, code_, mi_, x, y, str_);
72 void MathStringInset::normalize(NormalStream & os) const
74 os << "[string " << str_ << ' ' << "mathalpha" << "]";
78 void MathStringInset::maplize(MapleStream & os) const
80 if (code_ != LM_TC_VAR || str_.size() <= 1) {
81 os << ' ' << str_ << ' ';
85 // insert '*' between adjacent chars if type is LM_TC_VAR
87 for (string::size_type i = 1; i < str_.size(); ++i)
92 void MathStringInset::octavize(OctaveStream & os) const
94 if (code_ != LM_TC_VAR || str_.size() <= 1) {
95 os << ' ' << str_ << ' ';
99 // insert '*' between adjacent chars if type is LM_TC_VAR
101 for (string::size_type i = 1; i < str_.size(); ++i)
102 os << '*' << str_[i];
106 void MathStringInset::mathmlize(MathMLStream & os) const
108 if (code_ == LM_TC_VAR)
109 os << "<mi> " << str_ << " </mi>";
110 else if (code_ == LM_TC_CONST)
111 os << "<mn> " << str_ << " </mn>";
112 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
113 os << "<mtext> " << str_ << " </mtext>";
119 void MathStringInset::write(WriteStream & os) const
121 if (math_font_name(code_))
122 os << '\\' << math_font_name(code_) << '{' << str_ << '}';