Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <editeng/UnoForbiddenCharsTable.hxx>
30 : : #include <editeng/forbiddencharacterstable.hxx>
31 : : #include <osl/mutex.hxx>
32 : : #include <vcl/svapp.hxx>
33 : : #include <editeng/unolingu.hxx> // LocalToLanguage, LanguageToLocale
34 : :
35 : : using namespace ::com::sun::star;
36 : : using namespace ::com::sun::star::uno;
37 : : using namespace ::com::sun::star::container;
38 : : using namespace ::com::sun::star::lang;
39 : : using namespace ::com::sun::star::i18n;
40 : : using namespace ::rtl;
41 : : using namespace ::cppu;
42 : :
43 : 110 : SvxUnoForbiddenCharsTable::SvxUnoForbiddenCharsTable(::rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars) :
44 [ + - ]: 110 : mxForbiddenChars( xForbiddenChars )
45 : : {
46 : 110 : }
47 : :
48 [ + - ]: 98 : SvxUnoForbiddenCharsTable::~SvxUnoForbiddenCharsTable()
49 : : {
50 [ - + ]: 98 : }
51 : :
52 : 0 : void SvxUnoForbiddenCharsTable::onChange()
53 : : {
54 : 0 : }
55 : :
56 : 4 : ForbiddenCharacters SvxUnoForbiddenCharsTable::getForbiddenCharacters( const Locale& rLocale )
57 : : throw(NoSuchElementException, RuntimeException)
58 : : {
59 [ + - ]: 4 : SolarMutexGuard aGuard;
60 : :
61 [ - + ]: 4 : if(!mxForbiddenChars.is())
62 [ # # ]: 0 : throw RuntimeException();
63 : :
64 [ + - ]: 4 : const LanguageType eLang = SvxLocaleToLanguage( rLocale );
65 [ + - ]: 4 : const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, sal_False );
66 [ - + ]: 4 : if(!pForbidden)
67 [ # # ]: 0 : throw NoSuchElementException();
68 : :
69 [ + - ]: 4 : return *pForbidden;
70 : : }
71 : :
72 : 8 : sal_Bool SvxUnoForbiddenCharsTable::hasForbiddenCharacters( const Locale& rLocale )
73 : : throw(RuntimeException)
74 : : {
75 [ + - ]: 8 : SolarMutexGuard aGuard;
76 : :
77 [ - + ]: 8 : if(!mxForbiddenChars.is())
78 : 0 : return sal_False;
79 : :
80 [ + - ]: 8 : const LanguageType eLang = SvxLocaleToLanguage( rLocale );
81 [ + - ]: 8 : const ForbiddenCharacters* pForbidden = mxForbiddenChars->GetForbiddenCharacters( eLang, sal_False );
82 : :
83 [ + - ]: 8 : return NULL != pForbidden;
84 : : }
85 : :
86 : 13 : void SvxUnoForbiddenCharsTable::setForbiddenCharacters(const Locale& rLocale, const ForbiddenCharacters& rForbiddenCharacters )
87 : : throw(RuntimeException)
88 : : {
89 [ + - ]: 13 : SolarMutexGuard aGuard;
90 : :
91 [ - + ]: 13 : if(!mxForbiddenChars.is())
92 [ # # ]: 0 : throw RuntimeException();
93 : :
94 [ + - ]: 13 : const LanguageType eLang = SvxLocaleToLanguage( rLocale );
95 [ + - ]: 13 : mxForbiddenChars->SetForbiddenCharacters( eLang, rForbiddenCharacters );
96 : :
97 [ + - ][ + - ]: 13 : onChange();
98 : 13 : }
99 : :
100 : 0 : void SvxUnoForbiddenCharsTable::removeForbiddenCharacters( const Locale& rLocale )
101 : : throw(RuntimeException)
102 : : {
103 [ # # ]: 0 : SolarMutexGuard aGuard;
104 : :
105 [ # # ]: 0 : if(!mxForbiddenChars.is())
106 [ # # ]: 0 : throw RuntimeException();
107 : :
108 [ # # ]: 0 : const LanguageType eLang = SvxLocaleToLanguage( rLocale );
109 [ # # ]: 0 : mxForbiddenChars->ClearForbiddenCharacters( eLang );
110 : :
111 [ # # ][ # # ]: 0 : onChange();
112 : 0 : }
113 : :
114 : : // XSupportedLocales
115 : 35 : Sequence< Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
116 : : throw(RuntimeException)
117 : : {
118 [ + - ]: 35 : SolarMutexGuard aGuard;
119 : :
120 [ + - ]: 35 : const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->GetMap().size() : 0;
121 : :
122 [ + - ]: 35 : Sequence< Locale > aLocales( nCount );
123 [ + + ]: 35 : if( nCount )
124 : : {
125 [ + - ]: 4 : Locale* pLocales = aLocales.getArray();
126 : :
127 [ + + ]: 16 : for( SvxForbiddenCharactersTable::Map::iterator it = mxForbiddenChars->GetMap().begin();
128 : 8 : it != mxForbiddenChars->GetMap().end(); ++it )
129 : : {
130 : 4 : const sal_uLong nLanguage = it->first;
131 [ + - ]: 4 : SvxLanguageToLocale ( *pLocales++, static_cast < LanguageType > (nLanguage) );
132 : : }
133 : : }
134 : :
135 [ + - ]: 35 : return aLocales;
136 : : }
137 : :
138 : 0 : sal_Bool SAL_CALL SvxUnoForbiddenCharsTable::hasLocale( const Locale& aLocale )
139 : : throw(RuntimeException)
140 : : {
141 [ # # ]: 0 : SolarMutexGuard aGuard;
142 : :
143 [ # # ][ # # ]: 0 : return hasForbiddenCharacters( aLocale );
144 : : }
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|