Update ooo320-m1
[ooovba.git] / sc / source / core / inc / cellkeytranslator.hxx
blobf0873faf403b5cf5ac5388ceb1c91b18653a65d5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellkeytranslator.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CELLKEY_TRANSLATOR_HXX
32 #define SC_CELLKEY_TRANSLATOR_HXX
34 #include "global.hxx"
35 #include "formula/opcode.hxx"
36 #include "unotools/transliterationwrapper.hxx"
37 #include <hash_map>
38 #include <list>
39 #include <memory>
41 #include <com/sun/star/lang/Locale.hpp>
43 struct TransItem;
45 struct ScCellKeyword
47 const sal_Char* mpName;
48 OpCode meOpCode;
49 const ::com::sun::star::lang::Locale& mrLocale;
51 ScCellKeyword(const sal_Char* pName, OpCode eOpCode, const ::com::sun::star::lang::Locale& rLocale);
54 typedef ::std::hash_map< String, ::std::list<ScCellKeyword>, ScStringHashCode, ::std::equal_to<String> > ScCellKeywordHashMap;
56 /** Translate cell function keywords.
58 This class provides a convenient way to translate a string keyword used as
59 a cell function argument. Since Calc's built-in cell functions don't
60 localize string keywords, this class is used mainly to deal with an Excel
61 document where string names may be localized.
63 To use, simply call the
65 ScCellKeywordTranslator::transKeyword(...)
67 function.
69 Note that when the locale and/or the opcode is specified, the function
70 tries to find a string with matching locale and/or opcode. But when it
71 fails to find one that satisfies the specified locale and/or opcode, it
72 returns a translated string with non-matching locale and/or opcode if
73 available. */
74 class ScCellKeywordTranslator
76 public:
77 static void transKeyword(String& rName, const ::com::sun::star::lang::Locale* pLocale = NULL, OpCode eOpCode = ocNone);
78 ~ScCellKeywordTranslator();
80 private:
81 ScCellKeywordTranslator();
83 void init();
84 void addToMap(const String& rKey, const sal_Char* pName,
85 const ::com::sun::star::lang::Locale& rLocale,
86 OpCode eOpCode = ocNone);
87 void addToMap(const TransItem* pItems, const ::com::sun::star::lang::Locale& rLocale);
89 static ::std::auto_ptr<ScCellKeywordTranslator> spInstance;
90 ScCellKeywordHashMap maStringNameMap;
91 ::utl::TransliterationWrapper maTransWrapper;
94 #endif