7 #include "math_arrayinset.h"
8 #include "math_parser.h"
9 #include "math_mathmlstream.h"
13 using std::istringstream;
17 MathArrayInset::MathArrayInset(int m, int n)
22 MathArrayInset::MathArrayInset(int m, int n, char valign, string const & halign)
23 : MathGridInset(m, n, valign, halign)
27 MathArrayInset::MathArrayInset(char valign, string const & halign)
28 : MathGridInset(valign, halign)
32 MathArrayInset::MathArrayInset(string const & str)
35 vector< vector<string> > dat;
36 istringstream is(str.c_str());
40 istringstream ls(line.c_str());
41 typedef std::istream_iterator<string> iter;
42 vector<string> v = vector<string>(iter(ls), iter());
47 for (row_type row = 1; row < dat.size(); ++row)
49 for (col_type col = 1; col < dat[0].size(); ++col)
51 for (row_type row = 0; row < dat.size(); ++row)
52 for (col_type col = 0; col < dat[row].size(); ++col)
53 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
57 MathInset * MathArrayInset::clone() const
59 return new MathArrayInset(*this);
63 void MathArrayInset::metrics(MathMetricsInfo const & st) const
65 MathMetricsInfo mi = st;
66 if (mi.style == LM_ST_DISPLAY)
67 mi.style = LM_ST_TEXT;
68 MathGridInset::metrics(mi);
72 void MathArrayInset::write(WriteStream & os) const
76 os << "\\begin{array}";
78 if (v_align_ == 't' || v_align_ == 'b')
79 os << '[' << char(v_align_) << ']';
80 os << '{' << halign().c_str() << "}\n";
82 MathGridInset::write(os);
86 os << "\\end{array}\n";
90 void MathArrayInset::normalize(NormalStream & os) const
93 MathGridInset::normalize(os);
98 void MathArrayInset::maplize(MapleStream & os) const
101 MathGridInset::maplize(os);