summaryrefslogtreecommitdiff
path: root/ucb/source/ucp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-23 09:19:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-23 10:24:38 +0200
commit5c0d98c34ca0f3cbbac39fc7f9a3208a28aab18a (patch)
tree814b98d53e6bf1926a9723c986fa318b1d3f7f85 /ucb/source/ucp
parent26357bcb3838698e041d7079105144dfb72856e1 (diff)
ucb/gio: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I8e20d9800d9446a42e1e2baed51f650b324cc248 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99267 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb/source/ucp')
-rw-r--r--ucb/source/ucp/gio/gio_provider.cxx59
-rw-r--r--ucb/source/ucp/gio/gio_provider.hxx7
-rw-r--r--ucb/source/ucp/gio/ucpgio.component5
3 files changed, 22 insertions, 49 deletions
diff --git a/ucb/source/ucp/gio/gio_provider.cxx b/ucb/source/ucp/gio/gio_provider.cxx
index 2dbbd73fea9b..f0999d054b9c 100644
--- a/ucb/source/ucp/gio/gio_provider.cxx
+++ b/ucb/source/ucp/gio/gio_provider.cxx
@@ -94,31 +94,19 @@ XTYPEPROVIDER_IMPL_3( ContentProvider,
css::lang::XServiceInfo,
css::ucb::XContentProvider );
-XSERVICEINFO_COMMOM_IMPL( ContentProvider,
- "com.sun.star.comp.GIOContentProvider" )
-/// @throws css::uno::Exception
-static css::uno::Reference< css::uno::XInterface >
-ContentProvider_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
+css::uno::Sequence< OUString > SAL_CALL ContentProvider::getSupportedServiceNames()
{
- css::lang::XServiceInfo* pX = new ContentProvider( ucbhelper::getComponentContext(rSMgr) );
- return css::uno::Reference< css::uno::XInterface >::query( pX );
+ return { "com.sun.star.ucb.GIOContentProvider" };
}
-css::uno::Sequence< OUString >
-ContentProvider::getSupportedServiceNames_Static()
+OUString SAL_CALL ContentProvider::getImplementationName()
{
- css::uno::Sequence< OUString > aSNS { "com.sun.star.ucb.GIOContentProvider" };
- return aSNS;
+ return "com.sun.star.comp.GIOContentProvider";
}
-css::uno::Reference< css::lang::XSingleServiceFactory >
-ContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr )
+sal_Bool SAL_CALL ContentProvider::supportsService(const OUString& aServiceName)
{
- return cppu::createOneInstanceFactory(
- rxServiceMgr,
- ContentProvider::getImplementationName_Static(),
- ContentProvider_CreateInstance,
- ContentProvider::getSupportedServiceNames_Static() );
+ return cppu::supportsService(this, aServiceName);
}
@@ -134,32 +122,23 @@ static bool isDisabled()
return aDisable.indexOf("ucpgio1") >= 0;
}
-extern "C" SAL_DLLPUBLIC_EXPORT void * ucpgio1_component_getFactory( const char *pImplName,
- void *pServiceManager, void * )
-{
- void * pRet = nullptr;
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ucb_gio_ContentProvider_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
static bool bDisabled = isDisabled();
if (bDisabled)
return nullptr;
-
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr
- (static_cast< css::lang::XMultiServiceFactory * >( pServiceManager ) );
- css::uno::Reference< css::lang::XSingleServiceFactory > xFactory;
-
-#if !GLIB_CHECK_VERSION(2,36,0)
- g_type_init();
-#endif
- if ( ::gio::ContentProvider::getImplementationName_Static().equalsAscii( pImplName ) )
- xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
-
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
+ static rtl::Reference<gio::ContentProvider> g_Instance = [&]() {
+ #if !GLIB_CHECK_VERSION(2,36,0)
+ g_type_init();
+ #endif
+ return new gio::ContentProvider(context);
+ }();
+ g_Instance->acquire();
+ return static_cast<cppu::OWeakObject*>(g_Instance.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/gio/gio_provider.hxx b/ucb/source/ucp/gio/gio_provider.hxx
index 6bdb127acafd..855590cb42a7 100644
--- a/ucb/source/ucp/gio/gio_provider.hxx
+++ b/ucb/source/ucp/gio/gio_provider.hxx
@@ -50,13 +50,6 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- static OUString getImplementationName_Static();
- static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
-
- static css::uno::Reference< css::lang::XSingleServiceFactory >
- createServiceFactory( const css::uno::Reference<
- css::lang::XMultiServiceFactory >& rxServiceMgr );
-
// XContentProvider
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
diff --git a/ucb/source/ucp/gio/ucpgio.component b/ucb/source/ucp/gio/ucpgio.component
index 9fccd965d0ac..e0cdaa7dc583 100644
--- a/ucb/source/ucp/gio/ucpgio.component
+++ b/ucb/source/ucp/gio/ucpgio.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="ucpgio1" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.GIOContentProvider">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.GIOContentProvider"
+ constructor="ucb_gio_ContentProvider_get_implementation">
<service name="com.sun.star.ucb.GIOContentProvider"/>
</implementation>
</component>