#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
#include "insets/InsetExternal.h"
+#include "insets/InsetFloat.h"
#include "insets/InsetFloatList.h"
#include "insets/InsetGraphics.h"
#include "insets/InsetGraphicsParams.h"
#include "insets/InsetQuotes.h"
#include "insets/InsetSpecialChar.h"
#include "insets/InsetText.h"
+#include "insets/InsetWrap.h"
#include "support/convert.h"
#include "support/debug.h"
if (!inset)
return false;
+ if (InsetCollapsable * ci = inset->asInsetCollapsable())
+ ci->setButtonLabel();
+
cur.recordUndo();
if (cmd.action == LFUN_INDEX_INSERT) {
docstring ds = subst(text->getStringToIndex(cur), '\n', ' ');
if (edit)
inset->edit(cur, true);
// Now put this into inset
- cur.text()->insertStringAsLines(cur, ds);
+ cur.text()->insertStringAsLines(cur, ds, cur.current_font);
cur.leaveInset(*inset);
return true;
}
}
-bool Text::isRTL(Buffer const & buffer, Paragraph const & par) const
+bool Text::isRTL(Paragraph const & par) const
{
+ Buffer const & buffer = owner_->buffer();
return par.isRTL(buffer.params());
}
if (layout.empty())
layout = tclass.defaultLayoutName();
- if (para.forcePlainLayout())
+ if (owner_->forcePlainLayout())
// in this case only the empty layout is allowed
layout = tclass.plainLayoutName();
else if (para.usePlainLayout()) {
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;
enable = cur.inset().lyxCode() == FLEX_CODE
&& il.lyxtype() == type;
} else {
- enable = ((!isMainText(cur.bv().buffer())
+ enable = ((!isMainText()
&& cur.inset().nargs() == 1)
|| (cur.nextInset()
&& cur.nextInset()->nargs() == 1));
// However, without proper optimizations, this will inevitably
// result in unacceptable performance - just imagine a user who
// wants to select the complete content of a long document.
- if (!cur.selection()) {
- Change const & change = cur.paragraph().lookupChange(cur.pos());
- enable = change.changed();
- } else
+ if (!cur.selection())
+ enable = cur.paragraph().isChanged(cur.pos());
+ else
// TODO: context-sensitive enabling of LFUN_CHANGE_ACCEPT/REJECT
// for selections.
enable = true;
case LFUN_OUTLINE_OUT:
case LFUN_OUTLINE_DRAGMOVE:
// FIXME: LyX is not ready for outlining within inset.
- enable = isMainText(cur.bv().buffer())
+ enable = isMainText()
&& cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC;
break;
if (!clip.empty()) {
cur.recordUndo();
if (asParagraphs)
- insertStringAsParagraphs(cur, clip);
+ insertStringAsParagraphs(cur, clip, cur.current_font);
else
- insertStringAsLines(cur, clip);
+ insertStringAsLines(cur, clip, cur.current_font);
}
}