- features.amsstyle = ams();
-
- // Validation is necessary only if not using AMS math.
- // To be safe, we will always run mathedValidate.
- //if (features.amsstyle)
- // return;
-
- //Validate1(features);
-
- features.boldsymbol = true;
- features.binom = true;
-}
-
-/*
-void MathMatrixInset::Validate1(LaTeXFeatures & features)
-{
- MathIter it(cell());
-
- while (it.OK() && !(features.binom && features.boldsymbol)) {
- MathInset * p = it.GetInset();
- if (p) {
- p = it.GetActiveInset();
- if (p) {
- if (!features.binom && p->GetType() == LM_OT_MACRO &&
- p->name() == "binom") {
- features.binom = true;
- } else {
- for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
- p->setArgumentIdx(i);
- Validate1(features, p);
- }
- }
- } else {
- if (!features.boldsymbol && p->name() == "boldsymbol")
- features.boldsymbol = true;
- }
- }
- it.Next();
- }
-}
-*/
-
-
-void MathMatrixInset::header_write(std::ostream & os) const
-{
- bool n = numberedType();
-
- switch (GetType()) {
- case LM_OT_SIMPLE:
- os << "\\(";
- 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;
- }
-}
-
-
-void MathMatrixInset::footer_write(std::ostream & os) const
-{
- bool n = numberedType();
-
- switch (GetType()) {
- case LM_OT_SIMPLE:
- os << "\\)";
- 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;
- }
-}
-
-
-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)
-{
- switch (GetType()) {
- 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)
-{
- switch (GetType()) {
- case LM_OT_ALIGN:
- MathGridInset::delCol(col);
- break;
-
- default:
- break;
- }
-}
-
-void MathMatrixInset::breakLine()
-{
- if (GetType() == LM_OT_SIMPLE || GetType() == LM_OT_EQUATION)
- mutate(LM_OT_EQNARRAY);
- addRow(nrows() - 1);
-}
-
-
-void MathMatrixInset::splitCell(int idx)
-{
- if (idx == nargs() - 1) {
- lyxerr << "can't split last cell\n";
- return;
- }
-
- lyxerr << "unimplemented\n";
-}
-
-
-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;
- }
- //lyxerr << "mutating from '" << GetType() << "' to '" << newtype << "'\n";
- 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;
-}
-
-void MathMatrixInset::mutate(short newtype)
-{
- //lyxerr << "mutating from '" << GetType() << "' to '" << newtype << "'\n";
-
- if (newtype == GetType())
- return;
-
- switch (GetType()) {
- case LM_OT_SIMPLE:
- SetType(LM_OT_EQUATION);
- numbered(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);
- halign("rl");
- SetType(LM_OT_ALIGN);
- break;
-
- default:
- MathGridInset::addCol(1);
- MathGridInset::addCol(1);
- halign("rcl");
- SetType(LM_OT_EQNARRAY);
- mutate(newtype);
- break;
- }
- break;
-
- case LM_OT_EQNARRAY:
- switch (newtype) {
- case LM_OT_SIMPLE:
- glueall();
- break;
-
- case LM_OT_EQUATION:
- if (nrows() == 1) {
- MathGridInset::delCol(2);
- MathGridInset::delCol(1);
- SetType(LM_OT_EQUATION);
- mutate(newtype);
- } else
- lyxerr << "need to delete rows first\n";
- 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("lrl");
- 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";