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"
16 #include "MathStream.h"
18 #include "support/debug.h"
19 #include "support/docstream.h"
20 #include "support/gettext.h"
21 #include "support/lstrings.h"
22 #include "support/textutils.h"
24 #include "support/lassert.h"
30 docstring InsetMath::name() const
32 return from_utf8("Unknown");
36 MathData & InsetMath::cell(idx_type)
38 static MathData dummyCell(&buffer());
39 LYXERR0("I don't have any cell");
44 MathData const & InsetMath::cell(idx_type) const
46 static MathData dummyCell;
47 LYXERR0("I don't have any cell");
52 MathClass InsetMath::mathClass() const
58 void InsetMath::dump() const
60 lyxerr << "---------------------------------------------" << endl;
62 otexrowstream ots(os);
63 WriteStream wi(ots, false, true, WriteStream::wsDefault);
65 lyxerr << to_utf8(os.str());
66 lyxerr << "\n---------------------------------------------" << endl;
70 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
72 LYXERR0("InsetMath::metricsT(Text) called directly!");
76 void InsetMath::drawT(TextPainter &, int, int) const
78 LYXERR0("InsetMath::drawT(Text) called directly!");
82 void InsetMath::write(WriteStream & os) const
84 MathEnsurer ensurer(os);
85 docstring const s = name();
87 // We need an extra ' ' unless this is a single-char-non-ASCII name
88 // or anything non-ASCII follows
89 if (s.size() != 1 || isAlphaASCII(s[0]))
90 os.pendingSpace(true);
94 int InsetMath::plaintext(odocstringstream &,
95 OutputParams const &, size_t) const
97 // all math plain text output shall take place in InsetMathHull
103 void InsetMath::normalize(NormalStream & os) const
105 os << '[' << name() << "] ";
109 void InsetMath::octave(OctaveStream & os) const
111 NormalStream ns(os.os());
116 void InsetMath::maple(MapleStream & os) const
118 NormalStream ns(os.os());
123 void InsetMath::maxima(MaximaStream & os) const
125 MapleStream ns(os.os());
130 void InsetMath::mathematica(MathematicaStream & os) const
132 NormalStream ns(os.os());
137 void InsetMath::mathmlize(MathStream & os) const
139 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
141 NormalStream ns(os.os());
147 void InsetMath::htmlize(HtmlStream & os) const
149 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
150 os << MTag("span", "style='color: red;'");
151 NormalStream ns(os.os());
157 HullType InsetMath::getType() const
163 ostream & operator<<(ostream & os, MathAtom const & at)
165 odocstringstream oss;
166 otexrowstream ots(oss);
167 WriteStream wi(ots, false, false, WriteStream::wsDefault);
169 return os << to_utf8(oss.str());
173 odocstream & operator<<(odocstream & os, MathAtom const & at)
175 otexrowstream ots(os);
176 WriteStream wi(ots, false, false, WriteStream::wsDefault);