3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
7 * \author Martin Vermeer
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "InsetFlex.h"
18 #include "BufferParams.h"
20 #include "FuncRequest.h"
21 #include "FuncStatus.h"
24 #include "support/gettext.h"
33 InsetFlex::InsetFlex(Buffer * buf, string const & layoutName)
34 : InsetCollapsable(buf), name_(layoutName)
40 InsetFlex::InsetFlex(InsetFlex const & in)
41 : InsetCollapsable(in), name_(in.name_)
45 docstring InsetFlex::name() const
47 return from_utf8("Flex:" + name_);
51 InsetLayout::InsetDecoration InsetFlex::decoration() const
53 InsetLayout::InsetDecoration const dec = getLayout().decoration();
54 return dec == InsetLayout::DEFAULT ? InsetLayout::CONGLOMERATE : dec;
58 void InsetFlex::write(ostream & os) const
61 (name_.empty() ? "undefined" : name_) << "\n";
62 InsetCollapsable::write(os);
66 bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
67 FuncStatus & flag) const
69 switch (cmd.action()) {
70 case LFUN_INSET_DISSOLVE:
71 if (!cmd.argument().empty()) {
72 InsetLayout const & il = getLayout();
73 InsetLayout::InsetLyXType const type =
74 translateLyXType(to_utf8(cmd.argument()));
75 if (il.lyxtype() == type) {
76 FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
77 return InsetCollapsable::getStatus(cur, temp_cmd, flag);
83 return InsetCollapsable::getStatus(cur, cmd, flag);
88 void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
90 switch (cmd.action()) {
91 case LFUN_INSET_DISSOLVE:
92 if (!cmd.argument().empty()) {
93 InsetLayout const & il = getLayout();
94 InsetLayout::InsetLyXType const type =
95 translateLyXType(to_utf8(cmd.argument()));
97 if (il.lyxtype() == type) {
98 FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
99 InsetCollapsable::doDispatch(cur, temp_cmd);
106 InsetCollapsable::doDispatch(cur, cmd);