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;
56 otexrowstream ots(os, false);
57 WriteStream wi(ots, false, true, WriteStream::wsDefault);
59 lyxerr << to_utf8(os.str());
60 lyxerr << "\n---------------------------------------------" << endl;
64 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
66 LYXERR0("InsetMath::metricsT(Text) called directly!");
70 void InsetMath::drawT(TextPainter &, int, int) const
72 LYXERR0("InsetMath::drawT(Text) called directly!");
76 void InsetMath::write(WriteStream & os) const
78 MathEnsurer ensurer(os);
79 docstring const s = name();
81 // We need an extra ' ' unless this is a single-char-non-ASCII name
82 // or anything non-ASCII follows
83 if (s.size() != 1 || isAlphaASCII(s[0]))
84 os.pendingSpace(true);
88 int InsetMath::plaintext(odocstringstream &,
89 OutputParams const &, size_t) const
91 // all math plain text output shall take place in InsetMathHull
97 void InsetMath::normalize(NormalStream & os) const
99 os << '[' << name() << "] ";
103 void InsetMath::octave(OctaveStream & os) const
105 NormalStream ns(os.os());
110 void InsetMath::maple(MapleStream & os) const
112 NormalStream ns(os.os());
117 void InsetMath::maxima(MaximaStream & os) const
119 MapleStream ns(os.os());
124 void InsetMath::mathematica(MathematicaStream & os) const
126 NormalStream ns(os.os());
131 void InsetMath::mathmlize(MathStream & os) const
133 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
135 NormalStream ns(os.os());
141 void InsetMath::htmlize(HtmlStream & os) const
143 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
144 os << MTag("span", "style='color: red;'");
145 NormalStream ns(os.os());
151 HullType InsetMath::getType() const
157 ostream & operator<<(ostream & os, MathAtom const & at)
159 odocstringstream oss;
160 otexrowstream ots(oss, false);
161 WriteStream wi(ots, false, false, WriteStream::wsDefault);
163 return os << to_utf8(oss.str());
167 odocstream & operator<<(odocstream & os, MathAtom const & at)
169 otexrowstream ots(os, false);
170 WriteStream wi(ots, false, false, WriteStream::wsDefault);