nss: upgrade to release 3.73
[LibreOffice.git] / editeng / source / uno / UnoForbiddenCharsTable.cxx
blob8bb83f65583bf06b9d9127be0d1b687a0f7489aa
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 #include <sal/config.h>
22 #include <com/sun/star/container/NoSuchElementException.hpp>
23 #include <editeng/UnoForbiddenCharsTable.hxx>
24 #include <editeng/forbiddencharacterstable.hxx>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <vcl/svapp.hxx>
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::container;
31 using namespace ::com::sun::star::lang;
32 using namespace ::com::sun::star::i18n;
33 using namespace ::cppu;
35 SvxUnoForbiddenCharsTable::SvxUnoForbiddenCharsTable(std::shared_ptr<SvxForbiddenCharactersTable> const & xForbiddenChars)
36 : mxForbiddenChars(xForbiddenChars)
40 SvxUnoForbiddenCharsTable::~SvxUnoForbiddenCharsTable()
44 void SvxUnoForbiddenCharsTable::onChange()
48 ForbiddenCharacters SvxUnoForbiddenCharsTable::getForbiddenCharacters( const lang::Locale& rLocale )
50 SolarMutexGuard aGuard;
52 if (!mxForbiddenChars)
53 throw RuntimeException();
55 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
56 const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
57 if(!pForbidden)
58 throw NoSuchElementException();
60 return *pForbidden;
63 sal_Bool SvxUnoForbiddenCharsTable::hasForbiddenCharacters( const lang::Locale& rLocale )
65 SolarMutexGuard aGuard;
67 if (!mxForbiddenChars)
68 return false;
70 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
71 const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, false );
73 return nullptr != pForbidden;
76 void SvxUnoForbiddenCharsTable::setForbiddenCharacters(const lang::Locale& rLocale, const ForbiddenCharacters& rForbiddenCharacters )
78 SolarMutexGuard aGuard;
80 if (!mxForbiddenChars)
81 throw RuntimeException();
83 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
84 mxForbiddenChars->SetForbiddenCharacters( eLang, rForbiddenCharacters );
86 onChange();
89 void SvxUnoForbiddenCharsTable::removeForbiddenCharacters( const lang::Locale& rLocale )
91 SolarMutexGuard aGuard;
93 if (!mxForbiddenChars)
94 throw RuntimeException();
96 const LanguageType eLang = LanguageTag::convertToLanguageType( rLocale );
97 mxForbiddenChars->ClearForbiddenCharacters( eLang );
99 onChange();
102 // XSupportedLocales
103 Sequence< lang::Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
105 SolarMutexGuard aGuard;
107 const sal_Int32 nCount = mxForbiddenChars ? mxForbiddenChars->GetMap().size() : 0;
109 Sequence< lang::Locale > aLocales( nCount );
110 if( nCount )
112 lang::Locale* pLocales = aLocales.getArray();
114 for (auto const& elem : mxForbiddenChars->GetMap())
116 const LanguageType nLanguage = elem.first;
117 *pLocales++ = LanguageTag( nLanguage ).getLocale();
121 return aLocales;
124 sal_Bool SAL_CALL SvxUnoForbiddenCharsTable::hasLocale( const lang::Locale& aLocale )
126 SolarMutexGuard aGuard;
128 return hasForbiddenCharacters( aLocale );
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */