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;
20 MathArrayInset::MathArrayInset(string const & name, int m, int n)
21 : MathGridInset(m, n), name_(name)
25 MathArrayInset::MathArrayInset(string const & name, int m, int n,
26 char valign, string const & halign)
27 : MathGridInset(m, n, valign, halign), name_(name)
31 MathArrayInset::MathArrayInset(string const & name, char valign,
32 string const & halign)
33 : MathGridInset(valign, halign), name_(name)
37 MathArrayInset::MathArrayInset(string const & name, string const & str)
38 : MathGridInset(1, 1), name_(name)
40 vector< vector<string> > dat;
41 istringstream is(STRCONV(str));
43 while (getline(is, line)) {
44 istringstream ls(STRCONV(line));
45 typedef istream_iterator<string> iter;
46 vector<string> v = vector<string>(iter(ls), iter());
51 for (row_type row = 1; row < dat.size(); ++row)
53 for (col_type col = 1; col < dat[0].size(); ++col)
55 for (row_type row = 0; row < dat.size(); ++row)
56 for (col_type col = 0; col < dat[0].size(); ++col)
57 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
61 auto_ptr<InsetBase> MathArrayInset::clone() const
63 return auto_ptr<InsetBase>(new MathArrayInset(*this));
67 void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
69 ArrayChanger dummy(mi.base);
70 MathGridInset::metrics(mi);
76 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
78 ArrayChanger dummy(pi.base);
79 MathGridInset::draw(pi, x + 1, y);
80 drawMarkers2(pi, x, y);
84 void MathArrayInset::write(WriteStream & os) const
88 os << "\\begin{" << name_ << '}';
90 if (v_align_ == 't' || v_align_ == 'b')
91 os << '[' << char(v_align_) << ']';
92 os << '{' << halign() << "}\n";
94 MathGridInset::write(os);
98 os << "\\end{" << name_ << '}';
99 // adding a \n here is bad if the array is the last item
100 // in an \eqnarray...
104 void MathArrayInset::infoize(std::ostream & os) const
110 void MathArrayInset::normalize(NormalStream & os) const
112 os << '[' << name_ << ' ';
113 MathGridInset::normalize(os);
118 void MathArrayInset::maple(MapleStream & os) const
121 MathGridInset::maple(os);