]> git.lyx.org Git - features.git/commitdiff
Cleanup handling of LFUN_LAYOUT in getStatus
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 May 2016 12:10:30 +0000 (14:10 +0200)
committerRichard Heck <rgheck@lyx.org>
Sun, 29 May 2016 21:55:46 +0000 (17:55 -0400)
The way it works is:
* the inset defines forcePlainLayout() correctly
* Text::getStatus acts on it.

Note that, in Text::getStatus, testing for cur.inset().forcePlainLayout() does not make much sense, since one should pass the cursor idx as parameter.

There are many other lfuns that do not have to be handled directly by insets. InsetScript in particular has tests for way too many lfuns.

src/Text3.cpp
src/insets/InsetScript.cpp
src/insets/InsetScript.h
src/insets/InsetTabular.cpp

index 0e8b4127be617e84a1e7331f83631eb8b054c458..352d3cb429800660a24e1bdbbfb7a28f9f7f1c8e 100644 (file)
@@ -3109,7 +3109,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                docstring layout = cmd.argument();
                if (layout.empty())
                        layout = tclass.defaultLayoutName();
-               enable = !cur.inset().forcePlainLayout() && tclass.hasLayout(layout);
+               enable = !owner_->forcePlainLayout() && tclass.hasLayout(layout);
 
                flag.setOnOff(layout == cur.paragraph().layout().name());
                break;
index f8aae1e0c59d3a9eb789f4717b131027052d3d96..830307508daa541fbdcd1f230276cf0e39ea0b84 100644 (file)
@@ -263,7 +263,6 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
        switch (cmd.action()) {
-       case LFUN_LAYOUT:
        case LFUN_LAYOUT_PARAGRAPH:
        case LFUN_MATH_DISPLAY:
        case LFUN_BOX_INSERT:
index decfee37aeca3a3e7683ac51759295f2e40950c8..84ed50e1b12a09c94749556d8a98004b44fecc49 100644 (file)
@@ -80,6 +80,8 @@ public:
        ///
        void read(Lexer & lex);
        ///
+       bool forcePlainLayout(idx_type = 0) const { return true; }
+       ///
        bool neverIndent() const { return true; }
        ///
        int plaintext(odocstringstream & ods, OutputParams const & op,
index dda3003b835bba4e92fd010c20a4ede5d2aa9bb7..71036cc0fb10a8e229d36fe484b646b048d1e407 100644 (file)
@@ -3413,9 +3413,6 @@ bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        bool enabled = true;
        switch (cmd.action()) {
-       case LFUN_LAYOUT:
-               enabled = !forcePlainLayout();
-               break;
        case LFUN_LAYOUT_PARAGRAPH:
                enabled = allowParagraphCustomization();
                break;