+ case LFUN_TABULAR_STYLE_INSERT: {
+ string const style = cmd.getArg(0);
+ string const rows = cmd.getArg(1);
+ string const cols = cmd.getArg(2);
+ if (cols.empty() || !isStrInt(cols)
+ || rows.empty() || !isStrInt(rows))
+ break;
+ int const r = convert<int>(rows);
+ int const c = convert<int>(cols);
+
+ string suffix;
+ if (r == 1)
+ suffix = "_1x1";
+ else if (r == 2)
+ suffix = "_1x2";
+ FileName const tabstyle = libFileSearch("tabletemplates",
+ style + suffix + ".lyx", "lyx");
+ if (tabstyle.empty())
+ break;
+ UndoGroupHelper ugh(cur.buffer());
+ cur.recordUndo();
+ FuncRequest cmd2(LFUN_FILE_INSERT, tabstyle.absFileName() + " ignorelang");
+ lyx::dispatch(cmd2);
+ // go into table
+ cur.backwardPos();
+ if (r > 2) {
+ // move one cell up to middle cell
+ cur.up();
+ // add the missing rows
+ int const addrows = r - 3;
+ for (int i = 0 ; i < addrows ; ++i) {
+ FuncRequest fr(LFUN_TABULAR_FEATURE, "append-row");
+ lyx::dispatch(fr);
+ }
+ }
+ // add the missing columns
+ int const addcols = c - 1;
+ for (int i = 0 ; i < addcols ; ++i) {
+ FuncRequest fr(LFUN_TABULAR_FEATURE, "append-column");
+ lyx::dispatch(fr);
+ }
+ if (r > 1)
+ // go to first cell
+ cur.up();