From e915431be04734fd53eaa3aeaa2472f1f5532927 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 Jul 2020 13:52:35 +0200 Subject: ucb/ftp: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Ic71294b1fb2afd1726e0c5948d6f088b7cdac964 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99222 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ucb/Library_ucpftp1.mk | 1 - ucb/source/ucp/ftp/ftpcontentprovider.cxx | 42 ++++++----------------- ucb/source/ucp/ftp/ftpcontentprovider.hxx | 7 ---- ucb/source/ucp/ftp/ftpservices.cxx | 57 ------------------------------- ucb/source/ucp/ftp/ucpftp1.component | 5 +-- 5 files changed, 13 insertions(+), 99 deletions(-) delete mode 100644 ucb/source/ucp/ftp/ftpservices.cxx diff --git a/ucb/Library_ucpftp1.mk b/ucb/Library_ucpftp1.mk index 1eb8619783d7..94e2f3bc18f9 100644 --- a/ucb/Library_ucpftp1.mk +++ b/ucb/Library_ucpftp1.mk @@ -41,7 +41,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpftp1,\ ucb/source/ucp/ftp/ftploaderthread \ ucb/source/ucp/ftp/ftpresultsetbase \ ucb/source/ucp/ftp/ftpresultsetI \ - ucb/source/ucp/ftp/ftpservices \ ucb/source/ucp/ftp/ftpurl \ )) diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.cxx b/ucb/source/ucp/ftp/ftpcontentprovider.cxx index 57df6e2f6348..c906f361eec6 100644 --- a/ucb/source/ucp/ftp/ftpcontentprovider.cxx +++ b/ucb/source/ucp/ftp/ftpcontentprovider.cxx @@ -98,11 +98,6 @@ css::uno::Sequence< css::uno::Type > SAL_CALL FTPContentProvider::getTypes() // XServiceInfo methods. OUString SAL_CALL FTPContentProvider::getImplementationName() -{ - return getImplementationName_Static(); -} - -OUString FTPContentProvider::getImplementationName_Static() { return "com.sun.star.comp.FTPContentProvider"; } @@ -114,36 +109,10 @@ sal_Bool SAL_CALL FTPContentProvider::supportsService( const OUString& ServiceNa css::uno::Sequence< OUString > SAL_CALL FTPContentProvider::getSupportedServiceNames() { - return getSupportedServiceNames_Static(); -} - -/// @throws css::uno::Exception -static css::uno::Reference< css::uno::XInterface > -FTPContentProvider_CreateInstance( const css::uno::Reference< - css::lang::XMultiServiceFactory> & rSMgr ) -{ - css::lang::XServiceInfo* pX = new FTPContentProvider( ucbhelper::getComponentContext(rSMgr) ); - return css::uno::Reference< css::uno::XInterface >::query( pX ); -} - -css::uno::Sequence< OUString > FTPContentProvider::getSupportedServiceNames_Static() -{ - css::uno::Sequence aSNS { FTP_CONTENT_PROVIDER_SERVICE_NAME }; - return aSNS; + return { FTP_CONTENT_PROVIDER_SERVICE_NAME }; } -// Service factory implementation. -css::uno::Reference< css::lang::XSingleServiceFactory > -FTPContentProvider::createServiceFactory( const css::uno::Reference< - css::lang::XMultiServiceFactory >& rxServiceMgr ) -{ - return cppu::createOneInstanceFactory( - rxServiceMgr, - FTPContentProvider::getImplementationName_Static(), - FTPContentProvider_CreateInstance, - FTPContentProvider::getSupportedServiceNames_Static() ); -} // XContentProvider methods. @@ -266,4 +235,13 @@ bool FTPContentProvider::setHost( const OUString& host, return !present; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ucb_ftp_FTPContentProvider_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + static rtl::Reference g_Instance(new FTPContentProvider(context)); + g_Instance->acquire(); + return static_cast(g_Instance.get()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.hxx b/ucb/source/ucp/ftp/ftpcontentprovider.hxx index 042ed99fe0fd..093ddf6e9f64 100644 --- a/ucb/source/ucp/ftp/ftpcontentprovider.hxx +++ b/ucb/source/ucp/ftp/ftpcontentprovider.hxx @@ -65,13 +65,6 @@ namespace ftp 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/ftp/ftpservices.cxx b/ucb/source/ucp/ftp/ftpservices.cxx deleted file mode 100644 index a44ea3a24915..000000000000 --- a/ucb/source/ucp/ftp/ftpservices.cxx +++ /dev/null @@ -1,57 +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 -#include -#include "ftpcontentprovider.hxx" - -using namespace com::sun::star; -using namespace ftp; - - -extern "C" SAL_DLLPUBLIC_EXPORT void * ucpftp1_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; - - - // FTP Content Provider. - - - if ( FTPContentProvider::getImplementationName_Static(). - equalsAscii( pImplName ) ) - { - xFactory = FTPContentProvider::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/ftp/ucpftp1.component b/ucb/source/ucp/ftp/ucpftp1.component index 440f89c5de63..29fe0c0717b9 100644 --- a/ucb/source/ucp/ftp/ucpftp1.component +++ b/ucb/source/ucp/ftp/ucpftp1.component @@ -18,8 +18,9 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + -- cgit