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 28 29 // MARKER(update_precomp.py): autogen include statement, do not remove 30 #include "precompiled_svtools.hxx" 31 #include <svtools/svtdata.hxx> 32 #include <svtools/svtools.hrc> 33 #include <svtools/indexentryres.hxx> 34 35 // ------------------------------------------------------------------------- 36 // 37 // wrapper for locale specific translations data of indexentry algorithm 38 // 39 // ------------------------------------------------------------------------- 40 41 class IndexEntryRessourceData 42 { 43 friend class IndexEntryRessource; 44 private: /* data */ 45 String ma_Name; 46 String ma_Translation; 47 private: /* member functions */ 48 IndexEntryRessourceData () {} 49 public: 50 IndexEntryRessourceData ( const String &r_Algorithm, const String &r_Translation) 51 : ma_Name (r_Algorithm), ma_Translation (r_Translation) {} 52 53 const String& GetAlgorithm () const { return ma_Name; } 54 55 const String& GetTranslation () const { return ma_Translation; } 56 57 ~IndexEntryRessourceData () {} 58 59 IndexEntryRessourceData& operator= (const IndexEntryRessourceData& r_From) 60 { 61 ma_Name = r_From.GetAlgorithm(); 62 ma_Translation = r_From.GetTranslation(); 63 return *this; 64 } 65 }; 66 67 // ------------------------------------------------------------------------- 68 // 69 // implementation of the indexentry-algorithm-name translation 70 // 71 // ------------------------------------------------------------------------- 72 73 #define INDEXENTRY_RESSOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1) 74 75 IndexEntryRessource::IndexEntryRessource() 76 { 77 mp_Data = new IndexEntryRessourceData[INDEXENTRY_RESSOURCE_COUNT]; 78 79 #define ASCSTR(str) String(RTL_CONSTASCII_USTRINGPARAM(str)) 80 #define RESSTR(rid) String(SvtResId(rid)) 81 82 mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] = 83 IndexEntryRessourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC)); 84 mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] = 85 IndexEntryRessourceData (ASCSTR("dict"), RESSTR(STR_SVT_INDEXENTRY_DICTIONARY)); 86 mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] = 87 IndexEntryRessourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_INDEXENTRY_PINYIN)); 88 mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] = 89 IndexEntryRessourceData (ASCSTR("radical"), RESSTR(STR_SVT_INDEXENTRY_RADICAL)); 90 mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] = 91 IndexEntryRessourceData (ASCSTR("stroke"), RESSTR(STR_SVT_INDEXENTRY_STROKE)); 92 mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] = 93 IndexEntryRessourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_INDEXENTRY_ZHUYIN)); 94 mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] = 95 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by syllable)"), 96 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS)); 97 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] = 98 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by consonant)"), 99 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC)); 100 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] = 101 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by syllable)"), 102 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS)); 103 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] = 104 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by consonant)"), 105 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC)); 106 } 107 108 IndexEntryRessource::~IndexEntryRessource() 109 { 110 delete[] mp_Data; 111 } 112 113 const String& 114 IndexEntryRessource::GetTranslation (const String &r_Algorithm) 115 { 116 xub_StrLen nIndex = r_Algorithm.Search('.'); 117 String aLocaleFreeAlgorithm; 118 119 if (nIndex == STRING_NOTFOUND) 120 aLocaleFreeAlgorithm = r_Algorithm; 121 else { 122 nIndex += 1; 123 aLocaleFreeAlgorithm = String(r_Algorithm, nIndex, r_Algorithm.Len() - nIndex); 124 } 125 126 for (sal_uInt32 i = 0; i < INDEXENTRY_RESSOURCE_COUNT; i++) 127 if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm()) 128 return mp_Data[i].GetTranslation(); 129 return r_Algorithm; 130 } 131 132