]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
inactive new stuff to re-sync my tree before going on holyday
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_binominset.h"
5 #include "math_boxinset.h"
6 #include "math_decorationinset.h"
7 #include "math_dotsinset.h"
8 #include "math_funcinset.h"
9 #include "math_funcliminset.h"
10 #include "math_fracinset.h"
11 #include "math_kerninset.h"
12 #include "math_lefteqninset.h"
13 #include "math_macro.h"
14 #include "math_macrotable.h"
15 #include "math_macroarg.h"
16 #include "math_notinset.h"
17 #include "math_rootinset.h"
18 #include "math_sizeinset.h"
19 #include "math_spaceinset.h"
20 #include "math_specialcharinset.h"
21 #include "math_sqrtinset.h"
22 #include "math_stackrelinset.h"
23 #include "math_symbolinset.h"
24 #include "math_undersetinset.h"
25 #include "math_unknowninset.h"
26 #include "math_xarrowinset.h"
27 #include "math_xymatrixinset.h"
28 #include "math_xyarrowinset.h"
29
30
31 MathAtom createMathInset(latexkeys const * l)
32 {
33         switch (l->token) {
34         case LM_TK_FUNCLIM:
35                 return MathAtom(new MathFuncLimInset(l->name));
36         case LM_TK_SPECIAL:
37                 return MathAtom(new MathSpecialCharInset(static_cast<char>(l->id)));
38         case LM_TK_SYM:
39         case LM_TK_CMR:
40         case LM_TK_CMSY:
41         case LM_TK_CMM:
42         case LM_TK_CMEX:
43         case LM_TK_MSA:
44         case LM_TK_MSB:
45                 return MathAtom(new MathSymbolInset(l));
46         case LM_TK_STACK:
47                 return MathAtom(new MathStackrelInset);
48         case LM_TK_UNDERSET:
49                 return MathAtom(new MathUndersetInset);
50         case LM_TK_KERN: 
51                 return MathAtom(new MathKernInset);
52         case LM_TK_BINOM:
53         case LM_TK_CHOOSE:
54                 return MathAtom(new MathBinomInset);
55         case LM_TK_OVER:
56         case LM_TK_FRAC:
57                 return MathAtom(new MathFracInset);
58         case LM_TK_ATOP:
59                 return MathAtom(new MathFracInset(true));
60         case LM_TK_NOT:
61                 return MathAtom(new MathNotInset);
62         case LM_TK_LEFTEQN:
63                 return MathAtom(new MathLefteqnInset);
64         case LM_TK_SQRT:
65                 return MathAtom(new MathSqrtInset);
66         case LM_TK_ROOT:
67                 return MathAtom(new MathRootInset);
68         case LM_TK_DECORATION:
69                 return MathAtom(new MathDecorationInset(l->name));
70         case LM_TK_SPACE:
71                 return MathAtom(new MathSpaceInset(l->id));
72         case LM_TK_DOTS:
73                 return MathAtom(new MathDotsInset(l->name));
74         case LM_TK_BOX:
75                 return MathAtom(new MathBoxInset(l->name));
76         case LM_TK_FUNC:
77                 return MathAtom(new MathFuncInset(l->name));
78         case LM_TK_STY:
79                 return MathAtom(new MathSizeInset(l));
80         default:
81                 return MathAtom(new MathUnknownInset(l->name));
82         }
83 }
84
85
86 MathAtom createMathInset(string const & s)
87 {
88         //cerr << "creating inset with name: '" << s << "'\n";
89         if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
90                 return MathAtom(new MathMacroArgument(s[1] - '0'));
91
92         if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
93                         && s[2] >= '1' && s[2] <= '9')
94                 return MathAtom(new MathMacroArgument(s[2] - '0'));
95
96         if (s == "xymatrix")
97                 return MathAtom(new MathXYMatrixInset);
98
99         if (s == "xrightarrow")
100                 return MathAtom(new MathXArrowInset(s));
101
102         latexkeys const * l = in_word_set(s);
103         if (l)
104                 return createMathInset(l);
105
106         if (MathMacroTable::has(s)) 
107                 return MathAtom(new MathMacro(s));
108
109         //cerr << "creating inset 2 with name: '" << s << "'\n";
110         return MathAtom(new MathUnknownInset(s));
111 }