editeng/source/items/frmitems.cxx |   18 ++++++++++++++++++
 include/editeng/brushitem.hxx     |    2 ++
 2 files changed, 20 insertions(+)

New commits:
commit 01d183d2290668c310d592bf2e4c298ddcfb10b4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Aug 23 14:17:01 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 23 16:45:31 2024 +0200

    tdf#158556 make SvxBrushItem hashable
    
    Change-Id: I82794dbf004781a86c8443b72263528167fe0359
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172316
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/editeng/source/items/frmitems.cxx 
b/editeng/source/items/frmitems.cxx
index 25ac10818176..f457781e39bd 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -4255,6 +4255,7 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 
nMemberId ) const
 
 bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     nMemberId &= ~CONVERT_TWIPS;
     switch( nMemberId)
     {
@@ -4462,6 +4463,23 @@ bool SvxBrushItem::operator==( const SfxPoolItem& rAttr 
) const
     return bEqual;
 }
 
+size_t SvxBrushItem::hashCode() const
+{
+    std::size_t seed(0);
+    o3tl::hash_combine(seed, static_cast<sal_Int32>(aColor));
+    o3tl::hash_combine(seed, maComplexColor);
+    o3tl::hash_combine(seed, static_cast<sal_Int32>(aFilterColor));
+    o3tl::hash_combine(seed, eGraphicPos);
+    o3tl::hash_combine(seed, nGraphicTransparency);
+    if ( GPOS_NONE != eGraphicPos )
+    {
+        o3tl::hash_combine(seed, maStrLink);
+        o3tl::hash_combine(seed, maStrFilter);
+    }
+    o3tl::hash_combine(seed, nShadingValue);
+    return seed;
+}
+
 SvxBrushItem* SvxBrushItem::Clone( SfxItemPool* ) const
 {
     return new SvxBrushItem( *this );
diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx
index 6897e319a3b6..cc71f6135d80 100644
--- a/include/editeng/brushitem.hxx
+++ b/include/editeng/brushitem.hxx
@@ -85,6 +85,8 @@ public:
                                   OUString &rText, const IntlWrapper& ) const 
override;
 
     virtual bool             operator==( const SfxPoolItem& ) const override;
+    virtual bool             supportsHashCode() const override { return true; }
+    virtual size_t           hashCode() const override;
     virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 
nMemberId = 0 ) const override;
     virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 
nMemberId ) override;
 

Reply via email to