Ditch use of EditTextObject::Store() in ScGlobal::EETextObjEqual()
This was the last incarnation of SfxItem binary stream serialization that is to be eliminated after clipboard use is gone. The "full" EditTextObject::operator==() in EditTextObjectImpl::operator==(), and via ContentInfo::operator==() in SfxItemSet::operator==(), also compare the SfxItemPool pointers which gets in the way here (not stored to stream hence didn't matter and maybe the reason for not having switched EETextObjEqual() to use operator==() back in the days). Introduce *::Equals() functions that do not compare pool pointers and let SfxItemSet::Equals() in that case not assume it would be operating on one pool only. Change-Id: Ifff939a92101c7f74695b676a45a7fdbb4f1d7f6 Reviewed-on: https://gerrit.libreoffice.org/40492 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
@@ -225,13 +225,13 @@ void ContentInfo::Dump() const
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ContentInfo::operator==( const ContentInfo& rCompare ) const
|
||||
bool ContentInfo::Equals( const ContentInfo& rCompare, bool bComparePool ) const
|
||||
{
|
||||
if( (maText == rCompare.maText) &&
|
||||
(aStyle == rCompare.aStyle ) &&
|
||||
(maCharAttribs.size() == rCompare.maCharAttribs.size()) &&
|
||||
(eFamily == rCompare.eFamily ) &&
|
||||
(aParaAttribs == rCompare.aParaAttribs ) )
|
||||
aParaAttribs.Equals( rCompare.aParaAttribs, bComparePool ) )
|
||||
{
|
||||
for (size_t i = 0, n = maCharAttribs.size(); i < n; ++i)
|
||||
{
|
||||
@@ -455,6 +455,11 @@ bool EditTextObject::operator==( const EditTextObject& rCompare ) const
|
||||
return mpImpl->operator==(*rCompare.mpImpl);
|
||||
}
|
||||
|
||||
bool EditTextObject::Equals( const EditTextObject& rCompare, bool bComparePool ) const
|
||||
{
|
||||
return mpImpl->Equals(*rCompare.mpImpl, bComparePool);
|
||||
}
|
||||
|
||||
// #i102062#
|
||||
bool EditTextObject::isWrongListEqual(const EditTextObject& rCompare) const
|
||||
{
|
||||
@@ -1611,12 +1616,17 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
|
||||
}
|
||||
|
||||
bool EditTextObjectImpl::operator==( const EditTextObjectImpl& rCompare ) const
|
||||
{
|
||||
return Equals( rCompare, true);
|
||||
}
|
||||
|
||||
bool EditTextObjectImpl::Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const
|
||||
{
|
||||
if( this == &rCompare )
|
||||
return true;
|
||||
|
||||
if( ( aContents.size() != rCompare.aContents.size() ) ||
|
||||
( pPool != rCompare.pPool ) ||
|
||||
( bComparePool && pPool != rCompare.pPool ) ||
|
||||
( nMetric != rCompare.nMetric ) ||
|
||||
( nUserType!= rCompare.nUserType ) ||
|
||||
( nScriptType != rCompare.nScriptType ) ||
|
||||
@@ -1626,7 +1636,7 @@ bool EditTextObjectImpl::operator==( const EditTextObjectImpl& rCompare ) const
|
||||
|
||||
for (size_t i = 0, n = aContents.size(); i < n; ++i)
|
||||
{
|
||||
if (!(*(aContents[i]) == *(rCompare.aContents[i])))
|
||||
if (!(aContents[i]->Equals( *(rCompare.aContents[i]), bComparePool)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
|
||||
const WrongList* GetWrongList() const;
|
||||
void SetWrongList( WrongList* p );
|
||||
bool operator==( const ContentInfo& rCompare ) const;
|
||||
bool Equals( const ContentInfo& rCompare, bool bComparePool ) const;
|
||||
|
||||
// #i102062#
|
||||
bool isWrongListEqual(const ContentInfo& rCompare) const;
|
||||
@@ -272,6 +272,7 @@ public:
|
||||
void StoreUnicodeStrings( bool b ) { bStoreUnicodeStrings = b; }
|
||||
|
||||
bool operator==( const EditTextObjectImpl& rCompare ) const;
|
||||
bool Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const;
|
||||
|
||||
// #i102062#
|
||||
bool isWrongListEqual(const EditTextObjectImpl& rCompare) const;
|
||||
|
||||
@@ -133,6 +133,13 @@ public:
|
||||
|
||||
bool operator==( const EditTextObject& rCompare ) const;
|
||||
|
||||
/** Compare possibly ignoring SfxItemPool pointer.
|
||||
@param bComparePool
|
||||
if <FALSE/> ignore SfxItemPool pointer,
|
||||
if <TRUE/> compare also SfxItemPool pointer (identical to operator==())
|
||||
*/
|
||||
bool Equals( const EditTextObject& rCompare, bool bComparePool ) const;
|
||||
|
||||
// #i102062#
|
||||
bool isWrongListEqual(const EditTextObject& rCompare) const;
|
||||
|
||||
|
||||
@@ -206,6 +206,20 @@ public:
|
||||
void Store( SvStream &, bool bDirect = false ) const;
|
||||
|
||||
bool operator==(const SfxItemSet &) const;
|
||||
|
||||
/** Compare possibly ignoring SfxItemPool pointer.
|
||||
|
||||
This can be used to compare the content of two SfxItemSet even if they
|
||||
don't share the same pool. EditTextObject::Equals(...,false) uses this
|
||||
which is needed in ScGlobal::EETextObjEqual() for
|
||||
ScPageHFItem::operator==()
|
||||
|
||||
@param bComparePool
|
||||
if <FALSE/> ignore SfxItemPool pointer,
|
||||
if <TRUE/> compare also SfxItemPool pointer (identical to operator==())
|
||||
*/
|
||||
bool Equals(const SfxItemSet &, bool bComparePool) const;
|
||||
|
||||
sal_Int32 getHash() const;
|
||||
OString stringify() const;
|
||||
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
||||
|
||||
@@ -788,24 +788,7 @@ bool ScGlobal::EETextObjEqual( const EditTextObject* pObj1,
|
||||
return true;
|
||||
|
||||
if ( pObj1 && pObj2 )
|
||||
{
|
||||
// First test for equal text content
|
||||
sal_Int32 nParCount = pObj1->GetParagraphCount();
|
||||
if ( nParCount != pObj2->GetParagraphCount() )
|
||||
return false;
|
||||
for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
|
||||
if ( pObj1->GetText(nPar) != pObj2->GetText(nPar) )
|
||||
return false;
|
||||
|
||||
SvMemoryStream aStream1;
|
||||
SvMemoryStream aStream2;
|
||||
pObj1->Store( aStream1 );
|
||||
pObj2->Store( aStream2 );
|
||||
const sal_uInt64 nSize = aStream1.Tell();
|
||||
if ( aStream2.Tell() == nSize )
|
||||
if ( !memcmp( aStream1.GetData(), aStream2.GetData(), (sal_uInt16) nSize ) )
|
||||
return true;
|
||||
}
|
||||
return pObj1->Equals( *pObj2, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1445,13 +1445,21 @@ void SfxItemSet::Load
|
||||
}
|
||||
|
||||
bool SfxItemSet::operator==(const SfxItemSet &rCmp) const
|
||||
{
|
||||
return Equals( rCmp, true);
|
||||
}
|
||||
|
||||
bool SfxItemSet::Equals(const SfxItemSet &rCmp, bool bComparePool) const
|
||||
{
|
||||
// Values we can get quickly need to be the same
|
||||
const bool bDifferentPools = (m_pPool != rCmp.m_pPool);
|
||||
if ( m_pParent != rCmp.m_pParent ||
|
||||
m_pPool != rCmp.m_pPool ||
|
||||
(bComparePool && bDifferentPools) ||
|
||||
Count() != rCmp.Count() )
|
||||
return false;
|
||||
|
||||
// If we reach here and bDifferentPools==true that means bComparePool==false.
|
||||
|
||||
// Counting Ranges takes longer; they also need to be the same, however
|
||||
sal_uInt16 nCount1 = TotalCount();
|
||||
sal_uInt16 nCount2 = rCmp.TotalCount();
|
||||
@@ -1499,7 +1507,7 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const
|
||||
if ( *ppItem1 != *ppItem2 &&
|
||||
( ( !*ppItem1 || !*ppItem2 ) ||
|
||||
( IsInvalidItem(*ppItem1) || IsInvalidItem(*ppItem2) ) ||
|
||||
(m_pPool->IsItemPoolable(**ppItem1)) ||
|
||||
(!bDifferentPools && m_pPool->IsItemPoolable(**ppItem1)) ||
|
||||
**ppItem1 != **ppItem2 ) )
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user