]> git.lyx.org Git - lyx.git/blob - src/factory.C
54d08fa2ea7b80edb2c304fa63b030407df5b118
[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/insettext.h"
19
20
21 Inset * createInset(FuncRequest const & cmd)
22 {
23         BufferParams const & params = cmd.view()->buffer()->params;
24
25         switch (cmd.action) {
26
27                 case LFUN_INSET_MINIPAGE:
28                         return new InsetMinipage(params);
29
30                 case LFUN_INSERT_NOTE:
31                         return new InsetNote(params);
32
33                 case LFUN_INSET_ERT:
34                         return new InsetERT(params);
35
36                 case LFUN_INSET_EXTERNAL:
37                         return new InsetExternal;
38
39                 case LFUN_INSET_FOOTNOTE:
40                         return new InsetFoot(params);
41
42                 case LFUN_INSET_MARGINAL:
43                         return new InsetMarginal(params);
44
45                 case LFUN_INSET_OPTARG:
46                         return new InsetOptArg(params);
47
48                 case LFUN_INSET_FLOAT:
49                         // check if the float type exists
50                         if (params.getLyXTextClass().floats().typeExist(cmd.argument))
51                                 return new InsetFloat(params, cmd.argument);
52                         lyxerr << "Non-existent float type: " << cmd.argument << endl;
53                         return 0;
54
55                 case LFUN_INSET_WIDE_FLOAT:
56                         // check if the float type exists
57                         if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
58                                 InsetFloat * p = new InsetFloat(params, cmd.argument);
59                                 p->wide(true, params);
60                         }
61                         lyxerr << "Non-existent float type: " << cmd.argument << endl;
62                         return 0;
63
64         #if 0
65                 case LFUN_INSET_LIST:
66                         return new InsetList;
67
68                 case LFUN_INSET_THEOREM:
69                         return new InsetTheorem;
70         #endif
71
72                 default:
73                         break;
74         }
75         return 0;
76 }
77
78