1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX 28 #define INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX 29 30 #include <utility> 31 #include <rtl/ustring.hxx> 32 33 namespace com { namespace sun { namespace star { namespace i18n { 34 35 class widthfolding; 36 37 typedef std::pair< sal_Unicode, sal_Unicode > OneToOneMappingTable_t; 38 39 #define MAKE_PAIR(item1,item2) std::make_pair< sal_Unicode, sal_Unicode >((sal_Unicode)item1,(sal_Unicode)item2) 40 41 typedef sal_Int8 UnicodePairFlag; 42 typedef struct _UnicodePairWithFlag 43 { 44 sal_Unicode first; 45 sal_Unicode second; 46 UnicodePairFlag flag; 47 } UnicodePairWithFlag; 48 49 class oneToOneMapping 50 { 51 private: 52 // no copy, no substitution 53 oneToOneMapping( const oneToOneMapping& ); 54 oneToOneMapping& operator=( const oneToOneMapping& ); 55 public: 56 oneToOneMapping( OneToOneMappingTable_t *rpTable, const size_t rnSize, const size_t rnUnitSize = sizeof(OneToOneMappingTable_t) ); 57 virtual ~oneToOneMapping(); 58 59 // make index for fast search 60 // bluedawrf: not used 61 // void makeIndex(); 62 63 // binary search 64 virtual sal_Unicode find( const sal_Unicode nKey ) const; 65 66 // translator 67 sal_Unicode operator[] ( const sal_Unicode nKey ) const { return find( nKey ); }; 68 69 protected: 70 OneToOneMappingTable_t *mpTable; 71 size_t mnSize; 72 }; 73 74 class oneToOneMappingWithFlag : public oneToOneMapping 75 { 76 friend class widthfolding; 77 78 private: 79 // no copy, no substitution 80 oneToOneMappingWithFlag( const oneToOneMappingWithFlag& ); 81 oneToOneMappingWithFlag& operator=( const oneToOneMappingWithFlag& ); 82 public: 83 oneToOneMappingWithFlag( UnicodePairWithFlag *rpTableWF, const size_t rnSize, const UnicodePairFlag rnFlag ); 84 virtual ~oneToOneMappingWithFlag(); 85 86 // make index for fast search 87 void makeIndex(); 88 89 // index search 90 virtual sal_Unicode find( const sal_Unicode nKey ) const; 91 protected: 92 UnicodePairWithFlag *mpTableWF; 93 UnicodePairFlag mnFlag; 94 UnicodePairWithFlag **mpIndex[256]; 95 sal_Bool mbHasIndex; 96 }; 97 98 } } } } 99 100 #endif // _I18N_TRANSLITERATION_ONETOONEMAPPING_HXX_ 101