sc/source/filter/excel/excrecds.cxx | 5 ++- sfx2/source/appl/appopen.cxx | 5 ++- sfx2/source/appl/shutdowniconw32.cxx | 15 +++++----- sfx2/source/doc/graphhelp.cxx | 41 ++++++++++++++--------------- sfx2/source/doc/objserv.cxx | 6 +++- sfx2/source/doc/syspathw32.cxx | 21 +++++++------- sfx2/source/notebookbar/SfxNotebookBar.cxx | 14 ++++++--- svx/source/dialog/optgrid.cxx | 24 +++++++++------- 8 files changed, 74 insertions(+), 57 deletions(-)
New commits: commit 35bdc8b0014b1a9a97ccf02fb670e3f8911a9f13 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed May 1 20:27:00 2024 +0100 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 6 23:30:16 2024 +0200 always check return of SfxViewFrame::Current() Change-Id: If35fe03c775aec12ec534d02d58596aebcec764f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166985 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit caf719c59c6dc8db2b6a0eab8d47760277f112a3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166902 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit cd7ee2410a42da4b702cb32f57e038ba7d9f0854) diff --git a/svx/source/dialog/optgrid.cxx b/svx/source/dialog/optgrid.cxx index 2226eaa4e23c..66ddc8c4e5e8 100644 --- a/svx/source/dialog/optgrid.cxx +++ b/svx/source/dialog/optgrid.cxx @@ -161,17 +161,19 @@ SvxGridTabPage::SvxGridTabPage(weld::Container* pPage, weld::DialogController* p if (m_Emode != HTML_MODE) { - SfxViewFrame* pCurrent = SfxViewFrame::Current(); - OUString aModuleName = vcl::CommandInfoProvider::GetModuleIdentifier(pCurrent->GetFrame().GetFrameInterface()); - std::u16string_view sModulename = aModuleName.subView(aModuleName.lastIndexOf('.') + 1); - if (sModulename.starts_with(u"Text")) - m_Emode = WRITER_MODE; - else if (sModulename.starts_with(u"Spreadsheet")) - m_Emode = CALC_MODE; - else if (sModulename.starts_with(u"Presentation")) - m_Emode = IMPRESS_MODE; - else if (sModulename.starts_with(u"Drawing")) - m_Emode = DRAW_MODE; + if (SfxViewFrame* pCurrent = SfxViewFrame::Current()) + { + OUString aModuleName = vcl::CommandInfoProvider::GetModuleIdentifier(pCurrent->GetFrame().GetFrameInterface()); + std::u16string_view sModulename = aModuleName.subView(aModuleName.lastIndexOf('.') + 1); + if (sModulename.starts_with(u"Text")) + m_Emode = WRITER_MODE; + else if (sModulename.starts_with(u"Spreadsheet")) + m_Emode = CALC_MODE; + else if (sModulename.starts_with(u"Presentation")) + m_Emode = IMPRESS_MODE; + else if (sModulename.starts_with(u"Drawing")) + m_Emode = DRAW_MODE; + } } m_xCbxRotate->connect_toggled(LINK(this, SvxGridTabPage, ClickRotateHdl_Impl)); commit 2217b2425f0b2d1ac62aa5dd096fb11df107d6f8 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Apr 26 10:20:56 2024 +0100 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 6 23:29:57 2024 +0200 SfxViewFrame::Current() dereferenced without null check found with msvc -analyze and _Ret_maybenull_ Change-Id: Ia377822e93448dc61acd1482d34167c35a46836b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166705 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 95d3e0d478686c7fa84f0bb8c466a1082333a47b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166830 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit b18b3b51a7d397a16e85bf8ba83b27193c7cc8c5) diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 4e1b06e52268..37c67e1ef293 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -1044,9 +1044,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if( aFileName.startsWith("#") ) // Mark without URL { SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : nullptr; - if ( !pView ) + if (!pView) pView = SfxViewFrame::Current(); - pView->GetViewShell()->JumpToMark( aFileName.copy(1) ); + if (pView) + pView->GetViewShell()->JumpToMark( aFileName.copy(1) ); rReq.SetReturnValue( SfxViewFrameItem( pView ) ); return; } diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index c37c53c427fd..0437204670c6 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -453,6 +453,10 @@ static void sendErrorToLOK(ErrCodeMsg error) if (error.GetCode().GetClass() == ErrCodeClass::NONE) return; + SfxViewShell* pNotifier = SfxViewShell::Current(); + if (!pNotifier) + return; + boost::property_tree::ptree aTree; aTree.put("code", error); aTree.put("kind", ""); @@ -465,7 +469,7 @@ static void sendErrorToLOK(ErrCodeMsg error) std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, OString(aStream.str())); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, OString(aStream.str())); } namespace diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 41ae9c3c2666..42f11191d057 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -480,6 +480,9 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, if (bIsLOK) { + if (!pViewShell) + return false; + // Notebookbar was loaded too early what caused: // * in LOK: Paste Special feature was incorrectly initialized // Skip first request so Notebookbar will be initialized after document was loaded @@ -672,11 +675,12 @@ void SfxNotebookBar::ToggleMenubar() void SfxNotebookBar::ReloadNotebookBar(std::u16string_view sUIPath) { - if (SfxNotebookBar::IsActive()) - { - SfxViewShell* pViewShell = SfxViewShell::Current(); - sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame().GetBindings(), sUIPath, true); - } + if (!SfxNotebookBar::IsActive()) + return; + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (!pViewShell) + return; + sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame().GetBindings(), sUIPath, true); } IMPL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, pViewShell, void) commit cd57c1ad685ee2fe9dad7979961fbd71ab4b3da6 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Apr 26 11:11:44 2024 +0100 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 6 23:29:45 2024 +0200 WaE: C6011 Derefencing NULL pointer 'pMF' Change-Id: I76e85e8671623f7cdf994dce779c3944b8761acf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166731 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit e5c988821db31f285cdd207e2a2ac849c0f1c099) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166832 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 5582ea36163d060887ff319baaf817f8581fe0db) diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 7cfdf76fe60f..9d7600ae2da7 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<METAFILEPICT*>(GlobalLock( hMemory )); - - pMF->hMF = hMeta; - pMF->mm = MM_ANISOTROPIC; - - MapMode aWinMode( MapUnit::Map100thMM ); - - if ( aWinMode == pGDIMeta->GetPrefMapMode() ) + if (METAFILEPICT* pMF = static_cast<METAFILEPICT*>(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<void*>(hMemory); } else commit 615fd76c6ebea4efd228c5d3951b454ae56c1273 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Apr 26 11:42:35 2024 +0100 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 6 23:28:41 2024 +0200 Unchecked HeapAlloc Change-Id: Icd49d0b5f996d57d8e9518cb08fd3c3fc54fa779 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166732 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit a70a8f55973ec3e71f65335be75699f1d2a73d62) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166833 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 1ddc294779d81ce2a00b75d283f183890074e650) diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 2fb7cd2b7875..a237aac13547 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/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index f60f459829d7..dce19e3625c0 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<WCHAR*>(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; commit 03d7f2365f0fba25496d787d1bd2de0d58634892 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Thu Apr 18 14:46:30 2024 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 6 23:27:47 2024 +0200 xlsx export: fix corrupt file for Excel: protectedRange must have sqref Excel refuses to open a file if there is no sqref specified <protectedRanges> <protectedRange name="corruptFile"/> </protectedRanges> In this case, import failed to import sqref="10:131". A follow-up commit avoids exporting these shorthand ranges. I don't see much point in trying to create a unit test for this. (I assume protectedRange is simply round-tripped because I doubt LO has working support for protectedRanges.) commit 9cee6a45632623d3d7e5a574128940f96d8c926b Author: Eike Rathke on Thu Mar 20 10:16:50 2014 +0100 added ScEnhancedProtection to ScTableProtection Change-Id: I97ef1ee801898bdcace067d62890c4ce0e7cf1d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166265 Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Justin Luth <jl...@mail.com> (cherry picked from commit 78bd5e2523d077a67468b752d4788a2c3b43fb5f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166220 Tested-by: Jenkins (cherry picked from commit c3bbc3b5c06b743a206a33111c061d4d7d011f21) diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 86afa5a6c163..f18e9f829bbe 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -478,6 +478,9 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->startElement(XML_protectedRanges); for (const auto& rProt : rProts) { + if (!rProt.maRangeList.is()) + continue; // Excel refuses to open if sqref is missing from a protectedRange + SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && !rProt.maSecurityDescriptor.empty(), "sc.filter", "XclExpSheetProtection::SaveXml: losing BIFF security descriptor"); rWorksheet->singleElement( XML_protectedRange, @@ -492,7 +495,7 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) XML_hashValue, sax_fastparser::UseIf(rProt.maPasswordHash.maHashValue, !rProt.maPasswordHash.maHashValue.isEmpty()), XML_saltValue, sax_fastparser::UseIf(rProt.maPasswordHash.maSaltValue, !rProt.maPasswordHash.maSaltValue.isEmpty()), XML_spinCount, sax_fastparser::UseIf(OString::number(rProt.maPasswordHash.mnSpinCount), rProt.maPasswordHash.mnSpinCount != 0), - XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr() : nullptr); + XML_sqref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr()); } rWorksheet->endElement( XML_protectedRanges); }