diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 12:35:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-15 10:08:08 +0200 |
commit | b2835b2a65918c8ea73fde4ba6befa1fabbe6033 (patch) | |
tree | ec2d1f7e768568d85aa75ed515a169c2a4cfe3ac /scripting | |
parent | 0c688d3491c6f53ed06fbc5946e043e3b7509c63 (diff) |
scripting/protocolhandler: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I5618d68317a24bfe92dc166ffc81dcf5ffeba1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98740
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/protocolhandler/protocolhandler.component | 5 | ||||
-rw-r--r-- | scripting/source/protocolhandler/scripthandler.cxx | 73 | ||||
-rw-r--r-- | scripting/source/protocolhandler/scripthandler.hxx | 12 |
3 files changed, 8 insertions, 82 deletions
diff --git a/scripting/source/protocolhandler/protocolhandler.component b/scripting/source/protocolhandler/protocolhandler.component index d569cfe9911a..959c332c0e86 100644 --- a/scripting/source/protocolhandler/protocolhandler.component +++ b/scripting/source/protocolhandler/protocolhandler.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="protocolhandler" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.ScriptProtocolHandler"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.ScriptProtocolHandler" + constructor="scripting_ScriptProtocolHandler_get_implementation"> <service name="com.sun.star.frame.ProtocolHandler"/> </implementation> </component> diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index a759ef63070c..78d754300cfa 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -413,7 +413,7 @@ ScriptProtocolHandler::~ScriptProtocolHandler() /* XServiceInfo */ OUString SAL_CALL ScriptProtocolHandler::getImplementationName( ) { - return impl_getStaticImplementationName(); + return "com.sun.star.comp.ScriptProtocolHandler"; } /* XServiceInfo */ @@ -425,80 +425,17 @@ sal_Bool SAL_CALL ScriptProtocolHandler::supportsService(const OUString& sServic /* XServiceInfo */ Sequence< OUString > SAL_CALL ScriptProtocolHandler::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); -} - -/* Helper for XServiceInfo */ -Sequence< OUString > ScriptProtocolHandler::impl_getStaticSupportedServiceNames() -{ return {"com.sun.star.frame.ProtocolHandler"}; } -/* Helper for XServiceInfo */ -OUString ScriptProtocolHandler::impl_getStaticImplementationName() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +scripting_ScriptProtocolHandler_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return "com.sun.star.comp.ScriptProtocolHandler"; -} - -/* Helper for registry */ -Reference< XInterface > SAL_CALL ScriptProtocolHandler::impl_createInstance( -const Reference< css::lang::XMultiServiceFactory >& xServiceManager ) -{ - return Reference< XInterface > ( *new ScriptProtocolHandler( comphelper::getComponentContext(xServiceManager) ) ); -} - -/* Factory for registration */ -Reference< XSingleServiceFactory > ScriptProtocolHandler::impl_createFactory( -const Reference< XMultiServiceFactory >& xServiceManager ) -{ - Reference< XSingleServiceFactory > xReturn ( - cppu::createSingleFactory( xServiceManager, - ScriptProtocolHandler::impl_getStaticImplementationName(), - ScriptProtocolHandler::impl_createInstance, - ScriptProtocolHandler::impl_getStaticSupportedServiceNames() ) - ); - return xReturn; + return cppu::acquire(new ScriptProtocolHandler(context)); } } // namespace scripting_protocolhandler -extern "C" -{ - SAL_DLLPUBLIC_EXPORT void* protocolhandler_component_getFactory( const char * pImplementationName , - void * pServiceManager , - void * ) - { - // Set default return value for this operation - if it failed. - void * pReturn = nullptr ; - - if ( - ( pImplementationName != nullptr ) && - ( pServiceManager != nullptr ) - ) - { - // Define variables which are used in following macros. - css::uno::Reference< css::lang::XSingleServiceFactory > xFactory; - css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager( - static_cast< css::lang::XMultiServiceFactory* >( pServiceManager ) ) ; - - if ( ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName().equalsAscii( - pImplementationName ) ) - { - xFactory = ::scripting_protocolhandler::ScriptProtocolHandler::impl_createFactory( xServiceManager ); - } - - // Factory is valid - service was found. - if ( xFactory.is() ) - { - xFactory->acquire(); - pReturn = xFactory.get(); - } - } - - // Return with result of this operation. - return pReturn ; - } -} // extern "C" - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/protocolhandler/scripthandler.hxx b/scripting/source/protocolhandler/scripthandler.hxx index 1a40356463af..c7c3811efae4 100644 --- a/scripting/source/protocolhandler/scripthandler.hxx +++ b/scripting/source/protocolhandler/scripthandler.hxx @@ -82,18 +82,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() override; - /* Helper for XServiceInfo */ - static css::uno::Sequence < OUString > impl_getStaticSupportedServiceNames(); - static OUString impl_getStaticImplementationName(); - - /* Helper for registry */ - /// @throws css::uno::RuntimeException - static css::uno::Reference < css::uno::XInterface > SAL_CALL - impl_createInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - static css::uno::Reference < css::lang::XSingleServiceFactory > impl_createFactory( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - /* Implementation for XDispatchProvider */ virtual css::uno::Reference < css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& sTargetFrameName, |