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 & ) const
63 MathRow::Element e(MathRow::INSET, mathClass());
69 void InsetMath::metricsMarkers(MetricsInfo & mi, Dimension & dim,
72 if (!mi.base.macro_nesting)
73 Inset::metricsMarkers(dim, framesize);
77 void InsetMath::metricsMarkers2(MetricsInfo & mi, Dimension & dim,
80 if (!mi.base.macro_nesting)
81 Inset::metricsMarkers2(dim, framesize);
85 void InsetMath::drawMarkers(PainterInfo & pi, int x, int y) const
87 if (!pi.base.macro_nesting)
88 Inset::drawMarkers(pi, x, y);
92 void InsetMath::drawMarkers2(PainterInfo & pi, int x, int y) const
94 if (!pi.base.macro_nesting)
95 Inset::drawMarkers2(pi, x, y);
100 void InsetMath::dump() const
102 lyxerr << "---------------------------------------------" << endl;
104 otexrowstream ots(os);
105 WriteStream wi(ots, false, true, WriteStream::wsDefault);
107 lyxerr << to_utf8(os.str());
108 lyxerr << "\n---------------------------------------------" << endl;
112 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
114 LYXERR0("InsetMath::metricsT(Text) called directly!");
118 void InsetMath::drawT(TextPainter &, int, int) const
120 LYXERR0("InsetMath::drawT(Text) called directly!");
124 void InsetMath::write(WriteStream & os) const
126 MathEnsurer ensurer(os);
127 docstring const s = name();
129 // We need an extra ' ' unless this is a single-char-non-ASCII name
130 // or anything non-ASCII follows
131 if (s.size() != 1 || isAlphaASCII(s[0]))
132 os.pendingSpace(true);
136 int InsetMath::plaintext(odocstringstream &,
137 OutputParams const &, size_t) const
139 // all math plain text output shall take place in InsetMathHull
145 void InsetMath::normalize(NormalStream & os) const
147 os << '[' << name() << "] ";
151 void InsetMath::octave(OctaveStream & os) const
153 NormalStream ns(os.os());
158 void InsetMath::maple(MapleStream & os) const
160 NormalStream ns(os.os());
165 void InsetMath::maxima(MaximaStream & os) const
167 MapleStream ns(os.os());
172 void InsetMath::mathematica(MathematicaStream & os) const
174 NormalStream ns(os.os());
179 void InsetMath::mathmlize(MathStream & os) const
181 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
183 NormalStream ns(os.os());
189 void InsetMath::htmlize(HtmlStream & os) const
191 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
192 os << MTag("span", "style='color: red;'");
193 NormalStream ns(os.os());
199 HullType InsetMath::getType() const
205 ostream & operator<<(ostream & os, MathAtom const & at)
207 odocstringstream oss;
208 otexrowstream ots(oss);
209 WriteStream wi(ots, false, false, WriteStream::wsDefault);
211 return os << to_utf8(oss.str());
215 odocstream & operator<<(odocstream & os, MathAtom const & at)
217 otexrowstream ots(os);
218 WriteStream wi(ots, false, false, WriteStream::wsDefault);