From 41e524b4b83abd83db9091437a9b514c49ff161d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 16 Jul 2020 11:51:20 +0200 Subject: sdext/presenter: create instances with uno constructors See tdf#74608 for motivation. Change-Id: I51e7d54c97a1d4ed69bf3ffba09bf6a81ba098d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98918 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sdext/Library_PresenterScreen.mk | 1 - sdext/source/presenter/PresenterComponent.cxx | 58 ---------------------- .../source/presenter/PresenterProtocolHandler.cxx | 28 ++++------- .../source/presenter/PresenterProtocolHandler.hxx | 5 -- sdext/source/presenter/PresenterScreen.cxx | 22 +++++--- sdext/source/presenter/PresenterScreen.hxx | 21 ++++---- sdext/source/presenter/presenter.component | 8 +-- 7 files changed, 41 insertions(+), 102 deletions(-) delete mode 100644 sdext/source/presenter/PresenterComponent.cxx (limited to 'sdext') diff --git a/sdext/Library_PresenterScreen.mk b/sdext/Library_PresenterScreen.mk index cd4d09531794..6a2d0af4ca1e 100644 --- a/sdext/Library_PresenterScreen.mk +++ b/sdext/Library_PresenterScreen.mk @@ -32,7 +32,6 @@ $(eval $(call gb_Library_add_exception_objects,PresenterScreen,\ sdext/source/presenter/PresenterBitmapContainer \ sdext/source/presenter/PresenterButton \ sdext/source/presenter/PresenterCanvasHelper \ - sdext/source/presenter/PresenterComponent \ sdext/source/presenter/PresenterConfigurationAccess \ sdext/source/presenter/PresenterController \ sdext/source/presenter/PresenterCurrentSlideObserver \ diff --git a/sdext/source/presenter/PresenterComponent.cxx b/sdext/source/presenter/PresenterComponent.cxx deleted file mode 100644 index 4d882526002d..000000000000 --- a/sdext/source/presenter/PresenterComponent.cxx +++ /dev/null @@ -1,58 +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 "PresenterProtocolHandler.hxx" -#include "PresenterScreen.hxx" - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace cppu; -using namespace osl; - -namespace sdext::presenter { - -const struct ImplementationEntry gServiceEntries[] = -{ - { - PresenterProtocolHandler::Create, - PresenterProtocolHandler::getImplementationName_static, - PresenterProtocolHandler::getSupportedServiceNames_static, - createSingleComponentFactory, nullptr, 0 - }, - { - PresenterScreenJob::Create, - PresenterScreenJob::getImplementationName_static, - PresenterScreenJob::getSupportedServiceNames_static, - createSingleComponentFactory, nullptr, 0 - }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } -}; - -extern "C" SAL_DLLPUBLIC_EXPORT void * presenter_component_getFactory( - const char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , gServiceEntries); -} - -} // end of namespace sdext::presenter - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/presenter/PresenterProtocolHandler.cxx b/sdext/source/presenter/PresenterProtocolHandler.cxx index 64b00fd36f67..fcceaee4ce16 100644 --- a/sdext/source/presenter/PresenterProtocolHandler.cxx +++ b/sdext/source/presenter/PresenterProtocolHandler.cxx @@ -234,23 +234,6 @@ private: virtual ~Dispatch() override; }; -//----- Service --------------------------------------------------------------- - -OUString PresenterProtocolHandler::getImplementationName_static() -{ - return "org.libreoffice.comp.PresenterScreenProtocolHandler"; -} - -Sequence PresenterProtocolHandler::getSupportedServiceNames_static() -{ - return { "com.sun.star.frame.ProtocolHandler" }; -} - -Reference PresenterProtocolHandler::Create ( - SAL_UNUSED_PARAMETER const Reference&) -{ - return Reference(static_cast(new PresenterProtocolHandler)); -} //===== PresenterProtocolHandler ========================================================= @@ -291,7 +274,7 @@ void SAL_CALL PresenterProtocolHandler::initialize (const Sequence& aArgume OUString PresenterProtocolHandler::getImplementationName() { - return getImplementationName_static(); + return "org.libreoffice.comp.PresenterScreenProtocolHandler"; } sal_Bool PresenterProtocolHandler::supportsService(OUString const & ServiceName) @@ -302,7 +285,14 @@ sal_Bool PresenterProtocolHandler::supportsService(OUString const & ServiceName) css::uno::Sequence PresenterProtocolHandler::getSupportedServiceNames() { - return getSupportedServiceNames_static(); + return { "com.sun.star.frame.ProtocolHandler" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +sdext_PresenterProtocolHandler_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) +{ + return cppu::acquire(new PresenterProtocolHandler()); } //----- XDispatchProvider ----------------------------------------------------- diff --git a/sdext/source/presenter/PresenterProtocolHandler.hxx b/sdext/source/presenter/PresenterProtocolHandler.hxx index 43061f01928e..4d43cfe78d24 100644 --- a/sdext/source/presenter/PresenterProtocolHandler.hxx +++ b/sdext/source/presenter/PresenterProtocolHandler.hxx @@ -49,11 +49,6 @@ public: void SAL_CALL disposing() override; - static OUString getImplementationName_static(); - static css::uno::Sequence< OUString > getSupportedServiceNames_static(); - static css::uno::Reference Create( - const css::uno::Reference& rxContext); - // XInitialization virtual void SAL_CALL initialize( diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx index d04e4aff6855..25e5093bbab4 100644 --- a/sdext/source/presenter/PresenterScreen.cxx +++ b/sdext/source/presenter/PresenterScreen.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -85,23 +86,32 @@ namespace { }; } -//----- Service --------------------------------------------------------------- +//----- XServiceInfo --------------------------------------------------------------- -OUString PresenterScreenJob::getImplementationName_static() +Sequence< OUString > SAL_CALL PresenterScreenJob::getSupportedServiceNames() +{ + return { }; +} + +OUString SAL_CALL PresenterScreenJob::getImplementationName() { return "org.libreoffice.comp.PresenterScreenJob"; } -Sequence PresenterScreenJob::getSupportedServiceNames_static() +sal_Bool SAL_CALL PresenterScreenJob::supportsService(const OUString& aServiceName) { - return Sequence(); + return cppu::supportsService(this, aServiceName); } -Reference PresenterScreenJob::Create (const Reference& rxContext) + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +sdext_PresenterScreenJob_get_implementation( + css::uno::XComponentContext* context , css::uno::Sequence const&) { - return Reference(static_cast(new PresenterScreenJob(rxContext))); + return cppu::acquire(new PresenterScreenJob(context)); } + //===== PresenterScreenJob ==================================================== PresenterScreenJob::PresenterScreenJob (const Reference& rxContext) diff --git a/sdext/source/presenter/PresenterScreen.hxx b/sdext/source/presenter/PresenterScreen.hxx index 85c091621130..ca4ca7fe57e7 100644 --- a/sdext/source/presenter/PresenterScreen.hxx +++ b/sdext/source/presenter/PresenterScreen.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -38,11 +39,8 @@ namespace sdext::presenter { class PresenterController; typedef ::cppu::WeakComponentImplHelper < - css::task::XJob + css::task::XJob, css::lang::XServiceInfo > PresenterScreenJobInterfaceBase; -typedef ::cppu::WeakComponentImplHelper < - css::lang::XEventListener - > PresenterScreenInterfaceBase; /** The PresenterScreenJob service is instantiated every time a document is created or loaded. In its execute() method it then filters out all @@ -56,22 +54,22 @@ class PresenterScreenJob public: PresenterScreenJob(const PresenterScreenJob&) = delete; PresenterScreenJob& operator=(const PresenterScreenJob&) = delete; - static OUString getImplementationName_static(); - static css::uno::Sequence< OUString > getSupportedServiceNames_static(); - static css::uno::Reference Create( - const css::uno::Reference& rxContext); virtual void SAL_CALL disposing() override; - // XJob + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames () override; + // XJob virtual css::uno::Any SAL_CALL execute( const css::uno::Sequence& Arguments) override; -private: explicit PresenterScreenJob (const css::uno::Reference& rxContext); virtual ~PresenterScreenJob() override; +private: css::uno::Reference mxComponentContext; }; @@ -86,6 +84,9 @@ private: PresenterController is created and takes over the task of controlling the presenter screen.

*/ +typedef ::cppu::WeakComponentImplHelper < + css::lang::XEventListener + > PresenterScreenInterfaceBase; class PresenterScreen : private ::cppu::BaseMutex, public PresenterScreenInterfaceBase diff --git a/sdext/source/presenter/presenter.component b/sdext/source/presenter/presenter.component index b7687ba291f3..01e18b38eca0 100644 --- a/sdext/source/presenter/presenter.component +++ b/sdext/source/presenter/presenter.component @@ -8,9 +8,11 @@ * --> - - + xmlns="http://openoffice.org/2010/uno-components"> + + -- cgit v1.2.3