1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SC_CELLKEY_TRANSLATOR_HXX 25 #define SC_CELLKEY_TRANSLATOR_HXX 26 27 #include "global.hxx" 28 #include "formula/opcode.hxx" 29 #include "unotools/transliterationwrapper.hxx" 30 #include <hash_map> 31 #include <list> 32 #include <memory> 33 34 #include <com/sun/star/lang/Locale.hpp> 35 36 struct TransItem; 37 38 struct ScCellKeyword 39 { 40 const sal_Char* mpName; 41 OpCode meOpCode; 42 const ::com::sun::star::lang::Locale& mrLocale; 43 44 ScCellKeyword(const sal_Char* pName, OpCode eOpCode, const ::com::sun::star::lang::Locale& rLocale); 45 }; 46 47 typedef ::std::hash_map< String, ::std::list<ScCellKeyword>, ScStringHashCode, ::std::equal_to<String> > ScCellKeywordHashMap; 48 49 /** Translate cell function keywords. 50 51 This class provides a convenient way to translate a string keyword used as 52 a cell function argument. Since Calc's built-in cell functions don't 53 localize string keywords, this class is used mainly to deal with an Excel 54 document where string names may be localized. 55 56 To use, simply call the 57 58 ScCellKeywordTranslator::transKeyword(...) 59 60 function. 61 62 Note that when the locale and/or the opcode is specified, the function 63 tries to find a string with matching locale and/or opcode. But when it 64 fails to find one that satisfies the specified locale and/or opcode, it 65 returns a translated string with non-matching locale and/or opcode if 66 available. */ 67 class ScCellKeywordTranslator 68 { 69 public: 70 static void transKeyword(String& rName, const ::com::sun::star::lang::Locale* pLocale = NULL, OpCode eOpCode = ocNone); 71 ~ScCellKeywordTranslator(); 72 73 private: 74 ScCellKeywordTranslator(); 75 76 void init(); 77 void addToMap(const String& rKey, const sal_Char* pName, 78 const ::com::sun::star::lang::Locale& rLocale, 79 OpCode eOpCode = ocNone); 80 void addToMap(const TransItem* pItems, const ::com::sun::star::lang::Locale& rLocale); 81 82 static ::std::auto_ptr<ScCellKeywordTranslator> spInstance; 83 ScCellKeywordHashMap maStringNameMap; 84 ::utl::TransliterationWrapper maTransWrapper; 85 }; 86 87 #endif 88