7 #include "math_arrayinset.h"
8 #include "math_parser.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
16 using std::istringstream;
20 MathArrayInset::MathArrayInset(int m, int n)
25 MathArrayInset::MathArrayInset(int m, int n, char valign, string const & halign)
26 : MathGridInset(m, n, valign, halign)
30 MathArrayInset::MathArrayInset(char valign, string const & halign)
31 : MathGridInset(valign, halign)
35 MathArrayInset::MathArrayInset(string const & str)
38 vector< vector<string> > dat;
39 istringstream is(str.c_str());
43 istringstream ls(line.c_str());
44 typedef std::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[row].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(MathMetricsInfo const & st) const
68 MathMetricsInfo mi = st;
69 if (mi.style == LM_ST_DISPLAY)
70 mi.style = LM_ST_TEXT;
71 MathGridInset::metrics(mi);
75 void MathArrayInset::write(WriteStream & os) const
79 os << "\\begin{array}";
81 if (v_align_ == 't' || v_align_ == 'b')
82 os << '[' << char(v_align_) << ']';
83 os << '{' << halign() << "}\n";
85 MathGridInset::write(os);
89 os << "\\end{array}\n";
93 void MathArrayInset::normalize(NormalStream & os) const
96 MathGridInset::normalize(os);
101 void MathArrayInset::maplize(MapleStream & os) const
104 MathGridInset::maplize(os);