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 #include <editeng/forbiddencharacterstable.hxx>
22 #include <unotools/localedatawrapper.hxx>
25 SvxForbiddenCharactersTable::SvxForbiddenCharactersTable(
26 css::uno::Reference
<css::uno::XComponentContext
> xContext
)
27 : m_xContext(std::move(xContext
))
31 std::shared_ptr
<SvxForbiddenCharactersTable
>
32 SvxForbiddenCharactersTable::makeForbiddenCharactersTable(
33 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
)
35 return std::shared_ptr
<SvxForbiddenCharactersTable
>(new SvxForbiddenCharactersTable(rxContext
));
38 const css::i18n::ForbiddenCharacters
*
39 SvxForbiddenCharactersTable::GetForbiddenCharacters(LanguageType nLanguage
, bool bGetDefault
)
41 css::i18n::ForbiddenCharacters
* pForbiddenCharacters
= nullptr;
42 Map::iterator it
= maMap
.find(nLanguage
);
43 if (it
!= maMap
.end())
44 pForbiddenCharacters
= &(it
->second
);
45 else if (bGetDefault
&& m_xContext
.is())
47 LocaleDataWrapper
aWrapper(m_xContext
, LanguageTag(nLanguage
));
48 maMap
[nLanguage
] = aWrapper
.getForbiddenCharacters();
49 pForbiddenCharacters
= &maMap
[nLanguage
];
51 return pForbiddenCharacters
;
54 void SvxForbiddenCharactersTable::SetForbiddenCharacters(
55 LanguageType nLanguage
, const css::i18n::ForbiddenCharacters
& rForbiddenChars
)
57 maMap
[nLanguage
] = rForbiddenChars
;
60 void SvxForbiddenCharactersTable::ClearForbiddenCharacters(LanguageType nLanguage
)
62 maMap
.erase(nLanguage
);
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */