framework/inc/uielement/progressbarwrapper.hxx | 5 framework/inc/uielement/statusindicatorinterfacewrapper.hxx | 8 - framework/source/services/frame.cxx | 13 +- framework/source/uielement/progressbarwrapper.cxx | 13 -- framework/source/uielement/statusindicatorinterfacewrapper.cxx | 54 +++------- 5 files changed, 37 insertions(+), 56 deletions(-)
New commits: commit 78edbb9f6f6957c625fdf6ae4e9834e10e20a57a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 11:17:19 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 19:54:16 2024 +0200 use more concrete UNO types in XFrameImpl Change-Id: I5cb9a5bc02fd2d526d39c637e34715f501769034 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168776 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index f5d7226e869c..569cb962a8a7 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -79,6 +79,7 @@ #include <toolkit/helper/vclunohelper.hxx> #include <unotools/moduleoptions.hxx> +#include <unotools/weakref.hxx> #include <comphelper/diagnose_ex.hxx> #include <unotools/cmdoptions.hxx> #include <vcl/threadex.hxx> @@ -311,7 +312,7 @@ private: * This owner is used as source for all broadcasted events. * Further we hold it weak, because we don't wish to be disposed() .-) */ - void impl_setPropertyChangeBroadcaster(const css::uno::Reference< css::uno::XInterface >& xBroadcaster); + void impl_setPropertyChangeBroadcaster(XFrameImpl& rBroadcaster); /** add a new property info to the set of supported ones. * @@ -423,7 +424,7 @@ private: comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString> m_lVetoChangeListener; // hold it weak ... otherwise this helper has to be "killed" explicitly .-) - css::uno::WeakReference< css::uno::XInterface > m_xBroadcaster; + unotools::WeakReference< XFrameImpl > m_xBroadcaster; FrameContainer m_aChildFrameContainer; /// array of child frames /** @@ -515,7 +516,7 @@ void XFrameImpl::initListeners() m_xLayoutManager = css::frame::LayoutManager::create(m_xContext); // set information about all supported properties - impl_setPropertyChangeBroadcaster(static_cast< css::frame::XFrame* >(this)); + impl_setPropertyChangeBroadcaster(*this); impl_addPropertyInfo( css::beans::Property( FRAME_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER, @@ -1890,7 +1891,7 @@ void SAL_CALL XFrameImpl::setPropertyValue(const OUString& sProperty, aEvent.PropertyHandle = aPropInfo.Handle; aEvent.OldValue = aCurrentValue; aEvent.NewValue = aValue; - aEvent.Source.set(m_xBroadcaster.get(), css::uno::UNO_QUERY); + aEvent.Source = m_xBroadcaster; if (impl_existsVeto(aEvent)) throw css::beans::PropertyVetoException(); @@ -2835,10 +2836,10 @@ css::uno::Any XFrameImpl::impl_getPropertyValue(sal_Int32 nHandle) return aValue; } -void XFrameImpl::impl_setPropertyChangeBroadcaster(const css::uno::Reference< css::uno::XInterface >& xBroadcaster) +void XFrameImpl::impl_setPropertyChangeBroadcaster(XFrameImpl& xBroadcaster) { SolarMutexGuard g; - m_xBroadcaster = xBroadcaster; + m_xBroadcaster = &xBroadcaster; } void XFrameImpl::impl_addPropertyInfo(const css::beans::Property& aProperty) commit e133fd4eaec490da100b4fae45657573f466f0e1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 11:11:28 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 19:54:07 2024 +0200 use more concrete UNO types in ProgressBarWrapper Change-Id: Ia7f3f3cef44ee7db6850a75c3de307a8b35e3263 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168775 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/inc/uielement/progressbarwrapper.hxx b/framework/inc/uielement/progressbarwrapper.hxx index 5b6ca9019e16..5b44e1bb740b 100644 --- a/framework/inc/uielement/progressbarwrapper.hxx +++ b/framework/inc/uielement/progressbarwrapper.hxx @@ -23,9 +23,10 @@ #include <com/sun/star/awt/XWindow.hpp> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace framework{ +class StatusIndicatorInterfaceWrapper; class ProgressBarWrapper final : public UIElementWrapperBase { @@ -70,7 +71,7 @@ class ProgressBarWrapper final : public UIElementWrapperBase private: css::uno::Reference< css::awt::XWindow > m_xStatusBar; // Reference to our status bar XWindow - css::uno::WeakReference< css::uno::XInterface > m_xProgressBarIfacWrapper; + unotools::WeakReference< StatusIndicatorInterfaceWrapper > m_xProgressBarIfacWrapper; bool m_bOwnsInstance; // Indicator that we are owner of the XWindow sal_Int32 m_nRange; sal_Int32 m_nValue; diff --git a/framework/inc/uielement/statusindicatorinterfacewrapper.hxx b/framework/inc/uielement/statusindicatorinterfacewrapper.hxx index abfae53e754f..000405848cce 100644 --- a/framework/inc/uielement/statusindicatorinterfacewrapper.hxx +++ b/framework/inc/uielement/statusindicatorinterfacewrapper.hxx @@ -23,16 +23,18 @@ #include <com/sun/star/lang/XComponent.hpp> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <cppuhelper/implbase.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace framework { +class ProgressBarWrapper; class StatusIndicatorInterfaceWrapper final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator> { public: - StatusIndicatorInterfaceWrapper( const css::uno::Reference< css::lang::XComponent >& rStatusIndicatorImpl ); + StatusIndicatorInterfaceWrapper( const rtl::Reference< ProgressBarWrapper >& rStatusIndicatorImpl ); virtual ~StatusIndicatorInterfaceWrapper() override; // XStatusIndicator @@ -45,7 +47,7 @@ class StatusIndicatorInterfaceWrapper final : public ::cppu::WeakImplHelper< css virtual void SAL_CALL setValue( sal_Int32 nValue ) override; private: - css::uno::WeakReference< css::lang::XComponent > m_xStatusIndicatorImpl; + unotools::WeakReference< ProgressBarWrapper > m_xStatusIndicatorImpl; }; } diff --git a/framework/source/uielement/progressbarwrapper.cxx b/framework/source/uielement/progressbarwrapper.cxx index ad147111ff50..d92027c92c3a 100644 --- a/framework/source/uielement/progressbarwrapper.cxx +++ b/framework/source/uielement/progressbarwrapper.cxx @@ -291,17 +291,14 @@ uno::Reference< uno::XInterface > SAL_CALL ProgressBarWrapper::getRealInterface( return uno::Reference< uno::XInterface >(); else { - uno::Reference< uno::XInterface > xComp( m_xProgressBarIfacWrapper ); - if ( !xComp.is() ) + rtl::Reference< StatusIndicatorInterfaceWrapper > pWrapper( m_xProgressBarIfacWrapper ); + if ( !pWrapper.is() ) { - rtl::Reference<StatusIndicatorInterfaceWrapper> pWrapper = - new StatusIndicatorInterfaceWrapper( uno::Reference< lang::XComponent >(this) ); - xComp.set(static_cast< cppu::OWeakObject* >( pWrapper.get() ), - uno::UNO_QUERY ); - m_xProgressBarIfacWrapper = xComp; + pWrapper = new StatusIndicatorInterfaceWrapper( this ); + m_xProgressBarIfacWrapper = pWrapper.get(); } - return xComp; + return static_cast<cppu::OWeakObject*>(pWrapper.get()); } } diff --git a/framework/source/uielement/statusindicatorinterfacewrapper.cxx b/framework/source/uielement/statusindicatorinterfacewrapper.cxx index 6082f2aa5c3f..22ecc104bec3 100644 --- a/framework/source/uielement/statusindicatorinterfacewrapper.cxx +++ b/framework/source/uielement/statusindicatorinterfacewrapper.cxx @@ -28,7 +28,7 @@ namespace framework { StatusIndicatorInterfaceWrapper::StatusIndicatorInterfaceWrapper( - const css::uno::Reference< css::lang::XComponent >& rStatusIndicatorImpl ) : + const rtl::Reference< ProgressBarWrapper >& rStatusIndicatorImpl ) : m_xStatusIndicatorImpl( rStatusIndicatorImpl ) { } @@ -39,61 +39,41 @@ StatusIndicatorInterfaceWrapper::~StatusIndicatorInterfaceWrapper() void SAL_CALL StatusIndicatorInterfaceWrapper::start( const OUString& sText, - sal_Int32 nRange ) + sal_Int32 nRange ) { - Reference< XComponent > xComp( m_xStatusIndicatorImpl ); - if ( xComp.is() ) - { - ProgressBarWrapper* pProgressBar = static_cast<ProgressBarWrapper*>(xComp.get()); - if ( pProgressBar ) - pProgressBar->start( sText, nRange ); - } + rtl::Reference< ProgressBarWrapper > xProgressBar( m_xStatusIndicatorImpl ); + if ( xProgressBar.is() ) + xProgressBar->start( sText, nRange ); } void SAL_CALL StatusIndicatorInterfaceWrapper::end() { - Reference< XComponent > xComp( m_xStatusIndicatorImpl ); - if ( xComp.is() ) - { - ProgressBarWrapper* pProgressBar = static_cast<ProgressBarWrapper*>(xComp.get()); - if ( pProgressBar ) - pProgressBar->end(); - } + rtl::Reference< ProgressBarWrapper > xProgressBar( m_xStatusIndicatorImpl ); + if ( xProgressBar.is() ) + xProgressBar->end(); } void SAL_CALL StatusIndicatorInterfaceWrapper::reset() { - Reference< XComponent > xComp( m_xStatusIndicatorImpl ); - if ( xComp.is() ) - { - ProgressBarWrapper* pProgressBar = static_cast<ProgressBarWrapper*>(xComp.get()); - if ( pProgressBar ) - pProgressBar->reset(); - } + rtl::Reference< ProgressBarWrapper > xProgressBar( m_xStatusIndicatorImpl ); + if ( xProgressBar.is() ) + xProgressBar->reset(); } void SAL_CALL StatusIndicatorInterfaceWrapper::setText( const OUString& sText ) { - Reference< XComponent > xComp( m_xStatusIndicatorImpl ); - if ( xComp.is() ) - { - ProgressBarWrapper* pProgressBar = static_cast<ProgressBarWrapper*>(xComp.get()); - if ( pProgressBar ) - pProgressBar->setText( sText ); - } + rtl::Reference< ProgressBarWrapper > xProgressBar( m_xStatusIndicatorImpl ); + if ( xProgressBar.is() ) + xProgressBar->setText( sText ); } void SAL_CALL StatusIndicatorInterfaceWrapper::setValue( sal_Int32 nValue ) { - Reference< XComponent > xComp( m_xStatusIndicatorImpl ); - if ( xComp.is() ) - { - ProgressBarWrapper* pProgressBar = static_cast<ProgressBarWrapper*>(xComp.get()); - if ( pProgressBar ) - pProgressBar->setValue( nValue ); - } + rtl::Reference< ProgressBarWrapper > xProgressBar( m_xStatusIndicatorImpl ); + if ( xProgressBar.is() ) + xProgressBar->setValue( nValue ); } } // namespace framework