tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / core / inc / cellkeytranslator.hxx
blob953e0c99ed5976811134bd727232c487c079f413
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <formula/opcode.hxx>
23 #include <unotools/transliterationwrapper.hxx>
24 #include <vector>
25 #include <memory>
26 #include <unordered_map>
28 namespace com::sun::star::lang
30 struct Locale;
33 struct TransItem;
35 struct ScCellKeyword
37 const char* mpName;
38 OpCode meOpCode;
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(...)
57 function.
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
63 available. */
64 class ScCellKeywordTranslator
66 public:
67 static void transKeyword(OUString& rName, const css::lang::Locale* pLocale, OpCode eOpCode);
68 ~ScCellKeywordTranslator();
70 private:
71 ScCellKeywordTranslator();
73 void addToMap(const OUString& rKey, const char* pName, const css::lang::Locale& rLocale,
74 OpCode eOpCode);
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: */