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
13 #include "funcrequest.h"
14 #include "bufferparams.h"
16 #include "FloatList.h"
18 #include "BufferView.h"
21 #include "insets/insetcaption.h"
22 #include "insets/insetert.h"
23 #include "insets/insetexternal.h"
24 #include "insets/insetfloat.h"
25 #include "insets/insetfoot.h"
26 #include "insets/insetindex.h"
27 #include "insets/insetmarginal.h"
28 #include "insets/insetminipage.h"
29 #include "insets/insetnote.h"
30 #include "insets/insetoptarg.h"
31 #include "insets/insetparent.h"
32 #include "insets/insetref.h"
33 #include "insets/insettabular.h"
34 #include "insets/insettext.h"
35 #include "insets/insettoc.h"
36 #include "insets/inseturl.h"
37 #include "insets/insetwrap.h"
38 #include "frontends/Dialogs.h"
39 #include "frontends/LyXView.h"
45 Inset * createInset(FuncRequest const & cmd)
47 BufferView * bv = cmd.view();
48 BufferParams const & params = bv->buffer()->params;
52 case LFUN_INSET_MINIPAGE:
53 return new InsetMinipage(params);
55 case LFUN_INSERT_NOTE:
56 return new InsetNote(params);
59 return new InsetERT(params);
61 case LFUN_INSET_EXTERNAL:
62 return new InsetExternal;
64 case LFUN_INSET_FOOTNOTE:
65 return new InsetFoot(params);
67 case LFUN_INSET_MARGINAL:
68 return new InsetMarginal(params);
70 case LFUN_INSET_OPTARG:
71 return new InsetOptArg(params);
73 case LFUN_INSET_FLOAT:
74 // check if the float type exists
75 if (params.getLyXTextClass().floats().typeExist(cmd.argument))
76 return new InsetFloat(params, cmd.argument);
77 lyxerr << "Non-existent float type: " << cmd.argument << endl;
80 case LFUN_INSET_WIDE_FLOAT:
81 // check if the float type exists
82 if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
83 InsetFloat * p = new InsetFloat(params, cmd.argument);
84 p->wide(true, params);
86 lyxerr << "Non-existent float type: " << cmd.argument << endl;
90 if (cmd.argument == "figure")
91 return new InsetWrap(params, cmd.argument);
92 lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
95 case LFUN_INDEX_INSERT: {
96 string entry = cmd.argument;
98 entry = bv->getLyXText()->getStringToIndex(bv);
100 return new InsetIndex(InsetCommandParams("index", entry));
101 bv->owner()->getDialogs().createIndex();
105 case LFUN_TABULAR_INSERT:
106 if (!cmd.argument.empty()) {
109 ::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
110 return new InsetTabular(*bv->buffer(), r, c);
112 bv->owner()->getDialogs().showTabularCreate();
115 case LFUN_INSET_CAPTION:
116 if (bv->theLockingInset()) {
117 lyxerr << "Locking inset code: "
118 << static_cast<int>(bv->theLockingInset()->lyxCode());
119 InsetCaption * inset = new InsetCaption(params);
120 inset->setOwner(bv->theLockingInset());
121 inset->setAutoBreakRows(true);
122 inset->setDrawFrame(0, InsetText::LOCKED);
123 inset->setFrameColor(0, LColor::captionframe);
128 case LFUN_INDEX_PRINT:
129 return new InsetPrintIndex(InsetCommandParams("printindex"));
131 case LFUN_TOC_INSERT:
132 return new InsetTOC(InsetCommandParams("tableofcontents"));
134 case LFUN_PARENTINSERT:
135 return new InsetParent(
136 InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
138 case LFUN_INSERT_URL:
140 InsetCommandParams p;
141 p.setFromString(cmd.argument);
142 return new InsetUrl(p);
146 case LFUN_INSET_LIST:
147 return new InsetList;
149 case LFUN_INSET_THEOREM:
150 return new InsetTheorem;