2002-09-12 14:58:06 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file factory.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
2002-08-27 10:14:56 +00:00
|
|
|
|
|
|
|
|
|
#include "funcrequest.h"
|
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "FloatList.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "BufferView.h"
|
2002-08-28 17:33:42 +00:00
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/insetcaption.h"
|
2002-08-27 10:14:56 +00:00
|
|
|
|
#include "insets/insetert.h"
|
|
|
|
|
#include "insets/insetexternal.h"
|
|
|
|
|
#include "insets/insetfloat.h"
|
|
|
|
|
#include "insets/insetfoot.h"
|
2002-08-28 17:33:42 +00:00
|
|
|
|
#include "insets/insetindex.h"
|
2002-08-27 10:14:56 +00:00
|
|
|
|
#include "insets/insetmarginal.h"
|
|
|
|
|
#include "insets/insetminipage.h"
|
|
|
|
|
#include "insets/insetnote.h"
|
|
|
|
|
#include "insets/insetoptarg.h"
|
|
|
|
|
#include "insets/insetparent.h"
|
|
|
|
|
#include "insets/insetref.h"
|
2002-08-27 15:56:32 +00:00
|
|
|
|
#include "insets/insettabular.h"
|
2002-08-27 10:14:56 +00:00
|
|
|
|
#include "insets/insettext.h"
|
2002-08-28 17:33:42 +00:00
|
|
|
|
#include "insets/insettoc.h"
|
2002-08-29 13:05:55 +00:00
|
|
|
|
#include "insets/inseturl.h"
|
2002-09-10 10:18:58 +00:00
|
|
|
|
#include "insets/insetwrap.h"
|
2002-08-27 15:56:32 +00:00
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdio>
|
2002-08-27 10:14:56 +00:00
|
|
|
|
|
2002-09-03 12:31:22 +00:00
|
|
|
|
using std::endl;
|
2002-08-27 10:14:56 +00:00
|
|
|
|
|
|
|
|
|
Inset * createInset(FuncRequest const & cmd)
|
|
|
|
|
{
|
2002-08-27 15:56:32 +00:00
|
|
|
|
BufferView * bv = cmd.view();
|
|
|
|
|
BufferParams const & params = bv->buffer()->params;
|
2002-08-27 10:14:56 +00:00
|
|
|
|
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_MINIPAGE:
|
|
|
|
|
return new InsetMinipage(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSERT_NOTE:
|
|
|
|
|
return new InsetNote(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
|
return new InsetERT(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_EXTERNAL:
|
|
|
|
|
return new InsetExternal;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
|
return new InsetFoot(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
|
return new InsetMarginal(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_OPTARG:
|
|
|
|
|
return new InsetOptArg(params);
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_FLOAT:
|
2002-08-27 15:51:19 +00:00
|
|
|
|
// check if the float type exists
|
|
|
|
|
if (params.getLyXTextClass().floats().typeExist(cmd.argument))
|
2002-08-27 10:14:56 +00:00
|
|
|
|
return new InsetFloat(params, cmd.argument);
|
|
|
|
|
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
2002-08-27 15:51:19 +00:00
|
|
|
|
// check if the float type exists
|
|
|
|
|
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
|
2002-08-27 10:14:56 +00:00
|
|
|
|
InsetFloat * p = new InsetFloat(params, cmd.argument);
|
2002-08-27 15:51:19 +00:00
|
|
|
|
p->wide(true, params);
|
2002-08-27 10:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
|
2002-09-10 10:18:58 +00:00
|
|
|
|
case LFUN_INSET_WRAP:
|
|
|
|
|
if (cmd.argument == "figure")
|
|
|
|
|
return new InsetWrap(params, cmd.argument);
|
|
|
|
|
lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_INDEX_INSERT: {
|
|
|
|
|
string entry = cmd.argument;
|
|
|
|
|
if (entry.empty())
|
|
|
|
|
entry = bv->getLyXText()->getStringToIndex(bv);
|
|
|
|
|
if (!entry.empty())
|
|
|
|
|
return new InsetIndex(InsetCommandParams("index", entry));
|
|
|
|
|
bv->owner()->getDialogs().createIndex();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-27 15:56:32 +00:00
|
|
|
|
case LFUN_TABULAR_INSERT:
|
|
|
|
|
if (!cmd.argument.empty()) {
|
|
|
|
|
int r = 2;
|
|
|
|
|
int c = 2;
|
|
|
|
|
::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
|
|
|
|
|
return new InsetTabular(*bv->buffer(), r, c);
|
|
|
|
|
}
|
|
|
|
|
bv->owner()->getDialogs().showTabularCreate();
|
|
|
|
|
return 0;
|
|
|
|
|
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_INSET_CAPTION:
|
|
|
|
|
if (bv->theLockingInset()) {
|
|
|
|
|
lyxerr << "Locking inset code: "
|
|
|
|
|
<< static_cast<int>(bv->theLockingInset()->lyxCode());
|
|
|
|
|
InsetCaption * inset = new InsetCaption(params);
|
|
|
|
|
inset->setOwner(bv->theLockingInset());
|
|
|
|
|
inset->setAutoBreakRows(true);
|
|
|
|
|
inset->setDrawFrame(0, InsetText::LOCKED);
|
|
|
|
|
inset->setFrameColor(0, LColor::captionframe);
|
|
|
|
|
return inset;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case LFUN_INDEX_PRINT:
|
|
|
|
|
return new InsetPrintIndex(InsetCommandParams("printindex"));
|
|
|
|
|
|
|
|
|
|
case LFUN_TOC_INSERT:
|
|
|
|
|
return new InsetTOC(InsetCommandParams("tableofcontents"));
|
|
|
|
|
|
|
|
|
|
case LFUN_PARENTINSERT:
|
|
|
|
|
return new InsetParent(
|
|
|
|
|
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
|
|
|
|
|
|
2002-08-29 13:05:55 +00:00
|
|
|
|
case LFUN_INSERT_URL:
|
|
|
|
|
{
|
|
|
|
|
InsetCommandParams p;
|
|
|
|
|
p.setFromString(cmd.argument);
|
|
|
|
|
return new InsetUrl(p);
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-27 10:14:56 +00:00
|
|
|
|
#if 0
|
|
|
|
|
case LFUN_INSET_LIST:
|
|
|
|
|
return new InsetList;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_THEOREM:
|
|
|
|
|
return new InsetTheorem;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|