summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-27 16:58:59 +0200
committerEike Rathke <erack@redhat.com>2017-07-27 17:48:59 +0200
commit238de04de6c8b67f74c75514b86c08bf888feb48 (patch)
tree520fba3d64eca15c97ec04fd1d3a510348bd629d
parent221dae68df80298e81e6e6549636f3528f5c8bc3 (diff)
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>
-rw-r--r--editeng/source/editeng/editobj.cxx18
-rw-r--r--editeng/source/editeng/editobj2.hxx3
-rw-r--r--include/editeng/editobj.hxx7
-rw-r--r--include/svl/itemset.hxx14
-rw-r--r--sc/source/core/data/global.cxx19
-rw-r--r--svl/source/items/itemset.cxx12
6 files changed, 48 insertions, 25 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 3a7036b05fb8..c3ac63cd6d61 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -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
{
@@ -1612,11 +1617,16 @@ 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;
}
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 460a891f7632..21e91dcec7b8 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -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;
diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx
index 68aa86c7c20e..2807aa96a962 100644
--- a/include/editeng/editobj.hxx
+++ b/include/editeng/editobj.hxx
@@ -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;
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 971444099f31..95953dd08f7f 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -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;
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 34398fe41760..a5b4e10bda3d 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -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;
}
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index d59872fa3799..72ae16c836bb 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1446,12 +1446,20 @@ 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;