sc/source/core/tool/interpr5.cxx |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

New commits:
commit c2288a0732f2a10ba4590f3dace00294db389150
Author: Eike Rathke <er...@redhat.com>
Date:   Mon Mar 30 19:48:45 2015 +0200

    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/15073
    Tested-by: David Tardon <dtar...@redhat.com>
    Reviewed-by: David Tardon <dtar...@redhat.com>

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 3212363..2591b69 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);
             }
         }
     }
@@ -1245,11 +1250,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)
@@ -1453,7 +1458,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
@@ -1526,7 +1531,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
@@ -1605,7 +1610,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
@@ -1802,7 +1807,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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to