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 "MetricsInfo.h"
21 #include "support/debug.h"
22 #include "support/docstream.h"
23 #include "support/gettext.h"
24 #include "support/lassert.h"
25 #include "support/lstrings.h"
26 #include "support/textutils.h"
33 docstring InsetMath::name() const
35 return from_utf8("Unknown");
39 MathData & InsetMath::cell(idx_type)
41 static MathData dummyCell(&buffer());
42 LYXERR0("I don't have any cell");
47 MathData const & InsetMath::cell(idx_type) const
49 static MathData dummyCell;
50 LYXERR0("I don't have any cell");
55 MathClass InsetMath::mathClass() const
61 bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
63 MathRow::Element e(MathRow::INSET, mi);
65 e.mclass = mathClass();
70 void InsetMath::metricsMarkers(MetricsInfo & mi, Dimension & dim,
73 if (!mi.base.macro_nesting)
74 Inset::metricsMarkers(dim, framesize);
78 void InsetMath::metricsMarkers2(MetricsInfo & mi, Dimension & dim,
81 if (!mi.base.macro_nesting)
82 Inset::metricsMarkers2(dim, framesize);
86 void InsetMath::drawMarkers(PainterInfo & pi, int x, int y) const
88 if (!pi.base.macro_nesting)
89 Inset::drawMarkers(pi, x, y);
93 void InsetMath::drawMarkers2(PainterInfo & pi, int x, int y) const
95 if (!pi.base.macro_nesting)
96 Inset::drawMarkers2(pi, x, y);
101 void InsetMath::dump() const
103 lyxerr << "---------------------------------------------" << endl;
105 otexrowstream ots(os);
106 WriteStream wi(ots, false, true, WriteStream::wsDefault);
108 lyxerr << to_utf8(os.str());
109 lyxerr << "\n---------------------------------------------" << endl;
113 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
115 LYXERR0("InsetMath::metricsT(Text) called directly!");
119 void InsetMath::drawT(TextPainter &, int, int) const
121 LYXERR0("InsetMath::drawT(Text) called directly!");
125 void InsetMath::write(WriteStream & os) const
127 MathEnsurer ensurer(os);
128 docstring const s = name();
130 // We need an extra ' ' unless this is a single-char-non-ASCII name
131 // or anything non-ASCII follows
132 if (s.size() != 1 || isAlphaASCII(s[0]))
133 os.pendingSpace(true);
137 int InsetMath::plaintext(odocstringstream &,
138 OutputParams const &, size_t) const
140 // all math plain text output shall take place in InsetMathHull
146 void InsetMath::normalize(NormalStream & os) const
148 os << '[' << name() << "] ";
152 void InsetMath::octave(OctaveStream & os) const
154 NormalStream ns(os.os());
159 void InsetMath::maple(MapleStream & os) const
161 NormalStream ns(os.os());
166 void InsetMath::maxima(MaximaStream & os) const
168 MapleStream ns(os.os());
173 void InsetMath::mathematica(MathematicaStream & os) const
175 NormalStream ns(os.os());
180 void InsetMath::mathmlize(MathStream & os) const
182 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
184 NormalStream ns(os.os());
190 void InsetMath::htmlize(HtmlStream & os) const
192 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
193 os << MTag("span", "style='color: red;'");
194 NormalStream ns(os.os());
200 HullType InsetMath::getType() const
206 ostream & operator<<(ostream & os, MathAtom const & at)
208 odocstringstream oss;
209 otexrowstream ots(oss);
210 WriteStream wi(ots, false, false, WriteStream::wsDefault);
212 return os << to_utf8(oss.str());
216 odocstream & operator<<(odocstream & os, MathAtom const & at)
218 otexrowstream ots(os);
219 WriteStream wi(ots, false, false, WriteStream::wsDefault);