/Users/ericb/Desktop/SRC680_m247/starmath/source/types.cxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  OpenOffice.org - a multi-platform office productivity suite
00004  *
00005  *  $RCSfile: types.cxx,v $
00006  *
00007  *  $Revision: 1.4 $
00008  *
00009  *  last change: $Author: vg $ $Date: 2007/05/25 12:15:47 $
00010  *
00011  *  The Contents of this file are made available subject to
00012  *  the terms of GNU Lesser General Public License Version 2.1.
00013  *
00014  *
00015  *    GNU Lesser General Public License Version 2.1
00016  *    =============================================
00017  *    Copyright 2005 by Sun Microsystems, Inc.
00018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
00019  *
00020  *    This library is free software; you can redistribute it and/or
00021  *    modify it under the terms of the GNU Lesser General Public
00022  *    License version 2.1, as published by the Free Software Foundation.
00023  *
00024  *    This library is distributed in the hope that it will be useful,
00025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  *    Lesser General Public License for more details.
00028  *
00029  *    You should have received a copy of the GNU Lesser General Public
00030  *    License along with this library; if not, write to the Free Software
00031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00032  *    MA  02111-1307  USA
00033  *
00034  ************************************************************************/
00035 
00036 // MARKER(update_precomp.py): autogen include statement, do not remove
00037 #include "precompiled_starmath.hxx"
00038 
00039 
00040 #ifndef TYPES_HXX
00041 #include <types.hxx>
00042 #endif
00043 
00044 
00048 //    MS_UNDERBRACE   = (xub_Unicode) 0xE081,         0xF613 ?
00049 //    MS_OVERBRACE    = (xub_Unicode) 0xE082,         0xF612 ?
00050 
00051 struct MathConversionEntry
00052 {
00053     sal_Unicode     cMath;      // code point of the character from the
00054                                 // StarSymbol/OpenSymbol private-use-area
00055     sal_Unicode     cUnicode;   // 'official' Unicode code point the above
00056                                 // character should be matched to and vice versa.
00057                                 // See http://www.w3.org/TR/2000/WD-MathML2-20000211/bycodes.html
00058                                 // for most of them.
00059 //    const sal_Unicode *pFontName;
00060     sal_Unicode     cMathType;  // 0 if the same value of cUnicode is to be used
00061 };
00062 
00063 static MathConversionEntry aMathConvTbl[] = 
00064 {
00065 //    MS_UNDERBRACE,  0xF613,       // only Math-ML code-point available !
00066 //    MS_OVERBRACE,   0xF612,       // only Math-ML code-point available !
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     // predefined-user-defined symbols 
00092     // (code-points on the left as defined in 'officecfg' for SO8,
00093     // non-private-use-area characters uncommented):
00094 
00095 //    0x0041,         0x0391,     0,     // %ALPHA                  
00096 //    0x0042,         0x0392,     0,     // %BETA                   
00097     { 0xE0AC,         0x0393,     0 },      // %GAMMA                  
00098     { 0xE0AD,         0x0394,     0 },      // %DELTA                  
00099 //    0x0045,         0x0395,     0,     // %EPSILON                
00100 //    0x005A,         0x0396,     0,     // %ZETA                   
00101 //    0x0048,         0x0397,     0,     // %ETA                    
00102     { 0xE0AE,         0x0398,     0 },      // %THETA                  
00103 //    0x0049,         0x0399,     0,     // %IOTA                   
00104 //    0x004B,         0x039A,     0,     // %KAPPA                  
00105     { 0xE0AF,         0x039B,     0 },      // %LAMBDA                 
00106 //    0x004D,         0x039C,     0,     // %MU                     
00107 //    0x004E,         0x039D,     0,     // %NU                     
00108     { 0xE0B0,         0x039E,     0 },      // %XI                     
00109 //    0x004F,         0x039F,     0,     // %OMICRON                
00110     { 0xE0B1,         0x03A0,     0 },      // %PI                     
00111 //    0x0050,         0x03A1,     0,     // %RHO                    
00112     { 0xE0B2,         0x03A3,     0 },      // %SIGMA                  
00113 //    0x0054,         0x03A4,     0,     // %TAU                    
00114     { 0xE0B3,         0x03A5,     0 },      // %UPSILON                
00115     { 0xE0B4,         0x03A6,     0 },      // %PHI                    
00116 //    0x0058,         0x03A7,     0,     // %CHI                    
00117     { 0xE0B5,         0x03A8,     0 },      // %PSI                    
00118     { 0xE0B6,         0x03A9,     0 },      // %OMEGA                  
00119                     
00120     { 0xE0B7,         0x03B1,     0 },      // %alpha                  
00121     { 0xE0B8,         0x03B2,     0 },      // %beta                   
00122     { 0xE0B9,         0x03B3,     0 },      // %gamma                  
00123     { 0xE0BA,         0x03B4,     0 },      // %delta                  
00124     { 0xE0BB,         0x03B5,     0 },      // %epsilon                
00125     { 0xE0BC,         0x03B6,     0 },      // %zeta                   
00126     { 0xE0BD,         0x03B7,     0 },      // %eta                    
00127     { 0xE0BE,         0x03B8,     0 },      // %theta                  
00128     { 0xE0BF,         0x03B9,     0 },      // %iota                   
00129     { 0xE0C0,         0x03BA,     0 },      // %kappa                  
00130     { 0xE0C1,         0x03BB,     0 },      // %lambda                 
00131     { 0xE0C2,         0x03BC,     0 },      // %mu                     
00132     { 0xE0C3,         0x03BD,     0 },      // %nu                     
00133     { 0xE0C4,         0x03BE,     0 },      // %xi                     
00134     { 0xE0C5,         0x03BF,     0 },      // %omicron                
00135     { 0xE0C6,         0x03C0,     0 },      // %pi                     
00136     { 0xE0C7,         0x03C1,     0 },      // %rho                    
00137     { 0xE0C8,         0x03C3,     0 },      // %sigma                  
00138     { 0xE0C9,         0x03C4,     0 },      // %tau                    
00139     { 0xE0CA,         0x03C5,     0 },      // %upsilon                
00140     { 0xE0CB,         0x03C6,     0 },      // %phi                    
00141     { 0xE0CC,         0x03C7,     0 },      // %chi                    
00142     { 0xE0CD,         0x03C8,     0 },      // %psi                    
00143     { 0xE0CE,         0x03C9,     0 },      // %omega                  
00144                     
00145     { 0xE0CF,         0x025B,     0,/*x03B5*/}, // %varepsilon             
00146     { 0xE0D0,         0x03D1,     0 },      // %vartheta               
00147     { 0xE0D4,         0x03D5,     0 },      // %varphi                 
00148     { 0xE0D1,         0x03D6,     0 },      // %varpi                  
00149 //    0x03F1,         0x03F1,     0/*x03C1*/, // %varrho                 
00150     { 0xE0D3,         0x03C2,     0 },      // %varsigma               
00151                     
00152 //    0x2227,         0x2227,     0,     // %and                    
00153 //    0x2228,         0x2228,     0,     // %or                     
00154 //    0x2208,         0x2208,     0,     // %element                
00155 //    0x2209,         0x2209,     0,     // %noelement              
00156 //    0x226B,         0x226B,     0,     // %strictlygreaterthan    
00157 //    0x226A,         0x226A,     0,     // %strictlylessthan       
00158 //    0x2261,         0x2261,     0,     // %identical              
00159 //    0x221E,         0x221E,     0,     // %infinite               
00160 //    0x2260,         0x2260,     0,     // %notequal               
00161     { 0xE080,         0x2030,     0 },      // %perthousand            
00162 //    0x2222,         0x2222,     0,      // %angle                  
00163     { 0xE08C,         0x2192,     0 }       // %tendto                 
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;      // Math-ML code-point (there is no official unicode-point)
00231     else if (cChar == MS_UNDERBRACE)
00232         cRes = 0xF613;      // Math-ML code-point (there is no official unicode-point)
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;      // Math-ML code-point (there is no official unicode-point)
00243     else if (cChar == 0xF613)
00244         cRes = MS_UNDERBRACE;      // Math-ML code-point (there is no official unicode-point)
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 

Generated on Wed Feb 20 17:21:57 2008 for maths by  doxygen 1.5.1