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());
44 while (getline(is, line)) {
45 istringstream ls(line.c_str());
46 typedef istream_iterator<string> iter;
47 vector<string> v = vector<string>(iter(ls), iter());
52 for (row_type row = 1; row < dat.size(); ++row)
54 for (col_type col = 1; col < dat[0].size(); ++col)
56 for (row_type row = 0; row < dat.size(); ++row)
57 for (col_type col = 0; col < dat[0].size(); ++col)
58 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
62 MathInset * MathArrayInset::clone() const
64 return new MathArrayInset(*this);
68 void MathArrayInset::metrics(MathMetricsInfo const & st) const
70 MathMetricsInfo mi = st;
71 if (mi.style == LM_ST_DISPLAY)
72 mi.style = LM_ST_TEXT;
73 MathGridInset::metrics(mi);
77 void MathArrayInset::write(WriteStream & os) const
81 os << "\\begin{" << name_ << "}";
83 if (v_align_ == 't' || v_align_ == 'b')
84 os << '[' << char(v_align_) << ']';
85 os << '{' << halign() << "}\n";
87 MathGridInset::write(os);
91 os << "\\end{" << name_ << "}\n";
95 void MathArrayInset::normalize(NormalStream & os) const
97 os << "[" << name_ << " ";
98 MathGridInset::normalize(os);
103 void MathArrayInset::maplize(MapleStream & os) const
106 MathGridInset::maplize(os);