1*5900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5900e8ecSAndrew Rist * distributed with this work for additional information 6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an 15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 17*5900e8ecSAndrew Rist * specific language governing permissions and limitations 18*5900e8ecSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5900e8ecSAndrew Rist *************************************************************/ 21*5900e8ecSAndrew Rist 22*5900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir 25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 26cdf0e10cSrcweir #include "precompiled_svtools.hxx" 27cdf0e10cSrcweir #include <svtools/svtdata.hxx> 28cdf0e10cSrcweir #include <svtools/svtools.hrc> 29cdf0e10cSrcweir #include <svtools/indexentryres.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ------------------------------------------------------------------------- 32cdf0e10cSrcweir // 33cdf0e10cSrcweir // wrapper for locale specific translations data of indexentry algorithm 34cdf0e10cSrcweir // 35cdf0e10cSrcweir // ------------------------------------------------------------------------- 36cdf0e10cSrcweir 37cdf0e10cSrcweir class IndexEntryRessourceData 38cdf0e10cSrcweir { 39cdf0e10cSrcweir friend class IndexEntryRessource; 40cdf0e10cSrcweir private: /* data */ 41cdf0e10cSrcweir String ma_Name; 42cdf0e10cSrcweir String ma_Translation; 43cdf0e10cSrcweir private: /* member functions */ 44cdf0e10cSrcweir IndexEntryRessourceData () {} 45cdf0e10cSrcweir public: 46cdf0e10cSrcweir IndexEntryRessourceData ( const String &r_Algorithm, const String &r_Translation) 47cdf0e10cSrcweir : ma_Name (r_Algorithm), ma_Translation (r_Translation) {} 48cdf0e10cSrcweir 49cdf0e10cSrcweir const String& GetAlgorithm () const { return ma_Name; } 50cdf0e10cSrcweir 51cdf0e10cSrcweir const String& GetTranslation () const { return ma_Translation; } 52cdf0e10cSrcweir 53cdf0e10cSrcweir ~IndexEntryRessourceData () {} 54cdf0e10cSrcweir 55cdf0e10cSrcweir IndexEntryRessourceData& operator= (const IndexEntryRessourceData& r_From) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir ma_Name = r_From.GetAlgorithm(); 58cdf0e10cSrcweir ma_Translation = r_From.GetTranslation(); 59cdf0e10cSrcweir return *this; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir }; 62cdf0e10cSrcweir 63cdf0e10cSrcweir // ------------------------------------------------------------------------- 64cdf0e10cSrcweir // 65cdf0e10cSrcweir // implementation of the indexentry-algorithm-name translation 66cdf0e10cSrcweir // 67cdf0e10cSrcweir // ------------------------------------------------------------------------- 68cdf0e10cSrcweir 69cdf0e10cSrcweir #define INDEXENTRY_RESSOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1) 70cdf0e10cSrcweir 71cdf0e10cSrcweir IndexEntryRessource::IndexEntryRessource() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir mp_Data = new IndexEntryRessourceData[INDEXENTRY_RESSOURCE_COUNT]; 74cdf0e10cSrcweir 75cdf0e10cSrcweir #define ASCSTR(str) String(RTL_CONSTASCII_USTRINGPARAM(str)) 76cdf0e10cSrcweir #define RESSTR(rid) String(SvtResId(rid)) 77cdf0e10cSrcweir 78cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] = 79cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC)); 80cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] = 81cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("dict"), RESSTR(STR_SVT_INDEXENTRY_DICTIONARY)); 82cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] = 83cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_INDEXENTRY_PINYIN)); 84cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] = 85cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("radical"), RESSTR(STR_SVT_INDEXENTRY_RADICAL)); 86cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] = 87cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("stroke"), RESSTR(STR_SVT_INDEXENTRY_STROKE)); 88cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] = 89cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_INDEXENTRY_ZHUYIN)); 90cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] = 91cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by syllable)"), 92cdf0e10cSrcweir RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS)); 93cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] = 94cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by consonant)"), 95cdf0e10cSrcweir RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC)); 96cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] = 97cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by syllable)"), 98cdf0e10cSrcweir RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS)); 99cdf0e10cSrcweir mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] = 100cdf0e10cSrcweir IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by consonant)"), 101cdf0e10cSrcweir RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC)); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir IndexEntryRessource::~IndexEntryRessource() 105cdf0e10cSrcweir { 106cdf0e10cSrcweir delete[] mp_Data; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir const String& 110cdf0e10cSrcweir IndexEntryRessource::GetTranslation (const String &r_Algorithm) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir xub_StrLen nIndex = r_Algorithm.Search('.'); 113cdf0e10cSrcweir String aLocaleFreeAlgorithm; 114cdf0e10cSrcweir 115cdf0e10cSrcweir if (nIndex == STRING_NOTFOUND) 116cdf0e10cSrcweir aLocaleFreeAlgorithm = r_Algorithm; 117cdf0e10cSrcweir else { 118cdf0e10cSrcweir nIndex += 1; 119cdf0e10cSrcweir aLocaleFreeAlgorithm = String(r_Algorithm, nIndex, r_Algorithm.Len() - nIndex); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir for (sal_uInt32 i = 0; i < INDEXENTRY_RESSOURCE_COUNT; i++) 123cdf0e10cSrcweir if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm()) 124cdf0e10cSrcweir return mp_Data[i].GetTranslation(); 125cdf0e10cSrcweir return r_Algorithm; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128