+ Layout::LaTeXArgMap args = tclass[layout].args();
+ Layout::LaTeXArgMap::const_iterator lait = args.begin();
+ Layout::LaTeXArgMap::const_iterator const laend = args.end();
+ for (; lait != laend; ++lait) {
+ Layout::latexarg arg = (*lait).second;
+ if (arg.autoinsert) {
+ FuncRequest cmd(LFUN_ARGUMENT_INSERT, (*lait).first);
+ lyx::dispatch(cmd);
+ }
+ }
+
+ break;
+ }
+
+ case LFUN_ENVIRONMENT_SPLIT: {
+ bool const outer = cmd.argument() == "outer";
+ Paragraph const & para = cur.paragraph();
+ docstring layout = para.layout().name();
+ depth_type split_depth = cur.paragraph().params().depth();
+ if (outer) {
+ // check if we have an environment in our nesting hierarchy
+ pit_type pit = cur.pit();
+ Paragraph cpar = pars_[pit];
+ while (true) {
+ if (pit == 0 || cpar.params().depth() == 0)
+ break;
+ --pit;
+ cpar = pars_[pit];
+ if (cpar.params().depth() < split_depth
+ && cpar.layout().isEnvironment()) {
+ layout = cpar.layout().name();
+ split_depth = cpar.params().depth();
+ }
+ }
+ }
+ if (cur.pos() > 0)
+ lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK));
+ if (outer) {
+ while (cur.paragraph().params().depth() > split_depth)
+ lyx::dispatch(FuncRequest(LFUN_DEPTH_DECREMENT));
+ }
+ DocumentClass const & tc = bv->buffer().params().documentClass();
+ lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name()));
+ lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
+ lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
+ lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
+