summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-03-30 19:48:45 +0200
committerDavid Tardon <dtardon@redhat.com>2015-04-01 07:30:51 +0000
commit0f5cbcc5bd5fbde8f13a6655bd47dca4d7722ce9 (patch)
treeb5a43334c60804fb02a974d81ab2f6fa0474d825 /sc
parent501be50b5de178d6ae1047e1ba4bf144e248eb81 (diff)
Resolves: tdf#42481 propagate errors as errors in matrix calculations
... instead of setting an error string with an unwanted side effect that may lead to wrong results instead of error. Change-Id: I42ade52e86520535c879e9bd68156873d706f33c (cherry picked from commit 836d05d32e36aafc00de59ca51878f47f7ce816a) Reviewed-on: https://gerrit.libreoffice.org/15072 Tested-by: David Tardon <dtardon@redhat.com> Reviewed-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr5.cxx21
1 files changed, 13 insertions, 8 deletions
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index aa425b39aa47..7b46fd88956b 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1092,7 +1092,6 @@ static inline SCSIZE lcl_GetMinExtent( SCSIZE n1, SCSIZE n2 )
template<class _Function>
static ScMatrixRef lcl_MatrixCalculation(
- svl::SharedStringPool& rPool,
const ScMatrix& rMat1, const ScMatrix& rMat2, ScInterpreter* pInterpreter)
{
static _Function Op;
@@ -1111,13 +1110,19 @@ static ScMatrixRef lcl_MatrixCalculation(
{
for (j = 0; j < nMinR; j++)
{
+ sal_uInt16 nErr;
if (rMat1.IsValueOrEmpty(i,j) && rMat2.IsValueOrEmpty(i,j))
{
double d = Op(rMat1.GetDouble(i,j), rMat2.GetDouble(i,j));
xResMat->PutDouble( d, i, j);
}
+ else if (((nErr = rMat1.GetErrorIfNotString(i,j)) != 0) ||
+ ((nErr = rMat2.GetErrorIfNotString(i,j)) != 0))
+ {
+ xResMat->PutError( nErr, i, j);
+ }
else
- xResMat->PutString(rPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i, j);
+ xResMat->PutError( errNoValue, i, j);
}
}
}
@@ -1246,11 +1251,11 @@ void ScInterpreter::CalculateAddSub(bool _bSub)
ScMatrixRef pResMat;
if ( _bSub )
{
- pResMat = lcl_MatrixCalculation<MatrixSub>(mrStrPool, *pMat1, *pMat2, this);
+ pResMat = lcl_MatrixCalculation<MatrixSub>( *pMat1, *pMat2, this);
}
else
{
- pResMat = lcl_MatrixCalculation<MatrixAdd>(mrStrPool, *pMat1, *pMat2, this);
+ pResMat = lcl_MatrixCalculation<MatrixAdd>( *pMat1, *pMat2, this);
}
if (!pResMat)
@@ -1443,7 +1448,7 @@ void ScInterpreter::ScMul()
}
if (pMat1 && pMat2)
{
- ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixMul>(mrStrPool, *pMat1, *pMat2, this);
+ ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixMul>( *pMat1, *pMat2, this);
if (!pResMat)
PushNoValue();
else
@@ -1516,7 +1521,7 @@ void ScInterpreter::ScDiv()
}
if (pMat1 && pMat2)
{
- ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixDiv>(mrStrPool, *pMat1, *pMat2, this);
+ ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixDiv>( *pMat1, *pMat2, this);
if (!pResMat)
PushNoValue();
else
@@ -1595,7 +1600,7 @@ void ScInterpreter::ScPow()
fVal1 = GetDouble();
if (pMat1 && pMat2)
{
- ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixPow>(mrStrPool, *pMat1, *pMat2, this);
+ ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixPow>( *pMat1, *pMat2, this);
if (!pResMat)
PushNoValue();
else
@@ -1792,7 +1797,7 @@ void ScInterpreter::ScSumXMY2()
PushNoValue();
return;
} // if (nC1 != nC2 || nR1 != nR2)
- ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixSub>(mrStrPool, *pMat1, *pMat2, this);
+ ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixSub>( *pMat1, *pMat2, this);
if (!pResMat)
{
PushNoValue();