From 666e1ae80681f611aeb5aa83d43f595f7353a056 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 Jul 2020 20:22:54 +0200 Subject: fpicker/office: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Ia6e1aec18e6450de9c65ed059a25493fc54a9f75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98788 Tested-by: Jenkins Reviewed-by: Noel Grandin --- fpicker/source/office/OfficeFilePicker.cxx | 48 ++++++--------------- fpicker/source/office/OfficeFilePicker.hxx | 19 --------- fpicker/source/office/OfficeFolderPicker.cxx | 24 +++-------- fpicker/source/office/OfficeFolderPicker.hxx | 9 ---- fpicker/source/office/fps_office.component | 11 +++-- fpicker/source/office/fps_office.cxx | 62 ---------------------------- 6 files changed, 25 insertions(+), 148 deletions(-) delete mode 100644 fpicker/source/office/fps_office.cxx (limited to 'fpicker/source') diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index f9e4d74d2839..dd8e0d58203d 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -1027,7 +1027,7 @@ bool SvtFilePicker::implHandleInitializationArgument( const OUString& _rName, co /* XServiceInfo */ OUString SAL_CALL SvtFilePicker::getImplementationName() { - return impl_getStaticImplementationName(); + return "com.sun.star.svtools.OfficeFilePicker"; } /* XServiceInfo */ @@ -1039,28 +1039,16 @@ sal_Bool SAL_CALL SvtFilePicker::supportsService( const OUString& sServiceName ) /* XServiceInfo */ Sequence< OUString > SAL_CALL SvtFilePicker::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); + return { "com.sun.star.ui.dialogs.OfficeFilePicker" }; } -/* Helper for XServiceInfo */ -Sequence< OUString > SvtFilePicker::impl_getStaticSupportedServiceNames() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +fpicker_SvtFilePicker_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - Sequence seqServiceNames { "com.sun.star.ui.dialogs.OfficeFilePicker" }; - return seqServiceNames ; + return cppu::acquire(new SvtFilePicker()); } -/* Helper for XServiceInfo */ -OUString SvtFilePicker::impl_getStaticImplementationName() -{ - return "com.sun.star.svtools.OfficeFilePicker"; -} - -/* Helper for registry */ -Reference< XInterface > SvtFilePicker::impl_createInstance( - const Reference< XComponentContext >& ) -{ - return Reference< XInterface >( *new SvtFilePicker ); -} // SvtRemoteFilePicker @@ -1091,7 +1079,7 @@ std::shared_ptr SvtRemoteFilePicker::implCreateDialog(weld:: /* XServiceInfo */ OUString SAL_CALL SvtRemoteFilePicker::getImplementationName() { - return impl_getStaticImplementationName(); + return "com.sun.star.svtools.RemoteFilePicker"; } /* XServiceInfo */ @@ -1103,27 +1091,15 @@ sal_Bool SAL_CALL SvtRemoteFilePicker::supportsService( const OUString& sService /* XServiceInfo */ Sequence< OUString > SAL_CALL SvtRemoteFilePicker::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); -} - -/* Helper for XServiceInfo */ -Sequence< OUString > SvtRemoteFilePicker::impl_getStaticSupportedServiceNames() -{ - Sequence seqServiceNames { "com.sun.star.ui.dialogs.RemoteFilePicker" }; - return seqServiceNames ; + return { "com.sun.star.ui.dialogs.RemoteFilePicker" }; } -/* Helper for XServiceInfo */ -OUString SvtRemoteFilePicker::impl_getStaticImplementationName() -{ - return "com.sun.star.svtools.RemoteFilePicker"; -} -/* Helper for registry */ -Reference< XInterface > SvtRemoteFilePicker::impl_createInstance( - const Reference< XComponentContext >& ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +fpicker_SvtRemoteFilePicker_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - return Reference< XInterface >( *new SvtRemoteFilePicker ); + return cppu::acquire(new SvtRemoteFilePicker()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx index 3863bf1d5168..59f1073092fd 100644 --- a/fpicker/source/office/OfficeFilePicker.hxx +++ b/fpicker/source/office/OfficeFilePicker.hxx @@ -189,16 +189,6 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - /* Helper for XServiceInfo */ - static css::uno::Sequence< OUString > - impl_getStaticSupportedServiceNames(); - static OUString impl_getStaticImplementationName(); - - /* Helper for registry */ - /// @throws css::uno::Exception - static css::uno::Reference< css::uno::XInterface > impl_createInstance ( - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); - protected: // OCommonPicker overridables @@ -246,15 +236,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - /* Helper for XServiceInfo */ - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - static OUString impl_getStaticImplementationName(); - - /* Helper for registry */ - /// @throws css::uno::Exception - static css::uno::Reference< css::uno::XInterface > impl_createInstance ( - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); }; #endif // INCLUDED_FPICKER_SOURCE_OFFICE_OFFICEFILEPICKER_HXX diff --git a/fpicker/source/office/OfficeFolderPicker.cxx b/fpicker/source/office/OfficeFolderPicker.cxx index 8413020df96f..c941d6cb63c3 100644 --- a/fpicker/source/office/OfficeFolderPicker.cxx +++ b/fpicker/source/office/OfficeFolderPicker.cxx @@ -150,7 +150,7 @@ void SvtFolderPicker::cancel() /* XServiceInfo */ OUString SAL_CALL SvtFolderPicker::getImplementationName() { - return impl_getStaticImplementationName(); + return "com.sun.star.svtools.OfficeFolderPicker"; } /* XServiceInfo */ @@ -162,26 +162,14 @@ sal_Bool SAL_CALL SvtFolderPicker::supportsService( const OUString& sServiceName /* XServiceInfo */ Sequence< OUString > SAL_CALL SvtFolderPicker::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); -} - -/* Helper for XServiceInfo */ -Sequence< OUString > SvtFolderPicker::impl_getStaticSupportedServiceNames() -{ - Sequence< OUString > seqServiceNames { "com.sun.star.ui.dialogs.OfficeFolderPicker" }; - return seqServiceNames ; -} - -/* Helper for XServiceInfo */ -OUString SvtFolderPicker::impl_getStaticImplementationName() -{ - return "com.sun.star.svtools.OfficeFolderPicker"; + return { "com.sun.star.ui.dialogs.OfficeFolderPicker" }; } -/* Helper for registry */ -Reference< XInterface > SvtFolderPicker::impl_createInstance( const Reference< XComponentContext >& ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +fpicker_SvtFolderPicker_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - return Reference< XInterface >( *new SvtFolderPicker ); + return cppu::acquire(new SvtFolderPicker()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/source/office/OfficeFolderPicker.hxx b/fpicker/source/office/OfficeFolderPicker.hxx index acf9bd149b5e..db55849881b2 100644 --- a/fpicker/source/office/OfficeFolderPicker.hxx +++ b/fpicker/source/office/OfficeFolderPicker.hxx @@ -80,15 +80,6 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - /* Helper for XServiceInfo */ - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - static OUString impl_getStaticImplementationName(); - - /* Helper for registry */ - /// @throws css::uno::Exception - static css::uno::Reference< css::uno::XInterface > impl_createInstance ( - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); - protected: // OCommonPicker overridables diff --git a/fpicker/source/office/fps_office.component b/fpicker/source/office/fps_office.component index b76edc61b401..cdf5f82479e3 100644 --- a/fpicker/source/office/fps_office.component +++ b/fpicker/source/office/fps_office.component @@ -18,14 +18,17 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + - + - + diff --git a/fpicker/source/office/fps_office.cxx b/fpicker/source/office/fps_office.cxx deleted file mode 100644 index 335bf41e8028..000000000000 --- a/fpicker/source/office/fps_office.cxx +++ /dev/null @@ -1,62 +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 "OfficeFilePicker.hxx" -#include "OfficeFolderPicker.hxx" - -const cppu::ImplementationEntry g_entries[] = -{ - { - SvtRemoteFilePicker::impl_createInstance, - SvtRemoteFilePicker::impl_getStaticImplementationName, - SvtRemoteFilePicker::impl_getStaticSupportedServiceNames, - cppu::createSingleComponentFactory, nullptr, 0 - }, - { - SvtFilePicker::impl_createInstance, - SvtFilePicker::impl_getStaticImplementationName, - SvtFilePicker::impl_getStaticSupportedServiceNames, - cppu::createSingleComponentFactory, nullptr, 0 - }, - { - SvtFolderPicker::impl_createInstance, - SvtFolderPicker::impl_getStaticImplementationName, - SvtFolderPicker::impl_getStaticSupportedServiceNames, - cppu::createSingleComponentFactory, nullptr, 0 - }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } -}; - -extern "C" -{ -SAL_DLLPUBLIC_EXPORT void * fps_office_component_getFactory( - const char * pImplementationName, void * pServiceManager, void * pRegistryKey) -{ - return cppu::component_getFactoryHelper ( - pImplementationName, pServiceManager, pRegistryKey, g_entries); -} - -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit