From 9c0049cfae49c8e4ddef9125a69db2ad134c10c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 13:48:25 +0200 Subject: Merging upstream version 4:24.2.4. Signed-off-by: Daniel Baumann --- sfx2/source/appl/shutdowniconw32.cxx | 15 +++++++------ sfx2/source/control/bindings.cxx | 3 +++ sfx2/source/control/dispatch.cxx | 16 ++++++++------ sfx2/source/doc/graphhelp.cxx | 41 ++++++++++++++++++------------------ sfx2/source/doc/syspathw32.cxx | 21 +++++++++--------- sfx2/source/view/viewfrm.cxx | 4 ++-- 6 files changed, 54 insertions(+), 46 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 2fb7cd2b78..a237aac135 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -681,15 +681,16 @@ static OUString SHGetSpecialFolder( int nFolderID ) if( hHdl == NOERROR ) { - WCHAR *lpFolderA; - lpFolderA = ALLOC( WCHAR, 16000 ); - - SHGetPathFromIDListW( pidl, lpFolderA ); - aFolder = o3tl::toU( lpFolderA ); + if (WCHAR *lpFolderA = ALLOC(WCHAR, 16000)) + { + SHGetPathFromIDListW(pidl, lpFolderA); + aFolder = o3tl::toU(lpFolderA); - FREE( lpFolderA ); - SHFree_( pidl ); + FREE(lpFolderA); + SHFree_(pidl); + } } + return aFolder; } diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 47ddda2813..8beca9364e 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -945,6 +945,9 @@ SfxPoolItemHolder SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem** if ( dynamic_cast< const SfxModule *>( pShell ) == nullptr && dynamic_cast< const SfxApplication *>( pShell ) == nullptr && dynamic_cast< const SfxViewFrame *>( pShell ) == nullptr ) return SfxPoolItemHolder(); + if (!pShell) + return SfxPoolItemHolder(); + SfxItemPool &rPool = pShell->GetPool(); SfxRequest aReq( nId, nCallMode, rPool ); aReq.SetModifier( nModi ); diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index fe7271677f..bedad9a624 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -707,7 +707,7 @@ bool SfxDispatcher::GetShellAndSlot_Impl(sal_uInt16 nSlot, SfxShell** ppShell, *ppShell = GetShell(aSvr.GetShellLevel()); *ppSlot = aSvr.GetSlot(); - if ( nullptr == (*ppSlot)->GetExecFnc() && bRealSlot ) + if ( nullptr == (*ppSlot)->GetExecFnc() && bRealSlot && *ppShell ) *ppSlot = (*ppShell)->GetInterface()->GetRealSlot(*ppSlot); // Check only real slots as enum slots don't have an execute function! return !bRealSlot || ((nullptr != *ppSlot) && (nullptr != (*ppSlot)->GetExecFnc()) ); @@ -986,13 +986,15 @@ void SfxDispatcher::PostMsgHandler(std::unique_ptr pReq) 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()); + if (SfxShell *pSh = GetShell(aSvr.GetShellLevel())) + { + const SfxSlot *pSlot = aSvr.GetSlot(); - // 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 diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 7cfdf76fe6..9d7600ae2d 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -128,28 +128,29 @@ void* GraphicHelper::getWinMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta, co if ( hMemory ) { - METAFILEPICT* pMF = static_cast(GlobalLock( hMemory )); - - pMF->hMF = hMeta; - pMF->mm = MM_ANISOTROPIC; - - MapMode aWinMode( MapUnit::Map100thMM ); - - if ( aWinMode == pGDIMeta->GetPrefMapMode() ) + if (METAFILEPICT* pMF = static_cast(GlobalLock(hMemory))) { - pMF->xExt = aMetaSize.Width(); - pMF->yExt = aMetaSize.Height(); + pMF->hMF = hMeta; + pMF->mm = MM_ANISOTROPIC; + + MapMode aWinMode( MapUnit::Map100thMM ); + + if ( aWinMode == pGDIMeta->GetPrefMapMode() ) + { + pMF->xExt = aMetaSize.Width(); + pMF->yExt = aMetaSize.Height(); + } + else + { + Size aWinSize = OutputDevice::LogicToLogic( Size( aMetaSize.Width(), aMetaSize.Height() ), + pGDIMeta->GetPrefMapMode(), + aWinMode ); + pMF->xExt = aWinSize.Width(); + pMF->yExt = aWinSize.Height(); + } + + GlobalUnlock(hMemory); } - else - { - Size aWinSize = OutputDevice::LogicToLogic( Size( aMetaSize.Width(), aMetaSize.Height() ), - pGDIMeta->GetPrefMapMode(), - aWinMode ); - pMF->xExt = aWinSize.Width(); - pMF->yExt = aWinSize.Height(); - } - - GlobalUnlock( hMemory ); pResult = static_cast(hMemory); } else diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index f60f459829..dce19e3625 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -37,17 +37,18 @@ static bool SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize ) if( hHdl == NOERROR ) { - WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 )); - - SHGetPathFromIDListW( pidl, lpFolder ); - wcsncpy( pszFolder, lpFolder, nSize ); - - HeapFree( GetProcessHeap(), 0, lpFolder ); - IMalloc *pMalloc; - if( NOERROR == SHGetMalloc(&pMalloc) ) + if (WCHAR *lpFolder = static_cast(HeapAlloc(GetProcessHeap(), 0, 16000))) { - pMalloc->Free( pidl ); - pMalloc->Release(); + SHGetPathFromIDListW( pidl, lpFolder ); + wcsncpy( pszFolder, lpFolder, nSize ); + + HeapFree( GetProcessHeap(), 0, lpFolder ); + IMalloc *pMalloc; + if( NOERROR == SHGetMalloc(&pMalloc) ) + { + pMalloc->Free( pidl ); + pMalloc->Release(); + } } } return true; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index b14ff206fa..202064f130 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1093,8 +1093,8 @@ void SfxViewFrame::PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ) if ( nLevel ) { // more sub shells on the stack, which were not affected by PopSubShells_Impl - SfxShell *pSubShell = m_pDispatcher->GetShell( nLevel-1 ); - m_pDispatcher->Pop( *pSubShell, SfxDispatcherPopFlags::POP_UNTIL | SfxDispatcherPopFlags::POP_DELETE ); + if (SfxShell *pSubShell = m_pDispatcher->GetShell( nLevel-1 )) + m_pDispatcher->Pop( *pSubShell, SfxDispatcherPopFlags::POP_UNTIL | SfxDispatcherPopFlags::POP_DELETE ); } m_pDispatcher->Pop( i_rViewShell ); m_pDispatcher->Flush(); -- cgit v1.2.3