From c639da5a41c1390c90716de36b0869120562db9a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 6 May 2011 11:31:54 +0100 Subject: config leaks: drop dodgy LegacySingleton foo --- comphelper/Library_comphelp.mk | 1 - comphelper/Package_inc.mk | 1 - comphelper/inc/comphelper/componentmodule.hxx | 38 +--- .../inc/comphelper/legacysingletonfactory.hxx | 75 -------- comphelper/source/misc/legacysingletonfactory.cxx | 200 --------------------- 5 files changed, 1 insertion(+), 314 deletions(-) delete mode 100644 comphelper/inc/comphelper/legacysingletonfactory.hxx delete mode 100644 comphelper/source/misc/legacysingletonfactory.cxx (limited to 'comphelper') diff --git a/comphelper/Library_comphelp.mk b/comphelper/Library_comphelp.mk index 7c365bc97cd2..8336b8cb2124 100644 --- a/comphelper/Library_comphelp.mk +++ b/comphelper/Library_comphelp.mk @@ -90,7 +90,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/ihwrapnofilter \ comphelper/source/misc/instancelocker \ comphelper/source/misc/interaction \ - comphelper/source/misc/legacysingletonfactory \ comphelper/source/misc/listenernotification \ comphelper/source/misc/locale \ comphelper/source/misc/logging \ diff --git a/comphelper/Package_inc.mk b/comphelper/Package_inc.mk index 5794c56ab74d..fb6538e4700c 100644 --- a/comphelper/Package_inc.mk +++ b/comphelper/Package_inc.mk @@ -89,7 +89,6 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/ChainablePropert $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/stl_types.hxx,comphelper/stl_types.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/eventattachermgr.hxx,comphelper/eventattachermgr.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/componentcontext.hxx,comphelper/componentcontext.hxx)) -$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/legacysingletonfactory.hxx,comphelper/legacysingletonfactory.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/accessibleeventnotifier.hxx,comphelper/accessibleeventnotifier.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/ihwrapnofilter.hxx,comphelper/ihwrapnofilter.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/sequenceasvector.hxx,comphelper/sequenceasvector.hxx)) diff --git a/comphelper/inc/comphelper/componentmodule.hxx b/comphelper/inc/comphelper/componentmodule.hxx index 8aafa2c0261a..4bc917ef13d3 100644 --- a/comphelper/inc/comphelper/componentmodule.hxx +++ b/comphelper/inc/comphelper/componentmodule.hxx @@ -29,7 +29,6 @@ #define COMPHELPER_INC_COMPHELPER_COMPONENTMODULE_HXX #include -#include /** === begin UNO includes === **/ #include @@ -271,29 +270,6 @@ namespace comphelper ) ); } - //========================================================================== - //= OLegacySingletonRegistration - //========================================================================== - template - class OLegacySingletonRegistration - { - public: - OLegacySingletonRegistration( OModule& _rModule ); - }; - - //-------------------------------------------------------------------------- - template - OLegacySingletonRegistration::OLegacySingletonRegistration( OModule& _rModule ) - { - _rModule.registerImplementation( ComponentDescription( - TYPE::getImplementationName_static(), - TYPE::getSupportedServiceNames_static(), - ::rtl::OUString(), - &TYPE::Create, - &::comphelper::createLegacySingletonFactory - ) ); - } - //========================================================================== //= helpers //========================================================================== @@ -350,19 +326,7 @@ namespace comphelper OSingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ { \ } \ - }; \ - /* -------------------------------------------------------------------- */ \ - template < class TYPE > \ - class OLegacySingletonRegistration : public ::comphelper::OLegacySingletonRegistration< TYPE > \ - { \ - private: \ - typedef ::comphelper::OLegacySingletonRegistration< TYPE > BaseClass; \ - \ - public: \ - OLegacySingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ - { \ - } \ - }; \ + }; //========================================================================== //= implementing a OModule for a component library diff --git a/comphelper/inc/comphelper/legacysingletonfactory.hxx b/comphelper/inc/comphelper/legacysingletonfactory.hxx deleted file mode 100644 index d40f828d1384..000000000000 --- a/comphelper/inc/comphelper/legacysingletonfactory.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef COMPHELPER_LEGACYSINGLETONFACTORY_HXX -#define COMPHELPER_LEGACYSINGLETONFACTORY_HXX - -#include "comphelper/comphelperdllapi.h" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -#include - -//........................................................................ -namespace comphelper -{ -//........................................................................ - -/** creates a factory which can be used when implementing old-style singletons - - Before UNO having the component context concept, singletons were implemented by providing - a factory which return the very same component instance for every creation request. - - Nowadays, singletons are implemented by making them available at the component context, - as dedicated property. - - To bridge between both worlds - sometimes necessary to support legacy code, which instantiates - singletons at the global service manager, instead of obtaining the property at the - component context -, you can use the function below. I creates a single-component - factory, which behaves like the old factories did: Upon multiple creation requests, - it will always return the same instance. Additionally, the signature of the function - is the same as the signature of ::cppu::createSingleComponentFactory - (which creates a "normal" component factory), so you can use both factory functions - in the same context. -*/ -::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > - COMPHELPER_DLLPUBLIC createLegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, - const ::rtl::OUString& _rImplementationName, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames, - rtl_ModuleCount* _pModCount = NULL - ); - -//........................................................................ -} // namespace comphelper -//........................................................................ - -#endif // COMPHELPER_LEGACYSINGLETONFACTORY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/misc/legacysingletonfactory.cxx b/comphelper/source/misc/legacysingletonfactory.cxx deleted file mode 100644 index d469d2512c4f..000000000000 --- a/comphelper/source/misc/legacysingletonfactory.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_comphelper.hxx" - -#include "comphelper/legacysingletonfactory.hxx" - -/** === begin UNO includes === **/ -#include -#include -/** === end UNO includes === **/ - -#include - -#include - -//........................................................................ -namespace comphelper -{ -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::lang::XSingleComponentFactory; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::XComponentContext; - using ::com::sun::star::lang::XServiceInfo; - using ::com::sun::star::lang::XInitialization; - /** === end UNO using === **/ - - //==================================================================== - //= LegacySingletonFactory - //==================================================================== - typedef ::cppu::WeakImplHelper2 < XServiceInfo - , XSingleComponentFactory - > LegacySingletonFactory_Base; - - class COMPHELPER_DLLPRIVATE LegacySingletonFactory : public LegacySingletonFactory_Base - { - public: - LegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount - ); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); - - // XSingleComponentFactory - virtual Reference< XInterface > SAL_CALL createInstanceWithContext( const Reference< XComponentContext >& Context ) throw (Exception, RuntimeException); - virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const Sequence< Any >& Arguments, const Reference< XComponentContext >& Context ) throw (Exception, RuntimeException); - - protected: - ~LegacySingletonFactory(); - - private: - /** creates m_xInstance, returns whether it actually was created () or existed before ( - */ - bool impl_nts_ensureInstance( const Reference< XComponentContext >& _rxContext ); - - private: - ::osl::Mutex m_aMutex; - ::cppu::ComponentFactoryFunc m_componentFactoryFunc; - ::rtl::OUString m_sImplementationName; - Sequence< ::rtl::OUString > m_aServiceNames; - rtl_ModuleCount* m_pModuleCount; - Reference< XInterface > m_xTheInstance; - }; - - //-------------------------------------------------------------------- - LegacySingletonFactory::LegacySingletonFactory( ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount ) - :m_componentFactoryFunc ( _componentFactoryFunc ) - ,m_sImplementationName ( _rImplementationName ) - ,m_aServiceNames ( _rServiceNames ) - ,m_pModuleCount ( _pModCount ) - ,m_xTheInstance ( ) - { - if ( m_pModuleCount ) - m_pModuleCount->acquire( m_pModuleCount ); - } - - //-------------------------------------------------------------------- - LegacySingletonFactory::~LegacySingletonFactory() - { - if ( m_pModuleCount ) - m_pModuleCount->release( m_pModuleCount ); - } - - //-------------------------------------------------------------------- - ::rtl::OUString SAL_CALL LegacySingletonFactory::getImplementationName( ) throw (RuntimeException) - { - return m_sImplementationName; - } - - //-------------------------------------------------------------------- - ::sal_Bool SAL_CALL LegacySingletonFactory::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) - { - Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); - const ::rtl::OUString* pStart = aServices.getConstArray(); - const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength(); - return ::std::find( pStart, pEnd, _rServiceName ) != pEnd; - } - - //-------------------------------------------------------------------- - Sequence< ::rtl::OUString > SAL_CALL LegacySingletonFactory::getSupportedServiceNames( ) throw (RuntimeException) - { - return m_aServiceNames; - } - - //-------------------------------------------------------------------- - bool LegacySingletonFactory::impl_nts_ensureInstance( const Reference< XComponentContext >& _rxContext ) - { - if ( m_xTheInstance.is() ) - return false; - - m_xTheInstance = (*m_componentFactoryFunc)( _rxContext ); - if ( !m_xTheInstance.is() ) - throw RuntimeException(); - - return true; // true -> "was newly created" - } - - //-------------------------------------------------------------------- - Reference< XInterface > SAL_CALL LegacySingletonFactory::createInstanceWithContext( const Reference< XComponentContext >& _rxContext ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - impl_nts_ensureInstance( _rxContext ); - - return m_xTheInstance; - } - - //-------------------------------------------------------------------- - Reference< XInterface > SAL_CALL LegacySingletonFactory::createInstanceWithArgumentsAndContext( const Sequence< Any >& _rArguments, const Reference< XComponentContext >& _rxContext ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( !impl_nts_ensureInstance( _rxContext ) ) - throw RuntimeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Instance already created before, unable to initialize it." ) ), - *this - ); - - Reference< XInitialization > xInit( m_xTheInstance, UNO_QUERY_THROW ); - xInit->initialize( _rArguments ); - - return m_xTheInstance; - } - - //==================================================================== - //= createLegacySingletonFactory - //==================================================================== - Reference< XSingleComponentFactory > createLegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount ) - { - return new LegacySingletonFactory( _componentFactoryFunc, _rImplementationName, _rServiceNames, _pModCount ); - } - - -//........................................................................ -} // namespace comphelper -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit