diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2004-11-26 13:28:55 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2004-11-26 13:28:55 +0000 |
commit | ce692a101a7389755afc5fa6c66291ef52114853 (patch) | |
tree | 841f0bc6114236a2a5698f98039c103b99b282d4 /linguistic | |
parent | 2671d9ee8b561bb67a2e51b71931df60ecaf3674 (diff) |
INTEGRATION: CWS gt08hangulhanja (1.2.4); FILE MERGED
2004/11/23 15:09:47 iha 1.2.4.4: #118541# create only single instance of ConversionDictionaryList (OneInstanceFactory is not sufficient if different service managers are used)
2004/10/15 16:26:48 tl 1.2.4.3: RESYNC: (1.2-1.3); FILE MERGED
2004/10/11 11:38:10 iha 1.2.4.2: #118078# single instance for ConversionDictionaryList
2004/05/07 12:41:52 tl 1.2.4.1: #116074# check if dictionary is active added; ScriptTypeList list updatet to latest version
Diffstat (limited to 'linguistic')
-rw-r--r-- | linguistic/source/convdiclist.cxx | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx index 56d815ce0f65..bc732ee203f1 100644 --- a/linguistic/source/convdiclist.cxx +++ b/linguistic/source/convdiclist.cxx @@ -2,9 +2,9 @@ * * $RCSfile: convdiclist.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: rt $ $Date: 2004-09-17 13:34:18 $ + * last change: $Author: rt $ $Date: 2004-11-26 14:28:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,6 +86,9 @@ #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif +#ifndef INCLUDED_RTL_INSTANCE_HXX +#include <rtl/instance.hxx> +#endif #include <cppuhelper/factory.hxx> // helper for factories #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX @@ -465,9 +468,50 @@ void ConvDicNameContainer::AddConvDics( /////////////////////////////////////////////////////////////////////////// +namespace +{ +template<typename T, typename InitData, + typename Unique = InitData, typename Data = T> +class StaticWithInit_ { +public: + /** Gets the static. Mutual exclusion is performed using the + osl global mutex. + + @return + static variable + */ + static T & get() { + return *rtl_Instance< + T, StaticInstanceWithInit, + ::osl::MutexGuard, ::osl::GetGlobalMutex, + Data, InitData >::create( StaticInstanceWithInit(), + ::osl::GetGlobalMutex(), + InitData() ); + } +private: + struct StaticInstanceWithInit { + T * operator () ( Data d ) { + static T instance(d); + return &instance; + } + }; +}; + +//after src680m62 you can replace StaticWithInit_ with rtl::StaticWithInit and remove the above definition of StaticWithInit_ + +struct StaticConvDicList : public StaticWithInit_< + Reference<XInterface>, StaticConvDicList> { + Reference<XInterface> operator () () { + return (cppu::OWeakObject *) new ConvDicList; + } +}; +} + + void ConvDicList::MyAppExitListener::AtExit() { rMyDicList.FlushDics(); + StaticConvDicList::get().clear(); } ConvDicList::ConvDicList() : @@ -746,8 +790,7 @@ Reference< XInterface > SAL_CALL ConvDicList_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception) { - Reference< XInterface > xService = (cppu::OWeakObject *) new ConvDicList; - return xService; + return StaticConvDicList::get(); } @@ -782,18 +825,12 @@ void * SAL_CALL ConvDicList_getFactory( void * pRet = 0; if ( !ConvDicList::getImplementationName_Static().compareToAscii( pImplName ) ) { -/* Reference< XSingleServiceFactory > xFactory = + Reference< XSingleServiceFactory > xFactory = cppu::createOneInstanceFactory( pServiceManager, ConvDicList::getImplementationName_Static(), ConvDicList_CreateInstance, ConvDicList::getSupportedServiceNames_Static()); -*/ - Reference< XSingleServiceFactory > xFactory = - cppu::createSingleFactory( pServiceManager, - ConvDicList::getImplementationName_Static(), - ConvDicList_CreateInstance, - ConvDicList::getSupportedServiceNames_Static() ); // acquire, because we return an interface pointer instead of a reference xFactory->acquire(); pRet = xFactory.get(); |