LibreOffice Module editeng (master) 1
UnoForbiddenCharsTable.cxx
Go to the documentation of this file.
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 <sal/config.h>
21
22#include <com/sun/star/container/NoSuchElementException.hpp>
26#include <utility>
27#include <vcl/svapp.hxx>
28
29using namespace ::com::sun::star;
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::container;
32using namespace ::com::sun::star::lang;
33using namespace ::com::sun::star::i18n;
34using namespace ::cppu;
35
36SvxUnoForbiddenCharsTable::SvxUnoForbiddenCharsTable(std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenChars)
37 : mxForbiddenChars(std::move(xForbiddenChars))
38{
39}
40
42{
43}
44
46{
47}
48
49ForbiddenCharacters SvxUnoForbiddenCharsTable::getForbiddenCharacters( const lang::Locale& rLocale )
50{
51 SolarMutexGuard aGuard;
52
54 throw RuntimeException("No Forbidden Characters present");
55
56 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
57 const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
58 if(!pForbidden)
59 throw NoSuchElementException();
60
61 return *pForbidden;
62}
63
65{
66 SolarMutexGuard aGuard;
67
69 return false;
70
71 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
72 const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
73
74 return nullptr != pForbidden;
75}
76
77void SvxUnoForbiddenCharsTable::setForbiddenCharacters(const lang::Locale& rLocale, const ForbiddenCharacters& rForbiddenCharacters )
78{
79 SolarMutexGuard aGuard;
80
82 throw RuntimeException("No Forbidden Characters present");
83
84 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
85 mxForbiddenChars->SetForbiddenCharacters( eLang, rForbiddenCharacters );
86
87 onChange();
88}
89
91{
92 SolarMutexGuard aGuard;
93
95 throw RuntimeException("No Forbidden Characters present");
96
97 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
98 mxForbiddenChars->ClearForbiddenCharacters( eLang );
99
100 onChange();
101}
102
103// XSupportedLocales
104Sequence< lang::Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
105{
106 SolarMutexGuard aGuard;
107
108 const sal_Int32 nCount = mxForbiddenChars ? mxForbiddenChars->GetMap().size() : 0;
109
110 Sequence< lang::Locale > aLocales( nCount );
111 if( nCount )
112 {
113 lang::Locale* pLocales = aLocales.getArray();
114
115 for (auto const& elem : mxForbiddenChars->GetMap())
116 {
117 const LanguageType nLanguage = elem.first;
118 *pLocales++ = LanguageTag( nLanguage ).getLocale();
119 }
120 }
121
122 return aLocales;
123}
124
125sal_Bool SAL_CALL SvxUnoForbiddenCharsTable::hasLocale( const lang::Locale& aLocale )
126{
127 SolarMutexGuard aGuard;
128
129 return hasForbiddenCharacters( aLocale );
130}
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual css::uno::Sequence< css::lang::Locale > SAL_CALL getLocales() override
virtual sal_Bool SAL_CALL hasForbiddenCharacters(const css::lang::Locale &rLocale) override
virtual void SAL_CALL setForbiddenCharacters(const css::lang::Locale &rLocale, const css::i18n::ForbiddenCharacters &rForbiddenCharacters) override
std::shared_ptr< SvxForbiddenCharactersTable > mxForbiddenChars
virtual void onChange()
this virtual function is called if the forbidden characters are changed
virtual void SAL_CALL removeForbiddenCharacters(const css::lang::Locale &rLocale) override
virtual ~SvxUnoForbiddenCharsTable() override
virtual sal_Bool SAL_CALL hasLocale(const css::lang::Locale &aLocale) override
SvxUnoForbiddenCharsTable(std::shared_ptr< SvxForbiddenCharactersTable > xForbiddenChars)
virtual css::i18n::ForbiddenCharacters SAL_CALL getForbiddenCharacters(const css::lang::Locale &rLocale) override
int nCount
unsigned char sal_Bool