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 .
22 #include <formula/opcode.hxx>
23 #include <unotools/transliterationwrapper.hxx>
26 #include <unordered_map>
28 namespace com::sun::star::lang
39 const css::lang::Locale
& mrLocale
;
41 ScCellKeyword(const char* pName
, OpCode eOpCode
, const css::lang::Locale
& rLocale
);
44 typedef std::unordered_map
<OUString
, ::std::vector
<ScCellKeyword
>> ScCellKeywordHashMap
;
46 /** Translate cell function keywords.
48 This class provides a convenient way to translate a string keyword used as
49 a cell function argument. Since Calc's built-in cell functions don't
50 localize string keywords, this class is used mainly to deal with an Excel
51 document where string names may be localized.
53 To use, simply call the
55 ScCellKeywordTranslator::transKeyword(...)
59 Note that when the locale and/or the opcode is specified, the function
60 tries to find a string with matching locale and/or opcode. But when it
61 fails to find one that satisfies the specified locale and/or opcode, it
62 returns a translated string with non-matching locale and/or opcode if
64 class ScCellKeywordTranslator
67 static void transKeyword(OUString
& rName
, const css::lang::Locale
* pLocale
, OpCode eOpCode
);
68 ~ScCellKeywordTranslator();
71 ScCellKeywordTranslator();
73 void addToMap(const OUString
& rKey
, const char* pName
, const css::lang::Locale
& rLocale
,
75 void addToMap(const TransItem
* pItems
, const css::lang::Locale
& rLocale
);
77 static ::std::unique_ptr
<ScCellKeywordTranslator
> spInstance
;
78 ScCellKeywordHashMap maStringNameMap
;
79 ::utl::TransliterationWrapper maTransWrapper
;
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */