sfx2/source/appl/appdispatchprovider.cxx | 2 +- sfx2/source/appl/macroloader.cxx | 2 +- sfx2/source/control/thumbnailview.cxx | 3 +-- sfx2/source/control/thumbnailviewacc.cxx | 4 ++-- sfx2/source/control/unoctitm.cxx | 2 +- sfx2/source/dialog/backingcomp.cxx | 14 +++++++------- sfx2/source/doc/SfxDocumentMetaData.cxx | 2 +- sfx2/source/doc/sfxbasemodel.cxx | 4 ++-- sfx2/source/notify/globalevents.cxx | 8 ++++---- sfx2/source/sidebar/SidebarPanelBase.cxx | 2 +- sfx2/source/sidebar/Theme.cxx | 4 ++-- sfx2/source/view/ipclient.cxx | 4 ++-- sfx2/source/view/sfxbasecontroller.cxx | 10 +++++----- 13 files changed, 30 insertions(+), 31 deletions(-)
New commits: commit bad7f6376f96a008c1b1a77d262953c13eb8442b Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Apr 23 20:14:42 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Apr 30 18:53:26 2023 +0200 Use getXWeak in sfx2 Change-Id: I364f13308adf8b3257e53da2bc6576088bb958f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150867 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index 0ac4f59d88d1..363aa391d568 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -81,7 +81,7 @@ void SfxAppDispatchProvider::initialize( if (aArguments.getLength() != 1 || !(aArguments[0] >>= f)) { throw css::lang::IllegalArgumentException( "SfxAppDispatchProvider::initialize expects one XFrame argument", - static_cast<OWeakObject *>(this), 0); + getXWeak(), 0); } m_xFrame = f; } diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index bf6dd7669b39..da9f83a2b7c1 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -133,7 +133,7 @@ void SAL_CALL SfxMacroLoader::dispatchWithNotification( // executed a macro instead! frame::DispatchResultEvent aEvent; - aEvent.Source = static_cast< ::cppu::OWeakObject* >(this); + aEvent.Source = getXWeak(); if( nErr == ERRCODE_NONE ) aEvent.State = frame::DispatchResultState::SUCCESS; else diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 8ec9b80ea6d4..e48dea30e7d5 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1115,8 +1115,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) if( pItemAcc ) { css::uno::Any aOldAny, aNewAny; - aNewAny <<= css::uno::Reference< css::uno::XInterface >( - static_cast< ::cppu::OWeakObject* >( pItemAcc )); + aNewAny <<= css::uno::Reference(getXWeak( pItemAcc )); ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); } diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index f4ec85e5a89a..54a3af71fb93 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -490,7 +490,7 @@ void ThumbnailViewAcc::ThrowIfDisposed() SAL_WARN("sfx", "Calling disposed object. Throwing exception:"); throw lang::DisposedException ( "object has been already disposed", - static_cast<uno::XWeak*>(this)); + getXWeak()); } else { @@ -523,7 +523,7 @@ void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOld accessibility::AccessibleEventObject aEvtObject; aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.Source = getXWeak(); aEvtObject.NewValue = rNewValue; aEvtObject.OldValue = rOldValue; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index e7b84138e436..bfc155599a17 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -115,7 +115,7 @@ static void InterceptLOKStateChangeEvent( sal_uInt16 nSID, SfxViewFrame* pViewFr void SfxStatusDispatcher::ReleaseAll() { css::lang::EventObject aObject; - aObject.Source = static_cast<cppu::OWeakObject*>(this); + aObject.Source = getXWeak(); std::unique_lock aGuard(maMutex); maListeners.disposeAndClear( aGuard, aObject ); } diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 845435ddc4f4..2f3dc01744fc 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -329,12 +329,12 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f if (m_xFrame.is()) throw css::uno::RuntimeException( "already attached", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); if (!xFrame.is()) throw css::uno::RuntimeException( "invalid frame reference", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); if (!m_xWindow.is()) return; // disposed @@ -513,7 +513,7 @@ void SAL_CALL BackingComp::disposing( /*IN*/ const css::lang::EventObject& aEven if (!aEvent.Source.is() || aEvent.Source!=m_xWindow || !m_xWindow.is()) throw css::uno::RuntimeException( "unexpected source or called twice", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); m_xWindow.clear(); @@ -575,7 +575,7 @@ void SAL_CALL BackingComp::addEventListener( /*IN*/ const css::uno::Reference< c { throw css::uno::RuntimeException( "not supported", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); } @@ -618,7 +618,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno if (m_xWindow.is()) throw css::uno::Exception( "already initialized", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); css::uno::Reference< css::awt::XWindow > xParentWindow; if ( @@ -629,7 +629,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno { throw css::uno::Exception( "wrong or corrupt argument list", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); } // create the component window @@ -640,7 +640,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno if (!m_xWindow.is()) throw css::uno::RuntimeException( "couldn't create component window", - static_cast< ::cppu::OWeakObject* >(this)); + getXWeak()); // start listening for window disposing // It's set at our owner frame as component window later too. So it will may be disposed there ... diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index a9c26ee3138d..7d1f16c01fd9 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -1347,7 +1347,7 @@ void SAL_CALL SfxDocumentMetaData::dispose() } WeakComponentImplHelperBase::dispose(); // superclass m_NotifyListeners.disposeAndClear(css::lang::EventObject( - static_cast< ::cppu::OWeakObject* >(this))); + getXWeak())); m_isInitialized = false; m_meta.clear(); m_metaList.clear(); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 8ff60d41ff90..45c992c8dc5b 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1446,8 +1446,8 @@ void SAL_CALL SfxBaseModel::close( sal_Bool bDeliverOwnership ) if ( impl_isDisposed() || m_pData->m_bClosed || m_pData->m_bClosing ) return; - Reference< XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) ); - lang::EventObject aSource ( static_cast< ::cppu::OWeakObject* >(this) ); + Reference< XInterface > xSelfHold( getXWeak() ); + lang::EventObject aSource ( getXWeak() ); comphelper::OInterfaceContainerHelper2* pContainer = m_pData->m_aInterfaceContainer.getContainer( cppu::UnoType<util::XCloseListener>::get()); if (pContainer!=nullptr) { diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 83084b9878f1..d758e307d3a6 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -256,12 +256,12 @@ void SfxGlobalEvents_Impl::dispose() { tmpEvents.clear(); tmpModels.clear(); g.lock(); - m_aLegacyListeners.disposeAndClear(g, {static_cast<OWeakObject *>(this)}); - m_aDocumentListeners.disposeAndClear(g, {static_cast<OWeakObject *>(this)}); + m_aLegacyListeners.disposeAndClear(g, {getXWeak()}); + m_aDocumentListeners.disposeAndClear(g, {getXWeak()}); } for (auto const & i: listeners) { try { - i->disposing({static_cast< cppu::OWeakObject * >(this)}); + i->disposing({getXWeak()}); } catch (css::lang::DisposedException &) {} } } @@ -280,7 +280,7 @@ void SfxGlobalEvents_Impl::addEventListener( } } try { - xListener->disposing({static_cast< cppu::OWeakObject * >(this)}); + xListener->disposing({getXWeak()}); } catch (css::lang::DisposedException &) {} } diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index a662dffa5174..1bf3fe0fee8d 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -138,7 +138,7 @@ sal_Int16 SAL_CALL SidebarPanelBase::getType() Reference<XInterface> SAL_CALL SidebarPanelBase::getRealInterface() { - return Reference<XInterface>(static_cast<XWeak*>(this)); + return getXWeak(); } Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessible ( diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx index 5973460bbe9c..188910120e89 100644 --- a/sfx2/source/sidebar/Theme.cxx +++ b/sfx2/source/sidebar/Theme.cxx @@ -148,7 +148,7 @@ void Theme::disposing(std::unique_lock<std::mutex>&) ChangeListeners aListeners; aListeners.swap(maChangeListeners); - const lang::EventObject aEvent (static_cast<XWeak*>(this)); + const lang::EventObject aEvent (getXWeak()); for (const auto& rContainer : aListeners) { @@ -204,7 +204,7 @@ void SAL_CALL Theme::setPropertyValue ( const Any aOldValue (maRawValues[eItem]); const beans::PropertyChangeEvent aEvent( - static_cast<XWeak*>(this), + getXWeak(), rsPropertyName, false, eItem, diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index a9cff131655e..367d3070938b 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -707,8 +707,8 @@ void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject { if ( m_xImp->m_xObject.is() && rObject != m_xImp->m_xObject ) { - DBG_ASSERT( GetObject()->getClientSite() == static_cast<cppu::OWeakObject*>(m_xImp.get()), "Wrong ClientSite!" ); - if ( GetObject()->getClientSite() == static_cast<cppu::OWeakObject*>(m_xImp.get()) ) + DBG_ASSERT( GetObject()->getClientSite() == getXWeak(m_xImp.get()), "Wrong ClientSite!" ); + if ( GetObject()->getClientSite() == getXWeak(m_xImp.get()) ) { if ( GetObject()->getCurrentState() != embed::EmbedStates::LOADED ) SetObjectState( embed::EmbedStates::RUNNING ); diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 5d8973fa41e5..e9cd1f4642af 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -334,7 +334,7 @@ void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const la bool bCanClose = pShell->PrepareClose( false ); if ( !bCanClose ) { - throw util::CloseVetoException("Controller disagree ...",static_cast< ::cppu::OWeakObject*>(this)); + throw util::CloseVetoException("Controller disagree ...",getXWeak()); } } } @@ -846,7 +846,7 @@ void SfxBaseController::BorderWidthsChanged_Impl() return; frame::BorderWidths aBWidths = getBorder(); - Reference< uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY ); + Reference< uno::XInterface > xThis( getXWeak() ); ::comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer); while (pIterator.hasMoreElements()) @@ -1438,11 +1438,11 @@ void SAL_CALL SfxBaseController::appendInfobar(const OUString& sId, const OUStri || aInfobarType > static_cast<sal_Int32>(InfobarType::DANGER)) throw lang::IllegalArgumentException("Undefined InfobarType: " + OUString::number(aInfobarType), - static_cast<::cppu::OWeakObject*>(this), 0); + getXWeak(), 0); SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); if (pViewFrame->HasInfoBarWithID(sId)) throw lang::IllegalArgumentException("Infobar with ID '" + sId + "' already existing.", - static_cast<::cppu::OWeakObject*>(this), 0); + getXWeak(), 0); auto pInfoBar = pViewFrame->AppendInfoBar(sId, sPrimaryMessage, sSecondaryMessage, @@ -1469,7 +1469,7 @@ void SAL_CALL SfxBaseController::updateInfobar(const OUString& sId, const OUStri || aInfobarType > static_cast<sal_Int32>(InfobarType::DANGER)) throw lang::IllegalArgumentException("Undefined InfobarType: " + OUString::number(aInfobarType), - static_cast<::cppu::OWeakObject*>(this), 0); + getXWeak(), 0); SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); if (!pViewFrame->HasInfoBarWithID(sId)) throw css::container::NoSuchElementException("Infobar with ID '" + sId + "' not found.");