[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/inc sc/source

Eike Rathke erack at redhat.com
Mon Apr 13 13:06:34 PDT 2015


 sc/inc/scmatrix.hxx              |    3 +
 sc/source/core/tool/interpr1.cxx |    6 +--
 sc/source/core/tool/interpr5.cxx |   15 +++-----
 sc/source/core/tool/scmatrix.cxx |   72 ++++++++++++++++-----------------------
 4 files changed, 42 insertions(+), 54 deletions(-)

New commits:
commit 6b3decb3bb0a580c2978028660567ba3a66878ae
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Apr 2 21:16:00 2015 +0200

    use error value instead of string in array/matrix, tdf#42481 related
    
    Change-Id: Iaacf5636749077efc6f91f0eb0bac477cfcf4553
    Reviewed-on: https://gerrit.libreoffice.org/15129
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 6f8ad91..27d3777 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -264,6 +264,7 @@ public:
     /// Jump sal_False without path
     void PutEmptyPath( SCSIZE nC, SCSIZE nR);
     void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR );
+    void PutError( sal_uInt16 nErrorCode, SCSIZE nIndex );
     void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR);
 
     void FillDouble( double fVal,
@@ -388,7 +389,7 @@ public:
     void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero = true ) const;
     void MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const;
 
-    void SubAddOp(bool bSub, double fVal, svl::SharedString aString, ScMatrix& rMat);
+    void SubAddOp(bool bSub, double fVal, ScMatrix& rMat);
 
     ScMatrix& operator+= ( const ScMatrix& r );
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 4ad6f1e..1713089 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1499,8 +1499,7 @@ void ScInterpreter::ScNeg()
                             if ( pMat->IsValueOrEmpty(i,j) )
                                 pResMat->PutDouble( -pMat->GetDouble(i,j), i, j );
                             else
-                                pResMat->PutString(
-                                    mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i, j);
+                                pResMat->PutError( errNoValue, i, j);
                         }
                     }
                     PushMatrix( pResMat );
@@ -1553,8 +1552,7 @@ void ScInterpreter::ScNot()
                             if ( pMat->IsValueOrEmpty(i,j) )
                                 pResMat->PutDouble( double(pMat->GetDouble(i,j) == 0.0), i, j );
                             else
-                                pResMat->PutString(
-                                    mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i, j);
+                                pResMat->PutError( errNoValue, i, j);
                         }
                     }
                     PushMatrix( pResMat );
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 7b46fd8..3aab1c2 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1284,14 +1284,13 @@ void ScInterpreter::CalculateAddSub(bool _bSub)
         ScMatrixRef pResMat = GetNewMat(nC, nR, true);
         if (pResMat)
         {
-            svl::SharedString aString = mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE));
             if (bFlag || !_bSub )
             {
-                pMat->SubAddOp(_bSub, fVal, aString, *pResMat);
+                pMat->SubAddOp(_bSub, fVal, *pResMat);
             }
             else
             {
-                pMat->SubAddOp(false, -fVal, aString, *pResMat);
+                pMat->SubAddOp(false, -fVal, *pResMat);
             }
             PushMatrix(pResMat);
         }
@@ -1475,7 +1474,7 @@ void ScInterpreter::ScMul()
                 if (pMat->IsValue(i))
                     pResMat->PutDouble(pMat->GetDouble(i)*fVal, i);
                 else
-                    pResMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i);
+                    pResMat->PutError( errNoValue, i);
             PushMatrix(pResMat);
         }
         else
@@ -1554,14 +1553,14 @@ void ScInterpreter::ScDiv()
                     if (pMat->IsValue(i))
                         pResMat->PutDouble( div( fVal, pMat->GetDouble(i)), i);
                     else
-                        pResMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i);
+                        pResMat->PutError( errNoValue, i);
             }
             else
             {   for ( SCSIZE i = 0; i < nCount; i++ )
                     if (pMat->IsValue(i))
                         pResMat->PutDouble( div( pMat->GetDouble(i), fVal), i);
                     else
-                        pResMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i);
+                        pResMat->PutError( errNoValue, i);
             }
             PushMatrix(pResMat);
         }
@@ -1633,14 +1632,14 @@ void ScInterpreter::ScPow()
                     if (pMat->IsValue(i))
                         pResMat->PutDouble(pow(fVal,pMat->GetDouble(i)), i);
                     else
-                        pResMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i);
+                        pResMat->PutError( errNoValue, i);
             }
             else
             {   for ( SCSIZE i = 0; i < nCount; i++ )
                     if (pMat->IsValue(i))
                         pResMat->PutDouble(pow(pMat->GetDouble(i),fVal), i);
                     else
-                        pResMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), i);
+                        pResMat->PutError( errNoValue, i);
             }
             PushMatrix(pResMat);
         }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 4398308..90b2376 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -242,6 +242,7 @@ public:
     void PutEmpty(SCSIZE nC, SCSIZE nR);
     void PutEmptyPath(SCSIZE nC, SCSIZE nR);
     void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR );
+    void PutError( sal_uInt16 nErrorCode, SCSIZE nIndex );
     void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR);
     sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const;
     double GetDouble(SCSIZE nC, SCSIZE nR) const;
@@ -488,6 +489,13 @@ void ScMatrixImpl::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR )
     maMat.set(nR, nC, CreateDoubleError(nErrorCode));
 }
 
+void ScMatrixImpl::PutError( sal_uInt16 nErrorCode, SCSIZE nIndex )
+{
+    SCSIZE nC, nR;
+    CalcPosition(nIndex, nC, nR);
+    maMat.set(nR, nC, CreateDoubleError(nErrorCode));
+}
+
 void ScMatrixImpl::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
@@ -1871,34 +1879,11 @@ void ScMatrixImpl::AddValues( const ScMatrixImpl& rMat )
     }
 }
 
-namespace Op {
-
-template<typename T>
-struct return_type
-{
-    typedef T type;
-};
-
-template<>
-struct return_type<bool>
-{
-    typedef double type;
-};
-
-template<>
-struct return_type<char>
-{
-    typedef svl::SharedString type;
-};
-
-}
-
 template<typename T, typename U>
 struct wrapped_iterator
 {
     typedef ::std::bidirectional_iterator_tag iterator_category;
-    typedef typename T::const_iterator::value_type old_value_type;
-    typedef typename Op::return_type<old_value_type>::type value_type;
+    typedef double value_type;
     typedef value_type* pointer;
     typedef value_type& reference;
     typedef typename T::const_iterator::difference_type difference_type;
@@ -2294,6 +2279,11 @@ void ScMatrix::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR )
     pImpl->PutError(nErrorCode, nC, nR);
 }
 
+void ScMatrix::PutError( sal_uInt16 nErrorCode, SCSIZE nIndex )
+{
+    pImpl->PutError(nErrorCode, nIndex);
+}
+
 void ScMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
 {
     pImpl->PutBoolean(bVal, nC, nR);
@@ -2536,13 +2526,13 @@ struct AddOp
 {
 private:
     double mnVal;
-    svl::SharedString maString;
+    double mnError;
 
 public:
 
-    AddOp(double nVal, svl::SharedString aString):
+    AddOp(double nVal):
         mnVal(nVal),
-        maString(aString)
+        mnError( CreateDoubleError( errNoValue))
     {
     }
 
@@ -2556,14 +2546,14 @@ public:
         return mnVal + (double)bVal;
     }
 
-    svl::SharedString operator()(const svl::SharedString&) const
+    double operator()(const svl::SharedString&) const
     {
-        return maString;
+        return mnError;
     }
 
-    svl::SharedString operator()(char) const
+    double operator()(char) const
     {
-        return maString;
+        return mnVal;   // mnVal + 0.0
     }
 
     bool useFunctionForEmpty() const
@@ -2576,13 +2566,13 @@ struct SubOp
 {
 private:
     double mnVal;
-    svl::SharedString maString;
+    double mnError;
 
 public:
 
-    SubOp(double nVal, svl::SharedString aString):
+    SubOp(double nVal):
         mnVal(nVal),
-        maString(aString)
+        mnError( CreateDoubleError( errNoValue))
     {
     }
 
@@ -2596,14 +2586,14 @@ public:
         return mnVal - (double)bVal;
     }
 
-    svl::SharedString operator()(const svl::SharedString&) const
+    double operator()(const svl::SharedString&) const
     {
-        return maString;
+        return mnError;
     }
 
-    svl::SharedString operator()(char) const
+    double operator()(char) const
     {
-        return maString;
+        return mnVal;   // mnVal - 0.0
     }
 
     bool useFunctionForEmpty() const
@@ -2614,16 +2604,16 @@ public:
 
 }
 
-void ScMatrix::SubAddOp(bool bSub, double fVal, svl::SharedString aString, ScMatrix& rMat)
+void ScMatrix::SubAddOp(bool bSub, double fVal, ScMatrix& rMat)
 {
     if(bSub)
     {
-        SubOp aOp(fVal, aString);
+        SubOp aOp(fVal);
         pImpl->ApplyOperation(aOp, *rMat.pImpl);
     }
     else
     {
-        AddOp aOp(fVal, aString);
+        AddOp aOp(fVal);
         pImpl->ApplyOperation(aOp, *rMat.pImpl);
     }
 }


More information about the Libreoffice-commits mailing list