]> git.lyx.org Git - lyx.git/blob - src/mathed/math_tabularinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_tabularinset.C
1 #include <config.h>
2
3
4 #include "math_tabularinset.h"
5 #include "math_parser.h"
6 #include "math_mathmlstream.h"
7 #include "metricsinfo.h"
8 #include "math_streamstr.h"
9 #include "Lsstream.h"
10
11 #include <iterator>
12
13 using std::vector;
14 using std::istringstream;
15 using std::getline;
16 using std::istream_iterator;
17 using std::auto_ptr;
18
19
20 MathTabularInset::MathTabularInset(string const & name, int m, int n)
21         : MathGridInset(m, n), name_(name)
22 {}
23
24
25 MathTabularInset::MathTabularInset(string const & name, int m, int n,
26                 char valign, string const & halign)
27         : MathGridInset(m, n, valign, halign), name_(name)
28 {}
29
30
31 MathTabularInset::MathTabularInset(string const & name, char valign,
32                 string const & halign)
33         : MathGridInset(valign, halign), name_(name)
34 {}
35
36
37 auto_ptr<InsetBase> MathTabularInset::clone() const
38 {
39         return auto_ptr<InsetBase>(new MathTabularInset(*this));
40 }
41
42
43 void MathTabularInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
44 {
45         FontSetChanger dummy(mi.base, "textnormal");
46         return MathGridInset::metrics(mi);
47 }
48
49
50 void MathTabularInset::draw(PainterInfo & pi, int x, int y) const
51 {
52         FontSetChanger dummy(pi.base, "textnormal");
53         MathGridInset::draw(pi, x, y);
54 }
55
56
57 void MathTabularInset::write(WriteStream & os) const
58 {
59         if (os.fragile())
60                 os << "\\protect";
61         os << "\\begin{" << name_ << '}';
62
63         if (v_align_ == 't' || v_align_ == 'b')
64                 os << '[' << char(v_align_) << ']';
65         os << '{' << halign() << "}\n";
66
67         MathGridInset::write(os);
68
69         if (os.fragile())
70                 os << "\\protect";
71         os << "\\end{" << name_ << '}';
72         // adding a \n here is bad if the tabular is the last item
73         // in an \eqnarray...
74 }
75
76
77 void MathTabularInset::normalize(NormalStream & os) const
78 {
79         os << '[' << name_ << ' ';
80         MathGridInset::normalize(os);
81         os << ']';
82 }
83
84
85 void MathTabularInset::maple(MapleStream & os) const
86 {
87         os << "array(";
88         MathGridInset::maple(os);
89         os << ')';
90 }