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"
26 using std::istringstream;
27 using std::istream_iterator;
31 MathArrayInset::MathArrayInset(string const & name, int m, int n)
32 : MathGridInset(m, n), name_(name)
36 MathArrayInset::MathArrayInset(string const & name, int m, int n,
37 char valign, string const & halign)
38 : MathGridInset(m, n, valign, halign), name_(name)
42 MathArrayInset::MathArrayInset(string const & name, char valign,
43 string const & halign)
44 : MathGridInset(valign, halign), name_(name)
48 MathArrayInset::MathArrayInset(string const & name, string const & str)
49 : MathGridInset(1, 1), name_(name)
51 vector< vector<string> > dat;
52 istringstream is(str);
54 while (getline(is, line)) {
55 istringstream ls(line);
56 typedef istream_iterator<string> iter;
57 vector<string> v = vector<string>(iter(ls), iter());
62 for (row_type row = 1; row < dat.size(); ++row)
64 for (col_type col = 1; col < dat[0].size(); ++col)
66 for (row_type row = 0; row < dat.size(); ++row)
67 for (col_type col = 0; col < dat[0].size(); ++col)
68 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
72 auto_ptr<InsetBase> MathArrayInset::clone() const
74 return auto_ptr<InsetBase>(new MathArrayInset(*this));
78 void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
80 ArrayChanger dummy(mi.base);
81 MathGridInset::metrics(mi);
87 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
89 ArrayChanger dummy(pi.base);
90 MathGridInset::draw(pi, x + 1, y);
91 drawMarkers2(pi, x, y);
95 void MathArrayInset::write(WriteStream & os) const
99 os << "\\begin{" << name_ << '}';
101 if (v_align_ == 't' || v_align_ == 'b')
102 os << '[' << char(v_align_) << ']';
103 os << '{' << halign() << "}\n";
105 MathGridInset::write(os);
109 os << "\\end{" << name_ << '}';
110 // adding a \n here is bad if the array is the last item
111 // in an \eqnarray...
115 void MathArrayInset::infoize(std::ostream & os) const
121 void MathArrayInset::normalize(NormalStream & os) const
123 os << '[' << name_ << ' ';
124 MathGridInset::normalize(os);
129 void MathArrayInset::maple(MapleStream & os) const
132 MathGridInset::maple(os);