Kaydet (Commit) 12790438 authored tarafından Eike Rathke's avatar Eike Rathke

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 5a7a4325
    Date:   Tue Nov 10 14:59:05 2015 +0200

        editeng: boost::ptr_vector->std::vector<std::unique_ptr>

and

    commit 4ff5a555
    Date:   Tue Jan 19 15:17:30 2016 +0200

        loplugin:unusedmethods

Plus XEditAttribute::operator==() was wrong since

    commit 71158788
    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/40455Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst e9b9a456
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment