summaryrefslogtreecommitdiff
path: root/eventattacher
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-09 14:07:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-09 20:04:18 +0200
commitc6aa0d055ec6a102c269a4e1cd0fa98fd7c99d66 (patch)
treec9cc852380bae2bf199970aa62484d785b186ac2 /eventattacher
parent866cad33c6d05e9b60ccb4f8b0162edecb1faede (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>
Diffstat (limited to 'eventattacher')
-rw-r--r--eventattacher/source/eventattacher.cxx54
-rw-r--r--eventattacher/source/evtatt.component5
2 files changed, 12 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>