2 * \file math_stringinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_stringinset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
16 #include "math_support.h"
24 MathStringInset::MathStringInset(string const & s)
29 auto_ptr<InsetBase> MathStringInset::doClone() const
31 return auto_ptr<InsetBase>(new MathStringInset(*this));
35 void MathStringInset::metrics(MetricsInfo & mi, Dimension & dim) const
37 mathed_string_dim(mi.base.font, str_, dim);
41 void MathStringInset::draw(PainterInfo & pi, int x, int y) const
43 //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
44 docstring dstr(str_.begin(), str_.end());
49 void MathStringInset::normalize(NormalStream & os) const
51 os << "[string " << str_ << ' ' << "mathalpha" << ']';
55 void MathStringInset::maple(MapleStream & os) const
57 if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
58 os << ' ' << str_ << ' ';
62 // insert '*' between adjacent chars if type is LM_TC_VAR
64 for (string::size_type i = 1; i < str_.size(); ++i)
69 void MathStringInset::mathematica(MathematicaStream & os) const
71 os << ' ' << str_ << ' ';
75 void MathStringInset::octave(OctaveStream & os) const
77 if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
78 os << ' ' << str_ << ' ';
82 // insert '*' between adjacent chars if type is LM_TC_VAR
84 for (string::size_type i = 1; i < str_.size(); ++i)
89 void MathStringInset::mathmlize(MathMLStream & os) const
92 if (code_ == LM_TC_VAR)
93 os << "<mi> " << str_ << " </mi>";
94 else if (code_ == LM_TC_CONST)
95 os << "<mn> " << str_ << " </mn>";
96 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
97 os << "<mtext> " << str_ << " </mtext>";
104 void MathStringInset::write(WriteStream & os) const