From f8aa78379cfbff830b0e8dc6f2b6961dd09fa74b Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 8 Dec 2024 20:32:36 +0500 Subject: [PATCH] Simplify ProgressMonitor, StatusIndicator Change-Id: I1c17fa54e865c2750407783adbb2f73c095dbbfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178094 Reviewed-by: Mike Kaganski Tested-by: Jenkins --- .../source/controls/progressmonitor.cxx | 54 +---------------- .../source/controls/statusindicator.cxx | 58 +------------------ UnoControls/source/inc/progressmonitor.hxx | 56 ++---------------- UnoControls/source/inc/statusindicator.hxx | 54 ++--------------- 4 files changed, 11 insertions(+), 211 deletions(-) diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx index d58518e0e8ff..fbe84e34f7e7 100644 --- a/UnoControls/source/controls/progressmonitor.cxx +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -51,7 +51,7 @@ constexpr OUStringLiteral DEFAULT_BUTTONLABEL = u"Abbrechen"; namespace unocontrols { ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext >& rxContext ) - : BaseContainerControl ( rxContext ) + : ProgressMonitor_BASE(rxContext) { // It's not allowed to work with member in this method (refcounter !!!) // But with a HACK (++refcount) its "OK" :-( @@ -109,58 +109,6 @@ ProgressMonitor::~ProgressMonitor() impl_cleanMemory (); } -// XInterface -Any SAL_CALL ProgressMonitor::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< XLayoutConstrains* > ( this ) , - static_cast< XButton* > ( this ) , - static_cast< XProgressMonitor* > ( this ) - ) - ); - - if (aReturn.hasValue()) - return aReturn; - - // If searched interface not supported by this class ... - // ... ask baseclasses. - return BaseControl::queryInterface(rType); -} - -// XInterface -void SAL_CALL ProgressMonitor::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 ProgressMonitor::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 ProgressMonitor::getTypes() -{ - static OTypeCollection ourTypeCollection( - cppu::UnoType::get(), - cppu::UnoType::get(), - cppu::UnoType::get(), - BaseContainerControl::getTypes() ); - - return ourTypeCollection.getTypes(); -} - // XProgressMonitor void SAL_CALL ProgressMonitor::addText( const OUString& rTopic, diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx index 9301c2494106..c6135000754d 100644 --- a/UnoControls/source/controls/statusindicator.cxx +++ b/UnoControls/source/controls/statusindicator.cxx @@ -44,7 +44,7 @@ namespace unocontrols { // construct/destruct StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext >& rxContext ) - : BaseContainerControl ( rxContext ) + : StatusIndicator_BASE(rxContext) { // It's not allowed to work with member in this method (refcounter !!!) // But with a HACK (++refcount) its "OK" :-( @@ -72,62 +72,6 @@ StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext > StatusIndicator::~StatusIndicator() {} -// XInterface - -Any SAL_CALL StatusIndicator::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< XLayoutConstrains* > ( this ) , - static_cast< XStatusIndicator* > ( this ) - ) - ); - - // If searched interface not supported by this class ... - if ( !aReturn.hasValue() ) - { - // ... ask baseclasses. - aReturn = BaseControl::queryInterface( rType ); - } - - return aReturn; -} - -// XInterface - -void SAL_CALL StatusIndicator::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 StatusIndicator::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 StatusIndicator::getTypes() -{ - static OTypeCollection ourTypeCollection( - cppu::UnoType::get(), - cppu::UnoType::get(), - BaseContainerControl::getTypes() ); - - return ourTypeCollection.getTypes(); -} - // XStatusIndicator void SAL_CALL StatusIndicator::start( const OUString& sText, sal_Int32 nRange ) diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx index 46a4dc735484..cd7786a2d69b 100644 --- a/UnoControls/source/inc/progressmonitor.hxx +++ b/UnoControls/source/inc/progressmonitor.hxx @@ -50,63 +50,17 @@ struct IMPL_TextlistItem OUString sText; /// Right site of textline in dialog }; -class ProgressMonitor final : public css::awt::XLayoutConstrains - , public css::awt::XButton - , public css::awt::XProgressMonitor - , public BaseContainerControl +using ProgressMonitor_BASE = cppu::ImplInheritanceHelper; +class ProgressMonitor final : public ProgressMonitor_BASE { public: ProgressMonitor( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); virtual ~ProgressMonitor() 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; - // XProgressMonitor /** diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx index 5f18f135d2ef..8d3f024d03cf 100644 --- a/UnoControls/source/inc/statusindicator.hxx +++ b/UnoControls/source/inc/statusindicator.hxx @@ -42,62 +42,16 @@ constexpr sal_Int32 STATUSINDICATOR_BACKGROUNDCOLOR = sal_Int32(COL_LIGHTGRAY); constexpr sal_Int32 STATUSINDICATOR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE); constexpr sal_Int32 STATUSINDICATOR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK); -class StatusIndicator final : public css::awt::XLayoutConstrains - , public css::task::XStatusIndicator - , public BaseContainerControl +using StatusIndicator_BASE = cppu::ImplInheritanceHelper; +class StatusIndicator final : public StatusIndicator_BASE { public: StatusIndicator( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); virtual ~StatusIndicator() 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; - // XStatusIndicator virtual void SAL_CALL start(