formula/source/core/api/token.cxx | 30 ++++++++++++++++++++++++++++++ include/formula/token.hxx | 3 +++ include/formula/tokenarray.hxx | 3 +++ sc/source/core/data/formulacell.cxx | 4 ++++ 4 files changed, 40 insertions(+)
New commits: commit dad412e07f805a53ad73ce2e80d187a70c77e8de Author: Eike Rathke <er...@redhat.com> Date: Tue Dec 15 17:44:30 2015 +0100 Resolves: tdf#95440 SharedString are interned per document, re-intern ... if literal strings are copied with formula expression tokens. Change-Id: I13526907bb6c2c605c6ed9584fa6e3f2b18623b8 diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index d46b02d..339e927 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 + } + } +} + /*----------------------------------------------------------------------*/ @@ -1651,6 +1671,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(); @@ -1672,6 +1697,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 f2a93b6..618168e 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -151,6 +151,7 @@ public: virtual double GetDouble() const; virtual double& GetDoubleAsReference(); 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; @@ -283,6 +284,7 @@ public: virtual FormulaToken* Clone() const override; virtual svl::SharedString GetString() const override; + virtual void SetString( const svl::SharedString& rStr ) override; virtual bool operator==( const FormulaToken& rToken ) const override; DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaStringToken ) @@ -300,6 +302,7 @@ public: virtual FormulaToken* Clone() const override; virtual svl::SharedString GetString() const override; + virtual void SetString( const svl::SharedString& rStr ) override; virtual bool operator==( const FormulaToken& rToken ) const override; }; diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index 0f303ac..6dcbcfc 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -309,6 +309,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 5c87b52..e574af7 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -916,7 +916,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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits