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_parser.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17 #include "support/std_sstream.h"
22 using std::istringstream;
24 using std::istream_iterator;
28 MathArrayInset::MathArrayInset(string const & name, int m, int n)
29 : MathGridInset(m, n), name_(name)
33 MathArrayInset::MathArrayInset(string const & name, int m, int n,
34 char valign, string const & halign)
35 : MathGridInset(m, n, valign, halign), name_(name)
39 MathArrayInset::MathArrayInset(string const & name, char valign,
40 string const & halign)
41 : MathGridInset(valign, halign), name_(name)
45 MathArrayInset::MathArrayInset(string const & name, string const & str)
46 : MathGridInset(1, 1), name_(name)
48 vector< vector<string> > dat;
49 istringstream is(STRCONV(str));
51 while (getline(is, line)) {
52 istringstream ls(STRCONV(line));
53 typedef istream_iterator<string> iter;
54 vector<string> v = vector<string>(iter(ls), iter());
59 for (row_type row = 1; row < dat.size(); ++row)
61 for (col_type col = 1; col < dat[0].size(); ++col)
63 for (row_type row = 0; row < dat.size(); ++row)
64 for (col_type col = 0; col < dat[0].size(); ++col)
65 mathed_parse_cell(cell(index(row, col)), dat[row][col]);
69 auto_ptr<InsetBase> MathArrayInset::clone() const
71 return auto_ptr<InsetBase>(new MathArrayInset(*this));
75 void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
77 ArrayChanger dummy(mi.base);
78 MathGridInset::metrics(mi);
84 void MathArrayInset::draw(PainterInfo & pi, int x, int y) const
86 ArrayChanger dummy(pi.base);
87 MathGridInset::draw(pi, x + 1, y);
88 drawMarkers2(pi, x, y);
92 void MathArrayInset::write(WriteStream & os) const
96 os << "\\begin{" << name_ << '}';
98 if (v_align_ == 't' || v_align_ == 'b')
99 os << '[' << char(v_align_) << ']';
100 os << '{' << halign() << "}\n";
102 MathGridInset::write(os);
106 os << "\\end{" << name_ << '}';
107 // adding a \n here is bad if the array is the last item
108 // in an \eqnarray...
112 void MathArrayInset::infoize(std::ostream & os) const
118 void MathArrayInset::normalize(NormalStream & os) const
120 os << '[' << name_ << ' ';
121 MathGridInset::normalize(os);
126 void MathArrayInset::maple(MapleStream & os) const
129 MathGridInset::maple(os);