4 #include "math_arrayinset.h"
5 #include "math_parser.h"
6 #include "math_mathmlstream.h"
7 #include "metricsinfo.h"
8 #include "math_streamstr.h"
14 using std::istringstream;
16 using std::istream_iterator;
19 MathArrayInset::MathArrayInset(string const & name, int m, int n)
20 : MathGridInset(m, n), name_(name)
24 MathArrayInset::MathArrayInset(string const & name, int m, int n,
25 char valign, string const & halign)
26 : MathGridInset(m, n, valign, halign), name_(name)
30 MathArrayInset::MathArrayInset(string const & name, char valign,
31 string const & halign)
32 : MathGridInset(valign, halign), name_(name)
36 MathArrayInset::MathArrayInset(string const & name, string const & str)
37 : MathGridInset(1, 1), name_(name)
39 vector< vector<string> > dat;
40 istringstream is(str.c_str());
42 while (getline(is, line)) {
43 istringstream ls(line.c_str());
44 typedef istream_iterator<string> iter;
45 vector<string> v = vector<string>(iter(ls), iter());
50 for (row_type row = 1; row < dat.size(); ++row)
52 for (col_type col = 1; col < dat[0].size(); ++col)
54 for (row_type row = 0; row < dat.size(); ++row)
55 for (col_type col = 0; col < dat[0].size(); ++col)
56 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
60 MathInset * MathArrayInset::clone() const
62 return new MathArrayInset(*this);
66 void MathArrayInset::metrics(MetricsInfo & mi) const
68 ArrayChanger dummy(mi.base);
69 MathGridInset::metrics(mi);
74 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
76 ArrayChanger dummy(pi.base);
77 MathGridInset::draw(pi, x, y);
78 drawMarkers2(pi, x, y);
82 void MathArrayInset::write(WriteStream & os) const
86 os << "\\begin{" << name_ << '}';
88 if (v_align_ == 't' || v_align_ == 'b')
89 os << '[' << char(v_align_) << ']';
90 os << '{' << halign() << "}\n";
92 MathGridInset::write(os);
96 os << "\\end{" << name_ << '}';
97 // adding a \n here is bad if the array is the last item
102 void MathArrayInset::infoize(std::ostream & os) const
108 void MathArrayInset::normalize(NormalStream & os) const
110 os << '[' << name_ << ' ';
111 MathGridInset::normalize(os);
116 void MathArrayInset::maple(MapleStream & os) const
119 MathGridInset::maple(os);