7 #include "math_arrayinset.h"
8 #include "math_parser.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
16 using std::istringstream;
18 using std::istream_iterator;
21 MathArrayInset::MathArrayInset(string const & name, int m, int n)
22 : MathGridInset(m, n), name_(name)
26 MathArrayInset::MathArrayInset(string const & name, int m, int n,
27 char valign, string const & halign)
28 : MathGridInset(m, n, valign, halign), name_(name)
32 MathArrayInset::MathArrayInset(string const & name, char valign,
33 string const & halign)
34 : MathGridInset(valign, halign), name_(name)
38 MathArrayInset::MathArrayInset(string const & name, string const & str)
39 : MathGridInset(1, 1), name_(name)
41 vector< vector<string> > dat;
42 istringstream is(str.c_str());
46 istringstream ls(line.c_str());
47 typedef istream_iterator<string> iter;
48 vector<string> v = vector<string>(iter(ls), iter());
53 for (row_type row = 1; row < dat.size(); ++row)
55 for (col_type col = 1; col < dat[0].size(); ++col)
57 for (row_type row = 0; row < dat.size(); ++row)
58 for (col_type col = 0; col < dat[0].size(); ++col)
59 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
63 MathInset * MathArrayInset::clone() const
65 return new MathArrayInset(*this);
69 void MathArrayInset::metrics(MathMetricsInfo const & st) const
71 MathMetricsInfo mi = st;
72 if (mi.style == LM_ST_DISPLAY)
73 mi.style = LM_ST_TEXT;
74 MathGridInset::metrics(mi);
78 void MathArrayInset::write(WriteStream & os) const
82 os << "\\begin{" << name_ << "}";
84 if (v_align_ == 't' || v_align_ == 'b')
85 os << '[' << char(v_align_) << ']';
86 os << '{' << halign() << "}\n";
88 MathGridInset::write(os);
92 os << "\\end{" << name_ << "}\n";
96 void MathArrayInset::normalize(NormalStream & os) const
98 os << "[" << name_ << " ";
99 MathGridInset::normalize(os);
104 void MathArrayInset::maplize(MapleStream & os) const
107 MathGridInset::maplize(os);