diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-03 19:39:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-04 08:32:56 +0200 |
commit | 78639945dab254e2de5315c49e82c333e1056170 (patch) | |
tree | c043c0d237ae9257aadfcd755cefc9df0a786208 /UnoControls | |
parent | 7dcc18b5ac79d9a3e7564492428a275bf9b386db (diff) |
UnoControl: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I3df173e3c7064d3d925d3abe5c652b8cbe6c8ea5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97892
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls')
-rw-r--r-- | UnoControls/Library_ctl.mk | 1 | ||||
-rw-r--r-- | UnoControls/source/base/registercontrols.cxx | 122 | ||||
-rw-r--r-- | UnoControls/source/controls/framecontrol.cxx | 24 | ||||
-rw-r--r-- | UnoControls/source/controls/progressbar.cxx | 20 | ||||
-rw-r--r-- | UnoControls/source/controls/progressmonitor.cxx | 18 | ||||
-rw-r--r-- | UnoControls/source/controls/statusindicator.cxx | 21 | ||||
-rw-r--r-- | UnoControls/source/inc/framecontrol.hxx | 6 | ||||
-rw-r--r-- | UnoControls/source/inc/progressbar.hxx | 6 | ||||
-rw-r--r-- | UnoControls/source/inc/progressmonitor.hxx | 6 | ||||
-rw-r--r-- | UnoControls/source/inc/statusindicator.hxx | 6 | ||||
-rw-r--r-- | UnoControls/util/ctl.component | 16 |
11 files changed, 37 insertions, 209 deletions
diff --git a/UnoControls/Library_ctl.mk b/UnoControls/Library_ctl.mk index f7953e80e5a2..f6ef205f9615 100644 --- a/UnoControls/Library_ctl.mk +++ b/UnoControls/Library_ctl.mk @@ -31,7 +31,6 @@ $(eval $(call gb_Library_add_exception_objects,ctl,\ UnoControls/source/base/basecontainercontrol \ UnoControls/source/base/basecontrol \ UnoControls/source/base/multiplexer \ - UnoControls/source/base/registercontrols \ UnoControls/source/controls/OConnectionPointContainerHelper \ UnoControls/source/controls/OConnectionPointHelper \ UnoControls/source/controls/framecontrol \ diff --git a/UnoControls/source/base/registercontrols.cxx b/UnoControls/source/base/registercontrols.cxx deleted file mode 100644 index 40a51b8e85e0..000000000000 --- a/UnoControls/source/base/registercontrols.cxx +++ /dev/null @@ -1,122 +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 <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <comphelper/processfactory.hxx> -#include <cppuhelper/factory.hxx> - -#include <framecontrol.hxx> -#include <progressbar.hxx> -#include <progressmonitor.hxx> -#include <statusindicator.hxx> - -namespace com::sun::star::lang { class XMultiServiceFactory; } - -namespace { - -/// @throws css::uno::Exception -css::uno::Reference<css::uno::XInterface> FrameControl_createInstance( - css::uno::Reference<css::lang::XMultiServiceFactory> const & - rServiceManager) -{ - return static_cast<cppu::OWeakObject *>( - new unocontrols::FrameControl( - comphelper::getComponentContext(rServiceManager))); -} - -/// @throws css::uno::Exception -css::uno::Reference<css::uno::XInterface> ProgressBar_createInstance( - css::uno::Reference<css::lang::XMultiServiceFactory> const & - rServiceManager) -{ - return static_cast<cppu::OWeakObject *>( - new unocontrols::ProgressBar( - comphelper::getComponentContext(rServiceManager))); -} - -/// @throws css::uno::Exception -css::uno::Reference<css::uno::XInterface> -ProgressMonitor_createInstance( - css::uno::Reference<css::lang::XMultiServiceFactory> const & - rServiceManager) -{ - return static_cast<cppu::OWeakObject *>( - new unocontrols::ProgressMonitor( - comphelper::getComponentContext(rServiceManager))); -} - -/// @throws css::uno::Exception -css::uno::Reference<css::uno::XInterface> -StatusIndicator_createInstance( - css::uno::Reference<css::lang::XMultiServiceFactory> const & - rServiceManager) -{ - return static_cast<cppu::OWeakObject *>( - new unocontrols::StatusIndicator( - comphelper::getComponentContext(rServiceManager))); -} - -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * ctl_component_getFactory( - char const * pImplName, void * pServiceManager, SAL_UNUSED_PARAMETER void *) -{ - css::uno::Reference<css::lang::XMultiServiceFactory > smgr( - static_cast<css::lang::XMultiServiceFactory *>(pServiceManager)); - css::uno::Reference<css::lang::XSingleServiceFactory> fac; - if (unocontrols::FrameControl::impl_getStaticImplementationName() - .equalsAscii(pImplName)) - { - fac = cppu::createSingleFactory( - smgr, unocontrols::FrameControl::impl_getStaticImplementationName(), - &FrameControl_createInstance, - unocontrols::FrameControl::impl_getStaticSupportedServiceNames()); - } else if (unocontrols::ProgressBar::impl_getStaticImplementationName() - .equalsAscii(pImplName)) - { - fac = cppu::createSingleFactory( - smgr, unocontrols::ProgressBar::impl_getStaticImplementationName(), - &ProgressBar_createInstance, - unocontrols::ProgressBar::impl_getStaticSupportedServiceNames()); - } else if (unocontrols::ProgressMonitor::impl_getStaticImplementationName() - .equalsAscii(pImplName)) - { - fac = cppu::createSingleFactory( - smgr, - unocontrols::ProgressMonitor::impl_getStaticImplementationName(), - &ProgressMonitor_createInstance, - unocontrols::ProgressMonitor::impl_getStaticSupportedServiceNames()); - } else if (unocontrols::StatusIndicator::impl_getStaticImplementationName() - .equalsAscii(pImplName)) - { - fac = cppu::createSingleFactory( - smgr, - unocontrols::StatusIndicator::impl_getStaticImplementationName(), - &StatusIndicator_createInstance, - unocontrols::StatusIndicator::impl_getStaticSupportedServiceNames()); - } - if (fac.is()) { - fac->acquire(); - } - return fac.get(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx index 004facf6f942..8ecc73cf2d1a 100644 --- a/UnoControls/source/controls/framecontrol.cxx +++ b/UnoControls/source/controls/framecontrol.cxx @@ -155,12 +155,12 @@ Any SAL_CALL FrameControl::queryAggregation( const Type& aType ) OUString FrameControl::getImplementationName() { - return impl_getStaticImplementationName(); + return "stardiv.UnoControls.FrameControl"; } css::uno::Sequence<OUString> FrameControl::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); + return { "com.sun.star.frame.FrameControl" }; } // XControl @@ -252,20 +252,6 @@ void SAL_CALL FrameControl::unadvise( const Type& aTyp m_aConnectionPointContainer->unadvise( aType, xListener ); } -// impl but public method to register service - -Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames() -{ - return { "com.sun.star.frame.FrameControl" }; -} - -// impl but public method to register service - -OUString FrameControl::impl_getStaticImplementationName() -{ - return "stardiv.UnoControls.FrameControl"; -} - // OPropertySetHelper sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedValue , @@ -467,4 +453,10 @@ void FrameControl::impl_deleteFrame() } // namespace unocontrols +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_FrameControl_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::FrameControl(context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/progressbar.cxx b/UnoControls/source/controls/progressbar.cxx index d8c9b889f2b5..6b8de14f0b0f 100644 --- a/UnoControls/source/controls/progressbar.cxx +++ b/UnoControls/source/controls/progressbar.cxx @@ -283,20 +283,6 @@ Reference< XControlModel > SAL_CALL ProgressBar::getModel() return Reference< XControlModel >(); } -// impl but public method to register service - -Sequence< OUString > ProgressBar::impl_getStaticSupportedServiceNames() -{ - return css::uno::Sequence<OUString>(); -} - -// impl but public method to register service - -OUString ProgressBar::impl_getStaticImplementationName() -{ - return "stardiv.UnoControls.ProgressBar"; -} - // protected method void ProgressBar::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics ) @@ -407,4 +393,10 @@ void ProgressBar::impl_recalcRange () } // namespace unocontrols +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_ProgressBar_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::ProgressBar(context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx index 78278250942d..46f6fda8bcec 100644 --- a/UnoControls/source/controls/progressmonitor.cxx +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -530,18 +530,6 @@ void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int3 } } -// impl but public method to register service -Sequence< OUString > ProgressMonitor::impl_getStaticSupportedServiceNames() -{ - return css::uno::Sequence<OUString>(); -} - -// impl but public method to register service -OUString ProgressMonitor::impl_getStaticImplementationName() -{ - return "stardiv.UnoControls.ProgressMonitor"; -} - // protected method void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< XGraphics > & rGraphics ) { @@ -865,4 +853,10 @@ bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic ) } // namespace unocontrols +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_ProgressMonitor_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::ProgressMonitor(context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx index 033c787d01c2..9c70f92dcd88 100644 --- a/UnoControls/source/controls/statusindicator.cxx +++ b/UnoControls/source/controls/statusindicator.cxx @@ -343,20 +343,6 @@ void SAL_CALL StatusIndicator::setPosSize ( } } -// impl but public method to register service - -Sequence< OUString > StatusIndicator::impl_getStaticSupportedServiceNames() -{ - return css::uno::Sequence<OUString>(); -} - -// impl but public method to register service - -OUString StatusIndicator::impl_getStaticImplementationName() -{ - return "stardiv.UnoControls.StatusIndicator"; -} - // protected method WindowDescriptor StatusIndicator::impl_getWindowDescriptor( const css::uno::Reference< XWindowPeer >& xParentPeer ) @@ -459,4 +445,11 @@ void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent ) } // namespace unocontrols +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +stardiv_UnoControls_StatusIndicator_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new unocontrols::StatusIndicator(context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx index dad27d8f8f2f..4224a95bfbec 100644 --- a/UnoControls/source/inc/framecontrol.hxx +++ b/UnoControls/source/inc/framecontrol.hxx @@ -124,12 +124,6 @@ public: const css::uno::Reference< css::uno::XInterface >& xListener ) override; - // impl but public methods to register service! - - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - - static OUString impl_getStaticImplementationName(); - private: using OPropertySetHelper::getFastPropertyValue; diff --git a/UnoControls/source/inc/progressbar.hxx b/UnoControls/source/inc/progressbar.hxx index a85fd731de4a..1f735286377b 100644 --- a/UnoControls/source/inc/progressbar.hxx +++ b/UnoControls/source/inc/progressbar.hxx @@ -112,12 +112,6 @@ public: virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override; - // BaseControl - - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - - static OUString impl_getStaticImplementationName(); - private: virtual void impl_paint( sal_Int32 nX , diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx index 77927020582f..4f407eeda2e6 100644 --- a/UnoControls/source/inc/progressmonitor.hxx +++ b/UnoControls/source/inc/progressmonitor.hxx @@ -206,12 +206,6 @@ public: sal_Int32 nHeight , sal_Int16 nFlags ) override; - // BaseControl - - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - - static OUString impl_getStaticImplementationName(); - private: virtual void impl_paint( sal_Int32 nX , sal_Int32 nY , diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx index 658062c1512c..f47a52cbd814 100644 --- a/UnoControls/source/inc/statusindicator.hxx +++ b/UnoControls/source/inc/statusindicator.hxx @@ -148,12 +148,6 @@ public: sal_Int32 nHeight , sal_Int16 nFlags ) override; - // BaseControl - - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - - static OUString impl_getStaticImplementationName(); - private: virtual css::awt::WindowDescriptor impl_getWindowDescriptor( const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer diff --git a/UnoControls/util/ctl.component b/UnoControls/util/ctl.component index 3c0437d966b5..43c978bfba8e 100644 --- a/UnoControls/util/ctl.component +++ b/UnoControls/util/ctl.component @@ -18,11 +18,15 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="ctl" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="stardiv.UnoControls.FrameControl"> - <service name="com.sun.star.frame.FrameControl"/> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="stardiv.UnoControls.FrameControl" + constructor="stardiv_UnoControls_FrameControl_get_implementation"> + <service name="com.sun.star.frame.FrameControl" /> </implementation> - <implementation name="stardiv.UnoControls.ProgressBar"/> - <implementation name="stardiv.UnoControls.ProgressMonitor"/> - <implementation name="stardiv.UnoControls.StatusIndicator"/> + <implementation name="stardiv.UnoControls.ProgressBar" + constructor="stardiv_UnoControls_ProgressBar_get_implementation"/> + <implementation name="stardiv.UnoControls.ProgressMonitor" + constructor="stardiv_UnoControls_ProgressMonitor_get_implementation"/> + <implementation name="stardiv.UnoControls.StatusIndicator" + constructor="stardiv_UnoControls_StatusIndicator_get_implementation"/> </component> |