]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.cpp
#include cosmetics
[lyx.git] / src / mathed / InsetMath.cpp
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.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMath.h"
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "gettext.h"
18 #include "debug.h"
19
20 #include "support/docstream.h"
21 #include "support/lstrings.h"
22 #include "support/textutils.h"
23
24 #include <boost/current_function.hpp>
25 #include <boost/assert.hpp>
26
27 using std::endl;
28
29 namespace lyx {
30
31
32
33 MathData & InsetMath::cell(idx_type)
34 {
35         static MathData dummyCell;
36         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
37         return dummyCell;
38 }
39
40
41 MathData const & InsetMath::cell(idx_type) const
42 {
43         static MathData dummyCell;
44         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
45         return dummyCell;
46 }
47
48
49 void InsetMath::dump() const
50 {
51         lyxerr << "---------------------------------------------" << endl;
52         odocstringstream os;
53         WriteStream wi(os, false, true);
54         write(wi);
55         lyxerr << to_utf8(os.str());
56         lyxerr << "\n---------------------------------------------" << endl;
57 }
58
59
60 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
61 {
62         lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
63 }
64
65
66 void InsetMath::drawT(TextPainter &, int, int) const
67 {
68         lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
69 }
70
71
72 void InsetMath::write(WriteStream & os) const
73 {
74         docstring const s = name();
75         os << "\\" << s;
76         // We need an extra ' ' unless this is a single-char-non-ASCII name
77         // or anything non-ASCII follows
78         if (s.size() != 1 || isAlphaASCII(s[0]))
79                 os.pendingSpace(true);
80 }
81
82
83 int InsetMath::plaintext(Buffer const &, odocstream &,
84                          OutputParams const &) const
85 {
86         // all math plain text output shall take place in InsetMathHull
87         BOOST_ASSERT(false);
88         return 0;
89 }
90
91
92 void InsetMath::normalize(NormalStream & os) const
93 {
94         os << '[' << name() << "] ";
95 }
96
97
98 void InsetMath::octave(OctaveStream & os) const
99 {
100         NormalStream ns(os.os());
101         normalize(ns);
102 }
103
104
105 void InsetMath::maple(MapleStream & os) const
106 {
107         NormalStream ns(os.os());
108         normalize(ns);
109 }
110
111
112 void InsetMath::maxima(MaximaStream & os) const
113 {
114         MapleStream ns(os.os());
115         maple(ns);
116 }
117
118
119 void InsetMath::mathematica(MathematicaStream & os) const
120 {
121         NormalStream ns(os.os());
122         normalize(ns);
123 }
124
125
126 void InsetMath::mathmlize(MathStream & os) const
127 {
128         NormalStream ns(os.os());
129         normalize(ns);
130 }
131
132
133 HullType InsetMath::getType() const
134 {
135         return hullNone;
136 }
137
138
139 std::ostream & operator<<(std::ostream & os, MathAtom const & at)
140 {
141         odocstringstream oss;
142         WriteStream wi(oss, false, false);
143         at->write(wi);
144         return os << to_utf8(oss.str());
145 }
146
147
148 odocstream & operator<<(odocstream & os, MathAtom const & at)
149 {
150         WriteStream wi(os, false, false);
151         at->write(wi);
152         return os;
153 }
154
155
156 } // namespace lyx