1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_CORE_INC_CELLKEYTRANSLATOR_HXX
21 #define INCLUDED_SC_SOURCE_CORE_INC_CELLKEYTRANSLATOR_HXX
24 #include <formula/opcode.hxx>
25 #include <unotools/transliterationwrapper.hxx>
28 #include <unordered_map>
30 #include <com/sun/star/lang/Locale.hpp>
36 const sal_Char
* mpName
;
38 const ::com::sun::star::lang::Locale
& mrLocale
;
40 ScCellKeyword(const sal_Char
* pName
, OpCode eOpCode
, const ::com::sun::star::lang::Locale
& rLocale
);
43 typedef std::unordered_map
< OUString
, ::std::list
<ScCellKeyword
>, OUStringHash
> ScCellKeywordHashMap
;
45 /** Translate cell function keywords.
47 This class provides a convenient way to translate a string keyword used as
48 a cell function argument. Since Calc's built-in cell functions don't
49 localize string keywords, this class is used mainly to deal with an Excel
50 document where string names may be localized.
52 To use, simply call the
54 ScCellKeywordTranslator::transKeyword(...)
58 Note that when the locale and/or the opcode is specified, the function
59 tries to find a string with matching locale and/or opcode. But when it
60 fails to find one that satisfies the specified locale and/or opcode, it
61 returns a translated string with non-matching locale and/or opcode if
63 class ScCellKeywordTranslator
66 static void transKeyword(OUString
& rName
, const ::com::sun::star::lang::Locale
* pLocale
= NULL
, OpCode eOpCode
= ocNone
);
67 ~ScCellKeywordTranslator();
70 ScCellKeywordTranslator();
73 void addToMap(const OUString
& rKey
, const sal_Char
* pName
,
74 const ::com::sun::star::lang::Locale
& rLocale
,
75 OpCode eOpCode
= ocNone
);
76 void addToMap(const TransItem
* pItems
, const ::com::sun::star::lang::Locale
& rLocale
);
78 static ::std::unique_ptr
<ScCellKeywordTranslator
> spInstance
;
79 ScCellKeywordHashMap maStringNameMap
;
80 ::utl::TransliterationWrapper maTransWrapper
;
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */