diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-08 21:12:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-09 09:25:57 +0200 |
commit | 799e4577dac5d63e249792e2e330f72e9477be0d (patch) | |
tree | f42d6da700b2963ef6ebb796b38d82bfca760a4f /desktop/source/splash | |
parent | 7272a2edf113f29edeb8987ce649f85b776d9d23 (diff) |
desktop: create instances with uno constructors
See tdf#74608 for motivation
Change-Id: Id332d79c29c8e5f668663070d83aba596f017908
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98390
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop/source/splash')
-rw-r--r-- | desktop/source/splash/services_spl.cxx | 56 | ||||
-rw-r--r-- | desktop/source/splash/spl.component | 8 | ||||
-rw-r--r-- | desktop/source/splash/splash.cxx | 20 | ||||
-rw-r--r-- | desktop/source/splash/splash.hxx | 49 | ||||
-rw-r--r-- | desktop/source/splash/unxsplash.cxx | 35 | ||||
-rw-r--r-- | desktop/source/splash/unxsplash.hxx | 5 |
6 files changed, 20 insertions, 153 deletions
diff --git a/desktop/source/splash/services_spl.cxx b/desktop/source/splash/services_spl.cxx deleted file mode 100644 index cdb3151f230f..000000000000 --- a/desktop/source/splash/services_spl.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 <sal/config.h> - -#include <cppuhelper/factory.hxx> -#include <cppuhelper/implementationentry.hxx> -#include <sal/types.h> - -#include "splash.hxx" -#include "unxsplash.hxx" - -namespace { - -cppu::ImplementationEntry const services[] = { - { - &desktop::splash::create, - &desktop::splash::getImplementationName, - &desktop::splash::getSupportedServiceNames, - &cppu::createSingleComponentFactory, nullptr, 0 - }, - { - UnxSplash_createInstance, - UnxSplash_getImplementationName, - UnxSplash_getSupportedServiceNames, - ::cppu::createSingleComponentFactory, nullptr, 0 - }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } -}; - -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * spl_component_getFactory( - char const * pImplName, void * pServiceManager, void * pRegistryKey) -{ - return cppu::component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, services); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/splash/spl.component b/desktop/source/splash/spl.component index bc0ff98fc1fb..204dbffa8b89 100644 --- a/desktop/source/splash/spl.component +++ b/desktop/source/splash/spl.component @@ -18,11 +18,13 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="spl" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.office.comp.SplashScreen"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.office.comp.SplashScreen" + constructor="desktop_SplashScreen_get_implementation"> <service name="com.sun.star.office.SplashScreen"/> </implementation> - <implementation name="com.sun.star.office.comp.PipeSplashScreen"> + <implementation name="com.sun.star.office.comp.PipeSplashScreen" + constructor="desktop_UnxSplash_get_implementation"> <service name="com.sun.star.office.PipeSplashScreen"/> </implementation> </component> diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index b42ffe11b347..34c77e9bd827 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -18,7 +18,6 @@ */ -#include "splash.hxx" #include <sal/log.hxx> #include <vcl/bitmapex.hxx> #include <vcl/svapp.hxx> @@ -111,13 +110,13 @@ public: virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any>& aArguments ) override; virtual OUString SAL_CALL getImplementationName() override - { return desktop::splash::getImplementationName(); } + { return "com.sun.star.office.comp.SplashScreen"; } virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override { return cppu::supportsService(this, ServiceName); } virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override - { return desktop::splash::getSupportedServiceNames(); } + { return { "com.sun.star.office.SplashScreen" }; } }; SplashScreenWindow::SplashScreenWindow(SplashScreen *pSplash) @@ -626,19 +625,12 @@ osl::Mutex SplashScreen::_aMutex; } -css::uno::Reference< css::uno::XInterface > desktop::splash::create( - css::uno::Reference< css::uno::XComponentContext > const &) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +desktop_SplashScreen_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&) { - return static_cast< cppu::OWeakObject * >(new SplashScreen); + return cppu::acquire(new SplashScreen()); } -OUString desktop::splash::getImplementationName() { - return "com.sun.star.office.comp.SplashScreen"; -} - -css::uno::Sequence< OUString > desktop::splash::getSupportedServiceNames() -{ - return { "com.sun.star.office.SplashScreen" }; -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/splash/splash.hxx b/desktop/source/splash/splash.hxx deleted file mode 100644 index 0a31258d740e..000000000000 --- a/desktop/source/splash/splash.hxx +++ /dev/null @@ -1,49 +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 . - */ - -#ifndef INCLUDED_DESKTOP_SOURCE_SPLASH_SPLASH_HXX -#define INCLUDED_DESKTOP_SOURCE_SPLASH_SPLASH_HXX - -#include <sal/config.h> - -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -namespace com::sun::star { - namespace uno { - class XComponentContext; - class XInterface; - } -} - -namespace desktop::splash { - -css::uno::Reference< css::uno::XInterface > -create( css::uno::Reference< css::uno::XComponentContext > const & ); - -OUString getImplementationName(); - -css::uno::Sequence< OUString > -getSupportedServiceNames(); - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/splash/unxsplash.cxx b/desktop/source/splash/unxsplash.cxx index cf1c66144ea8..efee99e46023 100644 --- a/desktop/source/splash/unxsplash.cxx +++ b/desktop/source/splash/unxsplash.cxx @@ -22,6 +22,7 @@ #include <osl/process.h> #include <cppuhelper/supportsservice.hxx> #include <sal/log.hxx> +#include <rtl/ref.hxx> using namespace com::sun::star; @@ -102,7 +103,7 @@ UnxSplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& ) OUString UnxSplashScreen::getImplementationName() { - return UnxSplash_getImplementationName(); + return "com.sun.star.office.comp.PipeSplashScreen"; } sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName) @@ -112,37 +113,19 @@ sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName) css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames() { - return UnxSplash_getSupportedServiceNames(); -} - + return { "com.sun.star.office.PipeSplashScreen" }; } -using namespace desktop; - -// get service instance... -static uno::Reference< uno::XInterface > m_xINSTANCE; - -uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & ) -{ - static osl::Mutex s_aMutex; - if ( !m_xINSTANCE.is() ) - { - osl::MutexGuard guard( s_aMutex ); - if ( !m_xINSTANCE.is() ) - m_xINSTANCE = static_cast<cppu::OWeakObject*>(new UnxSplashScreen); - } - - return m_xINSTANCE; } -OUString UnxSplash_getImplementationName() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +desktop_UnxSplash_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&) { - return "com.sun.star.office.comp.PipeSplashScreen"; -} + static rtl::Reference< desktop::UnxSplashScreen > m_xINSTANCE(new desktop::UnxSplashScreen()); -uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw() -{ - return uno::Sequence< OUString > { "com.sun.star.office.PipeSplashScreen" }; + m_xINSTANCE->acquire(); + return static_cast<cppu::OWeakObject*>(m_xINSTANCE.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/splash/unxsplash.hxx b/desktop/source/splash/unxsplash.hxx index baa612a0df10..fa7ce196cda4 100644 --- a/desktop/source/splash/unxsplash.hxx +++ b/desktop/source/splash/unxsplash.hxx @@ -58,11 +58,6 @@ public: } -/// @throws css::uno::Exception -css::uno::Reference< css::uno::XInterface > UnxSplash_createInstance(const css::uno::Reference< css::uno::XComponentContext > & xCtx ); -OUString UnxSplash_getImplementationName(); -css::uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw (); - #endif // INCLUDED_DESKTOP_SOURCE_SPLASH_UNXSPLASH_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |