From 30360e1b1909c0450663487e73a2819c56fa8921 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 15:27:48 +0000 Subject: [PATCH] move more functions from InsetCollapsable::getStatus to Text git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30566 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text3.cpp | 97 +++++++++++++++++++++++++++++++- src/insets/InsetCollapsable.cpp | 98 --------------------------------- src/insets/InsetText.cpp | 2 +- 3 files changed, 96 insertions(+), 101 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index d48c15ac46..7c8678158c 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2611,6 +2611,13 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, break; } + case LFUN_LANGUAGE: + // FIXME: use isPassThru() here? + enable = !cur.inset().forceLTR(); + + case LFUN_BREAK_PARAGRAPH: + enable = cur.inset().getLayout().isMultiPar(); + case LFUN_WORD_DELETE_FORWARD: case LFUN_WORD_DELETE_BACKWARD: case LFUN_LINE_DELETE: @@ -2646,7 +2653,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_LINE_END: case LFUN_CHAR_DELETE_FORWARD: case LFUN_CHAR_DELETE_BACKWARD: - case LFUN_BREAK_PARAGRAPH: case LFUN_PARAGRAPH_SPACING: case LFUN_INSET_INSERT: case LFUN_WORD_UPCASE: @@ -2670,7 +2676,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_FONT_UULINE: case LFUN_FONT_UWAVE: case LFUN_FONT_SIZE: - case LFUN_LANGUAGE: case LFUN_TEXTSTYLE_APPLY: case LFUN_TEXTSTYLE_UPDATE: case LFUN_LAYOUT_PARAGRAPH: @@ -2716,6 +2721,94 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, && (cur.empty() || !cur.inset().insetAllowed(code))) enable = false; + switch (cmd.action) { + case LFUN_ACCENT_ACUTE: + case LFUN_ACCENT_BREVE: + case LFUN_ACCENT_CARON: + case LFUN_ACCENT_CEDILLA: + case LFUN_ACCENT_CIRCLE: + case LFUN_ACCENT_CIRCUMFLEX: + case LFUN_ACCENT_DOT: + case LFUN_ACCENT_GRAVE: + case LFUN_ACCENT_HUNGARIAN_UMLAUT: + case LFUN_ACCENT_MACRON: + case LFUN_ACCENT_OGONEK: + case LFUN_ACCENT_TIE: + case LFUN_ACCENT_TILDE: + case LFUN_ACCENT_UMLAUT: + case LFUN_ACCENT_UNDERBAR: + case LFUN_ACCENT_UNDERDOT: + case LFUN_APPENDIX: + case LFUN_BOX_INSERT: + case LFUN_BRANCH_INSERT: + case LFUN_CAPTION_INSERT: + case LFUN_DEPTH_DECREMENT: + case LFUN_DEPTH_INCREMENT: + case LFUN_ERT_INSERT: + case LFUN_FILE_INSERT: + case LFUN_FLEX_INSERT: + case LFUN_FLOAT_INSERT: + case LFUN_FLOAT_LIST_INSERT: + case LFUN_FLOAT_WIDE_INSERT: + case LFUN_FONT_BOLD: + case LFUN_FONT_BOLDSYMBOL: + case LFUN_FONT_TYPEWRITER: + case LFUN_FONT_DEFAULT: + case LFUN_FONT_EMPH: + case LFUN_FONT_NOUN: + case LFUN_FONT_ROMAN: + case LFUN_FONT_SANS: + case LFUN_FONT_FRAK: + case LFUN_FONT_ITAL: + case LFUN_FONT_SIZE: + case LFUN_FONT_STATE: + case LFUN_FONT_UNDERLINE: + case LFUN_FONT_STRIKEOUT: + case LFUN_FONT_UULINE: + case LFUN_FONT_UWAVE: + case LFUN_FOOTNOTE_INSERT: + case LFUN_HYPERLINK_INSERT: + case LFUN_INDEX_INSERT: + case LFUN_INDEX_PRINT: + case LFUN_INSET_INSERT: + case LFUN_LABEL_GOTO: + case LFUN_LABEL_INSERT: + case LFUN_LAYOUT_TABULAR: + case LFUN_LINE_INSERT: + case LFUN_MARGINALNOTE_INSERT: + case LFUN_MATH_DISPLAY: + case LFUN_MATH_INSERT: + case LFUN_MATH_AMS_MATRIX: + case LFUN_MATH_MATRIX: + case LFUN_MATH_MODE: + case LFUN_MENU_OPEN: + case LFUN_NEWLINE_INSERT: + case LFUN_NEWPAGE_INSERT: + case LFUN_NOACTION: + case LFUN_NOMENCL_INSERT: + case LFUN_NOMENCL_PRINT: + case LFUN_NOTE_INSERT: + case LFUN_NOTE_NEXT: + case LFUN_OPTIONAL_INSERT: + case LFUN_PHANTOM_INSERT: + case LFUN_REFERENCE_NEXT: + case LFUN_SERVER_GOTO_FILE_ROW: + case LFUN_SERVER_NOTIFY: + case LFUN_SERVER_SET_XY: + case LFUN_SPACE_INSERT: + case LFUN_SPECIALCHAR_INSERT: + case LFUN_TABULAR_INSERT: + case LFUN_TEXTSTYLE_APPLY: + case LFUN_TEXTSTYLE_UPDATE: + case LFUN_TOC_INSERT: + case LFUN_WRAP_INSERT: + if (!cur.inset().getLayout().isPassThru()) + enable = false; + break; + default: + break; + } + flag.setEnabled(enable); return true; } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index c23f45f70e..9c75d81fee 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -558,96 +558,6 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { switch (cmd.action) { - // FIXME At present, these are being enabled and disabled according to - // whether PASSTHRU has been set in the InsetLayout. This makes some - // sense, but there are other checks that should really be done. E.g., - // one should not be able to inset IndexPrint inside an optional argument!! - case LFUN_ACCENT_ACUTE: - case LFUN_ACCENT_BREVE: - case LFUN_ACCENT_CARON: - case LFUN_ACCENT_CEDILLA: - case LFUN_ACCENT_CIRCLE: - case LFUN_ACCENT_CIRCUMFLEX: - case LFUN_ACCENT_DOT: - case LFUN_ACCENT_GRAVE: - case LFUN_ACCENT_HUNGARIAN_UMLAUT: - case LFUN_ACCENT_MACRON: - case LFUN_ACCENT_OGONEK: - case LFUN_ACCENT_TIE: - case LFUN_ACCENT_TILDE: - case LFUN_ACCENT_UMLAUT: - case LFUN_ACCENT_UNDERBAR: - case LFUN_ACCENT_UNDERDOT: - case LFUN_APPENDIX: - case LFUN_BOX_INSERT: - case LFUN_BRANCH_INSERT: - case LFUN_CAPTION_INSERT: - case LFUN_DEPTH_DECREMENT: - case LFUN_DEPTH_INCREMENT: - case LFUN_ERT_INSERT: - case LFUN_FILE_INSERT: - case LFUN_FLEX_INSERT: - case LFUN_FLOAT_INSERT: - case LFUN_FLOAT_LIST_INSERT: - case LFUN_FLOAT_WIDE_INSERT: - case LFUN_FONT_BOLD: - case LFUN_FONT_BOLDSYMBOL: - case LFUN_FONT_TYPEWRITER: - case LFUN_FONT_DEFAULT: - case LFUN_FONT_EMPH: - case LFUN_FONT_NOUN: - case LFUN_FONT_ROMAN: - case LFUN_FONT_SANS: - case LFUN_FONT_FRAK: - case LFUN_FONT_ITAL: - case LFUN_FONT_SIZE: - case LFUN_FONT_STATE: - case LFUN_FONT_UNDERLINE: - case LFUN_FONT_STRIKEOUT: - case LFUN_FONT_UULINE: - case LFUN_FONT_UWAVE: - case LFUN_FOOTNOTE_INSERT: - case LFUN_HYPERLINK_INSERT: - case LFUN_INDEX_INSERT: - case LFUN_INDEX_PRINT: - case LFUN_INSET_INSERT: - case LFUN_LABEL_GOTO: - case LFUN_LABEL_INSERT: - case LFUN_LAYOUT_TABULAR: - case LFUN_LINE_INSERT: - case LFUN_MARGINALNOTE_INSERT: - case LFUN_MATH_DISPLAY: - case LFUN_MATH_INSERT: - case LFUN_MATH_AMS_MATRIX: - case LFUN_MATH_MATRIX: - case LFUN_MATH_MODE: - case LFUN_MENU_OPEN: - case LFUN_NEWLINE_INSERT: - case LFUN_NEWPAGE_INSERT: - case LFUN_NOACTION: - case LFUN_NOMENCL_INSERT: - case LFUN_NOMENCL_PRINT: - case LFUN_NOTE_INSERT: - case LFUN_NOTE_NEXT: - case LFUN_OPTIONAL_INSERT: - case LFUN_PHANTOM_INSERT: - case LFUN_REFERENCE_NEXT: - case LFUN_SERVER_GOTO_FILE_ROW: - case LFUN_SERVER_NOTIFY: - case LFUN_SERVER_SET_XY: - case LFUN_SPACE_INSERT: - case LFUN_SPECIALCHAR_INSERT: - case LFUN_TABULAR_INSERT: - case LFUN_TEXTSTYLE_APPLY: - case LFUN_TEXTSTYLE_UPDATE: - case LFUN_TOC_INSERT: - case LFUN_WRAP_INSERT: - if (getLayout().isPassThru()) { - flag.setEnabled(false); - return true; - } - return InsetText::getStatus(cur, cmd, flag); - case LFUN_INSET_TOGGLE: if (cmd.argument() == "open") flag.setEnabled(status_ != Open); @@ -660,14 +570,6 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd, flag.setEnabled(false); return true; - case LFUN_LANGUAGE: - flag.setEnabled(!getLayout().isForceLtr()); - return InsetText::getStatus(cur, cmd, flag); - - case LFUN_BREAK_PARAGRAPH: - flag.setEnabled(getLayout().isMultiPar()); - return true; - default: return InsetText::getStatus(cur, cmd, flag); } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 709ae04b4f..e960e87347 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -276,7 +276,7 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd) // FIXME this use of forceLTR is dubious // introduced in http://www.lyx.org/trac/changeset/21285 - if (getLayout().isForceLtr()) { + if (forceLTR()) { // 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