]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathCases.cpp
Fix bug #8782.
[lyx.git] / src / mathed / InsetMathCases.cpp
index 29eb2907de7326b0e60c1a838999272c46554d7b..88012aa247f1d36929509b45a06172e85d4215fd 100644 (file)
@@ -70,15 +70,12 @@ void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
-       switch (cmd.action_) {
-       case LFUN_INSET_MODIFY: {
-               istringstream is(to_utf8(cmd.argument()));
-               string s;
-               is >> s;
-               if (s != "tabular")
-                       break;
-               is >> s;
+       switch (cmd.action()) {
+       case LFUN_TABULAR_FEATURE: {
+               string s = cmd.getArg(0);
                // vertical lines and adding/deleting columns is not allowed for \cases
+               // FIXME: "I suspect that the break after cur.undispatched() should be a
+               // return; the recordUndo seems bogus too." (lasgouttes)
                if (s == "append-column" || s == "delete-column"
                    || s == "add-vline-left" || s == "add-vline-right") {
                        cur.undispatched();
@@ -96,14 +93,9 @@ void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
-       switch (cmd.action_) {
-       case LFUN_INSET_MODIFY: {
-               istringstream is(to_utf8(cmd.argument()));
-               string s;
-               is >> s;
-               if (s != "tabular")
-                       break;
-               is >> s;
+       switch (cmd.action()) {
+       case LFUN_TABULAR_FEATURE: {
+               string s = cmd.getArg(0);
                if (s == "add-vline-left" || s == "add-vline-right") {
                        flag.setEnabled(false);
                        flag.message(bformat(
@@ -132,11 +124,14 @@ void InsetMathCases::write(WriteStream & os) const
        MathEnsurer ensurer(os);
        if (os.fragile())
                os << "\\protect";
+       bool open = os.startOuterRow();
        os << "\\begin{cases}\n";
        InsetMathGrid::write(os);
        if (os.fragile())
                os << "\\protect";
        os << "\\end{cases}";
+       if (open)
+               os.startOuterRow();
 }
 
 
@@ -183,11 +178,16 @@ void InsetMathCases::validate(LaTeXFeatures & features) const
        InsetMathGrid::validate(features);
        if (features.runparams().math_flavor == OutputParams::MathAsHTML)
                // CSS based on eLyXer's
-               features.addPreambleSnippet("<style type=\"text/css\">\n"
+               features.addCSSSnippet(
                        "table.cases{display: inline-block; text-align: center;"
                        "border-left: thin solid black; vertical-align: middle; padding-left: 0.5ex;}\n"
-                       "table.cases td {text-align: left;}\n"
-                       "</style>");
+                       "table.cases td {text-align: left;}");
+}
+
+
+int InsetMathCases::displayColSpace(col_type) const
+{
+       return 20;
 }