diff options
-rw-r--r-- | formula/inc/formula/tokenarray.hxx | 1 | ||||
-rw-r--r-- | formula/source/core/api/token.cxx | 52 | ||||
-rw-r--r-- | sc/inc/tokenarray.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 52 |
4 files changed, 54 insertions, 53 deletions
diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx index aa382cd9653e..42c92127c856 100644 --- a/formula/inc/formula/tokenarray.hxx +++ b/formula/inc/formula/tokenarray.hxx @@ -94,7 +94,6 @@ public: virtual ~FormulaTokenArray(); FormulaTokenArray* Clone() const; /// True copy! - size_t GetHash() const; void Clear(); void DelRPN(); FormulaToken* First() { nIndex = 0; return Next(); } diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 5a47d2e43934..150be29a7a61 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -685,58 +685,6 @@ FormulaTokenArray* FormulaTokenArray::Clone() const return p; } -size_t FormulaTokenArray::GetHash() const -{ - static OUStringHash aHasher; - - size_t nHash = 1; - OpCode eOp; - StackVar eType; - const FormulaToken* p; - sal_uInt16 n = std::min<sal_uInt16>(nLen, 20); - for (sal_uInt16 i = 0; i < n; ++i) - { - p = pCode[i]; - eOp = p->GetOpCode(); - if (eOp == ocPush) - { - // This is stack variable. Do additional differentiation. - eType = p->GetType(); - switch (eType) - { - case svByte: - { - // Constant value. - sal_uInt8 nVal = p->GetByte(); - nHash += (static_cast<size_t>(nVal) << i); - continue; - } - case svDouble: - { - // Constant value. - double fVal = p->GetDouble(); - nHash += (static_cast<size_t>(fVal) << i); - continue; - } - case svString: - { - // Constant string. - const String& rStr = p->GetString(); - nHash += (aHasher(rStr) << i); - continue; - } - default: - // TODO: Decide later if we should generate hash from references as well. - ; - } - } - - // Use the opcode value in all the other cases. - nHash += (static_cast<size_t>(eOp) << i); - } - return nHash; -} - void FormulaTokenArray::Clear() { if( nRPN ) DelRPN(); diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index fd77250eaf67..01993e94847e 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -42,6 +42,8 @@ public: virtual ~ScTokenArray(); ScTokenArray* Clone() const; /// True copy! + size_t GetHash() const; + /// Exactly and only one range (valid or deleted) bool IsReference( ScRange& rRange ) const; /// Exactly and only one valid range (no #REF!s) diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index da787e1858be..b400f6d6720c 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1274,6 +1274,58 @@ bool ScTokenArray::ImplGetReference( ScRange& rRange, bool bValidOnly ) const return bIs; } +size_t ScTokenArray::GetHash() const +{ + static OUStringHash aHasher; + + size_t nHash = 1; + OpCode eOp; + StackVar eType; + const FormulaToken* p; + sal_uInt16 n = std::min<sal_uInt16>(nLen, 20); + for (sal_uInt16 i = 0; i < n; ++i) + { + p = pCode[i]; + eOp = p->GetOpCode(); + if (eOp == ocPush) + { + // This is stack variable. Do additional differentiation. + eType = p->GetType(); + switch (eType) + { + case svByte: + { + // Constant value. + sal_uInt8 nVal = p->GetByte(); + nHash += (static_cast<size_t>(nVal) << i); + continue; + } + case svDouble: + { + // Constant value. + double fVal = p->GetDouble(); + nHash += (static_cast<size_t>(fVal) << i); + continue; + } + case svString: + { + // Constant string. + const String& rStr = p->GetString(); + nHash += (aHasher(rStr) << i); + continue; + } + default: + // TODO: Decide later if we should generate hash from references as well. + ; + } + } + + // Use the opcode value in all the other cases. + nHash += (static_cast<size_t>(eOp) << i); + } + return nHash; +} + bool ScTokenArray::IsReference( ScRange& rRange ) const { return ImplGetReference( rRange, false ); |