2001-02-26 12:53:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_matrixinset.h"
|
2001-08-09 09:19:18 +00:00
|
|
|
#include "support.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "debug.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "Painter.h"
|
|
|
|
#include "LaTeXFeatures.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
namespace {
|
|
|
|
|
2001-08-02 09:59:09 +00:00
|
|
|
string getAlign(MathInsetTypes type, int cols)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
string align;
|
|
|
|
switch (type) {
|
|
|
|
case LM_OT_ALIGN:
|
|
|
|
for (int i = 0; i < cols; ++i)
|
|
|
|
align += "Rl";
|
|
|
|
break;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_ALIGNAT:
|
|
|
|
for (int i = 0; i < cols; ++i)
|
|
|
|
align += "rl";
|
|
|
|
break;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_MULTLINE:
|
|
|
|
align = "C";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
align = "rcl";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return align;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
string const star(bool n)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return n ? "" : "*";
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int getCols(short int type)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
int col;
|
|
|
|
switch (type) {
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
col = 3;
|
|
|
|
break;
|
2001-02-20 16:00:22 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_ALIGN:
|
|
|
|
case LM_OT_ALIGNAT:
|
|
|
|
col = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
col = 1;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
return col;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
2001-07-09 16:59:57 +00:00
|
|
|
// returns position of first relation operator in the array
|
|
|
|
// used for "intelligent splitting"
|
|
|
|
int firstRelOp(MathArray const & array)
|
|
|
|
{
|
2001-08-09 08:53:16 +00:00
|
|
|
for (MathArray::const_iterator it = array.begin(); it != array.end(); ++it)
|
|
|
|
if ((*it)->isRelOp())
|
|
|
|
return it - array.begin();
|
2001-07-09 16:59:57 +00:00
|
|
|
return array.size();
|
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-09-04 08:48:23 +00:00
|
|
|
|
|
|
|
MathMatrixInset::MathMatrixInset()
|
|
|
|
: MathGridInset(1, 1), objtype_(LM_OT_SIMPLE), nonum_(1), label_(1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
MathMatrixInset::MathMatrixInset(MathInsetTypes t)
|
2001-08-08 17:26:30 +00:00
|
|
|
: MathGridInset(getCols(t), 1), objtype_(t), nonum_(1), label_(1)
|
2001-08-02 09:59:09 +00:00
|
|
|
{
|
|
|
|
halign(getAlign(t, ncols()));
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-09-04 08:48:23 +00:00
|
|
|
MathMatrixInset::MathMatrixInset(MathInsetTypes t, int cols)
|
|
|
|
: MathGridInset(cols, 1), objtype_(t), nonum_(1), label_(1)
|
|
|
|
{
|
|
|
|
halign(getAlign(t, ncols()));
|
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathMatrixInset::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return new MathMatrixInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathMatrixInset::metrics(MathStyles) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
// let the cells adjust themselves
|
2001-07-26 06:56:43 +00:00
|
|
|
MathGridInset::metrics(size_);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
if (display()) {
|
|
|
|
ascent_ += 12;
|
|
|
|
descent_ += 12;
|
|
|
|
}
|
2001-03-06 17:44:53 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
if (numberedType()) {
|
|
|
|
int l = 0;
|
|
|
|
for (int row = 0; row < nrows(); ++row)
|
2001-07-20 14:54:13 +00:00
|
|
|
l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row)));
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
if (l)
|
|
|
|
width_ += 30 + l;
|
2001-02-16 09:25:43 +00:00
|
|
|
}
|
2001-09-03 11:38:04 +00:00
|
|
|
|
|
|
|
// make it at least as high as the current font
|
|
|
|
int asc = 0;
|
|
|
|
int des = 0;
|
|
|
|
math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
|
|
|
|
ascent_ = std::max(ascent_, asc);
|
|
|
|
descent_ = std::max(descent_, des);
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathMatrixInset::draw(Painter & pain, int x, int y) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
xo(x);
|
|
|
|
yo(y);
|
|
|
|
|
|
|
|
MathGridInset::draw(pain, x, y);
|
|
|
|
|
|
|
|
if (numberedType()) {
|
|
|
|
int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
|
2001-07-20 14:54:13 +00:00
|
|
|
for (int row = 0; row < nrows(); ++row) {
|
|
|
|
int yy = y + rowinfo_[row].offset_;
|
|
|
|
drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
header_write(os);
|
|
|
|
|
|
|
|
bool n = numberedType();
|
|
|
|
|
|
|
|
for (int row = 0; row < nrows(); ++row) {
|
|
|
|
for (int col = 0; col < ncols(); ++col) {
|
2001-07-26 06:56:43 +00:00
|
|
|
cell(index(row, col)).write(os, fragile);
|
2001-08-10 13:50:42 +00:00
|
|
|
os << eocString(col);
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
if (n) {
|
|
|
|
if (!label_[row].empty())
|
|
|
|
os << "\\label{" << label_[row] << "}";
|
|
|
|
if (nonum_[row])
|
|
|
|
os << "\\nonumber ";
|
2001-02-16 09:25:43 +00:00
|
|
|
}
|
2001-08-10 10:39:56 +00:00
|
|
|
os << eolString(row);
|
2001-02-16 09:25:43 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
footer_write(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string MathMatrixInset::label(int row) const
|
|
|
|
{
|
|
|
|
return label_[row];
|
|
|
|
}
|
|
|
|
|
2001-09-04 08:48:23 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathMatrixInset::label(int row, string const & label)
|
|
|
|
{
|
|
|
|
label_[row] = label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMatrixInset::numbered(int row, bool num)
|
|
|
|
{
|
|
|
|
nonum_[row] = !num;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathMatrixInset::numbered(int row) const
|
|
|
|
{
|
|
|
|
return !nonum_[row];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathMatrixInset::ams() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathMatrixInset::display() const
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
return getType() != LM_OT_SIMPLE;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
std::vector<string> const MathMatrixInset::getLabelList() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
std::vector<string> res;
|
|
|
|
for (int row = 0; row < nrows(); ++row)
|
|
|
|
if (!label_[row].empty() && nonum_[row] != 1)
|
|
|
|
res.push_back(label_[row]);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathMatrixInset::numberedType() const
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
if (getType() == LM_OT_SIMPLE)
|
2001-06-25 00:06:33 +00:00
|
|
|
return false;
|
|
|
|
for (int row = 0; row < nrows(); ++row)
|
|
|
|
if (!nonum_[row])
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMatrixInset::validate(LaTeXFeatures & features) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
features.amsstyle = ams();
|
|
|
|
|
|
|
|
// Validation is necessary only if not using AMS math.
|
2001-07-26 06:56:43 +00:00
|
|
|
// To be safe, we will always run mathedvalidate.
|
2001-06-25 00:06:33 +00:00
|
|
|
//if (features.amsstyle)
|
|
|
|
// return;
|
|
|
|
|
|
|
|
features.boldsymbol = true;
|
2001-07-13 14:54:56 +00:00
|
|
|
//features.binom = true;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathNestInset::validate(features);
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
void MathMatrixInset::header_write(std::ostream & os) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
bool n = numberedType();
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
switch (getType()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_SIMPLE:
|
2001-07-27 09:55:44 +00:00
|
|
|
os << '$';
|
|
|
|
if (cell(0).empty())
|
|
|
|
os << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQUATION:
|
|
|
|
if (n)
|
|
|
|
os << "\\begin{equation" << star(n) << "}\n";
|
|
|
|
else
|
|
|
|
os << "\\[\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
os << "\\begin{eqnarray" << star(n) << "}\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGN:
|
|
|
|
os << "\\begin{align" << star(n) << "}";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGNAT:
|
|
|
|
os << "\\begin{alignat" << star(n) << "}"
|
|
|
|
<< "{" << ncols()/2 << "}\n";
|
|
|
|
break;
|
2001-07-06 12:09:32 +00:00
|
|
|
default:
|
|
|
|
os << "\\begin{unknown" << star(n) << "}";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
void MathMatrixInset::footer_write(std::ostream & os) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
bool n = numberedType();
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
switch (getType()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_SIMPLE:
|
2001-07-27 09:55:44 +00:00
|
|
|
os << '$';
|
2001-06-25 00:06:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQUATION:
|
|
|
|
if (n)
|
|
|
|
os << "\\end{equation" << star(n) << "}\n";
|
|
|
|
else
|
|
|
|
os << "\\]\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
os << "\\end{eqnarray" << star(n) << "}\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGN:
|
|
|
|
os << "\\end{align" << star(n) << "}\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGNAT:
|
|
|
|
os << "\\end{alignat" << star(n) << "}\n";
|
|
|
|
break;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
os << "\\end{unknown" << star(n) << "}";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMatrixInset::addRow(int row)
|
|
|
|
{
|
|
|
|
nonum_.insert(nonum_.begin() + row + 1, !numberedType());
|
|
|
|
label_.insert(label_.begin() + row + 1, string());
|
|
|
|
MathGridInset::addRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMatrixInset::appendRow()
|
|
|
|
{
|
|
|
|
nonum_.push_back(!numberedType());
|
|
|
|
label_.push_back(string());
|
|
|
|
MathGridInset::appendRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMatrixInset::delRow(int row)
|
|
|
|
{
|
|
|
|
MathGridInset::delRow(row);
|
|
|
|
nonum_.erase(nonum_.begin() + row);
|
|
|
|
label_.erase(label_.begin() + row);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMatrixInset::addCol(int col)
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
switch (getType()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_EQUATION:
|
|
|
|
mutate(LM_OT_EQNARRAY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
mutate(LM_OT_ALIGN);
|
|
|
|
addCol(col);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGN:
|
|
|
|
case LM_OT_ALIGNAT:
|
|
|
|
MathGridInset::addCol(col);
|
|
|
|
halign(col, 'l');
|
|
|
|
MathGridInset::addCol(col);
|
|
|
|
halign(col, 'r');
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMatrixInset::delCol(int col)
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
switch (getType()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_ALIGN:
|
|
|
|
MathGridInset::delCol(col);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string MathMatrixInset::nicelabel(int row) const
|
|
|
|
{
|
|
|
|
if (nonum_[row])
|
|
|
|
return string();
|
|
|
|
if (label_[row].empty())
|
|
|
|
return string("(#)");
|
|
|
|
return "(" + label_[row] + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
short typecode(string const & s)
|
|
|
|
{
|
|
|
|
if (s == "equation")
|
|
|
|
return LM_OT_EQUATION;
|
|
|
|
if (s == "display")
|
|
|
|
return LM_OT_EQUATION;
|
|
|
|
if (s == "eqnarray")
|
|
|
|
return LM_OT_EQNARRAY;
|
|
|
|
if (s == "align")
|
|
|
|
return LM_OT_ALIGN;
|
|
|
|
if (s == "xalign")
|
|
|
|
return LM_OT_XALIGN;
|
|
|
|
if (s == "xxalign")
|
|
|
|
return LM_OT_XXALIGN;
|
|
|
|
if (s == "multline")
|
|
|
|
return LM_OT_MULTLINE;
|
|
|
|
return LM_OT_SIMPLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMatrixInset::mutate(string const & newtype)
|
|
|
|
{
|
|
|
|
if (newtype == "dump") {
|
|
|
|
dump();
|
|
|
|
return;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-07-26 06:56:43 +00:00
|
|
|
//lyxerr << "mutating from '" << getType() << "' to '" << newtype << "'\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
mutate(typecode(newtype));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMatrixInset::glueall()
|
|
|
|
{
|
|
|
|
MathArray ar;
|
|
|
|
for (int i = 0; i < nargs(); ++i)
|
|
|
|
ar.push_back(cell(i));
|
|
|
|
*this = MathMatrixInset(LM_OT_SIMPLE);
|
|
|
|
cell(0) = ar;
|
|
|
|
}
|
|
|
|
|
2001-08-01 13:28:45 +00:00
|
|
|
|
|
|
|
MathInsetTypes MathMatrixInset::getType() const
|
|
|
|
{
|
|
|
|
return objtype_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMatrixInset::setType(MathInsetTypes t)
|
|
|
|
{
|
|
|
|
objtype_ = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathMatrixInset::mutate(short newtype)
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
//lyxerr << "mutating from '" << getType() << "' to '" << newtype << "'\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
if (newtype == getType())
|
2001-06-25 00:06:33 +00:00
|
|
|
return;
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
switch (getType()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
case LM_OT_SIMPLE:
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_EQUATION);
|
2001-07-13 12:43:24 +00:00
|
|
|
numbered(0, false);
|
2001-06-25 00:06:33 +00:00
|
|
|
mutate(newtype);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQUATION:
|
|
|
|
switch (newtype) {
|
|
|
|
case LM_OT_SIMPLE:
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_SIMPLE);
|
2001-06-25 00:06:33 +00:00
|
|
|
break;
|
|
|
|
|
2001-07-09 16:59:57 +00:00
|
|
|
case LM_OT_ALIGN: {
|
2001-06-25 00:06:33 +00:00
|
|
|
MathGridInset::addCol(1);
|
2001-07-09 16:59:57 +00:00
|
|
|
|
|
|
|
// split it "nicely"
|
|
|
|
int pos = firstRelOp(cell(0));
|
|
|
|
cell(1) = cell(0);
|
|
|
|
cell(0).erase(pos, cell(0).size());
|
|
|
|
cell(1).erase(0, pos);
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
halign("rl");
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_ALIGN);
|
2001-06-25 00:06:33 +00:00
|
|
|
break;
|
2001-07-09 16:59:57 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-07-09 16:59:57 +00:00
|
|
|
case LM_OT_EQNARRAY:
|
2001-06-25 00:06:33 +00:00
|
|
|
default:
|
|
|
|
MathGridInset::addCol(1);
|
|
|
|
MathGridInset::addCol(1);
|
2001-07-09 16:59:57 +00:00
|
|
|
|
|
|
|
// split it "nicely" on the firest relop
|
2001-08-07 12:02:21 +00:00
|
|
|
int pos = firstRelOp(cell(0));
|
2001-07-09 16:59:57 +00:00
|
|
|
cell(1) = cell(0);
|
2001-08-07 12:02:21 +00:00
|
|
|
cell(0).erase(pos, cell(0).size());
|
|
|
|
cell(1).erase(0, pos);
|
|
|
|
|
|
|
|
if (cell(1).size()) {
|
|
|
|
cell(2) = cell(1);
|
|
|
|
cell(1).erase(1, cell(1).size());
|
|
|
|
cell(2).erase(0);
|
|
|
|
}
|
2001-07-09 16:59:57 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
halign("rcl");
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_EQNARRAY);
|
2001-06-25 00:06:33 +00:00
|
|
|
mutate(newtype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
switch (newtype) {
|
|
|
|
case LM_OT_SIMPLE:
|
2001-07-09 10:19:50 +00:00
|
|
|
case LM_OT_EQUATION: {
|
2001-07-09 16:59:57 +00:00
|
|
|
// set correct (no)numbering
|
2001-07-09 10:19:50 +00:00
|
|
|
bool allnonum = true;
|
|
|
|
for (int r = 0; r < nrows(); ++r) {
|
|
|
|
if (!nonum_[r])
|
|
|
|
allnonum = false;
|
|
|
|
}
|
2001-07-09 16:42:22 +00:00
|
|
|
|
2001-07-09 16:59:57 +00:00
|
|
|
// set first non-empty label
|
2001-07-09 16:42:22 +00:00
|
|
|
string label;
|
|
|
|
for (int r = 0; r < nrows(); ++r) {
|
|
|
|
if (!label_[r].empty()) {
|
|
|
|
label = label_[r];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
glueall();
|
2001-07-10 10:40:23 +00:00
|
|
|
|
|
|
|
nonum_[0] = allnonum;
|
|
|
|
label_[0] = label;
|
2001-07-06 12:09:32 +00:00
|
|
|
mutate(newtype);
|
2001-06-25 00:06:33 +00:00
|
|
|
break;
|
2001-07-09 10:19:50 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
case LM_OT_ALIGN:
|
2001-07-09 16:59:57 +00:00
|
|
|
default: {
|
2001-06-25 00:06:33 +00:00
|
|
|
for (int row = 0; row < nrows(); ++row) {
|
|
|
|
int c = 3 * row + 1;
|
|
|
|
cell(c).push_back(cell(c + 1));
|
|
|
|
}
|
|
|
|
MathGridInset::delCol(2);
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_ALIGN);
|
2001-06-25 00:06:33 +00:00
|
|
|
halign("rl");
|
|
|
|
mutate(newtype);
|
|
|
|
break;
|
2001-07-09 16:59:57 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LM_OT_ALIGN:
|
|
|
|
switch (newtype) {
|
|
|
|
case LM_OT_SIMPLE:
|
|
|
|
case LM_OT_EQUATION:
|
|
|
|
case LM_OT_EQNARRAY:
|
|
|
|
MathGridInset::addCol(1);
|
2001-07-26 06:56:43 +00:00
|
|
|
setType(LM_OT_EQNARRAY);
|
2001-07-06 12:09:32 +00:00
|
|
|
halign("rcl");
|
2001-06-25 00:06:33 +00:00
|
|
|
mutate(newtype);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-07-26 06:56:43 +00:00
|
|
|
lyxerr << "mutation from '" << getType()
|
2001-06-25 00:06:33 +00:00
|
|
|
<< "' to '" << newtype << "' not implemented\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-07-26 06:56:43 +00:00
|
|
|
lyxerr << "mutation from '" << getType()
|
2001-06-25 00:06:33 +00:00
|
|
|
<< "' to '" << newtype << "' not implemented\n";
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
}
|