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 : :
30 : : #include <sal/macros.h>
31 : : #include "lngopt.hxx"
32 : : #include "linguistic/lngprops.hxx"
33 : : #include "linguistic/misc.hxx"
34 : : #include <tools/debug.hxx>
35 : : #include <unotools/lingucfg.hxx>
36 : :
37 : : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
38 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
39 : :
40 : : #include <cppuhelper/factory.hxx> // helper for factories
41 : : #include <com/sun/star/container/XNameAccess.hpp>
42 : : #include <com/sun/star/registry/XSimpleRegistry.hpp>
43 : : #include <com/sun/star/registry/XRegistryKey.hpp>
44 : : #include <com/sun/star/lang/Locale.hpp>
45 : : #include <com/sun/star/i18n/ScriptType.hpp>
46 : : #include <i18npool/mslangid.hxx>
47 : :
48 : : using namespace utl;
49 : : using namespace osl;
50 : : using namespace com::sun::star;
51 : : using namespace com::sun::star::container;
52 : : using namespace com::sun::star::beans;
53 : : using namespace com::sun::star::lang;
54 : : using namespace com::sun::star::uno;
55 : : using namespace com::sun::star::linguistic2;
56 : : using namespace linguistic;
57 : :
58 : : using namespace com::sun::star::registry;
59 : :
60 : : using ::rtl::OUString;
61 : :
62 : :
63 : :
64 : : // static member intialization
65 : : SvtLinguOptions * LinguOptions::pData = NULL;
66 : : oslInterlockedCount LinguOptions::nRefCount;
67 : :
68 : :
69 : 90 : LinguOptions::LinguOptions()
70 : : {
71 [ + + ]: 90 : if (!pData)
72 : : {
73 [ + - ][ + - ]: 48 : pData = new SvtLinguOptions;
74 [ + - ]: 48 : SvtLinguConfig aLinguCfg;
75 [ + - ][ + - ]: 48 : aLinguCfg.GetOptions( *pData );
76 : : }
77 : :
78 : 90 : osl_incrementInterlockedCount( &nRefCount );
79 : 90 : }
80 : :
81 : :
82 : 0 : LinguOptions::LinguOptions(const LinguOptions & /*rOpt*/)
83 : : {
84 : : DBG_ASSERT( pData, "lng : data missing" );
85 : 0 : osl_incrementInterlockedCount( &nRefCount );
86 : 0 : }
87 : :
88 : :
89 : 86 : LinguOptions::~LinguOptions()
90 : : {
91 [ + - ][ + - ]: 86 : MutexGuard aGuard( GetLinguMutex() );
92 : :
93 [ + - ][ + + ]: 86 : if ( osl_decrementInterlockedCount( &nRefCount ) == 0 )
94 : : {
95 [ + - ][ + - ]: 46 : delete pData; pData = NULL;
96 [ + - ]: 86 : }
97 : 86 : }
98 : :
99 : : struct WID_Name
100 : : {
101 : : sal_Int32 nWID;
102 : : const char *pPropertyName;
103 : : };
104 : :
105 : : //! order of entries is import (see LinguOptions::GetName)
106 : : //! since the WID is used as index in this table!
107 : : WID_Name aWID_Name[] =
108 : : {
109 : : { 0, 0 },
110 : : { WID_IS_USE_DICTIONARY_LIST, UPN_IS_USE_DICTIONARY_LIST },
111 : : { WID_IS_IGNORE_CONTROL_CHARACTERS, UPN_IS_IGNORE_CONTROL_CHARACTERS },
112 : : { WID_IS_SPELL_UPPER_CASE, UPN_IS_SPELL_UPPER_CASE },
113 : : { WID_IS_SPELL_WITH_DIGITS, UPN_IS_SPELL_WITH_DIGITS },
114 : : { WID_IS_SPELL_CAPITALIZATION, UPN_IS_SPELL_CAPITALIZATION },
115 : : { WID_HYPH_MIN_LEADING, UPN_HYPH_MIN_LEADING },
116 : : { WID_HYPH_MIN_TRAILING, UPN_HYPH_MIN_TRAILING },
117 : : { WID_HYPH_MIN_WORD_LENGTH, UPN_HYPH_MIN_WORD_LENGTH },
118 : : { WID_DEFAULT_LOCALE, UPN_DEFAULT_LOCALE },
119 : : { WID_IS_SPELL_AUTO, UPN_IS_SPELL_AUTO },
120 : : { 0, 0 },
121 : : { 0, 0 },
122 : : { WID_IS_SPELL_SPECIAL, UPN_IS_SPELL_SPECIAL },
123 : : { WID_IS_HYPH_AUTO, UPN_IS_HYPH_AUTO },
124 : : { WID_IS_HYPH_SPECIAL, UPN_IS_HYPH_SPECIAL },
125 : : { WID_IS_WRAP_REVERSE, UPN_IS_WRAP_REVERSE },
126 : : { 0, 0 },
127 : : { 0, 0 },
128 : : { 0, 0 },
129 : : { 0, 0 },
130 : : { WID_DEFAULT_LANGUAGE, UPN_DEFAULT_LANGUAGE },
131 : : { WID_DEFAULT_LOCALE_CJK, UPN_DEFAULT_LOCALE_CJK },
132 : : { WID_DEFAULT_LOCALE_CTL, UPN_DEFAULT_LOCALE_CTL }
133 : : };
134 : :
135 : :
136 : 62 : OUString LinguOptions::GetName( sal_Int32 nWID )
137 : : {
138 [ + - ][ + - ]: 62 : MutexGuard aGuard( GetLinguMutex() );
139 : :
140 : 62 : OUString aRes;
141 : :
142 : 62 : sal_Int32 nLen = sizeof (aWID_Name) / sizeof (aWID_Name[0]);
143 [ + - ][ + - ]: 62 : if (0 <= nWID && nWID < nLen && aWID_Name[ nWID ].nWID == nWID)
[ + - ]
144 : 62 : aRes = OUString::createFromAscii(aWID_Name[nWID].pPropertyName);
145 : : else
146 : : OSL_FAIL("lng : unknown WID");
147 : :
148 [ + - ]: 62 : return aRes;
149 : : }
150 : :
151 : :
152 : :
153 : : //! map must be sorted by first entry in alphabetical increasing order.
154 : 48 : const SfxItemPropertyMapEntry* lcl_GetLinguProps()
155 : : {
156 : : static const SfxItemPropertyMapEntry aLinguProps[] =
157 : : {
158 : : { MAP_CHAR_LEN(UPN_DEFAULT_LANGUAGE), WID_DEFAULT_LANGUAGE,
159 [ + - ]: 48 : &::getCppuType( (sal_Int16*)0 ), 0, 0 },
160 : : { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE), WID_DEFAULT_LOCALE,
161 [ + - ]: 48 : &::getCppuType( (Locale* )0), 0, 0 },
162 : : { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE_CJK), WID_DEFAULT_LOCALE_CJK,
163 [ + - ]: 48 : &::getCppuType( (Locale* )0), 0, 0 },
164 : : { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE_CTL), WID_DEFAULT_LOCALE_CTL,
165 [ + - ]: 48 : &::getCppuType( (Locale* )0), 0, 0 },
166 : : { MAP_CHAR_LEN(UPN_HYPH_MIN_LEADING), WID_HYPH_MIN_LEADING,
167 [ + - ]: 48 : &::getCppuType( (sal_Int16*)0 ), 0, 0 },
168 : : { MAP_CHAR_LEN(UPN_HYPH_MIN_TRAILING), WID_HYPH_MIN_TRAILING,
169 [ + - ]: 48 : &::getCppuType( (sal_Int16*)0 ), 0, 0 },
170 : : { MAP_CHAR_LEN(UPN_HYPH_MIN_WORD_LENGTH), WID_HYPH_MIN_WORD_LENGTH,
171 [ + - ]: 48 : &::getCppuType( (sal_Int16*)0 ), 0, 0 },
172 : : { MAP_CHAR_LEN(UPN_IS_GERMAN_PRE_REFORM), WID_IS_GERMAN_PRE_REFORM, /*! deprecated !*/
173 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
174 : : { MAP_CHAR_LEN(UPN_IS_HYPH_AUTO), WID_IS_HYPH_AUTO,
175 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
176 : : { MAP_CHAR_LEN(UPN_IS_HYPH_SPECIAL), WID_IS_HYPH_SPECIAL,
177 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
178 : : { MAP_CHAR_LEN(UPN_IS_IGNORE_CONTROL_CHARACTERS), WID_IS_IGNORE_CONTROL_CHARACTERS,
179 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
180 : : { MAP_CHAR_LEN(UPN_IS_SPELL_AUTO), WID_IS_SPELL_AUTO,
181 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
182 : : { MAP_CHAR_LEN(UPN_IS_SPELL_CAPITALIZATION), WID_IS_SPELL_CAPITALIZATION,
183 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
184 : : { MAP_CHAR_LEN(UPN_IS_SPELL_HIDE), WID_IS_SPELL_HIDE, /*! deprecated !*/
185 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
186 : : { MAP_CHAR_LEN(UPN_IS_SPELL_IN_ALL_LANGUAGES), WID_IS_SPELL_IN_ALL_LANGUAGES, /*! deprecated !*/
187 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
188 : : { MAP_CHAR_LEN(UPN_IS_SPELL_SPECIAL), WID_IS_SPELL_SPECIAL,
189 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
190 : : { MAP_CHAR_LEN(UPN_IS_SPELL_UPPER_CASE), WID_IS_SPELL_UPPER_CASE,
191 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
192 : : { MAP_CHAR_LEN(UPN_IS_SPELL_WITH_DIGITS), WID_IS_SPELL_WITH_DIGITS,
193 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
194 : : { MAP_CHAR_LEN(UPN_IS_USE_DICTIONARY_LIST), WID_IS_USE_DICTIONARY_LIST,
195 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
196 : : { MAP_CHAR_LEN(UPN_IS_WRAP_REVERSE), WID_IS_WRAP_REVERSE,
197 [ + - ]: 48 : &::getBooleanCppuType(), 0, 0 },
198 : : { 0,0,0,0,0,0 }
199 [ + - ][ + - ]: 96 : };
[ # # ]
200 : 48 : return aLinguProps;
201 : : }
202 : 48 : LinguProps::LinguProps() :
203 [ + - ]: 48 : aEvtListeners (GetLinguMutex()),
204 [ + - ]: 48 : aPropListeners (GetLinguMutex()),
205 [ + - ][ + - ]: 144 : aPropertyMap(lcl_GetLinguProps())
[ + - ][ + - ]
[ + - ]
206 : : {
207 : 48 : bDisposing = sal_False;
208 : 48 : }
209 : :
210 : 126 : void LinguProps::launchEvent( const PropertyChangeEvent &rEvt ) const
211 : : {
212 : : cppu::OInterfaceContainerHelper *pContainer =
213 : 126 : aPropListeners.getContainer( rEvt.PropertyHandle );
214 [ - + ]: 126 : if (pContainer)
215 : : {
216 [ # # ]: 0 : cppu::OInterfaceIteratorHelper aIt( *pContainer );
217 [ # # ]: 0 : while (aIt.hasMoreElements())
218 : : {
219 [ # # ][ # # ]: 0 : Reference< XPropertyChangeListener > xRef( aIt.next(), UNO_QUERY );
220 [ # # ]: 0 : if (xRef.is())
221 [ # # ][ # # ]: 0 : xRef->propertyChange( rEvt );
222 [ # # ]: 0 : }
223 : : }
224 : 126 : }
225 : :
226 : 48 : Reference< XInterface > SAL_CALL LinguProps_CreateInstance(
227 : : const Reference< XMultiServiceFactory > & /*rSMgr*/ )
228 : : throw(Exception)
229 : : {
230 [ + - ][ + - ]: 48 : Reference< XInterface > xService = (cppu::OWeakObject*)new LinguProps;
231 : 48 : return xService;
232 : : }
233 : :
234 : 54 : Reference< XPropertySetInfo > SAL_CALL LinguProps::getPropertySetInfo()
235 : : throw(RuntimeException)
236 : : {
237 [ + - ][ + - ]: 54 : MutexGuard aGuard( GetLinguMutex() );
238 : :
239 : : static Reference< XPropertySetInfo > aRef =
240 [ + + ][ + - ]: 54 : new SfxItemPropertySetInfo( aPropertyMap );
[ + - ][ + - ]
[ + - ][ # # ]
241 [ + - ]: 54 : return aRef;
242 : : }
243 : :
244 : 68 : void SAL_CALL LinguProps::setPropertyValue(
245 : : const OUString& rPropertyName, const Any& rValue )
246 : : throw(UnknownPropertyException, PropertyVetoException,
247 : : IllegalArgumentException, WrappedTargetException, RuntimeException)
248 : : {
249 [ + - ][ + - ]: 68 : MutexGuard aGuard( GetLinguMutex() );
250 : :
251 [ + - ]: 68 : const SfxItemPropertySimpleEntry* pCur = aPropertyMap.getByName( rPropertyName );
252 [ + - ]: 68 : if (pCur)
253 : : {
254 [ + - ]: 68 : Any aOld( aConfig.GetProperty( pCur->nWID ) );
255 [ + + ][ + - ]: 68 : if (aOld != rValue && aConfig.SetProperty( pCur->nWID, rValue ))
[ + - ][ + + ]
256 : : {
257 : : PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName,
258 [ + - ][ + - ]: 64 : sal_False, pCur->nWID, aOld, rValue );
259 [ + - ][ + - ]: 64 : launchEvent( aChgEvt );
260 : 68 : }
261 [ + - ]: 68 : }
262 : : #ifdef LINGU_EXCEPTIONS
263 : : else
264 : : {
265 : : throw UnknownPropertyException();
266 : : }
267 : : #endif
268 : 68 : }
269 : :
270 : 421 : Any SAL_CALL LinguProps::getPropertyValue( const OUString& rPropertyName )
271 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
272 : : {
273 [ + - ][ + - ]: 421 : MutexGuard aGuard( GetLinguMutex() );
274 : :
275 : 421 : Any aRet;
276 : :
277 [ + - ]: 421 : const SfxItemPropertySimpleEntry* pCur = aPropertyMap.getByName( rPropertyName );
278 [ + - ]: 421 : if(pCur)
279 : : {
280 [ + - ]: 421 : aRet = aConfig.GetProperty( pCur->nWID );
281 : : }
282 : : #ifdef LINGU_EXCEPTIONS
283 : : else
284 : : {
285 : : throw UnknownPropertyException();
286 : : }
287 : : #endif
288 : :
289 [ + - ]: 421 : return aRet;
290 : : }
291 : :
292 : 485 : void SAL_CALL LinguProps::addPropertyChangeListener(
293 : : const OUString& rPropertyName,
294 : : const Reference< XPropertyChangeListener >& rxListener )
295 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
296 : : {
297 [ + - ][ + - ]: 485 : MutexGuard aGuard( GetLinguMutex() );
298 : :
299 [ + - ][ + - ]: 485 : if (!bDisposing && rxListener.is())
[ + - ]
300 : : {
301 [ + - ]: 485 : const SfxItemPropertySimpleEntry* pCur = aPropertyMap.getByName( rPropertyName );
302 [ + + ]: 485 : if(pCur)
303 [ + - ]: 445 : aPropListeners.addInterface( pCur->nWID, rxListener );
304 : : #ifdef LINGU_EXCEPTIONS
305 : : else
306 : : {
307 : : throw UnknownPropertyException();
308 : : }
309 : : #endif
310 [ + - ]: 485 : }
311 : 485 : }
312 : :
313 : 485 : void SAL_CALL LinguProps::removePropertyChangeListener(
314 : : const OUString& rPropertyName,
315 : : const Reference< XPropertyChangeListener >& rxListener )
316 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
317 : : {
318 [ + - ][ + - ]: 485 : MutexGuard aGuard( GetLinguMutex() );
319 : :
320 [ + + ][ + - ]: 485 : if (!bDisposing && rxListener.is())
[ + + ]
321 : : {
322 [ + - ]: 245 : const SfxItemPropertySimpleEntry* pCur = aPropertyMap.getByName( rPropertyName );
323 [ + - ]: 245 : if(pCur)
324 [ + - ]: 245 : aPropListeners.removeInterface( pCur->nWID, rxListener );
325 : : #ifdef LINGU_EXCEPTIONS
326 : : else
327 : : {
328 : : throw UnknownPropertyException();
329 : : }
330 : : #endif
331 [ + - ]: 485 : }
332 : 485 : }
333 : :
334 : 0 : void SAL_CALL LinguProps::addVetoableChangeListener(
335 : : const OUString& /*rPropertyName*/,
336 : : const Reference< XVetoableChangeListener >& /*xListener*/ )
337 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
338 : : {
339 : 0 : }
340 : :
341 : 0 : void SAL_CALL LinguProps::removeVetoableChangeListener(
342 : : const OUString& /*rPropertyName*/,
343 : : const Reference< XVetoableChangeListener >& /*xListener*/ )
344 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
345 : : {
346 : 0 : }
347 : :
348 : :
349 : 70 : void SAL_CALL LinguProps::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
350 : : throw(UnknownPropertyException, PropertyVetoException,
351 : : IllegalArgumentException, WrappedTargetException, RuntimeException)
352 : : {
353 [ + - ][ + - ]: 70 : MutexGuard aGuard( GetLinguMutex() );
354 : :
355 [ + - ]: 70 : Any aOld( aConfig.GetProperty( nHandle ) );
356 [ + + ][ + - ]: 70 : if (aOld != rValue && aConfig.SetProperty( nHandle, rValue ))
[ + - ][ + + ]
357 : : {
358 : : PropertyChangeEvent aChgEvt( (XPropertySet *) this,
359 [ + - ][ + - ]: 62 : LinguOptions::GetName( nHandle ), sal_False, nHandle, aOld, rValue );
[ + - ]
360 [ + - ][ + - ]: 62 : launchEvent( aChgEvt );
361 [ + - ]: 70 : }
362 : 70 : }
363 : :
364 : :
365 : 131818 : Any SAL_CALL LinguProps::getFastPropertyValue( sal_Int32 nHandle )
366 : : throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
367 : : {
368 [ + - ][ + - ]: 131818 : MutexGuard aGuard( GetLinguMutex() );
369 : :
370 [ + - ]: 131818 : Any aRes( aConfig.GetProperty( nHandle ) );
371 [ + - ]: 131818 : return aRes;
372 : : }
373 : :
374 : :
375 : : Sequence< PropertyValue > SAL_CALL
376 : 0 : LinguProps::getPropertyValues()
377 : : throw(RuntimeException)
378 : : {
379 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetLinguMutex() );
380 : :
381 [ # # ]: 0 : sal_Int32 nLen = aPropertyMap.getSize();
382 [ # # ]: 0 : Sequence< PropertyValue > aProps( nLen );
383 [ # # ]: 0 : PropertyValue *pProp = aProps.getArray();
384 [ # # ]: 0 : PropertyEntryVector_t aPropEntries = aPropertyMap.getPropertyEntries();
385 [ # # ]: 0 : PropertyEntryVector_t::const_iterator aIt = aPropEntries.begin();
386 [ # # ]: 0 : for (sal_Int32 i = 0; i < nLen; ++i, ++aIt)
387 : : {
388 : 0 : PropertyValue &rVal = pProp[i];
389 [ # # ]: 0 : Any aAny( aConfig.GetProperty( aIt->nWID ) );
390 : :
391 : 0 : rVal.Name = aIt->sName;
392 : 0 : rVal.Handle = aIt->nWID;
393 : 0 : rVal.Value = aAny;
394 : 0 : rVal.State = PropertyState_DIRECT_VALUE ;
395 : 0 : }
396 [ # # ]: 0 : return aProps;
397 : : }
398 : :
399 : : void SAL_CALL
400 : 0 : LinguProps::setPropertyValues( const Sequence< PropertyValue >& rProps )
401 : : throw(UnknownPropertyException, PropertyVetoException,
402 : : IllegalArgumentException, WrappedTargetException, RuntimeException)
403 : : {
404 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetLinguMutex() );
405 : :
406 : 0 : sal_Int32 nLen = rProps.getLength();
407 : 0 : const PropertyValue *pVal = rProps.getConstArray();
408 [ # # ]: 0 : for (sal_Int32 i = 0; i < nLen; ++i)
409 : : {
410 : 0 : const PropertyValue &rVal = pVal[i];
411 [ # # ]: 0 : setPropertyValue( rVal.Name, rVal.Value );
412 [ # # ]: 0 : }
413 : 0 : }
414 : :
415 : : void SAL_CALL
416 : 50 : LinguProps::dispose()
417 : : throw(RuntimeException)
418 : : {
419 [ + - ][ + - ]: 50 : MutexGuard aGuard( GetLinguMutex() );
420 : :
421 [ + + ]: 50 : if (!bDisposing)
422 : : {
423 : 48 : bDisposing = sal_True;
424 : :
425 : : //! its too late to save the options here!
426 : : // (see AppExitListener for saving)
427 : : //aOpt.Save(); // save (possible) changes before exiting
428 : :
429 [ + - ][ + - ]: 48 : EventObject aEvtObj( (XPropertySet *) this );
430 [ + - ]: 48 : aEvtListeners.disposeAndClear( aEvtObj );
431 [ + - ][ + - ]: 48 : aPropListeners.disposeAndClear( aEvtObj );
432 [ + - ]: 50 : }
433 : 50 : }
434 : :
435 : : void SAL_CALL
436 : 4 : LinguProps::addEventListener( const Reference< XEventListener >& rxListener )
437 : : throw(RuntimeException)
438 : : {
439 [ + - ][ + - ]: 4 : MutexGuard aGuard( GetLinguMutex() );
440 : :
441 [ + - ][ + - ]: 4 : if (!bDisposing && rxListener.is())
[ + - ]
442 [ + - ][ + - ]: 4 : aEvtListeners.addInterface( rxListener );
443 : 4 : }
444 : :
445 : : void SAL_CALL
446 : 2 : LinguProps::removeEventListener( const Reference< XEventListener >& rxListener )
447 : : throw(RuntimeException)
448 : : {
449 [ + - ][ + - ]: 2 : MutexGuard aGuard( GetLinguMutex() );
450 : :
451 [ + - ][ + - ]: 2 : if (!bDisposing && rxListener.is())
[ + - ]
452 [ + - ][ + - ]: 2 : aEvtListeners.removeInterface( rxListener );
453 : 2 : }
454 : :
455 : :
456 : : // Service specific part
457 : :
458 : : // XServiceInfo
459 : 6 : OUString SAL_CALL LinguProps::getImplementationName()
460 : : throw(RuntimeException)
461 : : {
462 [ + - ][ + - ]: 6 : MutexGuard aGuard( GetLinguMutex() );
463 [ + - ]: 6 : return getImplementationName_Static();
464 : : }
465 : :
466 : : // XServiceInfo
467 : 2 : sal_Bool SAL_CALL LinguProps::supportsService( const OUString& ServiceName )
468 : : throw(RuntimeException)
469 : : {
470 [ + - ][ + - ]: 2 : MutexGuard aGuard( GetLinguMutex() );
471 : :
472 [ + - ]: 2 : uno::Sequence< OUString > aSNL = getSupportedServiceNames();
473 : 2 : const OUString * pArray = aSNL.getConstArray();
474 [ + - ]: 2 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
475 [ + - ]: 2 : if( pArray[i] == ServiceName )
476 : 2 : return sal_True;
477 [ + - ][ + - ]: 2 : return sal_False;
478 : : }
479 : :
480 : : // XServiceInfo
481 : 6 : uno::Sequence< OUString > SAL_CALL LinguProps::getSupportedServiceNames()
482 : : throw(RuntimeException)
483 : : {
484 [ + - ][ + - ]: 6 : MutexGuard aGuard( GetLinguMutex() );
485 [ + - ]: 6 : return getSupportedServiceNames_Static();
486 : : }
487 : :
488 : : // ORegistryServiceManager_Static
489 : 54 : uno::Sequence< OUString > LinguProps::getSupportedServiceNames_Static()
490 : : throw()
491 : : {
492 [ + - ][ + - ]: 54 : MutexGuard aGuard( GetLinguMutex() );
493 : :
494 [ + - ]: 54 : uno::Sequence< OUString > aSNS( 1 ); // more than 1 service possible
495 [ + - ][ + - ]: 54 : aSNS.getArray()[0] = A2OU( SN_LINGU_PROPERTIES );
496 [ + - ]: 54 : return aSNS;
497 : : }
498 : :
499 : 142 : void * SAL_CALL LinguProps_getFactory( const sal_Char * pImplName,
500 : : XMultiServiceFactory *pServiceManager, void * )
501 : : {
502 : 142 : void * pRet = 0;
503 [ + + ]: 142 : if ( !LinguProps::getImplementationName_Static().compareToAscii( pImplName ) )
504 : : {
505 : : Reference< XSingleServiceFactory > xFactory =
506 : : cppu::createOneInstanceFactory(
507 : : pServiceManager,
508 : : LinguProps::getImplementationName_Static(),
509 : : LinguProps_CreateInstance,
510 [ + - ][ + - ]: 48 : LinguProps::getSupportedServiceNames_Static());
[ + - ]
511 : : // acquire, because we return an interface pointer instead of a reference
512 [ + - ]: 48 : xFactory->acquire();
513 [ + - ]: 48 : pRet = xFactory.get();
514 : : }
515 : 142 : return pRet;
516 : : }
517 : :
518 : :
519 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|