/src/libreoffice/editeng/source/misc/forbiddencharacterstable.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <editeng/forbiddencharacterstable.hxx> |
21 | | |
22 | | #include <unotools/localedatawrapper.hxx> |
23 | | #include <utility> |
24 | | |
25 | | SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( |
26 | | css::uno::Reference<css::uno::XComponentContext> xContext) |
27 | 98.3k | : m_xContext(std::move(xContext)) |
28 | 98.3k | { |
29 | 98.3k | } |
30 | | |
31 | | std::shared_ptr<SvxForbiddenCharactersTable> |
32 | | SvxForbiddenCharactersTable::makeForbiddenCharactersTable( |
33 | | const css::uno::Reference<css::uno::XComponentContext>& rxContext) |
34 | 98.3k | { |
35 | 98.3k | return std::shared_ptr<SvxForbiddenCharactersTable>(new SvxForbiddenCharactersTable(rxContext)); |
36 | 98.3k | } |
37 | | |
38 | | const css::i18n::ForbiddenCharacters* |
39 | | SvxForbiddenCharactersTable::GetForbiddenCharacters(LanguageType nLanguage, bool bGetDefault) |
40 | 1.23M | { |
41 | 1.23M | css::i18n::ForbiddenCharacters* pForbiddenCharacters = nullptr; |
42 | 1.23M | Map::iterator it = maMap.find(nLanguage); |
43 | 1.23M | if (it != maMap.end()) |
44 | 628k | pForbiddenCharacters = &(it->second); |
45 | 603k | else if (bGetDefault && m_xContext.is()) |
46 | 19.3k | { |
47 | 19.3k | const LocaleDataWrapper* pWrapper = LocaleDataWrapper::get(LanguageTag(nLanguage)); |
48 | 19.3k | maMap[nLanguage] = pWrapper->getForbiddenCharacters(); |
49 | 19.3k | pForbiddenCharacters = &maMap[nLanguage]; |
50 | 19.3k | } |
51 | 1.23M | return pForbiddenCharacters; |
52 | 1.23M | } |
53 | | |
54 | | void SvxForbiddenCharactersTable::SetForbiddenCharacters( |
55 | | LanguageType nLanguage, const css::i18n::ForbiddenCharacters& rForbiddenChars) |
56 | 10.5k | { |
57 | 10.5k | maMap[nLanguage] = rForbiddenChars; |
58 | 10.5k | } |
59 | | |
60 | | void SvxForbiddenCharactersTable::ClearForbiddenCharacters(LanguageType nLanguage) |
61 | 0 | { |
62 | 0 | maMap.erase(nLanguage); |
63 | 0 | } |
64 | | |
65 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |