]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
full support for vmatrix and Vmatrix,
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_amsarrayinset.h"
5 #include "math_binominset.h"
6 #include "math_boxinset.h"
7 #include "math_casesinset.h"
8 #include "math_decorationinset.h"
9 #include "math_dotsinset.h"
10 #include "math_funcinset.h"
11 #include "math_funcliminset.h"
12 #include "math_fracinset.h"
13 #include "math_kerninset.h"
14 #include "math_lefteqninset.h"
15 #include "math_macro.h"
16 #include "math_macrotable.h"
17 #include "math_macroarg.h"
18 #include "math_notinset.h"
19 #include "math_rootinset.h"
20 #include "math_sizeinset.h"
21 #include "math_spaceinset.h"
22 #include "math_splitinset.h"
23 #include "math_specialcharinset.h"
24 #include "math_sqrtinset.h"
25 #include "math_stackrelinset.h"
26 #include "math_symbolinset.h"
27 #include "math_undersetinset.h"
28 #include "math_unknowninset.h"
29 #include "math_xarrowinset.h"
30 #include "math_xymatrixinset.h"
31 #include "math_xyarrowinset.h"
32
33
34 MathAtom createMathInset(latexkeys const * l)
35 {
36         switch (l->token) {
37         case LM_TK_FUNCLIM:
38                 return MathAtom(new MathFuncLimInset(l->name));
39         case LM_TK_SPECIAL:
40                 return MathAtom(new MathSpecialCharInset(static_cast<char>(l->id)));
41         case LM_TK_SYM:
42         case LM_TK_CMR:
43         case LM_TK_CMSY:
44         case LM_TK_CMM:
45         case LM_TK_CMEX:
46         case LM_TK_MSA:
47         case LM_TK_MSB:
48                 return MathAtom(new MathSymbolInset(l));
49         case LM_TK_STACK:
50                 return MathAtom(new MathStackrelInset);
51         case LM_TK_UNDERSET:
52                 return MathAtom(new MathUndersetInset);
53         case LM_TK_KERN: 
54                 return MathAtom(new MathKernInset);
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 == "xymatrix")
100                 return MathAtom(new MathXYMatrixInset);
101
102         if (s == "xrightarrow")
103                 return MathAtom(new MathXArrowInset(s));
104
105         if (s == "split")
106                 return MathAtom(new MathSplitInset(1));
107
108         if (s == "cases")
109                 return MathAtom(new MathCasesInset);
110
111         if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix") 
112                 return MathAtom(new MathAMSArrayInset(s));
113
114         latexkeys const * l = in_word_set(s);
115         if (l)
116                 return createMathInset(l);
117
118         if (MathMacroTable::has(s)) 
119                 return MathAtom(new MathMacro(s));
120
121         //cerr << "creating inset 2 with name: '" << s << "'\n";
122         return MathAtom(new MathUnknownInset(s));
123 }