diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/scmatrix.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 30 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 63 |
3 files changed, 29 insertions, 69 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 2ad51e01fbf6..e85054e22b52 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 712316fbf441..f2f8dd66c3ef 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 a465e09d4a95..07e90db9f014 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); |