diff options
author | Tor Lillqvist <tml@collabora.com> | 2017-11-28 12:38:03 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2017-11-28 23:55:48 +0100 |
commit | aa28b54ab568fb7160095bb4a2fec338b1398b43 (patch) | |
tree | 63629ba22675ad34159a77b9d4831cef29bd5749 /sc | |
parent | 217b1e8e94859e06af66023f042c53cf329f5232 (diff) |
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/45404
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/tokenarray.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 17 |
3 files changed, 21 insertions, 16 deletions
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index 8b352b447f09..927b77bc5ffd 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -59,6 +59,9 @@ public: (not copied!) */ ScTokenArray( const ScTokenArray& ); virtual ~ScTokenArray() override; + + bool EqualTokens( const ScTokenArray* pArr2 ) const; + virtual void Clear() override; ScTokenArray* Clone() const; /// True copy! diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 940181582b22..ca6b49f20a75 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -619,26 +619,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 a849e034e176..55cbb9f1a7fc 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1852,6 +1852,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::Clear() { mnHashValue = 0; |