diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-06 10:09:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-07 08:19:14 +0100 |
commit | 536a6d6ca67d01c8470c242c6f1fd0750496eed4 (patch) | |
tree | cc2aed75621456aaeb31d26e910cc61baf3bfdd7 /sfx2/source/control | |
parent | 53a318196859140deb4b3c317db583a90cfd604c (diff) |
loplugin:flatten in sfx2
Change-Id: If4e07d497ead58a2ff58b5fdedd282b8784be421
Reviewed-on: https://gerrit.libreoffice.org/67435
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/control')
-rw-r--r-- | sfx2/source/control/bindings.cxx | 266 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 214 | ||||
-rw-r--r-- | sfx2/source/control/recentdocsviewitem.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/control/request.cxx | 82 | ||||
-rw-r--r-- | sfx2/source/control/shell.cxx | 34 | ||||
-rw-r--r-- | sfx2/source/control/statcach.cxx | 92 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 158 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 74 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailviewacc.cxx | 80 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 532 |
10 files changed, 779 insertions, 779 deletions
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 0a4e1fcc7169..2c8e71e96dee 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -317,51 +317,51 @@ void SfxBindings::Update pImpl->pSubBindings->Update( nId ); SfxStateCache* pCache = GetStateCache( nId ); - if ( pCache ) + if ( !pCache ) + return; + + pImpl->bInUpdate = true; + if ( pImpl->bMsgDirty ) { - pImpl->bInUpdate = true; - if ( pImpl->bMsgDirty ) + UpdateSlotServer_Impl(); + pCache = GetStateCache( nId ); + } + + if (pCache) + { + bool bInternalUpdate = true; + if( pCache->GetDispatch().is() && pCache->GetItemLink() ) { - UpdateSlotServer_Impl(); - pCache = GetStateCache( nId ); + pCache->SetCachedState(true); + bInternalUpdate = ( pCache->GetInternalController() != nullptr ); } - if (pCache) + if ( bInternalUpdate ) { - bool bInternalUpdate = true; - if( pCache->GetDispatch().is() && pCache->GetItemLink() ) + // Query Status + const SfxSlotServer* pMsgServer = pDispatcher ? pCache->GetSlotServer(*pDispatcher, pImpl->xProv) : nullptr; + if ( !pCache->IsControllerDirty() ) { - pCache->SetCachedState(true); - bInternalUpdate = ( pCache->GetInternalController() != nullptr ); + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); + return; } - - if ( bInternalUpdate ) + if (!pMsgServer) { - // Query Status - const SfxSlotServer* pMsgServer = pDispatcher ? pCache->GetSlotServer(*pDispatcher, pImpl->xProv) : nullptr; - if ( !pCache->IsControllerDirty() ) - { - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - return; - } - if (!pMsgServer) - { - pCache->SetState(SfxItemState::DISABLED, nullptr); - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - return; - } - - Update_Impl(*pCache); + pCache->SetState(SfxItemState::DISABLED, nullptr); + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); + return; } - pImpl->bAllDirty = false; + Update_Impl(*pCache); } - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); + pImpl->bAllDirty = false; } + + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); } @@ -370,19 +370,19 @@ void SfxBindings::Update() if ( pImpl->pSubBindings ) pImpl->pSubBindings->Update(); - if ( pDispatcher ) - { - if ( nRegLevel ) - return; + if ( !pDispatcher ) + return; - pImpl->bInUpdate = true; - pDispatcher->Flush(); - pDispatcher->Update_Impl(); - while ( !NextJob_Impl(nullptr) ) - ; // loop - pImpl->bInUpdate = false; - InvalidateSlotsInMap_Impl(); - } + if ( nRegLevel ) + return; + + pImpl->bInUpdate = true; + pDispatcher->Flush(); + pDispatcher->Update_Impl(); + while ( !NextJob_Impl(nullptr) ) + ; // loop + pImpl->bInUpdate = false; + InvalidateSlotsInMap_Impl(); } @@ -621,23 +621,23 @@ void SfxBindings::InvalidateShell // Find Level sal_uInt16 nLevel = pDispatcher->GetShellLevel(rSh); - if ( nLevel != USHRT_MAX ) + if ( nLevel == USHRT_MAX ) + return; + + for (std::unique_ptr<SfxStateCache>& pCache : pImpl->pCaches) { - for (std::unique_ptr<SfxStateCache>& pCache : pImpl->pCaches) - { - const SfxSlotServer *pMsgServer = - pCache->GetSlotServer(*pDispatcher, pImpl->xProv); - if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel ) - pCache->Invalidate(false); - } - pImpl->nMsgPos = 0; - if ( !nRegLevel ) - { - pImpl->aAutoTimer.Stop(); - pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); - pImpl->aAutoTimer.Start(); - pImpl->bFirstRound = true; - } + const SfxSlotServer *pMsgServer = + pCache->GetSlotServer(*pDispatcher, pImpl->xProv); + if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel ) + pCache->Invalidate(false); + } + pImpl->nMsgPos = 0; + if ( !nRegLevel ) + { + pImpl->aAutoTimer.Stop(); + pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); + pImpl->aAutoTimer.Start(); + pImpl->bFirstRound = true; } } @@ -692,22 +692,22 @@ void SfxBindings::Invalidate return; SfxStateCache* pCache = GetStateCache(nId); - if ( pCache ) - { - if ( bWithItem ) - pCache->ClearCache(); - pCache->Invalidate(bWithMsg); + if ( !pCache ) + return; - if ( !pDispatcher || pImpl->bAllDirty ) - return; + if ( bWithItem ) + pCache->ClearCache(); + pCache->Invalidate(bWithMsg); - pImpl->nMsgPos = std::min(GetSlotPos(nId), pImpl->nMsgPos); - if ( !nRegLevel ) - { - pImpl->aAutoTimer.Stop(); - pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); - pImpl->aAutoTimer.Start(); - } + if ( !pDispatcher || pImpl->bAllDirty ) + return; + + pImpl->nMsgPos = std::min(GetSlotPos(nId), pImpl->nMsgPos); + if ( !nRegLevel ) + { + pImpl->aAutoTimer.Stop(); + pImpl->aAutoTimer.SetTimeout(TIMEOUT_FIRST); + pImpl->aAutoTimer.Start(); } } @@ -1200,25 +1200,25 @@ void SfxBindings::UpdateControllers_Impl DBG_ASSERT( !pSlot || rCache.GetId() == pSlot->GetSlotId(), "SID mismatch" ); // bound until now, the Controller to update the Slot. - if (rCache.IsControllerDirty()) + if (!rCache.IsControllerDirty()) + return; + + if ( SfxItemState::DONTCARE == eState ) { - if ( SfxItemState::DONTCARE == eState ) - { - // ambiguous - rCache.SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM ); - } - else if ( SfxItemState::DEFAULT == eState && - SfxItemPool::IsSlot(rFound.nWhichId) ) - { - // no Status or Default but without Pool - SfxVoidItem aVoid(0); - rCache.SetState( SfxItemState::UNKNOWN, &aVoid ); - } - else if ( SfxItemState::DISABLED == eState ) - rCache.SetState(SfxItemState::DISABLED, nullptr); - else - rCache.SetState(SfxItemState::DEFAULT, pItem); + // ambiguous + rCache.SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM ); } + else if ( SfxItemState::DEFAULT == eState && + SfxItemPool::IsSlot(rFound.nWhichId) ) + { + // no Status or Default but without Pool + SfxVoidItem aVoid(0); + rCache.SetState( SfxItemState::UNKNOWN, &aVoid ); + } + else if ( SfxItemState::DISABLED == eState ) + rCache.SetState(SfxItemState::DISABLED, nullptr); + else + rCache.SetState(SfxItemState::DEFAULT, pItem); } IMPL_LINK( SfxBindings, NextJob, Timer *, pTimer, void ) @@ -1426,63 +1426,63 @@ void SfxBindings::LeaveRegistrations( const char *pFile, int nLine ) void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) { SfxDispatcher *pOldDispat = pDispatcher; - if ( pDisp != pDispatcher ) + if ( pDisp == pDispatcher ) + return; + + if ( pOldDispat ) { - if ( pOldDispat ) + SfxBindings* pBind = pOldDispat->GetBindings(); + while ( pBind ) { - SfxBindings* pBind = pOldDispat->GetBindings(); - while ( pBind ) - { - if ( pBind->pImpl->pSubBindings == this && pBind->pDispatcher != pDisp ) - pBind->SetSubBindings_Impl( nullptr ); - pBind = pBind->pImpl->pSubBindings; - } + if ( pBind->pImpl->pSubBindings == this && pBind->pDispatcher != pDisp ) + pBind->SetSubBindings_Impl( nullptr ); + pBind = pBind->pImpl->pSubBindings; } + } - pDispatcher = pDisp; + pDispatcher = pDisp; - css::uno::Reference < css::frame::XDispatchProvider > xProv; - if ( pDisp ) - xProv.set( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); + css::uno::Reference < css::frame::XDispatchProvider > xProv; + if ( pDisp ) + xProv.set( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); - SetDispatchProvider_Impl( xProv ); - InvalidateAll( true ); + SetDispatchProvider_Impl( xProv ); + InvalidateAll( true ); - if ( pDispatcher && !pOldDispat ) + if ( pDispatcher && !pOldDispat ) + { + if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) { - if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) - { - OSL_FAIL( "SubBindings already set before activating!" ); - pImpl->pSubBindings->ENTERREGISTRATIONS(); - } - LEAVEREGISTRATIONS(); + OSL_FAIL( "SubBindings already set before activating!" ); + pImpl->pSubBindings->ENTERREGISTRATIONS(); } - else if( !pDispatcher ) + LEAVEREGISTRATIONS(); + } + else if( !pDispatcher ) + { + ENTERREGISTRATIONS(); + if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) { - ENTERREGISTRATIONS(); - if ( pImpl->pSubBindings && pImpl->pSubBindings->pDispatcher != pOldDispat ) - { - OSL_FAIL( "SubBindings still set even when deactivating!" ); - pImpl->pSubBindings->LEAVEREGISTRATIONS(); - } + OSL_FAIL( "SubBindings still set even when deactivating!" ); + pImpl->pSubBindings->LEAVEREGISTRATIONS(); } + } - Broadcast( SfxHint( SfxHintId::DataChanged ) ); + Broadcast( SfxHint( SfxHintId::DataChanged ) ); - if ( pDisp ) - { - SfxBindings* pBind = pDisp->GetBindings(); - while ( pBind && pBind != this ) - { - if ( !pBind->pImpl->pSubBindings ) - { - pBind->SetSubBindings_Impl( this ); - break; - } + if ( !pDisp ) + return; - pBind = pBind->pImpl->pSubBindings; - } + SfxBindings* pBind = pDisp->GetBindings(); + while ( pBind && pBind != this ) + { + if ( !pBind->pImpl->pSubBindings ) + { + pBind->SetSubBindings_Impl( this ); + break; } + + pBind = pBind->pImpl->pSubBindings; } } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index b505412d3b4f..06c04362f763 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -314,72 +314,72 @@ void SfxDispatcher::Call_Impl(SfxShell& rShell, const SfxSlot &rSlot, SfxRequest SFX_STACK(SfxDispatcher::Call_Impl); // The slot may be called (meaning enabled) - if ( rSlot.IsMode(SfxSlotMode::FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) || rShell.IsConditionalFastCall(rReq)) + if ( !rSlot.IsMode(SfxSlotMode::FASTCALL) && !rShell.CanExecuteSlot_Impl(rSlot) && !rShell.IsConditionalFastCall(rReq) ) + return; + + if ( GetFrame() ) { - if ( GetFrame() ) - { - // Recording may start - css::uno::Reference< css::frame::XFrame > xFrame( - GetFrame()->GetFrame().GetFrameInterface(), - css::uno::UNO_QUERY); + // Recording may start + css::uno::Reference< css::frame::XFrame > xFrame( + GetFrame()->GetFrame().GetFrameInterface(), + css::uno::UNO_QUERY); - css::uno::Reference< css::beans::XPropertySet > xSet( - xFrame, - css::uno::UNO_QUERY); + css::uno::Reference< css::beans::XPropertySet > xSet( + xFrame, + css::uno::UNO_QUERY); - if ( xSet.is() ) - { - css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier"); - css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; - css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; - aProp >>= xSupplier; - if(xSupplier.is()) - xRecorder = xSupplier->getDispatchRecorder(); - - if ( bRecord && xRecorder.is() && !rSlot.IsMode(SfxSlotMode::NORECORD) ) - rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() ); - } + if ( xSet.is() ) + { + css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier"); + css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier; + css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; + aProp >>= xSupplier; + if(xSupplier.is()) + xRecorder = xSupplier->getDispatchRecorder(); + + if ( bRecord && xRecorder.is() && !rSlot.IsMode(SfxSlotMode::NORECORD) ) + rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() ); } - // Get all that is needed, because the slot may not have survived the - // Execute if it is a 'pseudo slot' for macros or verbs. - bool bAutoUpdate = rSlot.IsMode(SfxSlotMode::AUTOUPDATE); + } + // Get all that is needed, because the slot may not have survived the + // Execute if it is a 'pseudo slot' for macros or verbs. + bool bAutoUpdate = rSlot.IsMode(SfxSlotMode::AUTOUPDATE); - // API-call parentheses and document-lock during the calls - { - // 'this' must respond in the Destructor - bool bThisDispatcherAlive = true; - bool *pOldInCallAliveFlag = xImp->pInCallAliveFlag; - xImp->pInCallAliveFlag = &bThisDispatcherAlive; + // API-call parentheses and document-lock during the calls + { + // 'this' must respond in the Destructor + bool bThisDispatcherAlive = true; + bool *pOldInCallAliveFlag = xImp->pInCallAliveFlag; + xImp->pInCallAliveFlag = &bThisDispatcherAlive; - SfxExecFunc pFunc = rSlot.GetExecFnc(); - rShell.CallExec( pFunc, rReq ); + SfxExecFunc pFunc = rSlot.GetExecFnc(); + rShell.CallExec( pFunc, rReq ); - // If 'this' is still alive - if ( bThisDispatcherAlive ) - xImp->pInCallAliveFlag = pOldInCallAliveFlag; - else + // If 'this' is still alive + if ( bThisDispatcherAlive ) + xImp->pInCallAliveFlag = pOldInCallAliveFlag; + else + { + if ( pOldInCallAliveFlag ) { - if ( pOldInCallAliveFlag ) - { - // also protect nested stack frames - *pOldInCallAliveFlag = false; - } - - // do nothing after this object is dead - return; + // also protect nested stack frames + *pOldInCallAliveFlag = false; } + + // do nothing after this object is dead + return; } + } - if ( rReq.IsDone() ) - { - SfxBindings *pBindings = GetBindings(); + if ( rReq.IsDone() ) + { + SfxBindings *pBindings = GetBindings(); - // When AutoUpdate update immediately - if ( bAutoUpdate && pBindings ) - { - pBindings->Invalidate(rSlot.GetSlotId()); - pBindings->Update(rSlot.GetSlotId()); - } + // When AutoUpdate update immediately + if ( bAutoUpdate && pBindings ) + { + pBindings->Invalidate(rSlot.GetSlotId()); + pBindings->Update(rSlot.GetSlotId()); } } } @@ -1075,58 +1075,58 @@ void SfxDispatcher::PostMsgHandler(std::unique_ptr<SfxRequest> pReq) SFX_STACK(SfxDispatcher::PostMsgHandler); // Has also the Pool not yet died? - if ( !pReq->IsCancelled() ) + if ( pReq->IsCancelled() ) + return; + + if ( !IsLocked() ) { - if ( !IsLocked() ) + Flush(); + SfxSlotServer aSvr; + if ( FindServer_(pReq->GetSlot(), aSvr ) ) // HACK(x), whatever that was supposed to mean { - Flush(); - SfxSlotServer aSvr; - if ( FindServer_(pReq->GetSlot(), aSvr ) ) // HACK(x), whatever that was supposed to mean - { - const SfxSlot *pSlot = aSvr.GetSlot(); - SfxShell *pSh = GetShell(aSvr.GetShellLevel()); + const SfxSlot *pSlot = aSvr.GetSlot(); + SfxShell *pSh = GetShell(aSvr.GetShellLevel()); - // When the pSlot is a "Pseudoslot" for macros or Verbs, it can - // be destroyed in the Call_Impl, thus do not use it anymore! - pReq->SetSynchronCall( false ); - Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why bRecord? - } + // When the pSlot is a "Pseudoslot" for macros or Verbs, it can + // be destroyed in the Call_Impl, thus do not use it anymore! + pReq->SetSynchronCall( false ); + Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why bRecord? } + } + else + { + if ( xImp->bLocked ) + xImp->aReqArr.emplace_back(std::move(pReq)); else - { - if ( xImp->bLocked ) - xImp->aReqArr.emplace_back(std::move(pReq)); - else - xImp->xPoster->Post(std::move(pReq)); - } + xImp->xPoster->Post(std::move(pReq)); } } void SfxDispatcher::SetMenu_Impl() { #if HAVE_FEATURE_DESKTOP - if ( xImp->pFrame ) + if ( !xImp->pFrame ) + return; + + SfxViewFrame* pTop = xImp->pFrame->GetTopViewFrame(); + if ( !pTop || pTop->GetBindings().GetDispatcher() != this ) + return; + + SfxFrame& rFrame = pTop->GetFrame(); + if ( !rFrame.IsMenuBarOn_Impl() ) + return; + + css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), css::uno::UNO_QUERY ); + if ( xPropSet.is() ) { - SfxViewFrame* pTop = xImp->pFrame->GetTopViewFrame(); - if ( pTop && pTop->GetBindings().GetDispatcher() == this ) + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); + aValue >>= xLayoutManager; + if ( xLayoutManager.is() ) { - SfxFrame& rFrame = pTop->GetFrame(); - if ( rFrame.IsMenuBarOn_Impl() ) - { - css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), css::uno::UNO_QUERY ); - if ( xPropSet.is() ) - { - css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; - css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager"); - aValue >>= xLayoutManager; - if ( xLayoutManager.is() ) - { - OUString aMenuBarURL( "private:resource/menubar/menubar" ); - if ( !xLayoutManager->isElementVisible( aMenuBarURL ) ) - xLayoutManager->createElement( aMenuBarURL ); - } - } - } + OUString aMenuBarURL( "private:resource/menubar/menubar" ); + if ( !xLayoutManager->isElementVisible( aMenuBarURL ) ) + xLayoutManager->createElement( aMenuBarURL ); } } #endif @@ -1360,22 +1360,22 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne } } - if ( pTaskWin && ( bIsMDIApp || bIsIPOwner ) ) - { - bool bIsTaskActive = false; + if ( !pTaskWin || ( !bIsMDIApp && !bIsIPOwner ) ) + return; - SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl(); - if ( pActDispatcher && !bIsTaskActive ) - { - if ( this == pActDispatcher ) - bIsTaskActive = true; - } + bool bIsTaskActive = false; - if (bIsTaskActive && eStatBarId != StatusBarId::None && xImp->pFrame) - { - // internal frames also may control statusbar - xImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl(eStatBarId); - } + SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl(); + if ( pActDispatcher && !bIsTaskActive ) + { + if ( this == pActDispatcher ) + bIsTaskActive = true; + } + + if (bIsTaskActive && eStatBarId != StatusBarId::None && xImp->pFrame) + { + // internal frames also may control statusbar + xImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl(eStatBarId); } } diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx index 361ea310f929..bee417f91c7f 100644 --- a/sfx2/source/control/recentdocsviewitem.cxx +++ b/sfx2/source/control/recentdocsviewitem.cxx @@ -205,19 +205,19 @@ void RecentDocsViewItem::OpenDocument() xDispatch = xDispatchProvider->queryDispatch(aTargetURL, "_default", 0); - if (xDispatch.is()) - { - // Call dispatch asynchronously as we can be destroyed while dispatch is - // executed. VCL is not able to survive this as it wants to call listeners - // after select!!! - sfx2::LoadRecentFile *const pLoadRecentFile = new sfx2::LoadRecentFile; - pLoadRecentFile->xDispatch = xDispatch; - pLoadRecentFile->aTargetURL = aTargetURL; - pLoadRecentFile->aArgSeq = aArgsList; - pLoadRecentFile->pView.set(&mrParent); - - Application::PostUserEvent(LINK(nullptr, sfx2::RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true); - } + if (!xDispatch.is()) + return; + + // Call dispatch asynchronously as we can be destroyed while dispatch is + // executed. VCL is not able to survive this as it wants to call listeners + // after select!!! + sfx2::LoadRecentFile *const pLoadRecentFile = new sfx2::LoadRecentFile; + pLoadRecentFile->xDispatch = xDispatch; + pLoadRecentFile->aTargetURL = aTargetURL; + pLoadRecentFile->aArgSeq = aArgsList; + pLoadRecentFile->pView.set(&mrParent); + + Application::PostUserEvent(LINK(nullptr, sfx2::RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index dbe72939e288..830579b306cb 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -157,20 +157,20 @@ SfxRequest::SfxRequest pImpl->SetPool( rOrig.pImpl->pPool ); // setup macro recording if it was in the original SfxRequest - if (rOrig.pImpl->pViewFrame && rOrig.pImpl->xRecorder.is()) + if (!rOrig.pImpl->pViewFrame || !rOrig.pImpl->xRecorder.is()) + return; + + nSlot = rOrig.nSlot; + pImpl->pViewFrame = rOrig.pImpl->pViewFrame; + if (pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(nSlot, &pImpl->pShell, &pImpl->pSlot, true, true)) { - nSlot = rOrig.nSlot; - pImpl->pViewFrame = rOrig.pImpl->pViewFrame; - if (pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(nSlot, &pImpl->pShell, &pImpl->pSlot, true, true)) - { - pImpl->SetPool( &pImpl->pShell->GetPool() ); - pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame); - pImpl->aTarget = pImpl->pShell->GetName(); - } - else - { - SAL_WARN("sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlot)); - } + pImpl->SetPool( &pImpl->pShell->GetPool() ); + pImpl->xRecorder = SfxRequest::GetMacroRecorder(pImpl->pViewFrame); + pImpl->aTarget = pImpl->pShell->GetName(); + } + else + { + SAL_WARN("sfx", "Recording unsupported slot: " << pImpl->pPool->GetSlotId(nSlot)); } } @@ -335,42 +335,42 @@ void SfxRequest_Impl::Record OUString aCommand(".uno:"); aCommand += OUString( pSlot->GetUnoName(), strlen( pSlot->GetUnoName() ), RTL_TEXTENCODING_UTF8 ); OUString aCmd( aCommand ); - if(xRecorder.is()) + if(!xRecorder.is()) + return; + + uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY ); + if ( xReplace.is() && aCmd == ".uno:InsertText" ) { - uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY ); - if ( xReplace.is() && aCmd == ".uno:InsertText" ) + sal_Int32 nCount = xReplace->getCount(); + if ( nCount ) { - sal_Int32 nCount = xReplace->getCount(); - if ( nCount ) + frame::DispatchStatement aStatement; + uno::Any aElement = xReplace->getByIndex(nCount-1); + if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd ) { - frame::DispatchStatement aStatement; - uno::Any aElement = xReplace->getByIndex(nCount-1); - if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd ) - { - OUString aStr; - OUString aNew; - aStatement.aArgs[0].Value >>= aStr; - rArgs[0].Value >>= aNew; - aStr += aNew; - aStatement.aArgs[0].Value <<= aStr; - aElement <<= aStatement; - xReplace->replaceByIndex( nCount-1, aElement ); - return; - } + OUString aStr; + OUString aNew; + aStatement.aArgs[0].Value >>= aStr; + rArgs[0].Value >>= aNew; + aStr += aNew; + aStatement.aArgs[0].Value <<= aStr; + aElement <<= aStatement; + xReplace->replaceByIndex( nCount-1, aElement ); + return; } } + } - uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); + uno::Reference< util::XURLTransformer > xTransform = util::URLTransformer::create( xContext ); - css::util::URL aURL; - aURL.Complete = aCmd; - xTransform->parseStrict(aURL); + css::util::URL aURL; + aURL.Complete = aCmd; + xTransform->parseStrict(aURL); - if (bDone) - xRecorder->recordDispatch(aURL,rArgs); - else - xRecorder->recordDispatchAsComment(aURL,rArgs); - } + if (bDone) + xRecorder->recordDispatch(aURL,rArgs); + else + xRecorder->recordDispatchAsComment(aURL,rArgs); } diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index cf370b7dd238..47ad3b43efb9 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -595,26 +595,26 @@ void SfxShell::VerbExec(SfxRequest& rReq) { sal_uInt16 nId = rReq.GetSlot(); SfxViewShell *pViewShell = GetViewShell(); - if ( pViewShell ) + if ( !pViewShell ) + return; + + bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); + css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); + for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) { - bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); - css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); - for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) - { - // check for ReadOnly verbs - if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) - continue; + // check for ReadOnly verbs + if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) + continue; - // check for verbs that shouldn't appear in the menu - if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) - continue; + // check for verbs that shouldn't appear in the menu + if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) + continue; - if (nId == SID_VERB_START + nVerb++) - { - pViewShell->DoVerb(aList[n].VerbID); - rReq.Done(); - return; - } + if (nId == SID_VERB_START + nVerb++) + { + pViewShell->DoVerb(aList[n].VerbID); + rReq.Done(); + return; } } } diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index a190168ea1ce..080d5275a107 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -329,46 +329,46 @@ void SfxStateCache::SetState void SfxStateCache::SetVisibleState( bool bShow ) { - if ( bShow != bItemVisible ) - { - SfxItemState eState( SfxItemState::DEFAULT ); - const SfxPoolItem* pState( nullptr ); - bool bDeleteItem( false ); + if ( bShow == bItemVisible ) + return; - bItemVisible = bShow; - if ( bShow ) - { - if ( IsInvalidItem(pLastItem) || ( pLastItem == nullptr )) - { - pState = new SfxVoidItem( nId ); - bDeleteItem = true; - } - else - pState = pLastItem; + SfxItemState eState( SfxItemState::DEFAULT ); + const SfxPoolItem* pState( nullptr ); + bool bDeleteItem( false ); - eState = eLastState; - } - else + bItemVisible = bShow; + if ( bShow ) + { + if ( IsInvalidItem(pLastItem) || ( pLastItem == nullptr )) { - pState = new SfxVisibilityItem( nId, false ); + pState = new SfxVoidItem( nId ); bDeleteItem = true; } + else + pState = pLastItem; - // Update Controller - if ( !mxDispatch.is() && pController ) - { - for ( SfxControllerItem *pCtrl = pController; - pCtrl; - pCtrl = pCtrl->GetItemLink() ) - pCtrl->StateChanged( nId, eState, pState ); - } - - if ( pInternalController ) - pInternalController->StateChanged( nId, eState, pState ); + eState = eLastState; + } + else + { + pState = new SfxVisibilityItem( nId, false ); + bDeleteItem = true; + } - if ( bDeleteItem ) - delete pState; + // Update Controller + if ( !mxDispatch.is() && pController ) + { + for ( SfxControllerItem *pCtrl = pController; + pCtrl; + pCtrl = pCtrl->GetItemLink() ) + pCtrl->StateChanged( nId, eState, pState ); } + + if ( pInternalController ) + pInternalController->StateChanged( nId, eState, pState ); + + if ( bDeleteItem ) + delete pState; } @@ -439,23 +439,23 @@ void SfxStateCache::SetCachedState( bool bAlways ) // Only update if cached item exists and also able to process. // (If the State is sent, it must be ensured that a SlotServer is present, // see SfxControllerItem:: GetCoreMetric()) - if ( bAlways || ( !bItemDirty && !bSlotDirty ) ) + if ( !(bAlways || ( !bItemDirty && !bSlotDirty )) ) + return; + + // Update Controller + if ( !mxDispatch.is() && pController ) { - // Update Controller - if ( !mxDispatch.is() && pController ) - { - for ( SfxControllerItem *pCtrl = pController; - pCtrl; - pCtrl = pCtrl->GetItemLink() ) - pCtrl->StateChanged( nId, eLastState, pLastItem ); - } + for ( SfxControllerItem *pCtrl = pController; + pCtrl; + pCtrl = pCtrl->GetItemLink() ) + pCtrl->StateChanged( nId, eLastState, pLastItem ); + } - if ( pInternalController ) - static_cast<SfxDispatchController_Impl *>(pInternalController)->StateChanged( nId, eLastState, pLastItem, &aSlotServ ); + if ( pInternalController ) + static_cast<SfxDispatchController_Impl *>(pInternalController)->StateChanged( nId, eLastState, pLastItem, &aSlotServ ); - // Controller is now ok - bCtrlDirty = true; - } + // Controller is now ok + bCtrlDirty = true; } diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 3ece5e8fe522..75d9296e390e 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -573,109 +573,109 @@ void TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s pTarget = pRegion.get(); } - if (pTarget) - { - bool refresh = false; + if (!pTarget) + return; - sal_uInt16 nTargetRegion = pTarget->mnRegionId; - sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx - std::vector<sal_uInt16> aItemIds; // List of moved items ids (also prevents the invalidation of rItems iterators when we remove them as we go) + bool refresh = false; + + sal_uInt16 nTargetRegion = pTarget->mnRegionId; + sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx + std::vector<sal_uInt16> aItemIds; // List of moved items ids (also prevents the invalidation of rItems iterators when we remove them as we go) - std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aSelIter; - for ( aSelIter = rItems.begin(); aSelIter != rItems.end(); ++aSelIter, ++nTargetIdx ) + std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aSelIter; + for ( aSelIter = rItems.begin(); aSelIter != rItems.end(); ++aSelIter, ++nTargetIdx ) + { + const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(*aSelIter); + sal_uInt16 nSrcRegionId = pViewItem->mnRegionId; + + for (auto const & pRegion : maRegions) { - const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(*aSelIter); - sal_uInt16 nSrcRegionId = pViewItem->mnRegionId; + if (pRegion->mnRegionId == nSrcRegionId) + pSrc = pRegion.get(); + } - for (auto const & pRegion : maRegions) - { - if (pRegion->mnRegionId == nSrcRegionId) - pSrc = pRegion.get(); - } + if(pSrc) + { + bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId); - if(pSrc) + if (bCopy) { - bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId); - - if (bCopy) + OUString sQuery = SfxResId(STR_MSG_QUERY_COPY).replaceFirst("$1", pViewItem->maTitle).replaceFirst("$2", + getRegionName(nTargetRegion)); + std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); + if (xQueryDlg->run() != RET_YES) { - OUString sQuery = SfxResId(STR_MSG_QUERY_COPY).replaceFirst("$1", pViewItem->maTitle).replaceFirst("$2", - getRegionName(nTargetRegion)); - std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); - if (xQueryDlg->run() != RET_YES) - { - OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); - sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion)); - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, sMsg.replaceFirst( "$2",pViewItem->maTitle))); - xBox->run(); + OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); + sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion)); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, sMsg.replaceFirst( "$2",pViewItem->maTitle))); + xBox->run(); - return; //return if any single move operation fails - } + return; //return if any single move operation fails + } - if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) - { - continue; - } + if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) + { + continue; } + } - // move template to destination + // move template to destination - TemplateItemProperties aTemplateItem; - aTemplateItem.nId = nTargetIdx + 1; - aTemplateItem.nDocId = nTargetIdx; - aTemplateItem.nRegionId = nTargetRegion; - aTemplateItem.aName = pViewItem->maTitle; - aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx); - aTemplateItem.aRegionName = pViewItem->maHelpText; - aTemplateItem.aThumbnail = pViewItem->maPreview1; + TemplateItemProperties aTemplateItem; + aTemplateItem.nId = nTargetIdx + 1; + aTemplateItem.nDocId = nTargetIdx; + aTemplateItem.nRegionId = nTargetRegion; + aTemplateItem.aName = pViewItem->maTitle; + aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx); + aTemplateItem.aRegionName = pViewItem->maHelpText; + aTemplateItem.aThumbnail = pViewItem->maPreview1; - pTarget->maTemplates.push_back(aTemplateItem); + pTarget->maTemplates.push_back(aTemplateItem); - if (!bCopy) - { - // remove template from region cached data + if (!bCopy) + { + // remove template from region cached data - std::vector<TemplateItemProperties>::iterator pPropIter; - for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();) + std::vector<TemplateItemProperties>::iterator pPropIter; + for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();) + { + if (pPropIter->nDocId == pViewItem->mnDocId) { - if (pPropIter->nDocId == pViewItem->mnDocId) - { - pPropIter = pSrc->maTemplates.erase(pPropIter); - aItemIds.push_back(pViewItem->mnDocId + 1);//mnid - } - else - { - // Keep region document id synchronized with SfxDocumentTemplates - if (pPropIter->nDocId > pViewItem->mnDocId) - --pPropIter->nDocId; - - ++pPropIter; - } + pPropIter = pSrc->maTemplates.erase(pPropIter); + aItemIds.push_back(pViewItem->mnDocId + 1);//mnid } - - // Keep view document id synchronized with SfxDocumentTemplates - for (auto const& item : mItemList) + else { - auto pTemplateViewItem = static_cast<TemplateViewItem*>(item.get()); - if (pTemplateViewItem->mnDocId > pViewItem->mnDocId) - --pTemplateViewItem->mnDocId; + // Keep region document id synchronized with SfxDocumentTemplates + if (pPropIter->nDocId > pViewItem->mnDocId) + --pPropIter->nDocId; + + ++pPropIter; } } - } - refresh = true; + // Keep view document id synchronized with SfxDocumentTemplates + for (auto const& item : mItemList) + { + auto pTemplateViewItem = static_cast<TemplateViewItem*>(item.get()); + if (pTemplateViewItem->mnDocId > pViewItem->mnDocId) + --pTemplateViewItem->mnDocId; + } + } } - // Remove items from the current view - for (auto const& itemId : aItemIds) - RemoveItem(itemId); + refresh = true; + } - if (refresh) - { - CalculateItemPositions(); - Invalidate(); - } + // Remove items from the current view + for (auto const& itemId : aItemIds) + RemoveItem(itemId); + + if (refresh) + { + CalculateItemPositions(); + Invalidate(); } } diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index e31b95e2226a..cea98594642b 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1069,54 +1069,54 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) return; ThumbnailViewItem* pItem = mFilteredItemList[nItemPos]; - if (!pItem->isSelected()) - { - pItem->setSelection(true); - maItemStateHdl.Call(pItem); + if (pItem->isSelected()) + return; - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(); + pItem->setSelection(true); + maItemStateHdl.Call(pItem); + + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); - bool bNewOut = IsReallyVisible() && IsUpdateMode(); + bool bNewOut = IsReallyVisible() && IsUpdateMode(); - // if necessary scroll to the visible area - if (mbScroll && nItemId && mnCols) + // if necessary scroll to the visible area + if (mbScroll && nItemId && mnCols) + { + sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols); + if ( nNewLine < mnFirstLine ) { - sal_uInt16 nNewLine = static_cast<sal_uInt16>(nItemPos / mnCols); - if ( nNewLine < mnFirstLine ) - { - mnFirstLine = nNewLine; - } - else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) ) - { - mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); - } + mnFirstLine = nNewLine; } - - if ( bNewOut ) + else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) ) { - if ( IsReallyVisible() && IsUpdateMode() ) - Invalidate(); + mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); } + } - if( ImplHasAccessibleListeners() ) - { - // focus event (select) - ThumbnailViewItemAcc* pItemAcc = ThumbnailViewItemAcc::getImplementation( pItem->GetAccessible( false ) ); + if ( bNewOut ) + { + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); + } - if( pItemAcc ) - { - css::uno::Any aOldAny, aNewAny; - aNewAny <<= css::uno::Reference< css::uno::XInterface >( - static_cast< ::cppu::OWeakObject* >( pItemAcc )); - ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); - } + if( !ImplHasAccessibleListeners() ) + return; - // selection event - css::uno::Any aOldAny, aNewAny; - ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); - } + // focus event (select) + ThumbnailViewItemAcc* pItemAcc = ThumbnailViewItemAcc::getImplementation( pItem->GetAccessible( false ) ); + + if( pItemAcc ) + { + css::uno::Any aOldAny, aNewAny; + aNewAny <<= css::uno::Reference< css::uno::XInterface >( + static_cast< ::cppu::OWeakObject* >( pItemAcc )); + ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); } + + // selection event + css::uno::Any aOldAny, aNewAny; + ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); } bool ThumbnailView::IsItemSelected( sal_uInt16 nItemId ) const diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index 7e1dde9ab9fa..1cb7a5e085c7 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -48,25 +48,25 @@ ThumbnailViewAcc::~ThumbnailViewAcc() void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue ) { - if( nEventId ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); - accessibility::AccessibleEventObject aEvtObject; + if( !nEventId ) + return; + + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); + accessibility::AccessibleEventObject aEvtObject; - aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<uno::XWeak*>(this); - aEvtObject.NewValue = rNewValue; - aEvtObject.OldValue = rOldValue; + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; - for (auto const& tmpListener : aTmpListeners) + for (auto const& tmpListener : aTmpListeners) + { + try + { + tmpListener->notifyEvent( aEvtObject ); + } + catch(const uno::Exception&) { - try - { - tmpListener->notifyEvent( aEvtObject ); - } - catch(const uno::Exception&) - { - } } } } @@ -265,22 +265,22 @@ void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference ThrowIfDisposed(); ::osl::MutexGuard aGuard (m_aMutex); - if( rxListener.is() ) - { - bool bFound = false; + if( !rxListener.is() ) + return; + + bool bFound = false; - for (auto const& eventListener : mxEventListeners) + for (auto const& eventListener : mxEventListeners) + { + if( eventListener == rxListener ) { - if( eventListener == rxListener ) - { - bFound = true; - break; - } + bFound = true; + break; } - - if (!bFound) - mxEventListeners.push_back( rxListener ); } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) @@ -743,22 +743,22 @@ void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Refer { const ::osl::MutexGuard aGuard( maMutex ); - if( rxListener.is() ) - { - bool bFound = false; + if( !rxListener.is() ) + return; + + bool bFound = false; - for (auto const& eventListener : mxEventListeners) + for (auto const& eventListener : mxEventListeners) + { + if( eventListener == rxListener ) { - if( eventListener == rxListener ) - { - bFound = true; - break; - } + bFound = true; + break; } - - if (!bFound) - mxEventListeners.push_back( rxListener ); } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index bba646d4ff53..e6a590a4053f 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -359,79 +359,79 @@ void SfxDispatchController_Impl::addParametersToArgs( const css::util::URL& aURL { // Extract the parameter from the URL and put them into the property value sequence sal_Int32 nQueryIndex = aURL.Complete.indexOf( '?' ); - if ( nQueryIndex > 0 ) + if ( nQueryIndex <= 0 ) + return; + + OUString aParamString( aURL.Complete.copy( nQueryIndex+1 )); + sal_Int32 nIndex = 0; + do { - OUString aParamString( aURL.Complete.copy( nQueryIndex+1 )); - sal_Int32 nIndex = 0; - do - { - OUString aToken = aParamString.getToken( 0, '&', nIndex ); + OUString aToken = aParamString.getToken( 0, '&', nIndex ); - sal_Int32 nParmIndex = 0; - OUString aParamType; - OUString aParamName = aToken.getToken( 0, '=', nParmIndex ); - OUString aValue = (nParmIndex!=-1) ? aToken.getToken( 0, '=', nParmIndex ) : OUString(); + sal_Int32 nParmIndex = 0; + OUString aParamType; + OUString aParamName = aToken.getToken( 0, '=', nParmIndex ); + OUString aValue = (nParmIndex!=-1) ? aToken.getToken( 0, '=', nParmIndex ) : OUString(); - if ( !aParamName.isEmpty() ) - { - nParmIndex = 0; - aToken = aParamName; - aParamName = aToken.getToken( 0, ':', nParmIndex ); - aParamType = (nParmIndex!=-1) ? aToken.getToken( 0, ':', nParmIndex ) : OUString(); - } + if ( !aParamName.isEmpty() ) + { + nParmIndex = 0; + aToken = aParamName; + aParamName = aToken.getToken( 0, ':', nParmIndex ); + aParamType = (nParmIndex!=-1) ? aToken.getToken( 0, ':', nParmIndex ) : OUString(); + } - sal_Int32 nLen = rArgs.getLength(); - rArgs.realloc( nLen+1 ); - rArgs[nLen].Name = aParamName; + sal_Int32 nLen = rArgs.getLength(); + rArgs.realloc( nLen+1 ); + rArgs[nLen].Name = aParamName; - if ( aParamType.isEmpty() ) - { - // Default: LONG - rArgs[nLen].Value <<= aValue.toInt32(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BOOL], 4 )) - { - // sal_Bool support - rArgs[nLen].Value <<= aValue.toBoolean(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BYTE], 4 )) - { - // sal_uInt8 support - rArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_LONG], 4 )) - { - // LONG support - rArgs[nLen].Value <<= aValue.toInt32(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_SHORT], 5 )) - { - // SHORT support - rArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_HYPER], 5 )) - { - // HYPER support - rArgs[nLen].Value <<= aValue.toInt64(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_FLOAT], 5 )) - { - // FLOAT support - rArgs[nLen].Value <<= aValue.toFloat(); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_STRING], 6 )) - { - // STRING support - rArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); - } - else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_DOUBLE], 6)) - { - // DOUBLE support - rArgs[nLen].Value <<= aValue.toDouble(); - } + if ( aParamType.isEmpty() ) + { + // Default: LONG + rArgs[nLen].Value <<= aValue.toInt32(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BOOL], 4 )) + { + // sal_Bool support + rArgs[nLen].Value <<= aValue.toBoolean(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BYTE], 4 )) + { + // sal_uInt8 support + rArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_LONG], 4 )) + { + // LONG support + rArgs[nLen].Value <<= aValue.toInt32(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_SHORT], 5 )) + { + // SHORT support + rArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_HYPER], 5 )) + { + // HYPER support + rArgs[nLen].Value <<= aValue.toInt64(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_FLOAT], 5 )) + { + // FLOAT support + rArgs[nLen].Value <<= aValue.toFloat(); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_STRING], 6 )) + { + // STRING support + rArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); + } + else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_DOUBLE], 6)) + { + // DOUBLE support + rArgs[nLen].Value <<= aValue.toDouble(); } - while ( nIndex >= 0 ); } + while ( nIndex >= 0 ); } MapUnit SfxDispatchController_Impl::GetCoreMetric( SfxItemPool const & rPool, sal_uInt16 nSlotId ) @@ -612,201 +612,201 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, SolarMutexGuard aGuard; if ( - pDispatch && + !(pDispatch && ( (aURL.Protocol == ".uno:" && aURL.Path == aDispatchURL.Path) || (aURL.Protocol == "slot:" && aURL.Path.toInt32() == GetId()) - ) + )) ) - { - if ( !pDispatcher && pBindings ) - pDispatcher = GetBindings().GetDispatcher_Impl(); + return; + + if ( !pDispatcher && pBindings ) + pDispatcher = GetBindings().GetDispatcher_Impl(); - css::uno::Sequence< css::beans::PropertyValue > lNewArgs; - sal_Int32 nCount = aArgs.getLength(); + css::uno::Sequence< css::beans::PropertyValue > lNewArgs; + sal_Int32 nCount = aArgs.getLength(); - // Support for URL based arguments - INetURLObject aURLObj( aURL.Complete ); - if ( aURLObj.HasParam() ) - addParametersToArgs( aURL, lNewArgs ); + // Support for URL based arguments + INetURLObject aURLObj( aURL.Complete ); + if ( aURLObj.HasParam() ) + addParametersToArgs( aURL, lNewArgs ); - // Try to find call mode and frame name inside given arguments... - SfxCallMode nCall = SfxCallMode::RECORD; - sal_Int32 nMarkArg = -1; + // Try to find call mode and frame name inside given arguments... + SfxCallMode nCall = SfxCallMode::RECORD; + sal_Int32 nMarkArg = -1; - // Filter arguments which shouldn't be part of the sequence property value - sal_uInt16 nModifier(0); - std::vector< css::beans::PropertyValue > aAddArgs; - for( sal_Int32 n=0; n<nCount; n++ ) + // Filter arguments which shouldn't be part of the sequence property value + sal_uInt16 nModifier(0); + std::vector< css::beans::PropertyValue > aAddArgs; + for( sal_Int32 n=0; n<nCount; n++ ) + { + const css::beans::PropertyValue& rProp = aArgs[n]; + if( rProp.Name == "SynchronMode" ) { - const css::beans::PropertyValue& rProp = aArgs[n]; - if( rProp.Name == "SynchronMode" ) - { - bool bTemp; - if( rProp.Value >>= bTemp ) - nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON; - } - else if( rProp.Name == "Bookmark" ) - { - nMarkArg = n; - aAddArgs.push_back( aArgs[n] ); - } - else if( rProp.Name == "KeyModifier" ) - rProp.Value >>= nModifier; - else - aAddArgs.push_back( aArgs[n] ); + bool bTemp; + if( rProp.Value >>= bTemp ) + nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON; } - - // Add needed arguments to sequence property value - sal_uInt32 nAddArgs = aAddArgs.size(); - if ( nAddArgs > 0 ) + else if( rProp.Name == "Bookmark" ) { - sal_uInt32 nIndex( lNewArgs.getLength() ); - - lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() ); - for ( sal_uInt32 i = 0; i < nAddArgs; i++ ) - lNewArgs[nIndex++] = aAddArgs[i]; + nMarkArg = n; + aAddArgs.push_back( aArgs[n] ); } + else if( rProp.Name == "KeyModifier" ) + rProp.Value >>= nModifier; + else + aAddArgs.push_back( aArgs[n] ); + } - // Overwrite possible detected synchron argument, if real listener exists (currently no other way) - if ( rListener.is() ) - nCall = SfxCallMode::SYNCHRON; + // Add needed arguments to sequence property value + sal_uInt32 nAddArgs = aAddArgs.size(); + if ( nAddArgs > 0 ) + { + sal_uInt32 nIndex( lNewArgs.getLength() ); - if( GetId() == SID_JUMPTOMARK && nMarkArg == - 1 ) - { - // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document - // so we must retrieve this as an argument from the parsed URL - lNewArgs.realloc( lNewArgs.getLength()+1 ); - nMarkArg = lNewArgs.getLength()-1; - lNewArgs[nMarkArg].Name = "Bookmark"; - lNewArgs[nMarkArg].Value <<= aURL.Mark; - } + lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() ); + for ( sal_uInt32 i = 0; i < nAddArgs; i++ ) + lNewArgs[nIndex++] = aAddArgs[i]; + } - css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY); - if (! xFrameRef.is() && pDispatcher) - { - SfxViewFrame* pViewFrame = pDispatcher->GetFrame(); - if (pViewFrame) - xFrameRef = pViewFrame->GetFrame().GetFrameInterface(); - } + // Overwrite possible detected synchron argument, if real listener exists (currently no other way) + if ( rListener.is() ) + nCall = SfxCallMode::SYNCHRON; - bool bSuccess = false; - const SfxPoolItem* pItem = nullptr; - MapUnit eMapUnit( MapUnit::Map100thMM ); + if( GetId() == SID_JUMPTOMARK && nMarkArg == - 1 ) + { + // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document + // so we must retrieve this as an argument from the parsed URL + lNewArgs.realloc( lNewArgs.getLength()+1 ); + nMarkArg = lNewArgs.getLength()-1; + lNewArgs[nMarkArg].Name = "Bookmark"; + lNewArgs[nMarkArg].Value <<= aURL.Mark; + } - // Extra scope so that aInternalSet is destroyed before - // rListener->dispatchFinished potentially calls - // framework::Desktop::terminate -> SfxApplication::Deinitialize -> - // ~CntItemPool: - if (pDispatcher) - { - SfxAllItemSet aInternalSet( SfxGetpApp()->GetPool() ); - if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem ! - aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) ); + css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY); + if (! xFrameRef.is() && pDispatcher) + { + SfxViewFrame* pViewFrame = pDispatcher->GetFrame(); + if (pViewFrame) + xFrameRef = pViewFrame->GetFrame().GetFrameInterface(); + } - SfxShell* pShell( nullptr ); - // #i102619# Retrieve metric from shell before execution - the shell could be destroyed after execution - if ( pDispatcher->GetBindings() ) + bool bSuccess = false; + const SfxPoolItem* pItem = nullptr; + MapUnit eMapUnit( MapUnit::Map100thMM ); + + // Extra scope so that aInternalSet is destroyed before + // rListener->dispatchFinished potentially calls + // framework::Desktop::terminate -> SfxApplication::Deinitialize -> + // ~CntItemPool: + if (pDispatcher) + { + SfxAllItemSet aInternalSet( SfxGetpApp()->GetPool() ); + if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem ! + aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) ); + + SfxShell* pShell( nullptr ); + // #i102619# Retrieve metric from shell before execution - the shell could be destroyed after execution + if ( pDispatcher->GetBindings() ) + { + if ( !pDispatcher->IsLocked() ) { - if ( !pDispatcher->IsLocked() ) + const SfxSlot *pSlot = nullptr; + if ( pDispatcher->GetShellAndSlot_Impl( GetId(), &pShell, &pSlot, false, false ) ) { - const SfxSlot *pSlot = nullptr; - if ( pDispatcher->GetShellAndSlot_Impl( GetId(), &pShell, &pSlot, false, false ) ) + if ( bMasterSlave ) { - if ( bMasterSlave ) - { - // Extract slave command and add argument to the args list. Master slot MUST - // have a argument that has the same name as the master slot and type is SfxStringItem. - sal_Int32 nIndex = lNewArgs.getLength(); - lNewArgs.realloc( nIndex+1 ); - lNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); - lNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); - } + // Extract slave command and add argument to the args list. Master slot MUST + // have a argument that has the same name as the master slot and type is SfxStringItem. + sal_Int32 nIndex = lNewArgs.getLength(); + lNewArgs.realloc( nIndex+1 ); + lNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); + lNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); + } - eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); - std::unique_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); - TransformParameters(GetId(), lNewArgs, *xSet, pSlot); - if (xSet->Count()) - { - // execute with arguments - call directly - pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); - if ( pItem != nullptr ) - { - if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) - bSuccess = pBoolItem->GetValue(); - else if ( !pItem->IsVoidItem() ) - bSuccess = true; // all other types are true - } - // else bSuccess = false look to line 664 it is false - } - else + eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); + std::unique_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); + TransformParameters(GetId(), lNewArgs, *xSet, pSlot); + if (xSet->Count()) + { + // execute with arguments - call directly + pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); + if ( pItem != nullptr ) { - // Be sure to delete this before we send a dispatch - // request, which will destroy the current shell. - xSet.reset(); - - // execute using bindings, enables support for toggle/enum etc. - SfxRequest aReq( GetId(), nCall, pShell->GetPool() ); - aReq.SetModifier( nModifier ); - aReq.SetInternalArgs_Impl(aInternalSet); - pDispatcher->GetBindings()->Execute_Impl( aReq, pSlot, pShell ); - pItem = aReq.GetReturnValue(); - bSuccess = aReq.IsDone() || pItem != nullptr; + if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) + bSuccess = pBoolItem->GetValue(); + else if ( !pItem->IsVoidItem() ) + bSuccess = true; // all other types are true } + // else bSuccess = false look to line 664 it is false } else - SAL_INFO("sfx.control", "MacroPlayer: Unknown slot dispatched!"); - } - } - else - { - eMapUnit = GetCoreMetric( SfxGetpApp()->GetPool(), GetId() ); - // AppDispatcher - SfxAllItemSet aSet( SfxGetpApp()->GetPool() ); - TransformParameters( GetId(), lNewArgs, aSet ); - - if ( aSet.Count() ) - pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier); - else - // SfxRequests take empty sets as argument sets, GetArgs() returning non-zero! - pItem = pDispatcher->Execute(GetId(), nCall, nullptr, &aInternalSet, nModifier); - - // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) - if (SfxApplication* pApp = SfxApplication::Get()) - { - SfxDispatcher* pAppDispat = pApp->GetAppDispatcher_Impl(); - if ( pAppDispat ) { - const SfxPoolItem* pState=nullptr; - SfxItemState eState = pDispatcher->QueryState( GetId(), pState ); - StateChanged( GetId(), eState, pState ); + // Be sure to delete this before we send a dispatch + // request, which will destroy the current shell. + xSet.reset(); + + // execute using bindings, enables support for toggle/enum etc. + SfxRequest aReq( GetId(), nCall, pShell->GetPool() ); + aReq.SetModifier( nModifier ); + aReq.SetInternalArgs_Impl(aInternalSet); + pDispatcher->GetBindings()->Execute_Impl( aReq, pSlot, pShell ); + pItem = aReq.GetReturnValue(); + bSuccess = aReq.IsDone() || pItem != nullptr; } } - - bSuccess = (pItem != nullptr); + else + SAL_INFO("sfx.control", "MacroPlayer: Unknown slot dispatched!"); } } - - if ( rListener.is() ) + else { - css::frame::DispatchResultEvent aEvent; - if ( bSuccess ) - aEvent.State = css::frame::DispatchResultState::SUCCESS; + eMapUnit = GetCoreMetric( SfxGetpApp()->GetPool(), GetId() ); + // AppDispatcher + SfxAllItemSet aSet( SfxGetpApp()->GetPool() ); + TransformParameters( GetId(), lNewArgs, aSet ); + + if ( aSet.Count() ) + pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier); else - aEvent.State = css::frame::DispatchResultState::FAILURE; + // SfxRequests take empty sets as argument sets, GetArgs() returning non-zero! + pItem = pDispatcher->Execute(GetId(), nCall, nullptr, &aInternalSet, nModifier); - aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - if ( bSuccess && pItem && !pItem->IsVoidItem() ) + // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) + if (SfxApplication* pApp = SfxApplication::Get()) { - sal_uInt16 nSubId( 0 ); - if ( eMapUnit == MapUnit::MapTwip ) - nSubId |= CONVERT_TWIPS; - pItem->QueryValue( aEvent.Result, static_cast<sal_uInt8>(nSubId) ); + SfxDispatcher* pAppDispat = pApp->GetAppDispatcher_Impl(); + if ( pAppDispat ) + { + const SfxPoolItem* pState=nullptr; + SfxItemState eState = pDispatcher->QueryState( GetId(), pState ); + StateChanged( GetId(), eState, pState ); + } } - rListener->dispatchFinished( aEvent ); + bSuccess = (pItem != nullptr); } } + + if ( !rListener.is() ) + return; + + css::frame::DispatchResultEvent aEvent; + if ( bSuccess ) + aEvent.State = css::frame::DispatchResultState::SUCCESS; + else + aEvent.State = css::frame::DispatchResultState::FAILURE; + + aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); + if ( bSuccess && pItem && !pItem->IsVoidItem() ) + { + sal_uInt16 nSubId( 0 ); + if ( eMapUnit == MapUnit::MapTwip ) + nSubId |= CONVERT_TWIPS; + pItem->QueryValue( aEvent.Result, static_cast<sal_uInt8>(nSubId) ); + } + + rListener->dispatchFinished( aEvent ); } SfxDispatcher* SfxDispatchController_Impl::GetDispatcher() @@ -909,57 +909,57 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt pLastState = pState; } - if (bNotify) - { - css::uno::Any aState; - if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->IsVoidItem() ) - { - // Retrieve metric from pool to have correct sub ID when calling QueryValue - sal_uInt16 nSubId( 0 ); - MapUnit eMapUnit( MapUnit::Map100thMM ); - - // retrieve the core metric - // it's enough to check the objectshell, the only shell that does not use the pool of the document - // is SfxViewFrame, but it hasn't any metric parameters - // TODO/LATER: what about the FormShell? Does it use any metric data?! Perhaps it should use the Pool of the document! - if ( pSlotServ && pDispatcher ) - { - SfxShell* pShell = pDispatcher->GetShell( pSlotServ->GetShellLevel() ); - DBG_ASSERT( pShell, "Can't get core metric without shell!" ); - if ( pShell ) - eMapUnit = GetCoreMetric( pShell->GetPool(), nSID ); - } + if (!bNotify) + return; - if ( eMapUnit == MapUnit::MapTwip ) - nSubId |= CONVERT_TWIPS; + css::uno::Any aState; + if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->IsVoidItem() ) + { + // Retrieve metric from pool to have correct sub ID when calling QueryValue + sal_uInt16 nSubId( 0 ); + MapUnit eMapUnit( MapUnit::Map100thMM ); - pState->QueryValue( aState, static_cast<sal_uInt8>(nSubId) ); - } - else if ( eState == SfxItemState::DONTCARE ) + // retrieve the core metric + // it's enough to check the objectshell, the only shell that does not use the pool of the document + // is SfxViewFrame, but it hasn't any metric parameters + // TODO/LATER: what about the FormShell? Does it use any metric data?! Perhaps it should use the Pool of the document! + if ( pSlotServ && pDispatcher ) { - // Use special uno struct to transport don't care state - css::frame::status::ItemStatus aItemStatus; - aItemStatus.State = css::frame::status::ItemState::DONT_CARE; - aState <<= aItemStatus; + SfxShell* pShell = pDispatcher->GetShell( pSlotServ->GetShellLevel() ); + DBG_ASSERT( pShell, "Can't get core metric without shell!" ); + if ( pShell ) + eMapUnit = GetCoreMetric( pShell->GetPool(), nSID ); } - css::frame::FeatureStateEvent aEvent; - aEvent.FeatureURL = aDispatchURL; - aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - aEvent.IsEnabled = eState != SfxItemState::DISABLED; - aEvent.Requery = false; - aEvent.State = aState; + if ( eMapUnit == MapUnit::MapTwip ) + nSubId |= CONVERT_TWIPS; - if (pDispatcher && pDispatcher->GetFrame()) - { - InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent, pState); - } + pState->QueryValue( aState, static_cast<sal_uInt8>(nSubId) ); + } + else if ( eState == SfxItemState::DONTCARE ) + { + // Use special uno struct to transport don't care state + css::frame::status::ItemStatus aItemStatus; + aItemStatus.State = css::frame::status::ItemState::DONT_CARE; + aState <<= aItemStatus; + } - for (const OUString& rName: pDispatch->GetListeners().getContainedTypes()) - { - if (rName == aDispatchURL.Main || rName == aDispatchURL.Complete) - sendStatusChanged(rName, aEvent); - } + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL = aDispatchURL; + aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); + aEvent.IsEnabled = eState != SfxItemState::DISABLED; + aEvent.Requery = false; + aEvent.State = aState; + + if (pDispatcher && pDispatcher->GetFrame()) + { + InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent, pState); + } + + for (const OUString& rName: pDispatch->GetListeners().getContainedTypes()) + { + if (rName == aDispatchURL.Main || rName == aDispatchURL.Complete) + sendStatusChanged(rName, aEvent); } } |