summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-07-06 16:48:42 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-07-08 11:47:29 +0000
commitf5427fa4d7cb9ad79d68d0760030ca998ca1d0e5 (patch)
tree824c615b9f6a930f8c19c31bfe2e732e53c5537e
parent9bb4b60fd6deb348af37d9a51860e4d554ffbc35 (diff)
use ScMatrix::IsValueOrEmpty() on math operators Mul/Div/Pow, tdf#91453
... which aren't implemented at ScMatrix yet. Using IsValue() worked when errors were not propagated, and before that when errors were propagated because ScMatrix didn't have empty elements but instead was initialized to 0.0 Change-Id: Ib9c6d34f2e6a68e483b606923cbcc41a3c1d2f51 Reviewed-on: https://gerrit.libreoffice.org/16799 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/inc/scmatrix.hxx3
-rw-r--r--sc/source/core/tool/interpr5.cxx10
-rw-r--r--sc/source/core/tool/scmatrix.cxx13
3 files changed, 21 insertions, 5 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 27d3777521b3..63284e967234 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -342,6 +342,9 @@ public:
bool IsValue( SCSIZE nC, SCSIZE nR ) const;
/// @return <TRUE/> if value or boolean or empty or empty path.
+ bool IsValueOrEmpty( SCSIZE nIndex ) const;
+
+ /// @return <TRUE/> if value or boolean or empty or empty path.
bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
/// @return <TRUE/> if boolean.
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 3aab1c23a50d..4a093be5c6e9 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1471,7 +1471,7 @@ void ScInterpreter::ScMul()
{
SCSIZE nCount = nC * nR;
for ( SCSIZE i = 0; i < nCount; i++ )
- if (pMat->IsValue(i))
+ if (pMat->IsValueOrEmpty(i))
pResMat->PutDouble(pMat->GetDouble(i)*fVal, i);
else
pResMat->PutError( errNoValue, i);
@@ -1550,14 +1550,14 @@ void ScInterpreter::ScDiv()
SCSIZE nCount = nC * nR;
if (bFlag)
{ for ( SCSIZE i = 0; i < nCount; i++ )
- if (pMat->IsValue(i))
+ if (pMat->IsValueOrEmpty(i))
pResMat->PutDouble( div( fVal, pMat->GetDouble(i)), i);
else
pResMat->PutError( errNoValue, i);
}
else
{ for ( SCSIZE i = 0; i < nCount; i++ )
- if (pMat->IsValue(i))
+ if (pMat->IsValueOrEmpty(i))
pResMat->PutDouble( div( pMat->GetDouble(i), fVal), i);
else
pResMat->PutError( errNoValue, i);
@@ -1629,14 +1629,14 @@ void ScInterpreter::ScPow()
SCSIZE nCount = nC * nR;
if (bFlag)
{ for ( SCSIZE i = 0; i < nCount; i++ )
- if (pMat->IsValue(i))
+ if (pMat->IsValueOrEmpty(i))
pResMat->PutDouble(pow(fVal,pMat->GetDouble(i)), i);
else
pResMat->PutError( errNoValue, i);
}
else
{ for ( SCSIZE i = 0; i < nCount; i++ )
- if (pMat->IsValue(i))
+ if (pMat->IsValueOrEmpty(i))
pResMat->PutDouble(pow(pMat->GetDouble(i),fVal), i);
else
pResMat->PutError( errNoValue, i);
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 90b23765c041..707337e71275 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -259,6 +259,7 @@ public:
bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
bool IsValue( SCSIZE nIndex ) const;
bool IsValue( SCSIZE nC, SCSIZE nR ) const;
+ bool IsValueOrEmpty( SCSIZE nIndex ) const;
bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
bool IsBoolean( SCSIZE nC, SCSIZE nR ) const;
bool IsNumeric() const;
@@ -749,6 +750,13 @@ bool ScMatrixImpl::IsValue( SCSIZE nC, SCSIZE nR ) const
return false;
}
+bool ScMatrixImpl::IsValueOrEmpty( SCSIZE nIndex ) const
+{
+ SCSIZE nC, nR;
+ CalcPosition(nIndex, nC, nR);
+ return IsValueOrEmpty(nC, nR);
+}
+
bool ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
{
ValidColRowReplicated(nC, nR);
@@ -2364,6 +2372,11 @@ bool ScMatrix::IsValue( SCSIZE nC, SCSIZE nR ) const
return pImpl->IsValue(nC, nR);
}
+bool ScMatrix::IsValueOrEmpty( SCSIZE nIndex ) const
+{
+ return pImpl->IsValueOrEmpty(nIndex);
+}
+
bool ScMatrix::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
{
return pImpl->IsValueOrEmpty(nC, nR);