void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd) { LYXERR(Debug::ACTION, "InsetText::doDispatch(): cmd: " << cmd); // See bug #9042, for instance. if (isPassThru()) { // Force any new text to latex_language FIXME: This // should only be necessary in constructor, but new // paragraphs that are created by pressing enter at // the start of an existing paragraph get the buffer // language and not latex_language, so we take this // brute force approach. cur.current_font.setLanguage(latex_language); cur.real_current_font.setLanguage(latex_language); } switch (cmd.action()) { case LFUN_PASTE: case LFUN_CLIPBOARD_PASTE: case LFUN_SELECTION_PASTE: case LFUN_PRIMARY_SELECTION_PASTE: text_.dispatch(cur, cmd); // If we we can only store plain text, we must reset all // attributes. // FIXME: Change only the pasted paragraphs fixParagraphsFont(); break; case LFUN_INSET_DISSOLVE: { bool const main_inset = text_.isMainText(); bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); // cur.inset() is the tabular when this is a single cell (bug #9954) bool const one_cell = cur.inset().nargs() == 1; if (!main_inset && target_inset && one_cell) { // Text::dissolveInset assumes that the cursor // is inside the Inset. if (&cur.inset() != this) cur.pushBackward(*this); cur.beginUndoGroup(); text_.dispatch(cur, cmd); cur.endUndoGroup(); } else cur.undispatched(); break; } default: text_.dispatch(cur, cmd); } if (!cur.result().dispatched()) Inset::doDispatch(cur, cmd); }
void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd) { Inset * inset = itemInset(); FuncRequest tmpcmd(cmd); QModelIndex const & index = tocTV->currentIndex(); TocItem const & item = gui_view_.tocModels().currentItem(current_type_, index); // Start an undo group. cur.beginUndoGroup(); switch (cmd.action()) { case LFUN_CHANGE_ACCEPT: case LFUN_CHANGE_REJECT: case LFUN_SECTION_SELECT: dispatch(item.action()); cur.dispatch(tmpcmd); break; case LFUN_LABEL_COPY_AS_REF: { // For labels in math, we need to supply the label as a string FuncRequest label_copy(LFUN_LABEL_COPY_AS_REF, item.asString()); if (inset) inset->dispatch(cur, label_copy); break; } case LFUN_OUTLINE_UP: case LFUN_OUTLINE_DOWN: case LFUN_OUTLINE_IN: case LFUN_OUTLINE_OUT: outline(cmd.action()); break; default: if (inset) inset->dispatch(cur, tmpcmd); } cur.endUndoGroup(); }