- //lyxerr << "mutating from '" << getType() << "' to '" << newtype << "'\n";
-
- if (newtype == getType())
- return;
-
- switch (getType()) {
- case LM_OT_SIMPLE:
- setType(LM_OT_EQUATION);
- numbered(0, false);
- mutate(newtype);
- break;
-
- case LM_OT_EQUATION:
- switch (newtype) {
- case LM_OT_SIMPLE:
- setType(LM_OT_SIMPLE);
- break;
-
- case LM_OT_ALIGN: {
- MathGridInset::addCol(1);
-
- // split it "nicely"
- int pos = firstRelOp(cell(0));
- cell(1) = cell(0);
- cell(0).erase(pos, cell(0).size());
- cell(1).erase(0, pos);
-
- halign("rl");
- setType(LM_OT_ALIGN);
- break;
- }
-
- case LM_OT_EQNARRAY:
- default:
- MathGridInset::addCol(1);
- MathGridInset::addCol(1);
-
- // split it "nicely" on the firest relop
- int pos = firstRelOp(cell(0));
- cell(1) = cell(0);
- 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);
- }
-
- halign("rcl");
- setType(LM_OT_EQNARRAY);
- mutate(newtype);
- break;
- }
- break;
-
- case LM_OT_EQNARRAY:
- switch (newtype) {
- case LM_OT_SIMPLE:
- case LM_OT_EQUATION: {
- // set correct (no)numbering
- bool allnonum = true;
- for (int r = 0; r < nrows(); ++r) {
- if (!nonum_[r])
- allnonum = false;
- }
-
- // set first non-empty label
- string label;
- for (int r = 0; r < nrows(); ++r) {
- if (!label_[r].empty()) {
- label = label_[r];
- break;
- }
- }
-
- glueall();
-
- nonum_[0] = allnonum;
- label_[0] = label;
- mutate(newtype);
- break;
- }
-
- case LM_OT_ALIGN:
- default: {
- for (int row = 0; row < nrows(); ++row) {
- int c = 3 * row + 1;
- cell(c).push_back(cell(c + 1));
- }
- MathGridInset::delCol(2);
- setType(LM_OT_ALIGN);
- halign("rl");
- mutate(newtype);
- break;
- }
- }
- break;
-
- case LM_OT_ALIGN:
- switch (newtype) {
- case LM_OT_SIMPLE:
- case LM_OT_EQUATION:
- case LM_OT_EQNARRAY:
- MathGridInset::addCol(1);
- setType(LM_OT_EQNARRAY);
- halign("rcl");
- mutate(newtype);
- break;
-
- default:
- lyxerr << "mutation from '" << getType()
- << "' to '" << newtype << "' not implemented\n";
- break;
- }
- break;
-
- default:
- lyxerr << "mutation from '" << getType()
- << "' to '" << newtype << "' not implemented\n";