sc/source/core/tool/scmatrix.cxx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
New commits: commit 595eda782296916ddfec5f6d15e9abc5c61667ee Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon May 1 20:17:38 2023 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Mon May 1 23:11:32 2023 +0200 Related: tdf#119659 Use ValidColRowOrReplicated() for matrix dimension check ... instead of only ValidColRowReplicated(), and check the return value. With this, the abort wouldn't had happened but an empty string returned for this case (which would had been wrong as well, but the caller has to check dimensions). Change-Id: I75218c479896893146b0e73d3c82215fe61cdf6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151235 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 1f0b6a74d95f..3fdbf3438a47 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -802,7 +802,9 @@ bool ScMatrixImpl::IsStringOrEmpty( SCSIZE nIndex ) const bool ScMatrixImpl::IsStringOrEmpty( SCSIZE nC, SCSIZE nR ) const { - ValidColRowReplicated( nC, nR ); + if (!ValidColRowOrReplicated( nC, nR )) + return false; + switch (maMat.get_type(nR, nC)) { case mdds::mtm::element_empty: @@ -816,27 +818,33 @@ bool ScMatrixImpl::IsStringOrEmpty( SCSIZE nC, SCSIZE nR ) const bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const { + if (!ValidColRowOrReplicated( nC, nR )) + return false; + // Flag must indicate an 'empty' or 'empty cell' or 'empty result' element, // but not an 'empty path' element. - ValidColRowReplicated( nC, nR ); return maMat.get_type(nR, nC) == mdds::mtm::element_empty && maMatFlag.get_integer(nR, nC) != SC_MATFLAG_EMPTYPATH; } bool ScMatrixImpl::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const { + if (!ValidColRowOrReplicated( nC, nR )) + return false; + // Flag must indicate an 'empty cell' element instead of an // 'empty' or 'empty result' or 'empty path' element. - ValidColRowReplicated( nC, nR ); return maMat.get_type(nR, nC) == mdds::mtm::element_empty && maMatFlag.get_type(nR, nC) == mdds::mtm::element_empty; } bool ScMatrixImpl::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const { + if (!ValidColRowOrReplicated( nC, nR )) + return false; + // Flag must indicate an 'empty result' element instead of an // 'empty' or 'empty cell' or 'empty path' element. - ValidColRowReplicated( nC, nR ); return maMat.get_type(nR, nC) == mdds::mtm::element_empty && maMatFlag.get_integer(nR, nC) == SC_MATFLAG_EMPTYRESULT; } @@ -860,7 +868,9 @@ bool ScMatrixImpl::IsValue( SCSIZE nIndex ) const bool ScMatrixImpl::IsValue( SCSIZE nC, SCSIZE nR ) const { - ValidColRowReplicated(nC, nR); + if (!ValidColRowOrReplicated( nC, nR )) + return false; + switch (maMat.get_type(nR, nC)) { case mdds::mtm::element_boolean: @@ -874,7 +884,9 @@ bool ScMatrixImpl::IsValue( SCSIZE nC, SCSIZE nR ) const bool ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const { - ValidColRowReplicated(nC, nR); + if (!ValidColRowOrReplicated( nC, nR )) + return false; + switch (maMat.get_type(nR, nC)) { case mdds::mtm::element_boolean: @@ -889,7 +901,9 @@ bool ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const bool ScMatrixImpl::IsBoolean( SCSIZE nC, SCSIZE nR ) const { - ValidColRowReplicated( nC, nR ); + if (!ValidColRowOrReplicated( nC, nR )) + return false; + return maMat.get_type(nR, nC) == mdds::mtm::element_boolean; }