]> git.lyx.org Git - lyx.git/blob - src/factory.C
ac1368b63010f617c2b058786f91e3e5c4c7a707
[lyx.git] / src / factory.C
1
2 #include "funcrequest.h"
3 #include "bufferparams.h"
4 #include "buffer.h"
5 #include "FloatList.h"
6 #include "debug.h"
7 #include "BufferView.h"
8 #include "insets/insetert.h"
9 #include "insets/insetexternal.h"
10 #include "insets/insetfloat.h"
11 #include "insets/insetfoot.h"
12 #include "insets/insetmarginal.h"
13 #include "insets/insetminipage.h"
14 #include "insets/insetnote.h"
15 #include "insets/insetoptarg.h"
16 #include "insets/insetparent.h"
17 #include "insets/insetref.h"
18 #include "insets/insettabular.h"
19 #include "insets/insettext.h"
20 #include "frontends/Dialogs.h"
21 #include "frontends/LyXView.h"
22
23 #include <cstdio>
24
25
26 Inset * createInset(FuncRequest const & cmd)
27 {
28         BufferView * bv = cmd.view();
29         BufferParams const & params = bv->buffer()->params;
30
31         switch (cmd.action) {
32
33                 case LFUN_INSET_MINIPAGE:
34                         return new InsetMinipage(params);
35
36                 case LFUN_INSERT_NOTE:
37                         return new InsetNote(params);
38
39                 case LFUN_INSET_ERT:
40                         return new InsetERT(params);
41
42                 case LFUN_INSET_EXTERNAL:
43                         return new InsetExternal;
44
45                 case LFUN_INSET_FOOTNOTE:
46                         return new InsetFoot(params);
47
48                 case LFUN_INSET_MARGINAL:
49                         return new InsetMarginal(params);
50
51                 case LFUN_INSET_OPTARG:
52                         return new InsetOptArg(params);
53
54                 case LFUN_INSET_FLOAT:
55                         // check if the float type exists
56                         if (params.getLyXTextClass().floats().typeExist(cmd.argument))
57                                 return new InsetFloat(params, cmd.argument);
58                         lyxerr << "Non-existent float type: " << cmd.argument << endl;
59                         return 0;
60
61                 case LFUN_INSET_WIDE_FLOAT:
62                         // check if the float type exists
63                         if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
64                                 InsetFloat * p = new InsetFloat(params, cmd.argument);
65                                 p->wide(true, params);
66                         }
67                         lyxerr << "Non-existent float type: " << cmd.argument << endl;
68                         return 0;
69
70                 case LFUN_TABULAR_INSERT:
71                         if (!cmd.argument.empty()) {
72                                 int r = 2;
73                                 int c = 2;
74                                 ::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
75                                 return new InsetTabular(*bv->buffer(), r, c);
76                         }
77                         bv->owner()->getDialogs().showTabularCreate();
78                         return 0;
79
80         #if 0
81                 case LFUN_INSET_LIST:
82                         return new InsetList;
83
84                 case LFUN_INSET_THEOREM:
85                         return new InsetTheorem;
86         #endif
87
88                 default:
89                         break;
90         }
91         return 0;
92 }
93
94