[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sc/inc sc/source
Tor Lillqvist
tml at collabora.com
Fri Dec 1 01:18:35 UTC 2017
sc/inc/tokenarray.hxx | 3 +++
sc/source/core/data/conditio.cxx | 17 +----------------
sc/source/core/tool/token.cxx | 17 +++++++++++++++++
3 files changed, 21 insertions(+), 16 deletions(-)
New commits:
commit f2d84e1f206bbd9fd749054edc851126bab71ecc
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Nov 28 12:38:03 2017 +0200
Do as the FIXME suggested
Not exactly, though. The FIXME said "Make this a comparison operator
at the TokenArray?" but I think that would be misleading as the code
in question specifically does not check the TokenArrays for being
completely identical; it intentionally ignores the RPN part. So make
it a member function 'EqualTokens' instead.
Change-Id: I15d840c422844fa144415a76c1f8fcbd6cae3c83
Reviewed-on: https://gerrit.libreoffice.org/45462
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index b2b4edd896b3..e37d8e97cf1d 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -58,6 +58,9 @@ public:
/// Assignment with references to FormulaToken entries (not copied!)
ScTokenArray( const ScTokenArray& );
virtual ~ScTokenArray();
+
+ bool EqualTokens( const ScTokenArray* pArr2 ) const;
+
void ClearScTokenArray();
ScTokenArray* Clone() const; /// True copy!
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 7fd1ef53ac69..68fa98beb206 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -663,26 +663,11 @@ void ScConditionEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt )
StartListening();
}
-//FIXME: Make this a comparison operator at the TokenArray?
static bool lcl_IsEqual( const ScTokenArray* pArr1, const ScTokenArray* pArr2 )
{
// We only compare the non-RPN array
if ( pArr1 && pArr2 )
- {
- sal_uInt16 nLen = pArr1->GetLen();
- if ( pArr2->GetLen() != nLen )
- return false;
-
- FormulaToken** ppToken1 = pArr1->GetArray();
- FormulaToken** ppToken2 = pArr2->GetArray();
- for (sal_uInt16 i=0; i<nLen; i++)
- {
- if ( ppToken1[i] != ppToken2[i] &&
- !(*ppToken1[i] == *ppToken2[i]) )
- return false; // Difference
- }
- return true; // All entries are the same
- }
+ return pArr1->EqualTokens( pArr2 );
else
return !pArr1 && !pArr2; // Both 0? -> the same
}
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6671a5ab5dbc..ce2c7cd8b6cd 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1770,6 +1770,23 @@ ScTokenArray& ScTokenArray::operator=( const ScTokenArray& rArr )
return *this;
}
+bool ScTokenArray::EqualTokens( const ScTokenArray* pArr2) const
+{
+ // We only compare the non-RPN array
+ if ( pArr2->nLen != nLen )
+ return false;
+
+ FormulaToken** ppToken1 = GetArray();
+ FormulaToken** ppToken2 = pArr2->GetArray();
+ for (sal_uInt16 i=0; i<nLen; i++)
+ {
+ if ( ppToken1[i] != ppToken2[i] &&
+ !(*ppToken1[i] == *ppToken2[i]) )
+ return false; // Difference
+ }
+ return true; // All entries are the same
+}
+
void ScTokenArray::ClearScTokenArray()
{
Clear();
More information about the Libreoffice-commits
mailing list