00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "precompiled_starmath.hxx"
00038
00039
00040 #ifndef TYPES_HXX
00041 #include <types.hxx>
00042 #endif
00043
00044
00048
00049
00050
00051 struct MathConversionEntry
00052 {
00053 sal_Unicode cMath;
00054
00055 sal_Unicode cUnicode;
00056
00057
00058
00059
00060 sal_Unicode cMathType;
00061 };
00062
00063 static MathConversionEntry aMathConvTbl[] =
00064 {
00065
00066
00067 { MS_PLUS, 0x002B, 0 },
00068 { MS_LT, 0x003C, 0 },
00069 { MS_GT, 0x003E, 0 },
00070 { MS_LESLANT, 0x2264, 0 },
00071 { MS_GESLANT, 0x2265, 0 },
00072 { MS_DOTSLOW, 0x2026, 0 },
00073 { MS_RIGHTARROW, 0x2192, 0 },
00074 { MS_SQRT, 0x221A, 0 },
00075 { MS_HAT, 0x02C6, 0 },
00076 { MS_CHECK, 0x02C7, 0 },
00077 { MS_BREVE, 0x02D8, 0 },
00078 { MS_ACUTE, 0x00B4, 0 },
00079 { MS_GRAVE, 0x0060, 0 },
00080 { MS_TILDE, 0x02DC, 0 },
00081 { MS_BAR, 0x02C9, 0 },
00082 { MS_VEC, 0x2192, 0 },
00083 { MS_DDDOT, 0x22EF, 0 },
00084 { MS_LPARENT, 0x0028, 0 },
00085 { MS_RPARENT, 0x0029, 0 },
00086 { MS_PLACE, 0x25A1, 0 },
00087 { MS_LEFTARROW, 0x2190, 0 },
00088 { MS_UPARROW, 0x2191, 0 },
00089 { MS_DOWNARROW, 0x2193, 0 },
00090
00091
00092
00093
00094
00095
00096
00097 { 0xE0AC, 0x0393, 0 },
00098 { 0xE0AD, 0x0394, 0 },
00099
00100
00101
00102 { 0xE0AE, 0x0398, 0 },
00103
00104
00105 { 0xE0AF, 0x039B, 0 },
00106
00107
00108 { 0xE0B0, 0x039E, 0 },
00109
00110 { 0xE0B1, 0x03A0, 0 },
00111
00112 { 0xE0B2, 0x03A3, 0 },
00113
00114 { 0xE0B3, 0x03A5, 0 },
00115 { 0xE0B4, 0x03A6, 0 },
00116
00117 { 0xE0B5, 0x03A8, 0 },
00118 { 0xE0B6, 0x03A9, 0 },
00119
00120 { 0xE0B7, 0x03B1, 0 },
00121 { 0xE0B8, 0x03B2, 0 },
00122 { 0xE0B9, 0x03B3, 0 },
00123 { 0xE0BA, 0x03B4, 0 },
00124 { 0xE0BB, 0x03B5, 0 },
00125 { 0xE0BC, 0x03B6, 0 },
00126 { 0xE0BD, 0x03B7, 0 },
00127 { 0xE0BE, 0x03B8, 0 },
00128 { 0xE0BF, 0x03B9, 0 },
00129 { 0xE0C0, 0x03BA, 0 },
00130 { 0xE0C1, 0x03BB, 0 },
00131 { 0xE0C2, 0x03BC, 0 },
00132 { 0xE0C3, 0x03BD, 0 },
00133 { 0xE0C4, 0x03BE, 0 },
00134 { 0xE0C5, 0x03BF, 0 },
00135 { 0xE0C6, 0x03C0, 0 },
00136 { 0xE0C7, 0x03C1, 0 },
00137 { 0xE0C8, 0x03C3, 0 },
00138 { 0xE0C9, 0x03C4, 0 },
00139 { 0xE0CA, 0x03C5, 0 },
00140 { 0xE0CB, 0x03C6, 0 },
00141 { 0xE0CC, 0x03C7, 0 },
00142 { 0xE0CD, 0x03C8, 0 },
00143 { 0xE0CE, 0x03C9, 0 },
00144
00145 { 0xE0CF, 0x025B, 0,},
00146 { 0xE0D0, 0x03D1, 0 },
00147 { 0xE0D4, 0x03D5, 0 },
00148 { 0xE0D1, 0x03D6, 0 },
00149
00150 { 0xE0D3, 0x03C2, 0 },
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 { 0xE080, 0x2030, 0 },
00162
00163 { 0xE08C, 0x2192, 0 }
00164 };
00165
00166
00167 static int nMathToUnicodeLen = sizeof(aMathConvTbl) / sizeof(aMathConvTbl[0]);
00168
00169 sal_Unicode ConvertMathPrivateUseAreaToUnicode( sal_Unicode cChar )
00170 {
00171 sal_Unicode cRes = 0;
00172 if (IsInPrivateUseArea( cChar ))
00173 {
00174 for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i)
00175 {
00176 if (aMathConvTbl[i].cMath == cChar)
00177 cRes = aMathConvTbl[i].cUnicode;
00178 }
00179 }
00180 return cRes;
00181 }
00182
00183 sal_Unicode ConvertUnicodeToMathPrivateUseArea( sal_Unicode cChar )
00184 {
00185 sal_Unicode cRes = 0;
00186 for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i)
00187 {
00188 if (aMathConvTbl[i].cUnicode == cChar)
00189 cRes = aMathConvTbl[i].cMath;
00190 }
00191 return cRes;
00192 }
00193
00194
00195 sal_Unicode ConvertMathToMathType( sal_Unicode cChar )
00196 {
00197 sal_Unicode cRes = 0;
00198 for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i)
00199 {
00200 const MathConversionEntry &rEntry = aMathConvTbl[i];
00201 if (rEntry.cMath == cChar)
00202 {
00203 cRes = rEntry.cMathType;
00204 if (cRes == 0)
00205 cRes = rEntry.cUnicode;
00206 }
00207 }
00208 return cRes;
00209 }
00210
00211 sal_Unicode ConvertMathTypeToMath( sal_Unicode cChar )
00212 {
00213 sal_Unicode cRes = 0;
00214 for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i)
00215 {
00216 const MathConversionEntry &rEntry = aMathConvTbl[i];
00217 sal_Unicode cTmp = rEntry.cMathType;
00218 if (cTmp == 0)
00219 cTmp = rEntry.cUnicode;
00220 if (cTmp == cChar)
00221 cRes = rEntry.cMath;
00222 }
00223 return cRes;
00224 }
00225
00226 sal_Unicode ConvertMathToMathML( sal_Unicode cChar )
00227 {
00228 sal_Unicode cRes = 0;
00229 if (cChar == MS_OVERBRACE)
00230 cRes = 0xF612;
00231 else if (cChar == MS_UNDERBRACE)
00232 cRes = 0xF613;
00233 else
00234 cRes = ConvertMathPrivateUseAreaToUnicode( cChar );
00235 return cRes;
00236 }
00237
00238 sal_Unicode ConvertMathMLToMath( sal_Unicode cChar )
00239 {
00240 sal_Unicode cRes = 0;
00241 if (cChar == 0xF612)
00242 cRes = MS_OVERBRACE;
00243 else if (cChar == 0xF613)
00244 cRes = MS_UNDERBRACE;
00245 else
00246 cRes = ConvertUnicodeToMathPrivateUseArea( cChar );
00247 return cRes;
00248 }
00249
00250
00251 sal_Unicode GetTokenChar( sal_Unicode cChar, sal_Bool bConvertForExport )
00252 {
00253 sal_Unicode cRes = cChar;
00254 if (bConvertForExport)
00255 {
00256 sal_Unicode cTmp = ConvertMathPrivateUseAreaToUnicode( cChar );
00257 if (cTmp != 0)
00258 cRes = cTmp;
00259 }
00260 return cRes;
00261 }
00262
00263