2003-11-12 14:38:26 +00:00
|
|
|
/**
|
2007-09-05 15:29:04 +00:00
|
|
|
* \file InsetFlex.cpp
|
2003-11-12 14:38:26 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Martin Vermeer
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2003-11-12 14:38:26 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
#include "InsetFlex.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
2009-10-26 23:49:43 +00:00
|
|
|
#include "Cursor.h"
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "FuncStatus.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2008-06-18 18:54:31 +00:00
|
|
|
|
|
|
|
#include "support/gettext.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2008-04-09 09:36:08 +00:00
|
|
|
#include <ostream>
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
2008-04-05 20:24:05 +00:00
|
|
|
InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
|
2008-10-26 02:25:57 +00:00
|
|
|
: InsetCollapsable(buf), name_(layoutName)
|
2003-11-12 14:38:26 +00:00
|
|
|
{
|
2008-10-26 02:25:57 +00:00
|
|
|
status_= Collapsed;
|
2003-11-12 14:38:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
InsetFlex::InsetFlex(InsetFlex const & in)
|
2007-11-05 10:14:19 +00:00
|
|
|
: InsetCollapsable(in), name_(in.name_)
|
2007-11-03 00:56:48 +00:00
|
|
|
{}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
2009-07-13 14:06:05 +00:00
|
|
|
InsetLayout::InsetDecoration InsetFlex::decoration() const
|
|
|
|
{
|
|
|
|
InsetLayout::InsetDecoration const dec = getLayout().decoration();
|
|
|
|
return dec == InsetLayout::DEFAULT ? InsetLayout::CONGLOMERATE : dec;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetFlex::write(ostream & os) const
|
2003-11-12 14:38:26 +00:00
|
|
|
{
|
2008-02-14 03:42:54 +00:00
|
|
|
os << "Flex " <<
|
2008-02-14 03:49:12 +00:00
|
|
|
(name_.empty() ? "undefined" : name_) << "\n";
|
2008-02-27 20:43:16 +00:00
|
|
|
InsetCollapsable::write(os);
|
2003-11-12 14:38:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-26 23:49:43 +00:00
|
|
|
bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|
|
|
FuncStatus & flag) const
|
|
|
|
{
|
|
|
|
switch (cmd.action) {
|
|
|
|
case LFUN_INSET_DISSOLVE:
|
|
|
|
if (!cmd.argument().empty()) {
|
|
|
|
InsetLayout const & il = getLayout();
|
|
|
|
InsetLayout::InsetLyXType const type =
|
|
|
|
translateLyXType(to_utf8(cmd.argument()));
|
|
|
|
if (il.lyxtype() == type) {
|
|
|
|
FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
|
|
|
|
return InsetCollapsable::getStatus(cur, temp_cmd, flag);
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// fall-through
|
|
|
|
default:
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|
|
|
{
|
|
|
|
switch (cmd.action) {
|
|
|
|
case LFUN_INSET_DISSOLVE:
|
|
|
|
if (!cmd.argument().empty()) {
|
|
|
|
InsetLayout const & il = getLayout();
|
|
|
|
InsetLayout::InsetLyXType const type =
|
|
|
|
translateLyXType(to_utf8(cmd.argument()));
|
|
|
|
|
|
|
|
if (il.lyxtype() == type) {
|
|
|
|
FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
|
|
|
|
InsetCollapsable::doDispatch(cur, temp_cmd);
|
|
|
|
} else
|
|
|
|
cur.undispatched();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fall-through
|
|
|
|
default:
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|