1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: types.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_starmath.hxx"
38 //!! no official unicode code point for these in non-private-area
39 //!! (even MathMl uses the code points listed on the right which are
40 //!! from the private-use-area as well)
41 // MS_UNDERBRACE = (xub_Unicode) 0xE081, 0xF613 ?
42 // MS_OVERBRACE = (xub_Unicode) 0xE082, 0xF612 ?
44 struct MathConversionEntry
46 sal_Unicode cMath
; // code point of the character from the
47 // StarSymbol/OpenSymbol private-use-area
48 sal_Unicode cUnicode
; // 'official' Unicode code point the above
49 // character should be matched to and vice versa.
50 // See http://www.w3.org/TR/2000/WD-MathML2-20000211/bycodes.html
52 // const sal_Unicode *pFontName;
53 sal_Unicode cMathType
; // 0 if the same value of cUnicode is to be used
56 static MathConversionEntry aMathConvTbl
[] =
58 // MS_UNDERBRACE, 0xF613, // only Math-ML code-point available !
59 // MS_OVERBRACE, 0xF612, // only Math-ML code-point available !
60 { MS_PLUS
, 0x002B, 0 },
63 { MS_LESLANT
, 0x2264, 0 },
64 { MS_GESLANT
, 0x2265, 0 },
65 { MS_DOTSLOW
, 0x2026, 0 },
66 { MS_RIGHTARROW
, 0x2192, 0 },
67 { MS_SQRT
, 0x221A, 0 },
68 { MS_HAT
, 0x02C6, 0 },
69 { MS_CHECK
, 0x02C7, 0 },
70 { MS_BREVE
, 0x02D8, 0 },
71 { MS_ACUTE
, 0x00B4, 0 },
72 { MS_GRAVE
, 0x0060, 0 },
73 { MS_TILDE
, 0x02DC, 0 },
74 { MS_BAR
, 0x02C9, 0 },
75 { MS_VEC
, 0x2192, 0 },
76 { MS_DDDOT
, 0x22EF, 0 },
77 { MS_LPARENT
, 0x0028, 0 },
78 { MS_RPARENT
, 0x0029, 0 },
79 { MS_PLACE
, 0x25A1, 0 },
80 { MS_LEFTARROW
, 0x2190, 0 },
81 { MS_UPARROW
, 0x2191, 0 },
82 { MS_DOWNARROW
, 0x2193, 0 },
83 { MS_PLACE
, 0x2751, 0 },
85 // predefined-user-defined symbols
86 // (code-points on the left as defined in 'officecfg' for SO8,
87 // non-private-use-area characters uncommented):
89 // 0x0041, 0x0391, 0, // %ALPHA
90 // 0x0042, 0x0392, 0, // %BETA
91 { 0xE0AC, 0x0393, 0 }, // %GAMMA
92 { 0xE0AD, 0x0394, 0 }, // %DELTA
93 // 0x0045, 0x0395, 0, // %EPSILON
94 // 0x005A, 0x0396, 0, // %ZETA
95 // 0x0048, 0x0397, 0, // %ETA
96 { 0xE0AE, 0x0398, 0 }, // %THETA
97 // 0x0049, 0x0399, 0, // %IOTA
98 // 0x004B, 0x039A, 0, // %KAPPA
99 { 0xE0AF, 0x039B, 0 }, // %LAMBDA
100 // 0x004D, 0x039C, 0, // %MU
101 // 0x004E, 0x039D, 0, // %NU
102 { 0xE0B0, 0x039E, 0 }, // %XI
103 // 0x004F, 0x039F, 0, // %OMICRON
104 { 0xE0B1, 0x03A0, 0 }, // %PI
105 // 0x0050, 0x03A1, 0, // %RHO
106 { 0xE0B2, 0x03A3, 0 }, // %SIGMA
107 // 0x0054, 0x03A4, 0, // %TAU
108 { 0xE0B3, 0x03A5, 0 }, // %UPSILON
109 { 0xE0B4, 0x03A6, 0 }, // %PHI
110 // 0x0058, 0x03A7, 0, // %CHI
111 { 0xE0B5, 0x03A8, 0 }, // %PSI
112 { 0xE0B6, 0x03A9, 0 }, // %OMEGA
114 { 0xE0B7, 0x03B1, 0 }, // %alpha
115 { 0xE0B8, 0x03B2, 0 }, // %beta
116 { 0xE0B9, 0x03B3, 0 }, // %gamma
117 { 0xE0BA, 0x03B4, 0 }, // %delta
118 { 0xE0BB, 0x03B5, 0 }, // %epsilon
119 { 0xE0BC, 0x03B6, 0 }, // %zeta
120 { 0xE0BD, 0x03B7, 0 }, // %eta
121 { 0xE0BE, 0x03B8, 0 }, // %theta
122 { 0xE0BF, 0x03B9, 0 }, // %iota
123 { 0xE0C0, 0x03BA, 0 }, // %kappa
124 { 0xE0C1, 0x03BB, 0 }, // %lambda
125 { 0xE0C2, 0x03BC, 0 }, // %mu
126 { 0xE0C3, 0x03BD, 0 }, // %nu
127 { 0xE0C4, 0x03BE, 0 }, // %xi
128 { 0xE0C5, 0x03BF, 0 }, // %omicron
129 { 0xE0C6, 0x03C0, 0 }, // %pi
130 { 0xE0C7, 0x03C1, 0 }, // %rho
131 { 0xE0C8, 0x03C3, 0 }, // %sigma
132 { 0xE0C9, 0x03C4, 0 }, // %tau
133 { 0xE0CA, 0x03C5, 0 }, // %upsilon
134 { 0xE0CB, 0x03C6, 0 }, // %phi
135 { 0xE0CC, 0x03C7, 0 }, // %chi
136 { 0xE0CD, 0x03C8, 0 }, // %psi
137 { 0xE0CE, 0x03C9, 0 }, // %omega
139 { 0xE0CF, 0x025B, 0,/*x03B5*/}, // %varepsilon
140 { 0xE0D0, 0x03D1, 0 }, // %vartheta
141 { 0xE0D4, 0x03D5, 0 }, // %varphi
142 { 0xE0D1, 0x03D6, 0 }, // %varpi
143 // 0x03F1, 0x03F1, 0/*x03C1*/, // %varrho
144 { 0xE0D3, 0x03C2, 0 }, // %varsigma
146 // 0x2227, 0x2227, 0, // %and
147 // 0x2228, 0x2228, 0, // %or
148 // 0x2208, 0x2208, 0, // %element
149 // 0x2209, 0x2209, 0, // %noelement
150 // 0x226B, 0x226B, 0, // %strictlygreaterthan
151 // 0x226A, 0x226A, 0, // %strictlylessthan
152 // 0x2261, 0x2261, 0, // %identical
153 // 0x221E, 0x221E, 0, // %infinite
154 // 0x2260, 0x2260, 0, // %notequal
155 { 0xE080, 0x2030, 0 }, // %perthousand
156 // 0x2222, 0x2222, 0, // %angle
157 { 0xE08C, 0x2192, 0 } // %tendto
161 static int nMathToUnicodeLen
= sizeof(aMathConvTbl
) / sizeof(aMathConvTbl
[0]);
163 sal_Unicode
ConvertMathPrivateUseAreaToUnicode( sal_Unicode cChar
)
165 sal_Unicode cRes
= 0;
166 if (IsInPrivateUseArea( cChar
))
168 for (int i
= 0; i
< nMathToUnicodeLen
&& cRes
== 0; ++i
)
170 if (aMathConvTbl
[i
].cMath
== cChar
)
171 cRes
= aMathConvTbl
[i
].cUnicode
;
177 #ifdef TL_NOT_YET_USED
178 sal_Unicode
ConvertUnicodeToMathPrivateUseArea( sal_Unicode cChar
)
180 sal_Unicode cRes
= 0;
181 for (int i
= 0; i
< nMathToUnicodeLen
&& cRes
== 0; ++i
)
183 if (aMathConvTbl
[i
].cUnicode
== cChar
)
184 cRes
= aMathConvTbl
[i
].cMath
;
190 sal_Unicode
ConvertMathToMathType( sal_Unicode cChar
)
192 sal_Unicode cRes
= 0;
193 for (int i
= 0; i
< nMathToUnicodeLen
&& cRes
== 0; ++i
)
195 const MathConversionEntry
&rEntry
= aMathConvTbl
[i
];
196 if (rEntry
.cMath
== cChar
)
198 cRes
= rEntry
.cMathType
;
200 cRes
= rEntry
.cUnicode
;
206 sal_Unicode
ConvertMathTypeToMath( sal_Unicode cChar
)
208 sal_Unicode cRes
= 0;
209 for (int i
= 0; i
< nMathToUnicodeLen
&& cRes
== 0; ++i
)
211 const MathConversionEntry
&rEntry
= aMathConvTbl
[i
];
212 sal_Unicode cTmp
= rEntry
.cMathType
;
214 cTmp
= rEntry
.cUnicode
;
220 #endif //TL_NOT_YET_USED
222 sal_Unicode
ConvertMathToMathML( sal_Unicode cChar
)
224 sal_Unicode cRes
= 0;
225 if (cChar
== MS_OVERBRACE
)
226 cRes
= 0xF612; // Math-ML code-point (there is no official unicode-point)
227 else if (cChar
== MS_UNDERBRACE
)
228 cRes
= 0xF613; // Math-ML code-point (there is no official unicode-point)
230 cRes
= ConvertMathPrivateUseAreaToUnicode( cChar
);
234 #ifdef TL_NOT_YET_USED
235 sal_Unicode
ConvertMathMLToMath( sal_Unicode cChar
)
237 sal_Unicode cRes
= 0;
239 cRes
= MS_OVERBRACE
; // Math-ML code-point (there is no official unicode-point)
240 else if (cChar
== 0xF613)
241 cRes
= MS_UNDERBRACE
; // Math-ML code-point (there is no official unicode-point)
243 cRes
= ConvertUnicodeToMathPrivateUseArea( cChar
);
248 sal_Unicode
GetTokenChar( sal_Unicode cChar
, sal_Bool bConvertForExport
)
250 sal_Unicode cRes
= cChar
;
251 if (bConvertForExport
)
253 sal_Unicode cTmp
= ConvertMathPrivateUseAreaToUnicode( cChar
);
259 #endif //TL_NOT_YET_USED