diff options
author | Eike Rathke <erack@redhat.com> | 2023-05-01 20:17:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-05-01 23:11:32 +0200 |
commit | 595eda782296916ddfec5f6d15e9abc5c61667ee (patch) | |
tree | 6856e6f1c4bc005223aab3ac4743ef0700744196 /sc/source | |
parent | 1dc1595824509c58f86f819673719096f771f417 (diff) |
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 <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 28 |
1 files changed, 21 insertions, 7 deletions
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; } |