3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
9 * Full author contact details are available in file CREDITS.
14 #include "InsetMath.h"
17 #include "MathStream.h"
19 #include "support/debug.h"
20 #include "support/docstream.h"
21 #include "support/gettext.h"
22 #include "support/lstrings.h"
23 #include "support/textutils.h"
25 #include "support/lassert.h"
31 docstring InsetMath::name() const
33 return from_utf8("Unknown");
37 MathData & InsetMath::cell(idx_type)
39 static MathData dummyCell(&buffer());
40 LYXERR0("I don't have any cell");
45 MathData const & InsetMath::cell(idx_type) const
47 static MathData dummyCell;
48 LYXERR0("I don't have any cell");
53 MathClass InsetMath::mathClass() const
59 bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
61 MathRow::Element e(MathRow::INSET, mi);
63 e.mclass = mathClass();
69 void InsetMath::dump() const
71 lyxerr << "---------------------------------------------" << endl;
73 otexrowstream ots(os);
74 WriteStream wi(ots, false, true, WriteStream::wsDefault);
76 lyxerr << to_utf8(os.str());
77 lyxerr << "\n---------------------------------------------" << endl;
81 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
83 LYXERR0("InsetMath::metricsT(Text) called directly!");
87 void InsetMath::drawT(TextPainter &, int, int) const
89 LYXERR0("InsetMath::drawT(Text) called directly!");
93 void InsetMath::write(WriteStream & os) const
95 MathEnsurer ensurer(os);
96 docstring const s = name();
98 // We need an extra ' ' unless this is a single-char-non-ASCII name
99 // or anything non-ASCII follows
100 if (s.size() != 1 || isAlphaASCII(s[0]))
101 os.pendingSpace(true);
105 int InsetMath::plaintext(odocstringstream &,
106 OutputParams const &, size_t) const
108 // all math plain text output shall take place in InsetMathHull
114 void InsetMath::normalize(NormalStream & os) const
116 os << '[' << name() << "] ";
120 void InsetMath::octave(OctaveStream & os) const
122 NormalStream ns(os.os());
127 void InsetMath::maple(MapleStream & os) const
129 NormalStream ns(os.os());
134 void InsetMath::maxima(MaximaStream & os) const
136 MapleStream ns(os.os());
141 void InsetMath::mathematica(MathematicaStream & os) const
143 NormalStream ns(os.os());
148 void InsetMath::mathmlize(MathStream & os) const
150 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
152 NormalStream ns(os.os());
158 void InsetMath::htmlize(HtmlStream & os) const
160 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
161 os << MTag("span", "style='color: red;'");
162 NormalStream ns(os.os());
168 HullType InsetMath::getType() const
174 ostream & operator<<(ostream & os, MathAtom const & at)
176 odocstringstream oss;
177 otexrowstream ots(oss);
178 WriteStream wi(ots, false, false, WriteStream::wsDefault);
180 return os << to_utf8(oss.str());
184 odocstream & operator<<(odocstream & os, MathAtom const & at)
186 otexrowstream ots(os);
187 WriteStream wi(ots, false, false, WriteStream::wsDefault);