summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-03-31 17:21:44 +0200
committerEike Rathke <erack@redhat.com>2015-03-31 17:51:03 +0200
commite27d7c38ba1de0f4bbb1197bd84c063a0fdee9d1 (patch)
treea98c676fc296e3fcccb009fd7a16a18c9ce57f7e /sc
parentf3989e4d3d87f07a484d7c404bc2bfc678faa7f0 (diff)
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.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scmatrix.hxx5
-rw-r--r--sc/source/core/tool/interpr5.cxx30
-rw-r--r--sc/source/core/tool/scmatrix.cxx63
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);