Merge OSingleFactoryHelper into OFactoryComponentHelper
Change-Id: I7faf7a3ad54c80bd3c53525c92c26c0f980110f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145423 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
04fd7d0f53
commit
e001703df4
2 changed files with 149 additions and 223 deletions
|
@ -289,7 +289,6 @@ merge cppcanvas::PolyPolygon with cppcanvas::internal::ImplPolyPolygon
|
|||
merge cppcanvas::Renderer with cppcanvas::internal::ImplRenderer
|
||||
merge cppcanvas::SpriteCanvas with cppcanvas::internal::ImplSpriteCanvas
|
||||
merge cppcanvas::internal::ImplSprite with cppcanvas::internal::ImplCustomSprite
|
||||
merge cppu::(anonymous namespace)::OSingleFactoryHelper with cppu::(anonymous namespace)::OFactoryComponentHelper
|
||||
merge cppu::PropertySetMixinImpl with cppu::PropertySetMixin
|
||||
merge dbaccess::IPropertyContainer with dbaccess::OColumn
|
||||
merge dbaccess::IRefreshListener with dbaccess::OConnection
|
||||
|
|
|
@ -58,20 +58,30 @@ namespace cppu
|
|||
|
||||
namespace {
|
||||
|
||||
class OSingleFactoryHelper
|
||||
: public XServiceInfo
|
||||
struct OFactoryComponentHelper_Mutex
|
||||
{
|
||||
Mutex aMutex;
|
||||
};
|
||||
|
||||
class OFactoryComponentHelper
|
||||
: public OFactoryComponentHelper_Mutex
|
||||
, public OComponentHelper
|
||||
, public XServiceInfo
|
||||
, public XSingleServiceFactory
|
||||
, public lang::XSingleComponentFactory
|
||||
, public XUnloadingPreference
|
||||
{
|
||||
public:
|
||||
OSingleFactoryHelper(
|
||||
OFactoryComponentHelper(
|
||||
const Reference<XMultiServiceFactory > & rServiceManager,
|
||||
OUString aImplementationName_,
|
||||
ComponentInstantiation pCreateFunction_,
|
||||
ComponentFactoryFunc fptr,
|
||||
const Sequence< OUString > * pServiceNames_ )
|
||||
: xSMgr( rServiceManager )
|
||||
const Sequence< OUString > * pServiceNames_,
|
||||
bool bOneInstance_ )
|
||||
: OComponentHelper( aMutex )
|
||||
, bOneInstance( bOneInstance_ )
|
||||
, xSMgr( rServiceManager )
|
||||
, pCreateFunction( pCreateFunction_ )
|
||||
, m_fptr( fptr )
|
||||
, aImplementationName(std::move( aImplementationName_ ))
|
||||
|
@ -80,14 +90,16 @@ public:
|
|||
aServiceNames = *pServiceNames_;
|
||||
}
|
||||
|
||||
virtual ~OSingleFactoryHelper();
|
||||
|
||||
// XInterface
|
||||
Any SAL_CALL queryInterface( const Type & rType ) override;
|
||||
void SAL_CALL acquire() noexcept override
|
||||
{ OComponentHelper::acquire(); }
|
||||
void SAL_CALL release() noexcept override
|
||||
{ OComponentHelper::release(); }
|
||||
|
||||
// XSingleServiceFactory
|
||||
Reference<XInterface > SAL_CALL createInstance() override;
|
||||
virtual Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) override;
|
||||
Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments ) override;
|
||||
// XSingleComponentFactory
|
||||
virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
|
||||
Reference< XComponentContext > const & xContext ) override;
|
||||
|
@ -100,7 +112,31 @@ public:
|
|||
sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
|
||||
Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
|
||||
|
||||
// XTypeProvider
|
||||
virtual Sequence< Type > SAL_CALL getTypes() override;
|
||||
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
|
||||
|
||||
// XAggregation
|
||||
Any SAL_CALL queryAggregation( const Type & rType ) override;
|
||||
|
||||
// XUnloadingPreference
|
||||
virtual sal_Bool SAL_CALL releaseOnNotification() override;
|
||||
|
||||
// OComponentHelper
|
||||
void SAL_CALL dispose() override;
|
||||
|
||||
private:
|
||||
css::uno::Reference<css::uno::XInterface> createInstanceWithArgumentsEveryTime(
|
||||
css::uno::Sequence<css::uno::Any> const & rArguments,
|
||||
css::uno::Reference<css::uno::XComponentContext> const & xContext);
|
||||
|
||||
Reference<XInterface > xTheInstance;
|
||||
bool bOneInstance;
|
||||
protected:
|
||||
// needed for implementing XUnloadingPreference in inheriting classes
|
||||
bool isOneInstance() const {return bOneInstance;}
|
||||
bool isInstance() const {return xTheInstance.is();}
|
||||
|
||||
/**
|
||||
* Create an instance specified by the factory. The one instance logic is implemented
|
||||
* in the createInstance and createInstanceWithArguments methods.
|
||||
|
@ -116,32 +152,50 @@ protected:
|
|||
ComponentFactoryFunc m_fptr;
|
||||
Sequence< OUString > aServiceNames;
|
||||
OUString aImplementationName;
|
||||
|
||||
private:
|
||||
css::uno::Reference<css::uno::XInterface> createInstanceWithArgumentsEveryTime(
|
||||
css::uno::Sequence<css::uno::Any> const & rArguments,
|
||||
css::uno::Reference<css::uno::XComponentContext> const & xContext);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
OSingleFactoryHelper::~OSingleFactoryHelper()
|
||||
Any SAL_CALL OFactoryComponentHelper::queryInterface( const Type & rType )
|
||||
{
|
||||
return OComponentHelper::queryInterface( rType );
|
||||
}
|
||||
|
||||
|
||||
Any OSingleFactoryHelper::queryInterface( const Type & rType )
|
||||
// XAggregation
|
||||
Any OFactoryComponentHelper::queryAggregation( const Type & rType )
|
||||
{
|
||||
return ::cppu::queryInterface(
|
||||
rType,
|
||||
static_cast< XSingleComponentFactory * >( this ),
|
||||
static_cast< XSingleServiceFactory * >( this ),
|
||||
static_cast< XServiceInfo * >( this ) ,
|
||||
static_cast< XUnloadingPreference * >( this ));
|
||||
Any aRet( OComponentHelper::queryAggregation( rType ) );
|
||||
return (aRet.hasValue()
|
||||
? aRet
|
||||
: ::cppu::queryInterface(
|
||||
rType,
|
||||
static_cast< XSingleComponentFactory * >( this ),
|
||||
static_cast< XSingleServiceFactory * >( this ),
|
||||
static_cast< XServiceInfo * >( this ) ,
|
||||
static_cast< XUnloadingPreference * >( this )));
|
||||
}
|
||||
|
||||
// OSingleFactoryHelper
|
||||
Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime(
|
||||
// XTypeProvider
|
||||
Sequence< Type > OFactoryComponentHelper::getTypes()
|
||||
{
|
||||
Type ar[ 4 ];
|
||||
ar[ 0 ] = cppu::UnoType<XSingleServiceFactory>::get();
|
||||
ar[ 1 ] = cppu::UnoType<XServiceInfo>::get();
|
||||
ar[ 2 ] = cppu::UnoType<XUnloadingPreference>::get();
|
||||
|
||||
if (m_fptr)
|
||||
ar[ 3 ] = cppu::UnoType<XSingleComponentFactory>::get();
|
||||
|
||||
return Sequence< Type >( ar, m_fptr ? 4 : 3 );
|
||||
}
|
||||
|
||||
Sequence< sal_Int8 > OFactoryComponentHelper::getImplementationId()
|
||||
{
|
||||
return css::uno::Sequence<sal_Int8>();
|
||||
}
|
||||
|
||||
// OFactoryComponentHelper
|
||||
Reference<XInterface > OFactoryComponentHelper::createInstanceEveryTime(
|
||||
Reference< XComponentContext > const & xContext )
|
||||
{
|
||||
if (m_fptr)
|
||||
|
@ -163,36 +217,78 @@ Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime(
|
|||
}
|
||||
|
||||
// XSingleServiceFactory
|
||||
Reference<XInterface > OSingleFactoryHelper::createInstance()
|
||||
Reference<XInterface > OFactoryComponentHelper::createInstance()
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = createInstanceEveryTime( Reference< XComponentContext >() );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return createInstanceEveryTime( Reference< XComponentContext >() );
|
||||
}
|
||||
|
||||
// XSingleServiceFactory
|
||||
Reference<XInterface > OSingleFactoryHelper::createInstanceWithArguments(
|
||||
Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments(
|
||||
const Sequence<Any>& Arguments )
|
||||
{
|
||||
return createInstanceWithArgumentsEveryTime(
|
||||
Arguments, Reference< XComponentContext >() );
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### arguments will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = createInstanceWithArgumentsEveryTime(
|
||||
Arguments, Reference< XComponentContext >() );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return createInstanceWithArgumentsEveryTime( Arguments, Reference< XComponentContext >() );
|
||||
}
|
||||
|
||||
// XSingleComponentFactory
|
||||
|
||||
Reference< XInterface > OSingleFactoryHelper::createInstanceWithContext(
|
||||
Reference< XInterface > OFactoryComponentHelper::createInstanceWithContext(
|
||||
Reference< XComponentContext > const & xContext )
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### context will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = createInstanceEveryTime( xContext );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return createInstanceEveryTime( xContext );
|
||||
}
|
||||
|
||||
Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndContext(
|
||||
Reference< XInterface > OFactoryComponentHelper::createInstanceWithArgumentsAndContext(
|
||||
Sequence< Any > const & rArguments,
|
||||
Reference< XComponentContext > const & xContext )
|
||||
{
|
||||
return createInstanceWithArgumentsEveryTime(rArguments, xContext);
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### context and arguments will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = createInstanceWithArgumentsEveryTime( rArguments, xContext );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return createInstanceWithArgumentsEveryTime( rArguments, xContext );
|
||||
}
|
||||
|
||||
css::uno::Reference<css::uno::XInterface>
|
||||
OSingleFactoryHelper::createInstanceWithArgumentsEveryTime(
|
||||
OFactoryComponentHelper::createInstanceWithArgumentsEveryTime(
|
||||
css::uno::Sequence<css::uno::Any> const & rArguments,
|
||||
css::uno::Reference<css::uno::XComponentContext> const & xContext)
|
||||
{
|
||||
|
@ -223,193 +319,6 @@ OSingleFactoryHelper::createInstanceWithArgumentsEveryTime(
|
|||
return xRet;
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
OUString OSingleFactoryHelper::getImplementationName()
|
||||
{
|
||||
return aImplementationName;
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
sal_Bool OSingleFactoryHelper::supportsService(
|
||||
const OUString& ServiceName )
|
||||
{
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
Sequence< OUString > OSingleFactoryHelper::getSupportedServiceNames()
|
||||
{
|
||||
return aServiceNames;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct OFactoryComponentHelper_Mutex
|
||||
{
|
||||
Mutex aMutex;
|
||||
};
|
||||
|
||||
class OFactoryComponentHelper
|
||||
: public OFactoryComponentHelper_Mutex
|
||||
, public OComponentHelper
|
||||
, public OSingleFactoryHelper
|
||||
{
|
||||
public:
|
||||
OFactoryComponentHelper(
|
||||
const Reference<XMultiServiceFactory > & rServiceManager,
|
||||
const OUString & rImplementationName_,
|
||||
ComponentInstantiation pCreateFunction_,
|
||||
ComponentFactoryFunc fptr,
|
||||
const Sequence< OUString > * pServiceNames_,
|
||||
bool bOneInstance_ )
|
||||
: OComponentHelper( aMutex )
|
||||
, OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, fptr, pServiceNames_ )
|
||||
, bOneInstance( bOneInstance_ )
|
||||
{
|
||||
}
|
||||
|
||||
// XInterface
|
||||
Any SAL_CALL queryInterface( const Type & rType ) override;
|
||||
void SAL_CALL acquire() noexcept override
|
||||
{ OComponentHelper::acquire(); }
|
||||
void SAL_CALL release() noexcept override
|
||||
{ OComponentHelper::release(); }
|
||||
|
||||
// XSingleServiceFactory
|
||||
Reference<XInterface > SAL_CALL createInstance() override;
|
||||
Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments ) override;
|
||||
// XSingleComponentFactory
|
||||
virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
|
||||
Reference< XComponentContext > const & xContext ) override;
|
||||
virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
|
||||
Sequence< Any > const & rArguments,
|
||||
Reference< XComponentContext > const & xContext ) override;
|
||||
|
||||
// XTypeProvider
|
||||
virtual Sequence< Type > SAL_CALL getTypes() override;
|
||||
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
|
||||
|
||||
// XAggregation
|
||||
Any SAL_CALL queryAggregation( const Type & rType ) override;
|
||||
|
||||
// XUnloadingPreference
|
||||
virtual sal_Bool SAL_CALL releaseOnNotification() override;
|
||||
|
||||
// OComponentHelper
|
||||
void SAL_CALL dispose() override;
|
||||
|
||||
private:
|
||||
Reference<XInterface > xTheInstance;
|
||||
bool bOneInstance;
|
||||
protected:
|
||||
// needed for implementing XUnloadingPreference in inheriting classes
|
||||
bool isOneInstance() const {return bOneInstance;}
|
||||
bool isInstance() const {return xTheInstance.is();}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Any SAL_CALL OFactoryComponentHelper::queryInterface( const Type & rType )
|
||||
{
|
||||
return OComponentHelper::queryInterface( rType );
|
||||
}
|
||||
|
||||
// XAggregation
|
||||
Any OFactoryComponentHelper::queryAggregation( const Type & rType )
|
||||
{
|
||||
Any aRet( OComponentHelper::queryAggregation( rType ) );
|
||||
return (aRet.hasValue() ? aRet : OSingleFactoryHelper::queryInterface( rType ));
|
||||
}
|
||||
|
||||
// XTypeProvider
|
||||
Sequence< Type > OFactoryComponentHelper::getTypes()
|
||||
{
|
||||
Type ar[ 4 ];
|
||||
ar[ 0 ] = cppu::UnoType<XSingleServiceFactory>::get();
|
||||
ar[ 1 ] = cppu::UnoType<XServiceInfo>::get();
|
||||
ar[ 2 ] = cppu::UnoType<XUnloadingPreference>::get();
|
||||
|
||||
if (m_fptr)
|
||||
ar[ 3 ] = cppu::UnoType<XSingleComponentFactory>::get();
|
||||
|
||||
return Sequence< Type >( ar, m_fptr ? 4 : 3 );
|
||||
}
|
||||
|
||||
Sequence< sal_Int8 > OFactoryComponentHelper::getImplementationId()
|
||||
{
|
||||
return css::uno::Sequence<sal_Int8>();
|
||||
}
|
||||
|
||||
// XSingleServiceFactory
|
||||
Reference<XInterface > OFactoryComponentHelper::createInstance()
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = OSingleFactoryHelper::createInstance();
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return OSingleFactoryHelper::createInstance();
|
||||
}
|
||||
|
||||
Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments(
|
||||
const Sequence<Any>& Arguments )
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### arguments will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = OSingleFactoryHelper::createInstanceWithArguments( Arguments );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return OSingleFactoryHelper::createInstanceWithArguments( Arguments );
|
||||
}
|
||||
|
||||
// XSingleComponentFactory
|
||||
|
||||
Reference< XInterface > OFactoryComponentHelper::createInstanceWithContext(
|
||||
Reference< XComponentContext > const & xContext )
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### context will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = OSingleFactoryHelper::createInstanceWithContext( xContext );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return OSingleFactoryHelper::createInstanceWithContext( xContext );
|
||||
}
|
||||
|
||||
Reference< XInterface > OFactoryComponentHelper::createInstanceWithArgumentsAndContext(
|
||||
Sequence< Any > const & rArguments,
|
||||
Reference< XComponentContext > const & xContext )
|
||||
{
|
||||
if( bOneInstance )
|
||||
{
|
||||
if( !xTheInstance.is() )
|
||||
{
|
||||
MutexGuard aGuard( aMutex );
|
||||
// OSL_ENSURE( !xTheInstance.is(), "### context and arguments will be ignored!" );
|
||||
if( !xTheInstance.is() )
|
||||
xTheInstance = OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext );
|
||||
}
|
||||
return xTheInstance;
|
||||
}
|
||||
return OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext );
|
||||
}
|
||||
|
||||
|
||||
// OComponentHelper
|
||||
void OFactoryComponentHelper::dispose()
|
||||
|
@ -429,6 +338,25 @@ void OFactoryComponentHelper::dispose()
|
|||
xComp->dispose();
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
OUString OFactoryComponentHelper::getImplementationName()
|
||||
{
|
||||
return aImplementationName;
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
sal_Bool OFactoryComponentHelper::supportsService(
|
||||
const OUString& ServiceName )
|
||||
{
|
||||
return cppu::supportsService(this, ServiceName);
|
||||
}
|
||||
|
||||
// XServiceInfo
|
||||
Sequence< OUString > OFactoryComponentHelper::getSupportedServiceNames()
|
||||
{
|
||||
return aServiceNames;
|
||||
}
|
||||
|
||||
// XUnloadingPreference
|
||||
// This class is used for single factories, component factories and
|
||||
// one-instance factories. Depending on the usage this function has
|
||||
|
@ -481,7 +409,7 @@ public:
|
|||
virtual void SAL_CALL getFastPropertyValue(
|
||||
Any & rValue, sal_Int32 nHandle ) const override;
|
||||
|
||||
// OSingleFactoryHelper
|
||||
// OFactoryComponentHelper
|
||||
Reference<XInterface > createInstanceEveryTime(
|
||||
Reference< XComponentContext > const & xContext ) override;
|
||||
|
||||
|
@ -705,7 +633,6 @@ Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndCo
|
|||
}
|
||||
|
||||
|
||||
// OSingleFactoryHelper
|
||||
Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
|
||||
{
|
||||
OUString aActivatorUrl;
|
||||
|
|
Loading…
Reference in a new issue