[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Eike Rathke erack at redhat.com
Tue Mar 31 08:51:47 PDT 2015


 sc/inc/scmatrix.hxx              |    5 ---
 sc/source/core/tool/interpr1.cxx |    2 -
 sc/source/core/tool/interpr5.cxx |   30 +++++++++++++++++-
 sc/source/core/tool/scmatrix.cxx |   63 ---------------------------------------
 4 files changed, 30 insertions(+), 70 deletions(-)

New commits:
commit e27d7c38ba1de0f4bbb1197bd84c063a0fdee9d1
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Mar 31 17:21:44 2015 +0200

    Revert "tdf#89387 Add functor for ScAmpersand"
    
    This reverts commit 9a7959cd63be7b2f36da8af25e7673a525c4d66c.
    
    It is not an equivalent replacement for the existing functionality, i.e.
    it lacks the number to string conversion done through SvNumberFormatter
    and instead of concatenating a numeric element produces an error value
    element.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 2ad51e0..e85054e 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -43,10 +43,6 @@ struct CompareOptions;
 
 }
 
-namespace svl {
-class SharedStringPool;
-}
-
 /**
  * Try NOT to use this struct.  This struct should go away in a hopefully
  * not so distant futture.
@@ -398,7 +394,6 @@ public:
     void MulOp(svl::SharedString aString, double fVal, ScMatrix& rMat);
     void DivOp(bool bFlag, svl::SharedString aString, double fVal, ScMatrix& rMat);
     void PowOp(bool bFlag, svl::SharedString aString, double fVal, ScMatrix& rMat);
-    void AmpersandOp(bool bFlag, svl::SharedString aString, ScMatrix& rMat, svl::SharedStringPool& rStrPool);
 
     ScMatrix& operator+= ( const ScMatrix& r );
 
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 712316f..f2f8dd6 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1367,9 +1367,37 @@ void ScInterpreter::ScAmpersand()
                     for (SCSIZE j = 0; j < nR; ++j)
                         pResMat->PutError( nGlobalError, i, j);
             }
+            else if (bFlag)
+            {
+                for (SCSIZE i = 0; i < nC; ++i)
+                    for (SCSIZE j = 0; j < nR; ++j)
+                    {
+                        sal_uInt16 nErr = pMat->GetErrorIfNotString( i, j);
+                        if (nErr)
+                            pResMat->PutError( nErr, i, j);
+                        else
+                        {
+                            OUString aTmp = sStr;
+                            aTmp += pMat->GetString(*pFormatter, i, j).getString();
+                            pResMat->PutString(mrStrPool.intern(aTmp), i, j);
+                        }
+                    }
+            }
             else
             {
-                pMat->AmpersandOp(bFlag, sStr, *pResMat, mrStrPool);
+                for (SCSIZE i = 0; i < nC; ++i)
+                    for (SCSIZE j = 0; j < nR; ++j)
+                    {
+                        sal_uInt16 nErr = pMat->GetErrorIfNotString( i, j);
+                        if (nErr)
+                            pResMat->PutError( nErr, i, j);
+                        else
+                        {
+                            OUString aTmp = pMat->GetString(*pFormatter, i, j).getString();
+                            aTmp += sStr;
+                            pResMat->PutString(mrStrPool.intern(aTmp), i, j);
+                        }
+                    }
             }
             PushMatrix(pResMat);
         }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index a465e09..07e90db 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -29,7 +29,6 @@
 #include <boost/noncopyable.hpp>
 #include <svl/zforlist.hxx>
 #include <svl/sharedstring.hxx>
-#include <svl/sharedstringpool.hxx>
 #include <tools/stream.hxx>
 #include <rtl/math.hxx>
 
@@ -37,7 +36,6 @@
 
 #include <vector>
 #include <limits>
-#include <functional>
 
 #include <mdds/multi_type_matrix.hpp>
 #include <mdds/multi_type_vector_types.hpp>
@@ -2586,49 +2584,6 @@ public:
     }
 };
 
-
-struct AmpersandOp
-{
-private:
-    std::function<svl::SharedString(svl::SharedString,svl::SharedString)> maOp;
-    svl::SharedString maString;
-
-public:
-    typedef svl::SharedString empty_value_type;
-    typedef double number_value_type;
-    typedef svl::SharedString string_value_type;
-
-    AmpersandOp(std::function<svl::SharedString(svl::SharedString,svl::SharedString)> aOp, svl::SharedString aString):
-        maOp(aOp),
-        maString(aString)
-    { }
-
-    double operator()(double fVal) const
-    {
-        return CreateDoubleError(GetDoubleErrorValue(fVal));
-    }
-
-    double operator()(bool fVal) const
-    {
-        return CreateDoubleError(GetDoubleErrorValue(double(fVal)));
-    }
-
-    svl::SharedString operator()(svl::SharedString aVal) const
-    {
-        return maOp(maString, aVal);
-    }
-
-    svl::SharedString operator()(char) const
-    {
-        return maString;
-    }
-
-    bool useFunctionForEmpty() const
-    {
-        return true;
-    }
-};
-
 }
 
 void ScMatrix::NotOp(svl::SharedString aString, ScMatrix& rMat)
@@ -2707,24 +2662,6 @@ void ScMatrix::PowOp(bool bFlag, svl::SharedString aString, double fVal, ScMatri
     }
 }
 
-void ScMatrix::AmpersandOp(bool bFlag, svl::SharedString aString, ScMatrix& rMat, svl::SharedStringPool& rStrPool)
-{
-    if (bFlag)
-    {
-        auto amp_ = [&rStrPool](svl::SharedString a, svl::SharedString b) -> svl::SharedString
-                    {return rStrPool.intern(a.getString() += b.getString());};
-        matop::AmpersandOp aOp(amp_, aString);
-        pImpl->ApplyOperation(aOp, *rMat.pImpl);
-    }
-    else
-    {
-        auto amp_ = [&rStrPool](svl::SharedString a, svl::SharedString b) -> svl::SharedString
-                    {return rStrPool.intern(b.getString() += a.getString());};
-        matop::AmpersandOp aOp(amp_, aString);
-        pImpl->ApplyOperation(aOp, *rMat.pImpl);
-    }
-}
-
 ScMatrix& ScMatrix::operator+= ( const ScMatrix& r )
 {
     pImpl->AddValues(*r.pImpl);
commit f3989e4d3d87f07a484d7c404bc2bfc678faa7f0
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Mar 31 16:09:14 2015 +0200

    use error value instead of string in array/matrix, tdf#42481 related
    
    Change-Id: Ib97509609bd3e6629e3efd0c633535564f1c64d6

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 260ff93..a4b9fd0 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1002,7 +1002,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO
                         sc::CompareFunc(aComp.maCells[0], aComp.maCells[1], aComp.mbIgnoreCase, pOptions), j, k);
                 }
                 else
-                    aRes.mpMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), j, k);
+                    aRes.mpMat->PutError( errNoValue, j, k);
             }
         }
 


More information about the Libreoffice-commits mailing list