diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-26 17:03:46 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-26 21:41:14 +0200 |
commit | 1279043814865cd48c3b577c5e21db0b93d5c24c (patch) | |
tree | 8a94dbf6d0802e8b9425dfce4cf7d80cda3001b2 /editeng | |
parent | e9b9a456221b4b0660f90efa1ee092ea00c2c728 (diff) |
Restore and fix and fix harder the EditTextObject::operator==()
... chaining down to EditTextObjectImpl::operator==() that compared unique_ptr
instead of content with ContentInfo::operator==() that needed to use
XEditAttribute::operator==() instead of comparing pointers. That resulted in
always false..
Wrong as a chain of
commit 5a7a4325eca58c253270d4e9d327042a9ee2c5f0
Date: Tue Nov 10 14:59:05 2015 +0200
editeng: boost::ptr_vector->std::vector<std::unique_ptr>
and
commit 4ff5a5558472beee85eb1234dcc2aa2ed9000f6c
Date: Tue Jan 19 15:17:30 2016 +0200
loplugin:unusedmethods
Plus XEditAttribute::operator==() was wrong since
commit 71158788efb32ffc3bac5154c38ca5d79525155c
Date: Thu May 4 08:11:41 2006 +0000
INTEGRATION: CWS impressc03u3 (1.8.40); FILE MERGED
2006/04/27 12:33:10 cl 1.8.40.1: #i64360# fixed operator==
that (to fix a crash comparing items of different types) changed
- ( (pItem == rCompare.pItem) || (*pItem == *rCompare.pItem));
+ ( (pItem == rCompare.pItem) ||
+ ( pItem->Which() != rCompare.pItem->Which()) ||
+ (*pItem == *rCompare.pItem));
so returning true if Which-IDs differed, instead of
+ ((pItem == rCompare.pItem) ||
+ ((pItem->Which() == rCompare.pItem->Which()) &&
+ (*pItem == *rCompare.pItem)));
Change-Id: I8300c04001e98cb71e520bbe2c180aec0c0a3333
Reviewed-on: https://gerrit.libreoffice.org/40455
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 22 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 12 |
2 files changed, 33 insertions, 1 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 34eacc474167..3a7036b05fb8 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -225,6 +225,26 @@ void ContentInfo::Dump() const } #endif +bool ContentInfo::operator==( const ContentInfo& rCompare ) const +{ + if( (maText == rCompare.maText) && + (aStyle == rCompare.aStyle ) && + (maCharAttribs.size() == rCompare.maCharAttribs.size()) && + (eFamily == rCompare.eFamily ) && + (aParaAttribs == rCompare.aParaAttribs ) ) + { + for (size_t i = 0, n = maCharAttribs.size(); i < n; ++i) + { + if (!(*(maCharAttribs[i]) == *(rCompare.maCharAttribs[i]))) + return false; + } + + return true; + } + + return false; +} + EditTextObject::EditTextObject( SfxItemPool* pPool ) : mpImpl(new EditTextObjectImpl(this, pPool)) { @@ -1606,7 +1626,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]) == *(rCompare.aContents[i]))) return false; } diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index 928f4ba12b84..460a891f7632 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -69,8 +69,19 @@ public: bool IsFeature() const; void SetItem(const SfxPoolItem& rNew); + + inline bool operator==( const XEditAttribute& rCompare ) const; }; +inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const +{ + return (nStart == rCompare.nStart) && + (nEnd == rCompare.nEnd) && + ((pItem == rCompare.pItem) || + ((pItem->Which() == rCompare.pItem->Which()) && + (*pItem == *rCompare.pItem))); +} + struct XParaPortion { long nHeight; @@ -152,6 +163,7 @@ public: const WrongList* GetWrongList() const; void SetWrongList( WrongList* p ); + bool operator==( const ContentInfo& rCompare ) const; // #i102062# bool isWrongListEqual(const ContentInfo& rCompare) const; |