A bit more re-organization.
[lyx.git] / src / mathed / InsetMath.cpp
blob51b4deee709e484cf55c3411e111ba0a83d18461
1 /**
2 * \file InsetMath.cpp
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
7 * \author André Pönitz
9 * Full author contact details are available in file CREDITS.
12 #include <config.h>
14 #include "InsetMath.h"
15 #include "MathData.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"
26 using namespace std;
28 namespace lyx {
30 MathData & InsetMath::cell(idx_type)
32 static MathData dummyCell(&buffer());
33 LYXERR0("I don't have any cell");
34 return dummyCell;
38 MathData const & InsetMath::cell(idx_type) const
40 static MathData dummyCell;
41 LYXERR0("I don't have any cell");
42 return dummyCell;
46 void InsetMath::dump() const
48 lyxerr << "---------------------------------------------" << endl;
49 odocstringstream os;
50 WriteStream wi(os, false, true, WriteStream::wsDefault);
51 write(wi);
52 lyxerr << to_utf8(os.str());
53 lyxerr << "\n---------------------------------------------" << endl;
57 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
59 LYXERR0("InsetMath::metricsT(Text) called directly!");
63 void InsetMath::drawT(TextPainter &, int, int) const
65 LYXERR0("InsetMath::drawT(Text) called directly!");
69 void InsetMath::write(WriteStream & os) const
71 MathEnsurer ensurer(os);
72 docstring const s = name();
73 os << "\\" << s;
74 // We need an extra ' ' unless this is a single-char-non-ASCII name
75 // or anything non-ASCII follows
76 if (s.size() != 1 || isAlphaASCII(s[0]))
77 os.pendingSpace(true);
81 int InsetMath::plaintext(odocstream &, OutputParams const &) const
83 // all math plain text output shall take place in InsetMathHull
84 LASSERT(false, /**/);
85 return 0;
89 void InsetMath::normalize(NormalStream & os) const
91 os << '[' << name() << "] ";
95 void InsetMath::octave(OctaveStream & os) const
97 NormalStream ns(os.os());
98 normalize(ns);
102 void InsetMath::maple(MapleStream & os) const
104 NormalStream ns(os.os());
105 normalize(ns);
109 void InsetMath::maxima(MaximaStream & os) const
111 MapleStream ns(os.os());
112 maple(ns);
116 void InsetMath::mathematica(MathematicaStream & os) const
118 NormalStream ns(os.os());
119 normalize(ns);
123 void InsetMath::mathmlize(MathStream & os) const
125 NormalStream ns(os.os());
126 normalize(ns);
130 HullType InsetMath::getType() const
132 return hullNone;
136 ostream & operator<<(ostream & os, MathAtom const & at)
138 odocstringstream oss;
139 WriteStream wi(oss, false, false, WriteStream::wsDefault);
140 at->write(wi);
141 return os << to_utf8(oss.str());
145 odocstream & operator<<(odocstream & os, MathAtom const & at)
147 WriteStream wi(os, false, false, WriteStream::wsDefault);
148 at->write(wi);
149 return os;
153 } // namespace lyx