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.
This commit is contained in:
Jean-Marc Lasgouttes 2016-05-12 14:10:30 +02:00 committed by Richard Heck
parent f78967a802
commit 0d21dca360
4 changed files with 3 additions and 5 deletions

View File

@ -3109,7 +3109,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
docstring layout = cmd.argument(); docstring layout = cmd.argument();
if (layout.empty()) if (layout.empty())
layout = tclass.defaultLayoutName(); layout = tclass.defaultLayoutName();
enable = !cur.inset().forcePlainLayout() && tclass.hasLayout(layout); enable = !owner_->forcePlainLayout() && tclass.hasLayout(layout);
flag.setOnOff(layout == cur.paragraph().layout().name()); flag.setOnOff(layout == cur.paragraph().layout().name());
break; break;

View File

@ -263,7 +263,6 @@ bool InsetScript::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const FuncStatus & flag) const
{ {
switch (cmd.action()) { switch (cmd.action()) {
case LFUN_LAYOUT:
case LFUN_LAYOUT_PARAGRAPH: case LFUN_LAYOUT_PARAGRAPH:
case LFUN_MATH_DISPLAY: case LFUN_MATH_DISPLAY:
case LFUN_BOX_INSERT: case LFUN_BOX_INSERT:

View File

@ -80,6 +80,8 @@ public:
/// ///
void read(Lexer & lex); void read(Lexer & lex);
/// ///
bool forcePlainLayout(idx_type = 0) const { return true; }
///
bool neverIndent() const { return true; } bool neverIndent() const { return true; }
/// ///
int plaintext(odocstringstream & ods, OutputParams const & op, int plaintext(odocstringstream & ods, OutputParams const & op,

View File

@ -3413,9 +3413,6 @@ bool InsetTableCell::getStatus(Cursor & cur, FuncRequest const & cmd,
{ {
bool enabled = true; bool enabled = true;
switch (cmd.action()) { switch (cmd.action()) {
case LFUN_LAYOUT:
enabled = !forcePlainLayout();
break;
case LFUN_LAYOUT_PARAGRAPH: case LFUN_LAYOUT_PARAGRAPH:
enabled = allowParagraphCustomization(); enabled = allowParagraphCustomization();
break; break;