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