diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-09 14:07:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-09 20:04:18 +0200 |
commit | c6aa0d055ec6a102c269a4e1cd0fa98fd7c99d66 (patch) | |
tree | c9cc852380bae2bf199970aa62484d785b186ac2 | |
parent | 866cad33c6d05e9b60ccb4f8b0162edecb1faede (diff) |
eventattacher: create instances with uno constructors
See tdf#74608 for motivation
Change-Id: I61ae7e662c984961b507bf0394fcf8cf25496f0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98218
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | eventattacher/source/eventattacher.cxx | 54 | ||||
-rw-r--r-- | eventattacher/source/evtatt.component | 5 | ||||
-rwxr-xr-x | solenv/bin/native-code.py | 2 |
3 files changed, 14 insertions, 47 deletions
diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx index fb7bb7563a4f..4099c1bc64fb 100644 --- a/eventattacher/source/eventattacher.cxx +++ b/eventattacher/source/eventattacher.cxx @@ -40,6 +40,7 @@ #include <cppuhelper/factory.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> +#include <rtl/ref.hxx> namespace com::sun::star::lang { class XMultiServiceFactory; } @@ -53,9 +54,6 @@ using namespace cppu; using namespace osl; -#define SERVICENAME "com.sun.star.script.EventAttacher" -#define IMPLNAME "com.sun.star.comp.EventAttacher" - namespace comp_EventAttacher { @@ -213,7 +211,6 @@ public: virtual OUString SAL_CALL getImplementationName( ) override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - static Sequence< OUString > getSupportedServiceNames_Static( ); // XInitialization virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override; @@ -282,19 +279,9 @@ EventAttacherImpl::EventAttacherImpl( const Reference< XComponentContext >& rxCo } /// @throws Exception -static Reference< XInterface > EventAttacherImpl_CreateInstance( const Reference< XMultiServiceFactory >& rSMgr ) -{ - XEventAttacher* pEventAttacher = new EventAttacherImpl(comphelper::getComponentContext(rSMgr)); - - Reference< XInterface > xRet(pEventAttacher, UNO_QUERY); - - return xRet; -} - - OUString SAL_CALL EventAttacherImpl::getImplementationName( ) { - return IMPLNAME; + return "com.sun.star.comp.EventAttacher"; } sal_Bool SAL_CALL EventAttacherImpl::supportsService( const OUString& ServiceName ) @@ -304,13 +291,7 @@ sal_Bool SAL_CALL EventAttacherImpl::supportsService( const OUString& ServiceNam Sequence<OUString> SAL_CALL EventAttacherImpl::getSupportedServiceNames( ) { - return getSupportedServiceNames_Static(); -} - - -Sequence<OUString> EventAttacherImpl::getSupportedServiceNames_Static( ) -{ - return { SERVICENAME }; + return { "com.sun.star.script.EventAttacher" }; } void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments) @@ -858,30 +839,13 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachMultipleEventList } -extern "C" -{ -SAL_DLLPUBLIC_EXPORT void * evtatt_component_getFactory( - const char * pImplName, void * pServiceManager, void * ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +eventattacher_EventAttacher( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& ) { - void * pRet = nullptr; - - if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0) - { - Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory( - static_cast< XMultiServiceFactory * >( pServiceManager ), - IMPLNAME, - ::comp_EventAttacher::EventAttacherImpl_CreateInstance, - ::comp_EventAttacher::EventAttacherImpl::getSupportedServiceNames_Static() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; -} + static rtl::Reference<comp_EventAttacher::EventAttacherImpl> instance(new comp_EventAttacher::EventAttacherImpl(context)); + instance->acquire(); + return static_cast<cppu::OWeakObject*>(instance.get()); } diff --git a/eventattacher/source/evtatt.component b/eventattacher/source/evtatt.component index 2cbf71d4a744..40389217c039 100644 --- a/eventattacher/source/evtatt.component +++ b/eventattacher/source/evtatt.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="evtatt" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.EventAttacher"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.EventAttacher" + constructor="eventattacher_EventAttacher"> <service name="com.sun.star.script.EventAttacher"/> </implementation> </component> diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index ef2ed63dbf34..d67cf7209766 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -151,6 +151,8 @@ core_constructor_list = [ "drawinglayer_XPrimitive2DRenderer", # emfio/emfio.component "emfio_emfreader_XEmfParser_get_implementation", +# eventattacher/source/evtatt.component + "eventattacher_EventAttacher", # extensions/source/logging/log.component ("com_sun_star_comp_extensions_FileHandler", "#ifdef ANDROID"), ("com_sun_star_comp_extensions_LoggerPool", "#ifdef ANDROID"), |