3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
11 #include "funcrequest.h"
12 #include "bufferparams.h"
14 #include "FloatList.h"
16 #include "BufferView.h"
19 #include "insets/insetcaption.h"
20 #include "insets/insetert.h"
21 #include "insets/insetexternal.h"
22 #include "insets/insetfloat.h"
23 #include "insets/insetfoot.h"
24 #include "insets/insetindex.h"
25 #include "insets/insetmarginal.h"
26 #include "insets/insetminipage.h"
27 #include "insets/insetnote.h"
28 #include "insets/insetoptarg.h"
29 #include "insets/insetparent.h"
30 #include "insets/insetref.h"
31 #include "insets/insettabular.h"
32 #include "insets/insettext.h"
33 #include "insets/insettoc.h"
34 #include "insets/inseturl.h"
35 #include "insets/insetwrap.h"
36 #include "frontends/Dialogs.h"
37 #include "frontends/LyXView.h"
43 Inset * createInset(FuncRequest const & cmd)
45 BufferView * bv = cmd.view();
46 BufferParams const & params = bv->buffer()->params;
50 case LFUN_INSET_MINIPAGE:
51 return new InsetMinipage(params);
53 case LFUN_INSERT_NOTE:
54 return new InsetNote(params);
57 return new InsetERT(params);
59 case LFUN_INSET_EXTERNAL:
60 return new InsetExternal;
62 case LFUN_INSET_FOOTNOTE:
63 return new InsetFoot(params);
65 case LFUN_INSET_MARGINAL:
66 return new InsetMarginal(params);
68 case LFUN_INSET_OPTARG:
69 return new InsetOptArg(params);
71 case LFUN_INSET_FLOAT:
72 // check if the float type exists
73 if (params.getLyXTextClass().floats().typeExist(cmd.argument))
74 return new InsetFloat(params, cmd.argument);
75 lyxerr << "Non-existent float type: " << cmd.argument << endl;
78 case LFUN_INSET_WIDE_FLOAT:
79 // check if the float type exists
80 if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
81 InsetFloat * p = new InsetFloat(params, cmd.argument);
82 p->wide(true, params);
84 lyxerr << "Non-existent float type: " << cmd.argument << endl;
88 if (cmd.argument == "figure")
89 return new InsetWrap(params, cmd.argument);
90 lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
93 case LFUN_INDEX_INSERT: {
94 string entry = cmd.argument;
96 entry = bv->getLyXText()->getStringToIndex(bv);
98 return new InsetIndex(InsetCommandParams("index", entry));
99 bv->owner()->getDialogs().createIndex();
103 case LFUN_TABULAR_INSERT:
104 if (!cmd.argument.empty()) {
107 ::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
108 return new InsetTabular(*bv->buffer(), r, c);
110 bv->owner()->getDialogs().showTabularCreate();
113 case LFUN_INSET_CAPTION:
114 if (bv->theLockingInset()) {
115 lyxerr << "Locking inset code: "
116 << static_cast<int>(bv->theLockingInset()->lyxCode());
117 InsetCaption * inset = new InsetCaption(params);
118 inset->setOwner(bv->theLockingInset());
119 inset->setAutoBreakRows(true);
120 inset->setDrawFrame(0, InsetText::LOCKED);
121 inset->setFrameColor(0, LColor::captionframe);
126 case LFUN_INDEX_PRINT:
127 return new InsetPrintIndex(InsetCommandParams("printindex"));
129 case LFUN_TOC_INSERT:
130 return new InsetTOC(InsetCommandParams("tableofcontents"));
132 case LFUN_PARENTINSERT:
133 return new InsetParent(
134 InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
136 case LFUN_INSERT_URL:
138 InsetCommandParams p;
139 p.setFromString(cmd.argument);
140 return new InsetUrl(p);
144 case LFUN_INSET_LIST:
145 return new InsetList;
147 case LFUN_INSET_THEOREM:
148 return new InsetTheorem;