xref: /aoo41x/main/idl/source/cmptools/char.cxx (revision 79aad27f)
1*724893d4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*724893d4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*724893d4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*724893d4SAndrew Rist  * distributed with this work for additional information
6*724893d4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*724893d4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*724893d4SAndrew Rist  * "License"); you may not use this file except in compliance
9*724893d4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*724893d4SAndrew Rist  *
11*724893d4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*724893d4SAndrew Rist  *
13*724893d4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*724893d4SAndrew Rist  * software distributed under the License is distributed on an
15*724893d4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*724893d4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*724893d4SAndrew Rist  * specific language governing permissions and limitations
18*724893d4SAndrew Rist  * under the License.
19*724893d4SAndrew Rist  *
20*724893d4SAndrew Rist  *************************************************************/
21*724893d4SAndrew Rist 
22*724893d4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /****************** I N C L U D E S **************************************/
28cdf0e10cSrcweir #include <ctype.h>
29cdf0e10cSrcweir #include <string.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _TABLE_HXX //autogen
32cdf0e10cSrcweir #include <tools/table.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <char.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /****************** D A T E N ********************************************/
38cdf0e10cSrcweir static unsigned char EqualTab[ 256 ] = {
39cdf0e10cSrcweir   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
40cdf0e10cSrcweir  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
41cdf0e10cSrcweir  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
42cdf0e10cSrcweir  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
43cdf0e10cSrcweir  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
44cdf0e10cSrcweir  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
45cdf0e10cSrcweir  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
46cdf0e10cSrcweir  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
47cdf0e10cSrcweir  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
48cdf0e10cSrcweir  90,  91,  92,  93,  94,  95,  96,  97,  98,  99,
49cdf0e10cSrcweir 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
50cdf0e10cSrcweir 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
51cdf0e10cSrcweir 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
52cdf0e10cSrcweir 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
53cdf0e10cSrcweir 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
54cdf0e10cSrcweir 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
55cdf0e10cSrcweir 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
56cdf0e10cSrcweir 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
57cdf0e10cSrcweir 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
58cdf0e10cSrcweir 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
59cdf0e10cSrcweir 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
60cdf0e10cSrcweir 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
61cdf0e10cSrcweir 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
62cdf0e10cSrcweir 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
63cdf0e10cSrcweir 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
64cdf0e10cSrcweir 250, 251, 252, 253, 254, 255 };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /*************************************************************************
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir |*    RscChar::GetTable()
70cdf0e10cSrcweir |*
71cdf0e10cSrcweir |*    Beschreibung
72cdf0e10cSrcweir |*    Ersterstellung    MM 08.08.91
73cdf0e10cSrcweir |*    Letzte Aenderung  MM 08.08.91
74cdf0e10cSrcweir |*
75cdf0e10cSrcweir *************************************************************************/
76cdf0e10cSrcweir Table *         pCharTable  = NULL;
77cdf0e10cSrcweir unsigned char * pChange     = EqualTab;
GetTable(CharSet nSource,CharSet nDest)78cdf0e10cSrcweir char * SvChar::GetTable( CharSet nSource , CharSet nDest )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     if( nSource == nDest )
81cdf0e10cSrcweir         return (char *)EqualTab;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     if( !pCharTable )
84cdf0e10cSrcweir         pCharTable = new Table();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     sal_uInt8 * pSet;
87cdf0e10cSrcweir     pSet = (sal_uInt8 *)pCharTable->Get( ((sal_uLong)nSource << 16) + (sal_uLong)nDest );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     if( !pSet )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         pSet = new sal_uInt8[ 256 ];
92cdf0e10cSrcweir         memcpy( pSet, EqualTab, sizeof( EqualTab ) );
93cdf0e10cSrcweir         for( sal_uInt16 i = 128; i < 256; i++ )
94cdf0e10cSrcweir         {
95cdf0e10cSrcweir             char c = ByteString::Convert( pSet[i], nSource, nDest );
96cdf0e10cSrcweir             if( c )
97cdf0e10cSrcweir                 pSet[ i ] = (sal_uInt8)c;
98cdf0e10cSrcweir         }
99cdf0e10cSrcweir         pCharTable->Insert( ((sal_uLong)nSource << 16) + (sal_uLong)nDest, pSet );
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     return (char *)pSet;
103cdf0e10cSrcweir };
104