2001-06-25 00:06:33 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-11-20 09:06:12 +00:00
|
|
|
#include <iterator>
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "math_arrayinset.h"
|
2001-11-07 13:15:59 +00:00
|
|
|
#include "math_parser.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-11-09 08:35:57 +00:00
|
|
|
#include "Lsstream.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-11-08 06:42:20 +00:00
|
|
|
using std::vector;
|
2001-11-09 08:35:57 +00:00
|
|
|
using std::istringstream;
|
2001-11-08 06:42:20 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
MathArrayInset::MathArrayInset(int m, int n)
|
2001-08-08 17:26:30 +00:00
|
|
|
: MathGridInset(m, n)
|
2001-06-25 00:06:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
MathArrayInset::MathArrayInset(int m, int n, char valign, string const & halign)
|
|
|
|
: MathGridInset(m, n, valign, halign)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-11-07 13:15:59 +00:00
|
|
|
MathArrayInset::MathArrayInset(string const & str)
|
|
|
|
: MathGridInset(1, 1)
|
|
|
|
{
|
|
|
|
vector< vector<string> > dat;
|
2001-11-08 15:12:33 +00:00
|
|
|
istringstream is(str.c_str());
|
2001-11-07 13:15:59 +00:00
|
|
|
while (is) {
|
|
|
|
string line;
|
|
|
|
getline(is, line);
|
2001-11-08 15:12:33 +00:00
|
|
|
istringstream ls(line.c_str());
|
2001-11-07 13:15:59 +00:00
|
|
|
typedef std::istream_iterator<string> iter;
|
|
|
|
vector<string> v = vector<string>(iter(ls), iter());
|
|
|
|
if (v.size())
|
|
|
|
dat.push_back(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (row_type row = 1; row < dat.size(); ++row)
|
|
|
|
addRow(0);
|
|
|
|
for (col_type col = 1; col < dat[0].size(); ++col)
|
|
|
|
addCol(0);
|
|
|
|
for (row_type row = 0; row < dat.size(); ++row)
|
|
|
|
for (col_type col = 0; col < dat[row].size(); ++col)
|
|
|
|
mathed_parse_cell(cell(index(row, col)), dat[row][col]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathArrayInset::clone() const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
return new MathArrayInset(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathArrayInset::metrics(MathMetricsInfo const & st) const
|
|
|
|
{
|
|
|
|
MathMetricsInfo mi = st;
|
|
|
|
if (mi.style == LM_ST_DISPLAY)
|
|
|
|
mi.style = LM_ST_TEXT;
|
|
|
|
MathGridInset::metrics(mi);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathArrayInset::write(WriteStream & os) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-10-19 11:25:48 +00:00
|
|
|
if (os.fragile)
|
2001-06-25 00:06:33 +00:00
|
|
|
os << "\\protect";
|
|
|
|
os << "\\begin{array}";
|
|
|
|
|
|
|
|
if (v_align_ == 't' || v_align_ == 'b')
|
|
|
|
os << '[' << char(v_align_) << ']';
|
|
|
|
|
|
|
|
os << '{';
|
2001-09-26 16:52:34 +00:00
|
|
|
for (col_type col = 0; col < ncols(); ++col)
|
2001-09-04 13:32:06 +00:00
|
|
|
os << colinfo_[col].align_;
|
2001-06-25 00:06:33 +00:00
|
|
|
os << "}\n";
|
|
|
|
|
2001-10-19 11:25:48 +00:00
|
|
|
MathGridInset::write(os);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-10-19 11:25:48 +00:00
|
|
|
if (os.fragile)
|
2001-06-25 00:06:33 +00:00
|
|
|
os << "\\protect";
|
|
|
|
os << "\\end{array}\n";
|
|
|
|
}
|
2001-09-10 09:35:12 +00:00
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathArrayInset::normalize(NormalStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
|
|
|
os << "[array ";
|
2001-11-09 08:35:57 +00:00
|
|
|
MathGridInset::normalize(os);
|
2001-11-07 08:51:35 +00:00
|
|
|
os << "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathArrayInset::maplize(MapleStream & os) const
|
2001-09-10 09:35:12 +00:00
|
|
|
{
|
2001-11-09 08:35:57 +00:00
|
|
|
os << "array(";
|
|
|
|
MathGridInset::maplize(os);
|
|
|
|
os << ")";
|
2001-09-10 09:35:12 +00:00
|
|
|
}
|