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 WriteStream wi(os, false, true, WriteStream::wsDefault);
58 lyxerr << to_utf8(os.str());
59 lyxerr << "\n---------------------------------------------" << endl;
63 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
65 LYXERR0("InsetMath::metricsT(Text) called directly!");
69 void InsetMath::drawT(TextPainter &, int, int) const
71 LYXERR0("InsetMath::drawT(Text) called directly!");
75 void InsetMath::write(WriteStream & os) const
77 MathEnsurer ensurer(os);
78 docstring const s = name();
80 // We need an extra ' ' unless this is a single-char-non-ASCII name
81 // or anything non-ASCII follows
82 if (s.size() != 1 || isAlphaASCII(s[0]))
83 os.pendingSpace(true);
87 int InsetMath::plaintext(odocstream &, OutputParams const &) const
89 // all math plain text output shall take place in InsetMathHull
95 void InsetMath::normalize(NormalStream & os) const
97 os << '[' << name() << "] ";
101 void InsetMath::octave(OctaveStream & os) const
103 NormalStream ns(os.os());
108 void InsetMath::maple(MapleStream & os) const
110 NormalStream ns(os.os());
115 void InsetMath::maxima(MaximaStream & os) const
117 MapleStream ns(os.os());
122 void InsetMath::mathematica(MathematicaStream & os) const
124 NormalStream ns(os.os());
129 void InsetMath::mathmlize(MathStream & os) const
131 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
133 NormalStream ns(os.os());
139 void InsetMath::htmlize(HtmlStream & os) const
141 os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
142 os << MTag("span", "style='color: red;'");
143 NormalStream ns(os.os());
149 HullType InsetMath::getType() const
155 ostream & operator<<(ostream & os, MathAtom const & at)
157 odocstringstream oss;
158 WriteStream wi(oss, false, false, WriteStream::wsDefault);
160 return os << to_utf8(oss.str());
164 odocstream & operator<<(odocstream & os, MathAtom const & at)
166 WriteStream wi(os, false, false, WriteStream::wsDefault);