2 * \file math_arrayinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_arrayinset.h"
14 #include "math_data.h"
15 #include "math_parser.h"
16 #include "math_mathmlstream.h"
17 #include "math_streamstr.h"
18 #include "support/std_sstream.h"
25 using std::istringstream;
26 using std::istream_iterator;
30 MathArrayInset::MathArrayInset(string const & name, int m, int n)
31 : MathGridInset(m, n), name_(name)
35 MathArrayInset::MathArrayInset(string const & name, int m, int n,
36 char valign, string const & halign)
37 : MathGridInset(m, n, valign, halign), name_(name)
41 MathArrayInset::MathArrayInset(string const & name, char valign,
42 string const & halign)
43 : MathGridInset(valign, halign), name_(name)
47 MathArrayInset::MathArrayInset(string const & name, string const & str)
48 : MathGridInset(1, 1), name_(name)
50 vector< vector<string> > dat;
51 istringstream is(str);
53 while (getline(is, line)) {
54 istringstream ls(line);
55 typedef istream_iterator<string> iter;
56 vector<string> v = vector<string>(iter(ls), iter());
61 for (row_type row = 1; row < dat.size(); ++row)
63 for (col_type col = 1; col < dat[0].size(); ++col)
65 for (row_type row = 0; row < dat.size(); ++row)
66 for (col_type col = 0; col < dat[0].size(); ++col)
67 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
71 auto_ptr<InsetBase> MathArrayInset::clone() const
73 return auto_ptr<InsetBase>(new MathArrayInset(*this));
77 void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
79 ArrayChanger dummy(mi.base);
80 MathGridInset::metrics(mi);
86 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
88 ArrayChanger dummy(pi.base);
89 MathGridInset::draw(pi, x + 1, y);
90 drawMarkers2(pi, x, y);
94 void MathArrayInset::write(WriteStream & os) const
98 os << "\\begin{" << name_ << '}';
100 if (v_align_ == 't' || v_align_ == 'b')
101 os << '[' << char(v_align_) << ']';
102 os << '{' << halign() << "}\n";
104 MathGridInset::write(os);
108 os << "\\end{" << name_ << '}';
109 // adding a \n here is bad if the array is the last item
110 // in an \eqnarray...
114 void MathArrayInset::infoize(std::ostream & os) const
120 void MathArrayInset::normalize(NormalStream & os) const
122 os << '[' << name_ << ' ';
123 MathGridInset::normalize(os);
128 void MathArrayInset::maple(MapleStream & os) const
131 MathGridInset::maple(os);