1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellkeytranslator.hxx,v $
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
35 #include "formula/opcode.hxx"
36 #include "unotools/transliterationwrapper.hxx"
41 #include <com/sun/star/lang/Locale.hpp>
47 const sal_Char
* mpName
;
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(...)
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
74 class ScCellKeywordTranslator
77 static void transKeyword(String
& rName
, const ::com::sun::star::lang::Locale
* pLocale
= NULL
, OpCode eOpCode
= ocNone
);
78 ~ScCellKeywordTranslator();
81 ScCellKeywordTranslator();
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
;