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(STRCONV(str));
42 while (getline(is, line)) {
43 istringstream ls(STRCONV(line));
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 InsetBase * MathArrayInset::clone() const
62 return new MathArrayInset(*this);
66 void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
68 ArrayChanger dummy(mi.base);
69 MathGridInset::metrics(mi);
75 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
77 ArrayChanger dummy(pi.base);
78 MathGridInset::draw(pi, x + 1, y);
79 drawMarkers2(pi, x, y);
83 void MathArrayInset::write(WriteStream & os) const
87 os << "\\begin{" << name_ << '}';
89 if (v_align_ == 't' || v_align_ == 'b')
90 os << '[' << char(v_align_) << ']';
91 os << '{' << halign() << "}\n";
93 MathGridInset::write(os);
97 os << "\\end{" << name_ << '}';
98 // adding a \n here is bad if the array is the last item
103 void MathArrayInset::infoize(std::ostream & os) const
109 void MathArrayInset::normalize(NormalStream & os) const
111 os << '[' << name_ << ' ';
112 MathGridInset::normalize(os);
117 void MathArrayInset::maple(MapleStream & os) const
120 MathGridInset::maple(os);