diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-22 13:59:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-22 17:48:06 +0200 |
commit | 950d7d4d51e68cfae3a5d0d23a3d39e84e548357 (patch) | |
tree | 21773d3298f0367b4b99c34da9de75b87acfd12f /ucb/source/ucp/package | |
parent | b115d4899d827f885f7d35ced4cb64d2385e3422 (diff) |
ucb/package: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: Id93f1e18d6646e3747443678bf3d56fa75cb46ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99223
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb/source/ucp/package')
-rw-r--r-- | ucb/source/ucp/package/pkgprovider.cxx | 40 | ||||
-rw-r--r-- | ucb/source/ucp/package/pkgprovider.hxx | 7 | ||||
-rw-r--r-- | ucb/source/ucp/package/pkgservices.cxx | 56 | ||||
-rw-r--r-- | ucb/source/ucp/package/ucppkg1.component | 5 |
4 files changed, 21 insertions, 87 deletions
diff --git a/ucb/source/ucp/package/pkgprovider.cxx b/ucb/source/ucp/package/pkgprovider.cxx index 1183879b1d05..775ee6a5c692 100644 --- a/ucb/source/ucp/package/pkgprovider.cxx +++ b/ucb/source/ucp/package/pkgprovider.cxx @@ -140,38 +140,25 @@ XTYPEPROVIDER_IMPL_3( ContentProvider, // XServiceInfo methods. -XSERVICEINFO_COMMOM_IMPL( ContentProvider, - "com.sun.star.comp.ucb.PackageContentProvider" ) -/// @throws css::uno::Exception -static css::uno::Reference< css::uno::XInterface > -ContentProvider_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr ) +OUString +ContentProvider::getImplementationName() { - css::lang::XServiceInfo* pX = new ContentProvider( ucbhelper::getComponentContext(rSMgr) ); - return css::uno::Reference< css::uno::XInterface >::query( pX ); + return "com.sun.star.comp.ucb.PackageContentProvider"; } -css::uno::Sequence< OUString > -ContentProvider::getSupportedServiceNames_Static() +sal_Bool +ContentProvider::supportsService(const OUString& s) { - css::uno::Sequence< OUString > aSNS { "com.sun.star.ucb.PackageContentProvider" }; - return aSNS; + return cppu::supportsService(this, s); } -// Service factory implementation. - - -css::uno::Reference< css::lang::XSingleServiceFactory > -ContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) +css::uno::Sequence< OUString > +ContentProvider::getSupportedServiceNames() { - return cppu::createOneInstanceFactory( - rxServiceMgr, - ContentProvider::getImplementationName_Static(), - ContentProvider_CreateInstance, - ContentProvider::getSupportedServiceNames_Static() ); + return { "com.sun.star.ucb.PackageContentProvider" }; } - // XContentProvider methods. @@ -276,4 +263,13 @@ void ContentProvider::removePackage( const OUString & rName ) } } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ucb_package_ContentProvider_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + static rtl::Reference<ContentProvider> g_Instance(new 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/package/pkgprovider.hxx b/ucb/source/ucp/package/pkgprovider.hxx index 327000b890e0..8fac2917367e 100644 --- a/ucb/source/ucp/package/pkgprovider.hxx +++ b/ucb/source/ucp/package/pkgprovider.hxx @@ -70,13 +70,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/package/pkgservices.cxx b/ucb/source/ucp/package/pkgservices.cxx deleted file mode 100644 index c6409e2ca42c..000000000000 --- a/ucb/source/ucp/package/pkgservices.cxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include "pkgprovider.hxx" - -using namespace com::sun::star; - - -extern "C" SAL_DLLPUBLIC_EXPORT void * ucppkg1_component_getFactory( - const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) -{ - void * pRet = nullptr; - - uno::Reference< lang::XMultiServiceFactory > xSMgr( - static_cast< lang::XMultiServiceFactory * >( pServiceManager ) ); - uno::Reference< lang::XSingleServiceFactory > xFactory; - - - // Create factory, if implementation name matches. - - - if ( ::package_ucp::ContentProvider::getImplementationName_Static(). - equalsAscii( pImplName ) ) - { - xFactory = ::package_ucp::ContentProvider::createServiceFactory( xSMgr ); - } - - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/package/ucppkg1.component b/ucb/source/ucp/package/ucppkg1.component index 4210c6d6669a..80959b5ef835 100644 --- a/ucb/source/ucp/package/ucppkg1.component +++ b/ucb/source/ucp/package/ucppkg1.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="ucppkg1" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.ucb.PackageContentProvider"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.ucb.PackageContentProvider" + constructor="ucb_package_ContentProvider_get_implementation"> <service name="com.sun.star.ucb.PackageContentProvider"/> </implementation> </component> |