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 void InsetMath::dump() const
54 lyxerr << "---------------------------------------------" << endl;
57 otexrowstream ots(os,texrow);
58 WriteStream wi(ots, false, true, WriteStream::wsDefault);
60 lyxerr << to_utf8(os.str());
61 lyxerr << "\n---------------------------------------------" << endl;
65 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
67 LYXERR0("InsetMath::metricsT(Text) called directly!");
71 void InsetMath::drawT(TextPainter &, int, int) const
73 LYXERR0("InsetMath::drawT(Text) called directly!");
77 void InsetMath::write(WriteStream & os) const
79 MathEnsurer ensurer(os);
80 docstring const s = name();
82 // We need an extra ' ' unless this is a single-char-non-ASCII name
83 // or anything non-ASCII follows
84 if (s.size() != 1 || isAlphaASCII(s[0]))
85 os.pendingSpace(true);
89 int InsetMath::plaintext(odocstringstream &,
90 OutputParams const &, size_t) const
92 // all math plain text output shall take place in InsetMathHull
98 void InsetMath::normalize(NormalStream & os) const
100 os << '[' << name() << "] ";
104 void InsetMath::octave(OctaveStream & os) const
106 NormalStream ns(os.os());
111 void InsetMath::maple(MapleStream & os) const
113 NormalStream ns(os.os());
118 void InsetMath::maxima(MaximaStream & os) const
120 MapleStream ns(os.os());
125 void InsetMath::mathematica(MathematicaStream & os) const
127 NormalStream ns(os.os());
132 void InsetMath::mathmlize(MathStream & os) const
134 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
136 NormalStream ns(os.os());
142 void InsetMath::htmlize(HtmlStream & os) const
144 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
145 os << MTag("span", "style='color: red;'");
146 NormalStream ns(os.os());
152 HullType InsetMath::getType() const
158 ostream & operator<<(ostream & os, MathAtom const & at)
160 odocstringstream oss;
161 TexRow texrow(false);
162 otexrowstream ots(oss,texrow);
163 WriteStream wi(ots, false, false, WriteStream::wsDefault);
165 return os << to_utf8(oss.str());
169 odocstream & operator<<(odocstream & os, MathAtom const & at)
171 TexRow texrow(false);
172 otexrowstream ots(os,texrow);
173 WriteStream wi(ots, false, false, WriteStream::wsDefault);