sc/source/ui/unoobj/cellsuno.cxx | 4 +++- sc/source/ui/vba/vbarange.cxx | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)
New commits: commit 31e47d1e76052b52a4aa058306cd17a1c0ef36aa Author: Eike Rathke <er...@redhat.com> AuthorDate: Tue Jun 14 13:55:09 2022 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Wed Jun 15 11:18:54 2022 +0200 Related: tdf#149325 Fix yet another VbaRange empty ScRangeList access Change-Id: If2c44795ab794482b841138bdd55f37c4d30b592 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135824 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 0834cda6ae8e7bd4306d2a0464492344ebf1c104) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135853 diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 529830d6f510..b2117cefccf8 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6714,7 +6714,9 @@ uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorBy if (pRangesImp) { const ScRangeList& rRanges = pRangesImp->GetRangeList(); - OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" ); + SAL_WARN_IF( rRanges.size() != 1, "sc", "ScTableSheetObj::createCursorByRange: Range? Ranges?"); + if (rRanges.empty()) + return nullptr; return new ScCellCursorObj( pDocSh, rRanges[ 0 ] ); } } diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index d277d444901b..b98b5471ff7b 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -1288,9 +1288,12 @@ uno::Reference< sheet::XSheetCellRange > lclExpandToMerged( const uno::Reference { aOldAddress = aNewAddress; uno::Reference< sheet::XSheetCellCursor > xCursor( xSheet->createCursorByRange( xNewCellRange ), uno::UNO_SET_THROW ); - xCursor->collapseToMergedArea(); - xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW ); - aNewAddress = lclGetRangeAddress( xNewCellRange ); + if (xCursor.is()) + { + xCursor->collapseToMergedArea(); + xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW ); + aNewAddress = lclGetRangeAddress( xNewCellRange ); + } } while( bRecursive && (aOldAddress != aNewAddress) ); return xNewCellRange;