]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathAMSArray.cpp
Cmake export tests: Added sublabel handling also to revertedTests
[lyx.git] / src / mathed / InsetMathAMSArray.cpp
index 39589649780e6eabb513302c5736369fab3d204f..12a92da0803176e67ccdfbbd88c446217a1aae47 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include "support/lstrings.h"
 
+#include <sstream>
 #include <ostream>
 
 
-namespace lyx {
+using namespace std;
+using namespace lyx::support;
 
-using support::bformat;
+namespace lyx {
 
 
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name, int m, int n)
-       : InsetMathGrid(m, n), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name,
+               int m, int n)
+       : InsetMathGrid(buf, m, n), name_(name)
 {}
 
 
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name)
-       : InsetMathGrid(1, 1), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name)
+       : InsetMathGrid(buf, 1, 1), name_(name)
 {}
 
 
@@ -103,20 +106,27 @@ void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const
 bool InsetMathAMSArray::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
-       switch (cmd.action) {
-       case LFUN_TABULAR_FEATURE: {
-               docstring const & s = cmd.argument();
+       switch (cmd.action()) {
+       case LFUN_INSET_MODIFY: {
+               istringstream is(to_utf8(cmd.argument()));
+               string s;
+               is >> s;
+               if (s != "tabular")
+                       break;
+               is >> s;
                if (s == "add-vline-left" || s == "add-vline-right") {
                        flag.message(bformat(
-                               from_utf8(N_("Can't add vertical grid lines in '%1$s'")),       name_));
+                               from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
+                               name_));
                        flag.setEnabled(false);
                        return true;
                }
-               return InsetMathGrid::getStatus(cur, cmd, flag);
+               break;
        }
        default:
-               return InsetMathGrid::getStatus(cur, cmd, flag);
+               break;
        }
+       return InsetMathGrid::getStatus(cur, cmd, flag);
 }
 
 
@@ -124,8 +134,11 @@ void InsetMathAMSArray::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
        os << "\\begin{" << name_ << '}';
+       bool open = os.startOuterRow();
        InsetMathGrid::write(os);
        os << "\\end{" << name_ << '}';
+       if (open)
+               os.startOuterRow();
 }
 
 
@@ -147,11 +160,12 @@ void InsetMathAMSArray::normalize(NormalStream & os) const
 
 void InsetMathAMSArray::validate(LaTeXFeatures & features) const
 {
-       if (name_ != "CD")
-               features.require("amsmath");
-       // amscd is independent of amsmath although it is part of the amsmath bundle
        if (name_ == "CD")
+               // amscd is independent of amsmath although it is part of
+               // the amsmath bundle
                features.require("amscd");
+       else
+               features.require("amsmath");
        InsetMathGrid::validate(features);
 }