1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: lngopt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_linguistic.hxx"
35 #include "lngprops.hxx"
37 #include <tools/debug.hxx>
38 #include <svtools/lingucfg.hxx>
39 #include <vcl/svapp.hxx>
41 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
42 #include <cppuhelper/implbase1.hxx> // helper for implementations
44 #include <cppuhelper/factory.hxx> // helper for factories
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/registry/XSimpleRegistry.hpp>
47 #include <com/sun/star/registry/XRegistryKey.hpp>
48 #include <com/sun/star/lang/Locale.hpp>
49 #include <unotools/processfactory.hxx>
54 using namespace com::sun::star
;
55 using namespace com::sun::star::container
;
56 using namespace com::sun::star::beans
;
57 using namespace com::sun::star::lang
;
58 using namespace com::sun::star::uno
;
59 using namespace com::sun::star::linguistic2
;
60 using namespace linguistic
;
62 using namespace com::sun::star::registry
;
64 ///////////////////////////////////////////////////////////////////////////
67 // static member intialization
68 SvtLinguOptions
* LinguOptions::pData
= NULL
;
69 vos::ORefCount
LinguOptions::aRefCount
;
72 LinguOptions::LinguOptions()
76 pData
= new SvtLinguOptions
;
77 SvtLinguConfig aLinguCfg
;
78 aLinguCfg
.GetOptions( *pData
);
85 LinguOptions::LinguOptions(const LinguOptions
& /*rOpt*/)
87 DBG_ASSERT( pData
, "lng : data missing" );
92 LinguOptions::~LinguOptions()
94 MutexGuard
aGuard( GetLinguMutex() );
98 delete pData
; pData
= NULL
;
103 BOOL
LinguOptions::SetLocale_Impl( INT16
&rLanguage
, Any
&rOld
, const Any
&rVal
)
109 INT16 nNew
= LocaleToLanguage( aNew
);
110 if (nNew
!= rLanguage
)
112 Locale
aLocale( CreateLocale( rLanguage
) );
113 rOld
.setValue( &aLocale
, ::getCppuType((Locale
*)0 ));
122 BOOL
LinguOptions::SetValue( Any
&rOld
, const Any
&rVal
, INT32 nWID
)
124 MutexGuard
aGuard( GetLinguMutex() );
133 case WID_IS_GERMAN_PRE_REFORM
: /*! deprecated !*/ break;
134 case WID_IS_USE_DICTIONARY_LIST
: pbVal
= &pData
->bIsUseDictionaryList
; break;
135 case WID_IS_IGNORE_CONTROL_CHARACTERS
: pbVal
= &pData
->bIsIgnoreControlCharacters
; break;
136 case WID_IS_HYPH_AUTO
: pbVal
= &pData
->bIsHyphAuto
; break;
137 case WID_IS_HYPH_SPECIAL
: pbVal
= &pData
->bIsHyphSpecial
; break;
138 case WID_IS_SPELL_AUTO
: pbVal
= &pData
->bIsSpellAuto
; break;
139 case WID_IS_SPELL_HIDE
: /*! deprecated !*/ break;
140 case WID_IS_SPELL_IN_ALL_LANGUAGES
:/*! deprecated !*/ break;
141 case WID_IS_SPELL_SPECIAL
: pbVal
= &pData
->bIsSpellSpecial
; break;
142 case WID_IS_WRAP_REVERSE
: pbVal
= &pData
->bIsSpellReverse
; break;
143 case WID_DEFAULT_LANGUAGE
: pnVal
= &pData
->nDefaultLanguage
; break;
144 case WID_IS_SPELL_CAPITALIZATION
: pbVal
= &pData
->bIsSpellCapitalization
; break;
145 case WID_IS_SPELL_WITH_DIGITS
: pbVal
= &pData
->bIsSpellWithDigits
; break;
146 case WID_IS_SPELL_UPPER_CASE
: pbVal
= &pData
->bIsSpellUpperCase
; break;
147 case WID_HYPH_MIN_LEADING
: pnVal
= &pData
->nHyphMinLeading
; break;
148 case WID_HYPH_MIN_TRAILING
: pnVal
= &pData
->nHyphMinTrailing
; break;
149 case WID_HYPH_MIN_WORD_LENGTH
: pnVal
= &pData
->nHyphMinWordLength
; break;
150 case WID_DEFAULT_LOCALE
:
152 bRes
= SetLocale_Impl( pData
->nDefaultLanguage
, rOld
, rVal
);
155 case WID_DEFAULT_LOCALE_CJK
:
157 bRes
= SetLocale_Impl( pData
->nDefaultLanguage_CJK
, rOld
, rVal
);
160 case WID_DEFAULT_LOCALE_CTL
:
162 bRes
= SetLocale_Impl( pData
->nDefaultLanguage_CTL
, rOld
, rVal
);
167 DBG_ASSERT( 0,"lng : unknown WID");
196 // pData->SetModified();
201 void LinguOptions::GetValue( Any
&rVal
, INT32 nWID
) const
203 MutexGuard
aGuard( GetLinguMutex() );
211 case WID_IS_GERMAN_PRE_REFORM
: pbVal
= &bDummy
; /*! deprecated !*/ break;
212 case WID_IS_USE_DICTIONARY_LIST
: pbVal
= &pData
->bIsUseDictionaryList
; break;
213 case WID_IS_IGNORE_CONTROL_CHARACTERS
: pbVal
= &pData
->bIsIgnoreControlCharacters
; break;
214 case WID_IS_HYPH_AUTO
: pbVal
= &pData
->bIsHyphAuto
; break;
215 case WID_IS_HYPH_SPECIAL
: pbVal
= &pData
->bIsHyphSpecial
; break;
216 case WID_IS_SPELL_AUTO
: pbVal
= &pData
->bIsSpellAuto
; break;
217 case WID_IS_SPELL_HIDE
: pbVal
= &bDummy
; /*! deprecated !*/ break;
218 case WID_IS_SPELL_IN_ALL_LANGUAGES
:pbVal
= &bDummy
; /*! deprecated !*/ break;
219 case WID_IS_SPELL_SPECIAL
: pbVal
= &pData
->bIsSpellSpecial
; break;
220 case WID_IS_WRAP_REVERSE
: pbVal
= &pData
->bIsSpellReverse
; break;
221 case WID_DEFAULT_LANGUAGE
: pnVal
= &pData
->nDefaultLanguage
; break;
222 case WID_IS_SPELL_CAPITALIZATION
: pbVal
= &pData
->bIsSpellCapitalization
; break;
223 case WID_IS_SPELL_WITH_DIGITS
: pbVal
= &pData
->bIsSpellWithDigits
; break;
224 case WID_IS_SPELL_UPPER_CASE
: pbVal
= &pData
->bIsSpellUpperCase
; break;
225 case WID_HYPH_MIN_LEADING
: pnVal
= &pData
->nHyphMinLeading
; break;
226 case WID_HYPH_MIN_TRAILING
: pnVal
= &pData
->nHyphMinTrailing
; break;
227 case WID_HYPH_MIN_WORD_LENGTH
: pnVal
= &pData
->nHyphMinWordLength
; break;
228 case WID_DEFAULT_LOCALE
:
230 Locale
aLocale( CreateLocale( pData
->nDefaultLanguage
) );
231 rVal
.setValue( &aLocale
, ::getCppuType((Locale
*)0 ));
234 case WID_DEFAULT_LOCALE_CJK
:
236 Locale
aLocale( CreateLocale( pData
->nDefaultLanguage_CJK
) );
237 rVal
.setValue( &aLocale
, ::getCppuType((Locale
*)0 ));
240 case WID_DEFAULT_LOCALE_CTL
:
242 Locale
aLocale( CreateLocale( pData
->nDefaultLanguage_CTL
) );
243 rVal
.setValue( &aLocale
, ::getCppuType((Locale
*)0 ));
248 DBG_ASSERT( 0,"lng : unknown WID");
262 const char *pPropertyName
;
265 //! order of entries is import (see LinguOptions::GetName)
266 //! since the WID is used as index in this table!
267 WID_Name aWID_Name
[] =
270 { WID_IS_USE_DICTIONARY_LIST
, UPN_IS_USE_DICTIONARY_LIST
},
271 { WID_IS_IGNORE_CONTROL_CHARACTERS
, UPN_IS_IGNORE_CONTROL_CHARACTERS
},
272 { WID_IS_SPELL_UPPER_CASE
, UPN_IS_SPELL_UPPER_CASE
},
273 { WID_IS_SPELL_WITH_DIGITS
, UPN_IS_SPELL_WITH_DIGITS
},
274 { WID_IS_SPELL_CAPITALIZATION
, UPN_IS_SPELL_CAPITALIZATION
},
275 { WID_HYPH_MIN_LEADING
, UPN_HYPH_MIN_LEADING
},
276 { WID_HYPH_MIN_TRAILING
, UPN_HYPH_MIN_TRAILING
},
277 { WID_HYPH_MIN_WORD_LENGTH
, UPN_HYPH_MIN_WORD_LENGTH
},
278 { WID_DEFAULT_LOCALE
, UPN_DEFAULT_LOCALE
},
279 { WID_IS_SPELL_AUTO
, UPN_IS_SPELL_AUTO
},
282 { WID_IS_SPELL_SPECIAL
, UPN_IS_SPELL_SPECIAL
},
283 { WID_IS_HYPH_AUTO
, UPN_IS_HYPH_AUTO
},
284 { WID_IS_HYPH_SPECIAL
, UPN_IS_HYPH_SPECIAL
},
285 { WID_IS_WRAP_REVERSE
, UPN_IS_WRAP_REVERSE
},
290 { WID_DEFAULT_LANGUAGE
, UPN_DEFAULT_LANGUAGE
},
291 { WID_DEFAULT_LOCALE_CJK
, UPN_DEFAULT_LOCALE_CJK
},
292 { WID_DEFAULT_LOCALE_CTL
, UPN_DEFAULT_LOCALE_CTL
}
296 OUString
LinguOptions::GetName( INT32 nWID
)
298 MutexGuard
aGuard( GetLinguMutex() );
302 INT32 nLen
= sizeof( aWID_Name
) / sizeof( aWID_Name
[0] );
303 if (0 <= nWID
&& nWID
< nLen
304 && aWID_Name
[ nWID
].nWID
== nWID
)
306 aRes
= OUString( RTL_CONSTASCII_USTRINGPARAM(
307 aWID_Name
[ nWID
].pPropertyName
) );
311 DBG_ASSERT( 0,"lng : unknown WID");
318 ///////////////////////////////////////////////////////////////////////////
320 //! map must be sorted by first entry in alphabetical increasing order.
321 const SfxItemPropertyMapEntry
* lcl_GetLinguProps()
323 static const SfxItemPropertyMapEntry aLinguProps
[] =
325 { MAP_CHAR_LEN(UPN_DEFAULT_LANGUAGE
), WID_DEFAULT_LANGUAGE
,
326 &::getCppuType( (sal_Int16
*)0 ), 0, 0 },
327 { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE
), WID_DEFAULT_LOCALE
,
328 &::getCppuType( (Locale
* )0), 0, 0 },
329 { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE_CJK
), WID_DEFAULT_LOCALE_CJK
,
330 &::getCppuType( (Locale
* )0), 0, 0 },
331 { MAP_CHAR_LEN(UPN_DEFAULT_LOCALE_CTL
), WID_DEFAULT_LOCALE_CTL
,
332 &::getCppuType( (Locale
* )0), 0, 0 },
333 { MAP_CHAR_LEN(UPN_HYPH_MIN_LEADING
), WID_HYPH_MIN_LEADING
,
334 &::getCppuType( (sal_Int16
*)0 ), 0, 0 },
335 { MAP_CHAR_LEN(UPN_HYPH_MIN_TRAILING
), WID_HYPH_MIN_TRAILING
,
336 &::getCppuType( (sal_Int16
*)0 ), 0, 0 },
337 { MAP_CHAR_LEN(UPN_HYPH_MIN_WORD_LENGTH
), WID_HYPH_MIN_WORD_LENGTH
,
338 &::getCppuType( (sal_Int16
*)0 ), 0, 0 },
339 { MAP_CHAR_LEN(UPN_IS_GERMAN_PRE_REFORM
), WID_IS_GERMAN_PRE_REFORM
, /*! deprecated !*/
340 &::getBooleanCppuType(), 0, 0 },
341 { MAP_CHAR_LEN(UPN_IS_HYPH_AUTO
), WID_IS_HYPH_AUTO
,
342 &::getBooleanCppuType(), 0, 0 },
343 { MAP_CHAR_LEN(UPN_IS_HYPH_SPECIAL
), WID_IS_HYPH_SPECIAL
,
344 &::getBooleanCppuType(), 0, 0 },
345 { MAP_CHAR_LEN(UPN_IS_IGNORE_CONTROL_CHARACTERS
), WID_IS_IGNORE_CONTROL_CHARACTERS
,
346 &::getBooleanCppuType(), 0, 0 },
347 { MAP_CHAR_LEN(UPN_IS_SPELL_AUTO
), WID_IS_SPELL_AUTO
,
348 &::getBooleanCppuType(), 0, 0 },
349 { MAP_CHAR_LEN(UPN_IS_SPELL_CAPITALIZATION
), WID_IS_SPELL_CAPITALIZATION
,
350 &::getBooleanCppuType(), 0, 0 },
351 { MAP_CHAR_LEN(UPN_IS_SPELL_HIDE
), WID_IS_SPELL_HIDE
, /*! deprecated !*/
352 &::getBooleanCppuType(), 0, 0 },
353 { MAP_CHAR_LEN(UPN_IS_SPELL_IN_ALL_LANGUAGES
), WID_IS_SPELL_IN_ALL_LANGUAGES
, /*! deprecated !*/
354 &::getBooleanCppuType(), 0, 0 },
355 { MAP_CHAR_LEN(UPN_IS_SPELL_SPECIAL
), WID_IS_SPELL_SPECIAL
,
356 &::getBooleanCppuType(), 0, 0 },
357 { MAP_CHAR_LEN(UPN_IS_SPELL_UPPER_CASE
), WID_IS_SPELL_UPPER_CASE
,
358 &::getBooleanCppuType(), 0, 0 },
359 { MAP_CHAR_LEN(UPN_IS_SPELL_WITH_DIGITS
), WID_IS_SPELL_WITH_DIGITS
,
360 &::getBooleanCppuType(), 0, 0 },
361 { MAP_CHAR_LEN(UPN_IS_USE_DICTIONARY_LIST
), WID_IS_USE_DICTIONARY_LIST
,
362 &::getBooleanCppuType(), 0, 0 },
363 { MAP_CHAR_LEN(UPN_IS_WRAP_REVERSE
), WID_IS_WRAP_REVERSE
,
364 &::getBooleanCppuType(), 0, 0 },
369 LinguProps::LinguProps() :
370 aEvtListeners (GetLinguMutex()),
371 aPropListeners (GetLinguMutex()),
372 aPropertyMap(lcl_GetLinguProps())
377 void LinguProps::launchEvent( const PropertyChangeEvent
&rEvt
) const
379 cppu::OInterfaceContainerHelper
*pContainer
=
380 aPropListeners
.getContainer( rEvt
.PropertyHandle
);
383 cppu::OInterfaceIteratorHelper
aIt( *pContainer
);
384 while (aIt
.hasMoreElements())
386 Reference
< XPropertyChangeListener
> xRef( aIt
.next(), UNO_QUERY
);
388 xRef
->propertyChange( rEvt
);
393 Reference
< XInterface
> SAL_CALL
LinguProps_CreateInstance(
394 const Reference
< XMultiServiceFactory
> & /*rSMgr*/ )
397 Reference
< XInterface
> xService
= (cppu::OWeakObject
*)new LinguProps
;
401 Reference
< XPropertySetInfo
> SAL_CALL
LinguProps::getPropertySetInfo()
402 throw(RuntimeException
)
404 MutexGuard
aGuard( GetLinguMutex() );
406 static Reference
< XPropertySetInfo
> aRef
=
407 new SfxItemPropertySetInfo( &aPropertyMap
);
411 void SAL_CALL
LinguProps::setPropertyValue(
412 const OUString
& rPropertyName
, const Any
& rValue
)
413 throw(UnknownPropertyException
, PropertyVetoException
,
414 IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
416 MutexGuard
aGuard( GetLinguMutex() );
418 const SfxItemPropertySimpleEntry
* pCur
= aPropertyMap
.getByName( rPropertyName
);
421 Any
aOld( aConfig
.GetProperty( pCur
->nWID
) );
422 if (aOld
!= rValue
&& aConfig
.SetProperty( pCur
->nWID
, rValue
))
424 PropertyChangeEvent
aChgEvt( (XPropertySet
*) this, rPropertyName
,
425 FALSE
, pCur
->nWID
, aOld
, rValue
);
426 launchEvent( aChgEvt
);
429 #ifdef LINGU_EXCEPTIONS
432 throw UnknownPropertyException();
437 Any SAL_CALL
LinguProps::getPropertyValue( const OUString
& rPropertyName
)
438 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
440 MutexGuard
aGuard( GetLinguMutex() );
444 const SfxItemPropertySimpleEntry
* pCur
= aPropertyMap
.getByName( rPropertyName
);
447 aRet
= aConfig
.GetProperty( pCur
->nWID
);
449 #ifdef LINGU_EXCEPTIONS
452 throw UnknownPropertyException();
459 void SAL_CALL
LinguProps::addPropertyChangeListener(
460 const OUString
& rPropertyName
,
461 const Reference
< XPropertyChangeListener
>& rxListener
)
462 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
464 MutexGuard
aGuard( GetLinguMutex() );
466 if (!bDisposing
&& rxListener
.is())
468 const SfxItemPropertySimpleEntry
* pCur
= aPropertyMap
.getByName( rPropertyName
);
470 aPropListeners
.addInterface( pCur
->nWID
, rxListener
);
471 #ifdef LINGU_EXCEPTIONS
474 throw UnknownPropertyException();
480 void SAL_CALL
LinguProps::removePropertyChangeListener(
481 const OUString
& rPropertyName
,
482 const Reference
< XPropertyChangeListener
>& rxListener
)
483 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
485 MutexGuard
aGuard( GetLinguMutex() );
487 if (!bDisposing
&& rxListener
.is())
489 const SfxItemPropertySimpleEntry
* pCur
= aPropertyMap
.getByName( rPropertyName
);
491 aPropListeners
.removeInterface( pCur
->nWID
, rxListener
);
492 #ifdef LINGU_EXCEPTIONS
495 throw UnknownPropertyException();
501 void SAL_CALL
LinguProps::addVetoableChangeListener(
502 const OUString
& /*rPropertyName*/,
503 const Reference
< XVetoableChangeListener
>& /*xListener*/ )
504 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
506 // MutexGuard aGuard( GetLinguMutex() );
509 void SAL_CALL
LinguProps::removeVetoableChangeListener(
510 const OUString
& /*rPropertyName*/,
511 const Reference
< XVetoableChangeListener
>& /*xListener*/ )
512 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
514 // MutexGuard aGuard( GetLinguMutex() );
518 void SAL_CALL
LinguProps::setFastPropertyValue( sal_Int32 nHandle
, const Any
& rValue
)
519 throw(UnknownPropertyException
, PropertyVetoException
,
520 IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
522 MutexGuard
aGuard( GetLinguMutex() );
524 Any
aOld( aConfig
.GetProperty( nHandle
) );
525 if (aOld
!= rValue
&& aConfig
.SetProperty( nHandle
, rValue
))
527 PropertyChangeEvent
aChgEvt( (XPropertySet
*) this,
528 LinguOptions::GetName( nHandle
), FALSE
, nHandle
, aOld
, rValue
);
529 launchEvent( aChgEvt
);
534 Any SAL_CALL
LinguProps::getFastPropertyValue( sal_Int32 nHandle
)
535 throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
537 MutexGuard
aGuard( GetLinguMutex() );
539 Any
aRes( aConfig
.GetProperty( nHandle
) );
544 Sequence
< PropertyValue
> SAL_CALL
545 LinguProps::getPropertyValues()
546 throw(RuntimeException
)
548 MutexGuard
aGuard( GetLinguMutex() );
550 INT32 nLen
= aPropertyMap
.getSize();
551 Sequence
< PropertyValue
> aProps( nLen
);
552 PropertyValue
*pProp
= aProps
.getArray();
553 PropertyEntryVector_t aPropEntries
= aPropertyMap
.getPropertyEntries();
554 PropertyEntryVector_t::const_iterator aIt
= aPropEntries
.begin();
555 for (INT32 i
= 0; i
< nLen
; ++i
, ++aIt
)
557 PropertyValue
&rVal
= pProp
[i
];
558 Any
aAny( aConfig
.GetProperty( aIt
->nWID
) );
560 rVal
.Name
= aIt
->sName
;
561 rVal
.Handle
= aIt
->nWID
;
563 rVal
.State
= PropertyState_DIRECT_VALUE
;
569 LinguProps::setPropertyValues( const Sequence
< PropertyValue
>& rProps
)
570 throw(UnknownPropertyException
, PropertyVetoException
,
571 IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
573 MutexGuard
aGuard( GetLinguMutex() );
575 INT32 nLen
= rProps
.getLength();
576 const PropertyValue
*pVal
= rProps
.getConstArray();
577 for (INT32 i
= 0; i
< nLen
; ++i
)
579 const PropertyValue
&rVal
= pVal
[i
];
580 setPropertyValue( rVal
.Name
, rVal
.Value
);
585 LinguProps::dispose()
586 throw(RuntimeException
)
588 MutexGuard
aGuard( GetLinguMutex() );
594 //! its too late to save the options here!
595 // (see AppExitListener for saving)
596 //aOpt.Save(); // save (possible) changes before exiting
598 EventObject
aEvtObj( (XPropertySet
*) this );
599 aEvtListeners
.disposeAndClear( aEvtObj
);
600 aPropListeners
.disposeAndClear( aEvtObj
);
605 LinguProps::addEventListener( const Reference
< XEventListener
>& rxListener
)
606 throw(RuntimeException
)
608 MutexGuard
aGuard( GetLinguMutex() );
610 if (!bDisposing
&& rxListener
.is())
611 aEvtListeners
.addInterface( rxListener
);
615 LinguProps::removeEventListener( const Reference
< XEventListener
>& rxListener
)
616 throw(RuntimeException
)
618 MutexGuard
aGuard( GetLinguMutex() );
620 if (!bDisposing
&& rxListener
.is())
621 aEvtListeners
.removeInterface( rxListener
);
625 ///////////////////////////////////////////////////////////////////////////
626 // Service specific part
630 OUString SAL_CALL
LinguProps::getImplementationName()
631 throw(RuntimeException
)
633 MutexGuard
aGuard( GetLinguMutex() );
634 return getImplementationName_Static();
638 sal_Bool SAL_CALL
LinguProps::supportsService( const OUString
& ServiceName
)
639 throw(RuntimeException
)
641 MutexGuard
aGuard( GetLinguMutex() );
643 uno::Sequence
< OUString
> aSNL
= getSupportedServiceNames();
644 const OUString
* pArray
= aSNL
.getConstArray();
645 for( INT32 i
= 0; i
< aSNL
.getLength(); i
++ )
646 if( pArray
[i
] == ServiceName
)
652 uno::Sequence
< OUString
> SAL_CALL
LinguProps::getSupportedServiceNames()
653 throw(RuntimeException
)
655 MutexGuard
aGuard( GetLinguMutex() );
656 return getSupportedServiceNames_Static();
659 // ORegistryServiceManager_Static
660 uno::Sequence
< OUString
> LinguProps::getSupportedServiceNames_Static()
663 MutexGuard
aGuard( GetLinguMutex() );
665 uno::Sequence
< OUString
> aSNS( 1 ); // auch mehr als 1 Service moeglich
666 aSNS
.getArray()[0] = A2OU( SN_LINGU_PROPERTIES
);
671 sal_Bool SAL_CALL
LinguProps_writeInfo( void * /*pServiceManager*/,
672 XRegistryKey
* pRegistryKey
)
677 aImpl
+= LinguProps::getImplementationName_Static().getStr();
678 aImpl
.AppendAscii( "/UNO/SERVICES" );
679 Reference
< XRegistryKey
> xNewKey
=
680 pRegistryKey
->createKey(aImpl
);
681 uno::Sequence
< OUString
> aServices
= LinguProps::getSupportedServiceNames_Static();
682 for( INT32 i
= 0; i
< aServices
.getLength(); i
++ )
683 xNewKey
->createKey( aServices
.getConstArray()[i
]);
693 void * SAL_CALL
LinguProps_getFactory( const sal_Char
* pImplName
,
694 XMultiServiceFactory
*pServiceManager
, void * )
697 if ( !LinguProps::getImplementationName_Static().compareToAscii( pImplName
) )
699 Reference
< XSingleServiceFactory
> xFactory
=
700 cppu::createOneInstanceFactory(
702 LinguProps::getImplementationName_Static(),
703 LinguProps_CreateInstance
,
704 LinguProps::getSupportedServiceNames_Static());
705 // acquire, because we return an interface pointer instead of a reference
707 pRet
= xFactory
.get();
712 ///////////////////////////////////////////////////////////////////////////