branch: Fix #6045: Possible to insert table floats into figure floats.

The lfuns, LFUN_FLOAT_INSERT and LFUN_WRAP_INSERT are now only enabled when they should be.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@31318 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-09-07 08:40:40 +00:00
parent 0c0b77274a
commit 0113ce8310
3 changed files with 46 additions and 7 deletions

View File

@ -52,13 +52,15 @@
#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
#include "insets/InsetExternal.h"
#include "insets/InsetFloat.h"
#include "insets/InsetGraphics.h"
#include "insets/InsetGraphicsParams.h"
#include "insets/InsetFloatList.h"
#include "insets/InsetNewline.h"
#include "insets/InsetQuotes.h"
#include "insets/InsetSpecialChar.h"
#include "insets/InsetText.h"
#include "insets/InsetGraphics.h"
#include "insets/InsetGraphicsParams.h"
#include "insets/InsetWrap.h"
#include "support/convert.h"
#include "support/debug.h"
@ -2062,9 +2064,36 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
break;
case LFUN_FLOAT_INSERT:
case LFUN_FLOAT_WIDE_INSERT:
// FIXME: If there is a selection, we should check whether there
// are floats in the selection, but this has performance issues, see
// LFUN_CHANGE_ACCEPT/REJECT.
code = FLOAT_CODE;
// not allowed in description items
enable = !inDescriptionItem(cur);
if (inDescriptionItem(cur))
// not allowed in description items
enable = false;
else {
InsetCode const inset_code = cur.inset().lyxCode();
// algorithm floats cannot be put in another float
if (to_utf8(cmd.argument()) == "algorithm") {
enable = inset_code != WRAP_CODE && inset_code != FLOAT_CODE;
break;
}
// for figures and tables: only allow in another
// float or wrap if it is of the same type and
// not a subfloat already
if(cur.inset().lyxCode() == code) {
InsetFloat const & ins =
static_cast<InsetFloat const &>(cur.inset());
enable = ins.params().type == to_utf8(cmd.argument())
&& !ins.params().subfloat;
} else if(cur.inset().lyxCode() == WRAP_CODE) {
InsetWrap const & ins =
static_cast<InsetWrap const &>(cur.inset());
enable = ins.params().type == to_utf8(cmd.argument());
}
}
break;
case LFUN_WRAP_INSERT:
code = WRAP_CODE;

View File

@ -380,9 +380,16 @@ int InsetFloat::docbook(odocstream & os, OutputParams const & runparams) const
bool InsetFloat::insetAllowed(InsetCode code) const
{
return code != FOOT_CODE
&& code != MARGIN_CODE
&& (code != FLOAT_CODE || !params_.subfloat);
// The case that code == FLOAT_CODE is handled in Text3.cpp,
// because we need to know what type of float is meant.
switch(code) {
case WRAP_CODE:
case FOOT_CODE:
case MARGIN_CODE:
return false;
default:
return InsetCollapsable::insetAllowed(code);
}
}

View File

@ -65,6 +65,9 @@ What's new
- Sort document classes case insensitively (bug 1492).
- Disable to insert floats into another float when this is not
allowed (bug 6045).
* DOCUMENTATION AND LOCALIZATION