xref: /aoo41x/main/idl/source/cmptools/char.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_idl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /****************** I N C L U D E S **************************************/
32*cdf0e10cSrcweir #include <ctype.h>
33*cdf0e10cSrcweir #include <string.h>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _TABLE_HXX //autogen
36*cdf0e10cSrcweir #include <tools/table.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <char.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /****************** D A T E N ********************************************/
42*cdf0e10cSrcweir static unsigned char EqualTab[ 256 ] = {
43*cdf0e10cSrcweir   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
44*cdf0e10cSrcweir  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
45*cdf0e10cSrcweir  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
46*cdf0e10cSrcweir  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
47*cdf0e10cSrcweir  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
48*cdf0e10cSrcweir  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
49*cdf0e10cSrcweir  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
50*cdf0e10cSrcweir  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
51*cdf0e10cSrcweir  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
52*cdf0e10cSrcweir  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,
53*cdf0e10cSrcweir 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
54*cdf0e10cSrcweir 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
55*cdf0e10cSrcweir 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
56*cdf0e10cSrcweir 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
57*cdf0e10cSrcweir 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
58*cdf0e10cSrcweir 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
59*cdf0e10cSrcweir 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
60*cdf0e10cSrcweir 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
61*cdf0e10cSrcweir 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
62*cdf0e10cSrcweir 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
63*cdf0e10cSrcweir 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
64*cdf0e10cSrcweir 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
65*cdf0e10cSrcweir 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
66*cdf0e10cSrcweir 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
67*cdf0e10cSrcweir 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
68*cdf0e10cSrcweir 250, 251, 252, 253, 254, 255 };
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir /*************************************************************************
72*cdf0e10cSrcweir |*
73*cdf0e10cSrcweir |*    RscChar::GetTable()
74*cdf0e10cSrcweir |*
75*cdf0e10cSrcweir |*    Beschreibung
76*cdf0e10cSrcweir |*    Ersterstellung    MM 08.08.91
77*cdf0e10cSrcweir |*    Letzte Aenderung  MM 08.08.91
78*cdf0e10cSrcweir |*
79*cdf0e10cSrcweir *************************************************************************/
80*cdf0e10cSrcweir Table *         pCharTable  = NULL;
81*cdf0e10cSrcweir unsigned char * pChange     = EqualTab;
82*cdf0e10cSrcweir char * SvChar::GetTable( CharSet nSource , CharSet nDest )
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir     if( nSource == nDest )
85*cdf0e10cSrcweir         return (char *)EqualTab;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     if( !pCharTable )
88*cdf0e10cSrcweir         pCharTable = new Table();
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     sal_uInt8 * pSet;
91*cdf0e10cSrcweir     pSet = (sal_uInt8 *)pCharTable->Get( ((sal_uLong)nSource << 16) + (sal_uLong)nDest );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     if( !pSet )
94*cdf0e10cSrcweir     {
95*cdf0e10cSrcweir         pSet = new sal_uInt8[ 256 ];
96*cdf0e10cSrcweir         memcpy( pSet, EqualTab, sizeof( EqualTab ) );
97*cdf0e10cSrcweir         for( sal_uInt16 i = 128; i < 256; i++ )
98*cdf0e10cSrcweir         {
99*cdf0e10cSrcweir             char c = ByteString::Convert( pSet[i], nSource, nDest );
100*cdf0e10cSrcweir             if( c )
101*cdf0e10cSrcweir                 pSet[ i ] = (sal_uInt8)c;
102*cdf0e10cSrcweir         }
103*cdf0e10cSrcweir         pCharTable->Insert( ((sal_uLong)nSource << 16) + (sal_uLong)nDest, pSet );
104*cdf0e10cSrcweir     }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     return (char *)pSet;
107*cdf0e10cSrcweir };
108