diff options
author | Eike Rathke <erack@redhat.com> | 2015-12-15 17:44:30 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-12-16 07:05:24 +0000 |
commit | 58c8f4dc6c7d6897e36c0c754162035f70e3385f (patch) | |
tree | 4641ae64d93c1df540ba1c91f808b4b60a426847 | |
parent | aae3875f6ccc7d660195398bfb4854f46cc0e84b (diff) |
Resolves: tdf#95440 SharedString are interned per document, re-intern
... if literal strings are copied with formula expression tokens.
(cherry picked from commit dad412e07f805a53ad73ce2e80d187a70c77e8de)
Conflicts:
include/formula/token.hxx
Change-Id: I13526907bb6c2c605c6ed9584fa6e3f2b18623b8
Reviewed-on: https://gerrit.libreoffice.org/20731
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | formula/source/core/api/token.cxx | 30 | ||||
-rw-r--r-- | include/formula/token.hxx | 5 | ||||
-rw-r--r-- | include/formula/tokenarray.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 4 |
4 files changed, 41 insertions, 1 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 9f16f4ce90d0..a8df23978588 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -204,6 +204,11 @@ svl::SharedString FormulaToken::GetString() const return svl::SharedString(); // invalid string } +void FormulaToken::SetString( const svl::SharedString& ) +{ + SAL_WARN( "formula.core", "FormulaToken::SetString: virtual dummy called" ); +} + sal_uInt16 FormulaToken::GetIndex() const { SAL_WARN( "formula.core", "FormulaToken::GetIndex: virtual dummy called" ); @@ -1523,6 +1528,21 @@ FormulaToken* FormulaTokenArray::AddOpCode( OpCode eOp ) return AddToken( *pRet ); } +void FormulaTokenArray::ReinternStrings( svl::SharedStringPool& rPool ) +{ + for (sal_uInt16 i=0; i < nLen; ++i) + { + switch (pCode[i]->GetType()) + { + case svString: + pCode[i]->SetString( rPool.intern( pCode[i]->GetString().getString())); + break; + default: + ; // nothing + } + } +} + /*----------------------------------------------------------------------*/ @@ -1653,6 +1673,11 @@ svl::SharedString FormulaStringToken::GetString() const return maString; } +void FormulaStringToken::SetString( const svl::SharedString& rStr ) +{ + maString = rStr; +} + bool FormulaStringToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ) && maString == r.GetString(); @@ -1674,6 +1699,11 @@ svl::SharedString FormulaStringOpToken::GetString() const return maString; } +void FormulaStringOpToken::SetString( const svl::SharedString& rStr ) +{ + maString = rStr; +} + bool FormulaStringOpToken::operator==( const FormulaToken& r ) const { return FormulaByteToken::operator==( r ) && maString == r.GetString(); diff --git a/include/formula/token.hxx b/include/formula/token.hxx index 6d6550b5df72..b0b143e1c2f5 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -150,7 +150,8 @@ public: virtual void SetForceArray( bool b ); virtual double GetDouble() const; virtual double& GetDoubleAsReference(); - virtual svl::SharedString GetString() const; + virtual svl::SharedString GetString() const; + virtual void SetString( const svl::SharedString& rStr ); virtual sal_uInt16 GetIndex() const; virtual void SetIndex( sal_uInt16 n ); virtual bool IsGlobal() const; @@ -288,6 +289,7 @@ public: virtual FormulaToken* Clone() const SAL_OVERRIDE; virtual svl::SharedString GetString() const SAL_OVERRIDE; + virtual void SetString( const svl::SharedString& rStr ) SAL_OVERRIDE; virtual bool operator==( const FormulaToken& rToken ) const SAL_OVERRIDE; DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaStringToken ) @@ -305,6 +307,7 @@ public: virtual FormulaToken* Clone() const SAL_OVERRIDE; virtual svl::SharedString GetString() const SAL_OVERRIDE; + virtual void SetString( const svl::SharedString& rStr ) SAL_OVERRIDE; virtual bool operator==( const FormulaToken& rToken ) const SAL_OVERRIDE; }; diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index 58bb092f3a7a..f907b1c4114f 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -314,6 +314,9 @@ public: /** Determines if this formula may be followed by a reference. */ bool MayReferenceFollow(); + + /** Re-intern SharedString in case the SharedStringPool differs. */ + void ReinternStrings( svl::SharedStringPool& rPool ); }; inline OpCode FormulaTokenArray::GetOuterFuncOpCode() diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 11d56f39fd2a..36c64e19c743 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -853,7 +853,11 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons } if (!pDocument->IsClipOrUndo()) + { + if (&pDocument->GetSharedStringPool() != &rCell.pDocument->GetSharedStringPool()) + pCode->ReinternStrings( pDocument->GetSharedStringPool()); pCode->AdjustReferenceOnCopy( aPos); + } if ( nCloneFlags & SC_CLONECELL_ADJUST3DREL ) pCode->ReadjustRelative3DReferences( rCell.aPos, aPos ); |