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 InsetMath::marker_type InsetMath::marker(BufferView const *) const
63 return nargs() > 0 ? MARKER : NO_MARKER;
67 bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
69 MathRow::Element e(mi, MathRow::INSET, mathClass());
71 e.marker = mi.base.macro_nesting ? NO_MARKER : marker(mi.base.bv);
77 void InsetMath::dump() const
79 lyxerr << "---------------------------------------------" << endl;
81 otexrowstream ots(os);
82 WriteStream wi(ots, false, true, WriteStream::wsDefault);
84 lyxerr << to_utf8(os.str());
85 lyxerr << "\n---------------------------------------------" << endl;
89 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
91 LYXERR0("InsetMath::metricsT(Text) called directly!");
95 void InsetMath::drawT(TextPainter &, int, int) const
97 LYXERR0("InsetMath::drawT(Text) called directly!");
101 void InsetMath::write(WriteStream & os) const
103 MathEnsurer ensurer(os);
104 docstring const s = name();
106 // We need an extra ' ' unless this is a single-char-non-ASCII name
107 // or anything non-ASCII follows
108 if (s.size() != 1 || isAlphaASCII(s[0]))
109 os.pendingSpace(true);
113 int InsetMath::plaintext(odocstringstream &,
114 OutputParams const &, size_t) const
116 // all math plain text output shall take place in InsetMathHull
122 void InsetMath::normalize(NormalStream & os) const
124 os << '[' << name() << "] ";
128 void InsetMath::octave(OctaveStream & os) const
130 NormalStream ns(os.os());
135 void InsetMath::maple(MapleStream & os) const
137 NormalStream ns(os.os());
142 void InsetMath::maxima(MaximaStream & os) const
144 MapleStream ns(os.os());
149 void InsetMath::mathematica(MathematicaStream & os) const
151 NormalStream ns(os.os());
156 void InsetMath::mathmlize(MathStream & os) const
158 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
160 NormalStream ns(os.os());
166 void InsetMath::htmlize(HtmlStream & os) const
168 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
169 os << MTag("span", "style='color: red;'");
170 NormalStream ns(os.os());
176 HullType InsetMath::getType() const
182 ostream & operator<<(ostream & os, MathAtom const & at)
184 odocstringstream oss;
185 otexrowstream ots(oss);
186 WriteStream wi(ots, false, false, WriteStream::wsDefault);
188 return os << to_utf8(oss.str());
192 odocstream & operator<<(odocstream & os, MathAtom const & at)
194 otexrowstream ots(os);
195 WriteStream wi(ots, false, false, WriteStream::wsDefault);