From 0d21dca360b55d83acae2a15466fdb879831ff03 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 12 May 2016 14:10:30 +0200 Subject: [PATCH] Cleanup handling of LFUN_LAYOUT in getStatus 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 | 2 +- src/insets/InsetScript.cpp | 1 - src/insets/InsetScript.h | 2 ++ src/insets/InsetTabular.cpp | 3 --- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 0e8b4127be..352d3cb429 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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; diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp index f8aae1e0c5..830307508d 100644 --- a/src/insets/InsetScript.cpp +++ b/src/insets/InsetScript.cpp @@ -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: diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h index decfee37ae..84ed50e1b1 100644 --- a/src/insets/InsetScript.h +++ b/src/insets/InsetScript.h @@ -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, diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index dda3003b83..71036cc0fb 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -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; -- 2.39.2