[Libreoffice-commits] core.git: sc/inc sc/source
Eike Rathke
erack at redhat.com
Wed Mar 2 20:21:02 UTC 2016
sc/inc/scmatrix.hxx | 6 +++---
sc/source/core/tool/interpr6.cxx | 4 ++--
sc/source/core/tool/scmatrix.cxx | 32 ++++++++++++++++++++++++--------
3 files changed, 29 insertions(+), 13 deletions(-)
New commits:
commit b2f5336b08b5f638f890a626eb2aeefaf499a79b
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 2 21:18:24 2016 +0100
Resolves: tdf#98297 exclude error values from COUNT in array/matrix
Change-Id: I202dcc2a2b90ee8ed27815b97a2aad6e4df2f1b9
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index e177bed..64147c2 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -366,7 +366,7 @@ public:
virtual IterateResult Sum(bool bTextAsZero) const = 0;
virtual IterateResult SumSquare(bool bTextAsZero) const = 0;
virtual IterateResult Product(bool bTextAsZero) const = 0;
- virtual size_t Count(bool bCountStrings) const = 0;
+ virtual size_t Count(bool bCountStrings, bool bCountErrors) const = 0;
virtual size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const = 0;
virtual size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const = 0;
@@ -574,7 +574,7 @@ public:
virtual IterateResult Sum(bool bTextAsZero) const override;
virtual IterateResult SumSquare(bool bTextAsZero) const override;
virtual IterateResult Product(bool bTextAsZero) const override;
- virtual size_t Count(bool bCountStrings) const override;
+ virtual size_t Count(bool bCountStrings, bool bCountErrors) const override;
virtual size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const override;
virtual size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const override;
@@ -785,7 +785,7 @@ public:
virtual IterateResult Sum(bool bTextAsZero) const override;
virtual IterateResult SumSquare(bool bTextAsZero) const override;
virtual IterateResult Product(bool bTextAsZero) const override;
- virtual size_t Count(bool bCountStrings) const override;
+ virtual size_t Count(bool bCountStrings, bool bCountErrors) const override;
virtual size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const override;
virtual size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const override;
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 306d81f..78d6f47 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -433,10 +433,10 @@ void IterateMatrix(
}
break;
case ifCOUNT:
- rCount += pMat->Count(bTextAsZero);
+ rCount += pMat->Count(bTextAsZero, false); // do not count error values
break;
case ifCOUNT2:
- rCount += pMat->Count(true);
+ rCount += pMat->Count(true, true); // do count error values
break;
case ifPRODUCT:
{
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 279701e..1a5d012 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -284,7 +284,7 @@ public:
ScMatrix::IterateResult Sum(bool bTextAsZero) const;
ScMatrix::IterateResult SumSquare(bool bTextAsZero) const;
ScMatrix::IterateResult Product(bool bTextAsZero) const;
- size_t Count(bool bCountStrings) const;
+ size_t Count(bool bCountStrings, bool bCountErrors) const;
size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const;
size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const;
@@ -1163,8 +1163,10 @@ class CountElements : public std::unary_function<MatrixImplType::element_block_n
{
size_t mnCount;
bool mbCountString;
+ bool mbCountErrors;
public:
- explicit CountElements(bool bCountString) : mnCount(0), mbCountString(bCountString) {}
+ explicit CountElements(bool bCountString, bool bCountErrors) :
+ mnCount(0), mbCountString(bCountString), mbCountErrors(bCountErrors) {}
size_t getCount() const { return mnCount; }
@@ -1173,6 +1175,20 @@ public:
switch (node.type)
{
case mdds::mtm::element_numeric:
+ mnCount += node.size;
+ if (!mbCountErrors)
+ {
+ typedef MatrixImplType::numeric_block_type block_type;
+
+ block_type::const_iterator it = block_type::begin(*node.data);
+ block_type::const_iterator itEnd = block_type::end(*node.data);
+ for (; it != itEnd; ++it)
+ {
+ if (!::rtl::math::isFinite(*it))
+ --mnCount;
+ }
+ }
+ break;
case mdds::mtm::element_boolean:
mnCount += node.size;
break;
@@ -1782,9 +1798,9 @@ ScMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const
return GetValueWithCount<sc::op::Product>(bTextAsZero, maMat);
}
-size_t ScMatrixImpl::Count(bool bCountStrings) const
+size_t ScMatrixImpl::Count(bool bCountStrings, bool bCountErrors) const
{
- CountElements aFunc(bCountStrings);
+ CountElements aFunc(bCountStrings, bCountErrors);
maMat.walk(aFunc);
return aFunc.getCount();
}
@@ -2682,9 +2698,9 @@ ScMatrix::IterateResult ScFullMatrix::Product(bool bTextAsZero) const
return pImpl->Product(bTextAsZero);
}
-size_t ScFullMatrix::Count(bool bCountStrings) const
+size_t ScFullMatrix::Count(bool bCountStrings, bool bCountErrors) const
{
- return pImpl->Count(bCountStrings);
+ return pImpl->Count(bCountStrings, bCountErrors);
}
size_t ScFullMatrix::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const
@@ -3581,10 +3597,10 @@ ScMatrix::IterateResult ScVectorRefMatrix::Product(bool bTextAsZero) const
return mpFullMatrix->Product(bTextAsZero);
}
-size_t ScVectorRefMatrix::Count(bool bCountStrings) const
+size_t ScVectorRefMatrix::Count(bool bCountStrings, bool bCountErrors) const
{
const_cast<ScVectorRefMatrix*>(this)->ensureFullMatrix();
- return mpFullMatrix->Count(bCountStrings);
+ return mpFullMatrix->Count(bCountStrings, bCountErrors);
}
size_t ScVectorRefMatrix::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const
More information about the Libreoffice-commits
mailing list