]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fix some group boxes.
[lyx.git] / src / Text3.cpp
index e51d323e03733b9d17be95dd7c6bef4ee4b4b8f2..7baf9a8eba4fc0e0f22544a72c9458b4892870d7 100644 (file)
@@ -2078,19 +2078,28 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_TABULAR_INSERT: {
-               if (cur.buffer()->masterParams().tablestyle != "default") {
-                       FuncRequest fr(LFUN_TABULAR_STYLE_INSERT,
-                                      cur.buffer()->masterParams().tablestyle + " "
-                                      + to_ascii(cmd.argument()));
-                       lyx::dispatch(fr);
+               // if there were no arguments, just open the dialog
+               if (cmd.argument().empty()) {
+                       bv->showDialog("tabularcreate");
                        break;
+               } else if (cur.buffer()->masterParams().tablestyle != "default"
+                          || bv->buffer().params().documentClass().tablestyle() != "default") {
+                       string tabstyle = cur.buffer()->masterParams().tablestyle;
+                       if (tabstyle == "default")
+                               tabstyle = bv->buffer().params().documentClass().tablestyle();
+                       if (!libFileSearch("tabletemplates", tabstyle + ".lyx").empty()) {
+                               FuncRequest fr(LFUN_TABULAR_STYLE_INSERT,
+                                              tabstyle + " " + to_ascii(cmd.argument()));
+                               lyx::dispatch(fr);
+                               break;
+                       } else
+                               // Unknown style. Report and fall back to default.
+                               cur.errorMessage(from_utf8(N_("Table Style ")) + from_utf8(tabstyle) +
+                                                    from_utf8(N_(" not known")));
+                       
                }
-               // if there were no arguments, just open the dialog
                if (doInsertInset(cur, this, cmd, false, true))
                        cur.posForward();
-               else
-                       bv->showDialog("tabularcreate");
-
                break;
        }