diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-16 11:51:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-16 20:35:53 +0200 |
commit | 41e524b4b83abd83db9091437a9b514c49ff161d (patch) | |
tree | 322855f4c365614b9d05c7bdb51bf9f44077fac4 /sdext/source/presenter | |
parent | 079ebdc3fd8413d3ab4d254d7576500a9547965f (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext/source/presenter')
-rw-r--r-- | sdext/source/presenter/PresenterComponent.cxx | 58 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterProtocolHandler.cxx | 28 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterProtocolHandler.hxx | 5 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterScreen.cxx | 22 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterScreen.hxx | 21 | ||||
-rw-r--r-- | sdext/source/presenter/presenter.component | 8 |
6 files changed, 41 insertions, 101 deletions
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 <cppuhelper/factory.hxx> -#include <cppuhelper/implementationentry.hxx> - -#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<OUString> PresenterProtocolHandler::getSupportedServiceNames_static() -{ - return { "com.sun.star.frame.ProtocolHandler" }; -} - -Reference<XInterface> PresenterProtocolHandler::Create ( - SAL_UNUSED_PARAMETER const Reference<uno::XComponentContext>&) -{ - return Reference<XInterface>(static_cast<XWeak*>(new PresenterProtocolHandler)); -} //===== PresenterProtocolHandler ========================================================= @@ -291,7 +274,7 @@ void SAL_CALL PresenterProtocolHandler::initialize (const Sequence<Any>& 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<OUString> 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<css::uno::Any> 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<css::uno::XInterface> Create( - const css::uno::Reference<css::uno::XComponentContext>& 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 <com/sun/star/presentation/XPresentationSupplier.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> #include <cppuhelper/compbase.hxx> +#include <cppuhelper/supportsservice.hxx> #include <vcl/svapp.hxx> #include <sal/log.hxx> @@ -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<OUString> PresenterScreenJob::getSupportedServiceNames_static() +sal_Bool SAL_CALL PresenterScreenJob::supportsService(const OUString& aServiceName) { - return Sequence<OUString>(); + return cppu::supportsService(this, aServiceName); } -Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext) + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +sdext_PresenterScreenJob_get_implementation( + css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&) { - return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext))); + return cppu::acquire(new PresenterScreenJob(context)); } + //===== PresenterScreenJob ==================================================== PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& 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 <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/task/XJob.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/drawing/framework/XConfigurationController.hpp> #include <com/sun/star/presentation/XPresentation2.hpp> #include <rtl/ref.hxx> @@ -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<css::uno::XInterface> Create( - const css::uno::Reference<css::uno::XComponentContext>& 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<css::beans::NamedValue >& Arguments) override; -private: explicit PresenterScreenJob (const css::uno::Reference<css::uno::XComponentContext>& rxContext); virtual ~PresenterScreenJob() override; +private: css::uno::Reference<css::uno::XComponentContext> mxComponentContext; }; @@ -86,6 +84,9 @@ private: PresenterController is created and takes over the task of controlling the presenter screen.</p> */ +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 @@ * --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="presenter" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="org.libreoffice.comp.PresenterScreenJob"/> - <implementation name="org.libreoffice.comp.PresenterScreenProtocolHandler"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.libreoffice.comp.PresenterScreenJob" + constructor="sdext_PresenterScreenJob_get_implementation" /> + <implementation name="org.libreoffice.comp.PresenterScreenProtocolHandler" + constructor="sdext_PresenterProtocolHandler_get_implementation"> <service name="com.sun.star.frame.ProtocolHandler"/> </implementation> </component> |