+2004-11-22 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * math_hullinset.[Ch] (rowChangeOK): new
+ * math_hullinset.C (addRow, delRow): check wether rows can be changed
+ * math_hullinset.C (addCol, delCol): remove lyxerr warning since we
+ should never come here if colChangeOK() is false
+ * math_hullinset.C (delCol): don't delete if this is the only column
+ * math_hullinset.C (getStatus): fix LFUN_TABULAR_FEATURE
+
2004-11-16 Lars Gullik Bjonnes <larsbj@gullik.net>
* math_inset.h: include math_data.h to satisfy concept checks.
}
+bool MathHullInset::rowChangeOK() const
+{
+ return
+ type_ == "eqnarray" || type_ == "align" ||
+ type_ == "flalign" || type_ == "alignat" ||
+ type_ == "xalignat" || type_ == "xxalignat" ||
+ type_ == "gather" || type_ == "multline";
+}
+
+
bool MathHullInset::colChangeOK() const
{
return
void MathHullInset::addRow(row_type row)
{
+ if (!rowChangeOK())
+ return;
nonum_.insert(nonum_.begin() + row + 1, !numberedType());
label_.insert(label_.begin() + row + 1, string());
MathGridInset::addRow(row);
void MathHullInset::swapRow(row_type row)
{
- if (nrows() == 1)
+ if (nrows() <= 1)
return;
if (row + 1 == nrows())
--row;
void MathHullInset::delRow(row_type row)
{
- if (nrows() <= 1)
+ if (nrows() <= 1 || !rowChangeOK())
return;
MathGridInset::delRow(row);
nonum_.erase(nonum_.begin() + row);
void MathHullInset::addCol(col_type col)
{
- if (colChangeOK())
- MathGridInset::addCol(col);
- else
- lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
+ if (!colChangeOK())
+ return;
+ MathGridInset::addCol(col);
}
void MathHullInset::delCol(col_type col)
{
- if (colChangeOK())
- MathGridInset::delCol(col);
- else
- lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
+ if (ncols() <= 1 || !colChangeOK())
+ return;
+ MathGridInset::delCol(col);
}
// we handle these
return true;
case LFUN_TABULAR_FEATURE: {
- // should be more precise
istringstream is(cmd.argument);
string s;
is >> s;
- if ((type_ == "simple" || type_ == "equation")
- && (s == "append-column"
- || s == "delete-column"
- || s == "swap-column"
- || s == "copy-column"
- || s == "delete-column"
- || s == "append-row"
+ if (!rowChangeOK()
+ && (s == "append-row"
|| s == "delete-row"
- || s == "swap-row"
|| s == "copy-row"))
return false;
- if ((type_ == "eqnarray")
+ if (nrows() <= 1
+ && (s == "delete-row" || s == "swap-row"))
+ return false;
+ if (!colChangeOK()
&& (s == "append-column"
- || s == "delete-column"))
+ || s == "delete-column"
+ || s == "copy-column"))
+ return false;
+ if (ncols() <= 1
+ && (s == "delete-column" || s == "swap-column"))
return false;
return MathGridInset::getStatus(cur, cmd, flag);
}
void addRow(row_type row);
/// delete a row
void delRow(row_type row);
- ///
+ /// swap two rows
void swapRow(row_type row);
/// add a column
void addCol(col_type col);
char const * standardFont() const;
/// consistency check
void check() const;
+ /// can this change its number of rows?
+ bool rowChangeOK() const;
/// can this change its number of cols?
bool colChangeOK() const;