UnoControls/inc/basecontainercontrol.hxx | 41 +---------- UnoControls/inc/basecontrol.hxx | 79 ++--------------------- UnoControls/source/base/basecontainercontrol.cxx | 39 ----------- UnoControls/source/base/basecontrol.cxx | 74 --------------------- UnoControls/source/controls/framecontrol.cxx | 34 ++------- UnoControls/source/controls/progressbar.cxx | 53 --------------- UnoControls/source/inc/framecontrol.hxx | 7 +- UnoControls/source/inc/progressbar.hxx | 34 +-------- 8 files changed, 34 insertions(+), 327 deletions(-)
New commits: commit 05eb50c396c3ff2adcc824cba20f8af1ed0d27c8 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Dec 7 23:15:21 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Dec 7 22:14:59 2024 +0100 Simplify unocontrols::BaseControl hierarchy Change-Id: I7c690cd429b2ac52f8aac602b4c9129bdd774b09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178052 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx index 18e027cc43d5..bdc63b481b7a 100644 --- a/UnoControls/inc/basecontainercontrol.hxx +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -33,9 +33,11 @@ struct IMPL_ControlInfo OUString sName; }; -class BaseContainerControl : public css::awt::XControlModel - , public css::awt::XControlContainer - , public BaseControl +using BaseContainerControl_BASE = cppu::ImplInheritanceHelper<BaseControl, + css::awt::XControlModel, + css::awt::XControlContainer>; + +class BaseContainerControl : public BaseContainerControl_BASE { public: @@ -43,37 +45,6 @@ public: virtual ~BaseContainerControl() override; - // XInterface - - /** - @short give answer, if interface is supported - @descr The interfaces are searched by type. - - @seealso XInterface - - @param "rType" is the type of searched interface. - - @return Any information about found interface - - @onerror A RuntimeException is thrown. - */ - - virtual css::uno::Any SAL_CALL queryInterface( - const css::uno::Type& aType - ) override; - - // XTypeProvider - - /** - @short get information about supported interfaces - @seealso XTypeProvider - @return Sequence of types of all supported interfaces - - @onerror A RuntimeException is thrown. - */ - - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - // XControl virtual void SAL_CALL createPeer( @@ -121,7 +92,7 @@ public: virtual void SAL_CALL setVisible( sal_Bool bVisible ) override; protected: - using WeakComponentImplHelper::disposing; + using WeakComponentImplHelperBase::disposing; virtual css::awt::WindowDescriptor impl_getWindowDescriptor( const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx index 9f60537bb7cb..90cdf51f7c7a 100644 --- a/UnoControls/inc/basecontrol.hxx +++ b/UnoControls/inc/basecontrol.hxx @@ -39,82 +39,19 @@ namespace unocontrols { class OMRCListenerMultiplexerHelper; } namespace unocontrols { -class BaseControl : public css::lang::XServiceInfo - , public css::awt::XPaintListener - , public css::awt::XWindowListener - , public css::awt::XView - , public css::awt::XWindow - , public css::awt::XControl - , public cppu::BaseMutex - , public ::cppu::WeakComponentImplHelper<> +class BaseControl : public cppu::BaseMutex, + public cppu::WeakComponentImplHelper<css::lang::XServiceInfo, + css::awt::XPaintListener, + css::awt::XWindowListener, + css::awt::XView, + css::awt::XWindow, + css::awt::XControl> { public: BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); virtual ~BaseControl() override; - // XInterface - - /** - @short give answer, if interface is supported - @descr The interfaces are searched by type. - - @seealso XInterface - - @param "rType" is the type of searched interface. - - @return Any information about found interface - - @onerror A RuntimeException is thrown. - */ - - virtual css::uno::Any SAL_CALL queryInterface( - const css::uno::Type& aType - ) override; - - /** - @short increment refcount - @seealso XInterface - @seealso release() - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL acquire() noexcept override; - - /** - @short decrement refcount - @seealso XInterface - @seealso acquire() - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL release() noexcept override; - - // XTypeProvider - - /** - @short get information about supported interfaces - @seealso XTypeProvider - @return Sequence of types of all supported interfaces - - @onerror A RuntimeException is thrown. - */ - - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - - /** - @short get implementation id - @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled. - Another way, cache is enabled. - - @seealso XTypeProvider - @return ID as Sequence of byte - - @onerror A RuntimeException is thrown. - */ - - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - // XServiceInfo virtual sal_Bool SAL_CALL supportsService( @@ -265,7 +202,7 @@ public: virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override; protected: - using WeakComponentImplHelper::disposing; + using WeakComponentImplHelperBase::disposing; const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;} diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index bf638a9c56a4..f78ed4552eac 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -40,7 +40,7 @@ namespace unocontrols { // construct/destruct BaseContainerControl::BaseContainerControl( const Reference< XComponentContext >& rxContext ) - : BaseControl ( rxContext ) + : BaseContainerControl_BASE(rxContext) , m_aListeners ( m_aMutex ) { } @@ -49,43 +49,6 @@ BaseContainerControl::~BaseContainerControl() { } -// XInterface - -Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType ) -{ - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper! - Any aReturn ( ::cppu::queryInterface( rType , - static_cast< XControlModel* > ( this ) , - static_cast< XControlContainer* > ( this ) - ) - ); - - // If searched interface supported by this class ... - if ( aReturn.hasValue() ) - { - // ... return this information. - return aReturn; - } - else - { - // Else; ... ask baseclass for interfaces! - return BaseControl::queryInterface( rType ); - } -} - -// XTypeProvider - -Sequence< Type > SAL_CALL BaseContainerControl::getTypes() -{ - static OTypeCollection ourTypeCollection( - cppu::UnoType<XControlModel>::get(), - cppu::UnoType<XControlContainer>::get(), - BaseControl::getTypes() ); - - return ourTypeCollection.getTypes(); -} - // XControl void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit , diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx index 247142e5c151..59c5888d4c3f 100644 --- a/UnoControls/source/base/basecontrol.cxx +++ b/UnoControls/source/base/basecontrol.cxx @@ -65,80 +65,6 @@ BaseControl::~BaseControl() { } -// XInterface - -Any SAL_CALL BaseControl::queryInterface( const Type& rType ) -{ - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper! - Any aReturn ( ::cppu::queryInterface( rType , - static_cast< XPaintListener*> ( this ) , - static_cast< XWindowListener*> ( this ) , - static_cast< XView* > ( this ) , - static_cast< XWindow* > ( this ) , - static_cast< XServiceInfo* > ( this ) , - static_cast< XControl* > ( this ) - ) - ); - - // If searched interface supported by this class ... - if ( aReturn.hasValue() ) - { - // ... return this information. - return aReturn; - } - else - { - // Else; ... ask baseclass for interfaces! - return WeakComponentImplHelper::queryInterface( rType ); - } -} - -// XInterface - -void SAL_CALL BaseControl::acquire() noexcept -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - WeakComponentImplHelper::acquire(); -} - -// XInterface - -void SAL_CALL BaseControl::release() noexcept -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - WeakComponentImplHelper::release(); -} - -// XTypeProvider - -Sequence< Type > SAL_CALL BaseControl::getTypes() -{ - static OTypeCollection ourTypeCollection( - cppu::UnoType<XPaintListener>::get(), - cppu::UnoType<XWindowListener>::get(), - cppu::UnoType<XView>::get(), - cppu::UnoType<XWindow>::get(), - cppu::UnoType<XServiceInfo>::get(), - cppu::UnoType<XControl>::get(), - WeakComponentImplHelper::getTypes() ); - - return ourTypeCollection.getTypes(); -} - -// XTypeProvider - -Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); -} - // XServiceInfo OUString SAL_CALL BaseControl::getImplementationName() diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx index 6b12862d734b..e6eefda2124c 100644 --- a/UnoControls/source/controls/framecontrol.cxx +++ b/UnoControls/source/controls/framecontrol.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <comphelper/sequence.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <osl/diagnose.h> @@ -58,7 +59,7 @@ enum PropertyHandle // values represent index in PropertyArray // construct/destruct FrameControl::FrameControl( const Reference< XComponentContext >& rxContext) - : BaseControl ( rxContext ) + : FrameControl_BASE ( rxContext ) , OBroadcastHelper ( m_aMutex ) , OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) ) , m_aConnectionPointContainer ( new OConnectionPointContainerHelper(m_aMutex) ) @@ -72,23 +73,10 @@ FrameControl::~FrameControl() // XInterface Any SAL_CALL FrameControl::queryInterface( const Type& rType ) { - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper! - Any aReturn ( ::cppu::queryInterface( rType , - static_cast< XControlModel* > ( this ) , - static_cast< XConnectionPointContainer* > ( this ) - ) - ); - + Any aReturn = OPropertySetHelper::queryInterface(rType); if (aReturn.hasValue()) return aReturn; - - // If searched interface not supported by this class ... - // ... ask baseclasses. - aReturn = OPropertySetHelper::queryInterface(rType); - if (aReturn.hasValue()) - return aReturn; - return BaseControl::queryInterface(rType); + return FrameControl_BASE::queryInterface(rType); } // XInterface @@ -98,7 +86,7 @@ void SAL_CALL FrameControl::acquire() noexcept // Don't use mutex or guard in this method!!! Is a method of XInterface. // Forward to baseclass - BaseControl::acquire(); + FrameControl_BASE::acquire(); } // XInterface @@ -108,20 +96,16 @@ void SAL_CALL FrameControl::release() noexcept // Don't use mutex or guard in this method!!! Is a method of XInterface. // Forward to baseclass - BaseControl::release(); + FrameControl_BASE::release(); } // XTypeProvider Sequence< Type > SAL_CALL FrameControl::getTypes() { - static OTypeCollection ourTypeCollection( - cppu::UnoType<XControlModel>::get(), - cppu::UnoType<XControlContainer>::get(), - cppu::UnoType<XConnectionPointContainer>::get(), - BaseControl::getTypes() ); - - return ourTypeCollection.getTypes(); + static Sequence myTypes = comphelper::concatSequences(FrameControl_BASE::getTypes(), + OPropertySetHelper::getTypes()); + return myTypes; } OUString FrameControl::getImplementationName() diff --git a/UnoControls/source/controls/progressbar.cxx b/UnoControls/source/controls/progressbar.cxx index 85653c1cc1a3..e2425916bbcc 100644 --- a/UnoControls/source/controls/progressbar.cxx +++ b/UnoControls/source/controls/progressbar.cxx @@ -34,7 +34,7 @@ namespace unocontrols { // construct/destruct ProgressBar::ProgressBar( const Reference< XComponentContext >& rxContext ) - : BaseControl ( rxContext ) + : ProgressBar_BASE ( rxContext ) , m_bHorizontal ( PROGRESSBAR_DEFAULT_HORIZONTAL ) , m_aBlockSize ( PROGRESSBAR_DEFAULT_BLOCKDIMENSION ) , m_nForegroundColor ( PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR ) @@ -50,57 +50,6 @@ ProgressBar::~ProgressBar() { } -// XInterface -Any SAL_CALL ProgressBar::queryInterface( const Type& rType ) -{ - // Ask for my own supported interfaces ... - // Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper! - Any aReturn ( ::cppu::queryInterface( rType , - static_cast< XControlModel* > ( this ) , - static_cast< XProgressBar* > ( this ) - ) - ); - - if (aReturn.hasValue()) - return aReturn; - - // If searched interface not supported by this class ... - // ... ask baseclasses. - return BaseControl::queryInterface(rType); -} - -// XInterface -void SAL_CALL ProgressBar::acquire() noexcept -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - BaseControl::acquire(); -} - -// XInterface -void SAL_CALL ProgressBar::release() noexcept -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - BaseControl::release(); -} - -// XTypeProvider - -Sequence< Type > SAL_CALL ProgressBar::getTypes() -{ - static OTypeCollection ourTypeCollection( - cppu::UnoType<XControlModel>::get(), - cppu::UnoType<XProgressBar>::get(), - BaseControl::getTypes() ); - - return ourTypeCollection.getTypes(); -} - // XProgressBar void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor ) diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx index 514e7cd79994..f8b5cd423582 100644 --- a/UnoControls/source/inc/framecontrol.hxx +++ b/UnoControls/source/inc/framecontrol.hxx @@ -31,9 +31,10 @@ namespace unocontrols { class OConnectionPointContainerHelper; } namespace unocontrols { -class FrameControl final : public css::awt::XControlModel - , public css::lang::XConnectionPointContainer - , public BaseControl // This order is necessary for right initialization of m_aMutex! +using FrameControl_BASE = cppu::ImplInheritanceHelper<BaseControl, css::awt::XControlModel, + css::lang::XConnectionPointContainer>; + +class FrameControl final : public FrameControl_BASE // This order is necessary for right initialization of m_aMutex! , public ::cppu::OBroadcastHelper , public ::cppu::OPropertySetHelper { diff --git a/UnoControls/source/inc/progressbar.hxx b/UnoControls/source/inc/progressbar.hxx index 3c9f5c8bebf1..78104ca3b924 100644 --- a/UnoControls/source/inc/progressbar.hxx +++ b/UnoControls/source/inc/progressbar.hxx @@ -41,9 +41,11 @@ constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE = 1; constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE); constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK); -class ProgressBar final : public css::awt::XControlModel - , public css::awt::XProgressBar - , public BaseControl +using ProgressBar_BASE = cppu::ImplInheritanceHelper<BaseControl, + css::awt::XControlModel, + css::awt::XProgressBar>; + +class ProgressBar final : public ProgressBar_BASE { public: @@ -51,32 +53,6 @@ public: virtual ~ProgressBar() override; - // XInterface - - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; - - /** - @short increment refcount - @seealso XInterface - @seealso release() - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL acquire() noexcept override; - - /** - @short decrement refcount - @seealso XInterface - @seealso acquire() - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL release() noexcept override; - - // XTypeProvider - - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; - // XProgressBar virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override;