- 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 (row_type row = 0; row < nrows(); ++row) {
- if (!nonum_[row])
- allnonum = false;
- }
-
- // set first non-empty label
- string label;
- for (row_type row = 0; row < nrows(); ++row) {
- if (!label_[row].empty()) {
- label = label_[row];
- break;
- }
- }
-
- glueall();
-
- nonum_[0] = allnonum;
- label_[0] = label;
- mutate(newtype);
- break;
- }
+ else if (type_ == "equation") {
+ if (smaller(newtype, type_)) {
+ setType("simple");
+ mutate(newtype);
+ } else if (newtype == "eqnarray") {
+ MathGridInset::addCol(1);
+ MathGridInset::addCol(1);
+
+ // split it "nicely" on the firest relop
+ pos_type pos = firstRelOp(cell(0));
+ cell(1) = MathArray(cell(0), pos, cell(0).size());
+ cell(0).erase(pos, cell(0).size());
+
+ if (cell(1).size()) {
+ cell(2) = MathArray(cell(1), 1, cell(1).size());
+ cell(1).erase(1, cell(1).size());
+ }
+ setType("eqnarray");
+ mutate(newtype);
+ } else {
+ MathGridInset::addCol(1);
+ // split it "nicely"
+ pos_type pos = firstRelOp(cell(0));
+ cell(1) = cell(0);
+ cell(0).erase(pos, cell(0).size());
+ cell(1).erase(0, pos);
+ setType("align");
+ mutate(newtype);
+ }
+ }