editeng/source/items/frmitems.cxx |   13 +++++++++++++
 include/editeng/ulspitem.hxx      |   14 +++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

New commits:
commit 7e241c2babf3ad705619a120ffc71e475ce7bb7a
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 22 18:58:52 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Aug 22 21:59:21 2024 +0200

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

diff --git a/editeng/source/items/frmitems.cxx 
b/editeng/source/items/frmitems.cxx
index ee8c84888c45..3a02201b65f0 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -1713,6 +1713,7 @@ bool SvxULSpaceItem::QueryValue( uno::Any& rVal, 
sal_uInt8 nMemberId ) const
 
 bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     nMemberId &= ~CONVERT_TWIPS;
     sal_Int32 nVal = 0;
@@ -1785,6 +1786,17 @@ bool SvxULSpaceItem::operator==( const SfxPoolItem& 
rAttr ) const
              nPropLower == rSpaceItem.nPropLower );
 }
 
+size_t SvxULSpaceItem::hashCode() const
+{
+    std::size_t seed(0);
+    o3tl::hash_combine(seed, nUpper);
+    o3tl::hash_combine(seed, nLower);
+    o3tl::hash_combine(seed, bContext);
+    o3tl::hash_combine(seed, nPropUpper);
+    o3tl::hash_combine(seed, nPropLower);
+    return seed;
+}
+
 SvxULSpaceItem* SvxULSpaceItem::Clone( SfxItemPool* ) const
 {
     return new SvxULSpaceItem( *this );
@@ -1854,6 +1866,7 @@ bool SvxULSpaceItem::GetPresentation
 
 void SvxULSpaceItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv )
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     nUpper = static_cast<sal_uInt16>(BigInt::Scale( nUpper, nMult, nDiv ));
     nLower = static_cast<sal_uInt16>(BigInt::Scale( nLower, nMult, nDiv ));
 }
diff --git a/include/editeng/ulspitem.hxx b/include/editeng/ulspitem.hxx
index b0131ab9904d..59e92f4b691b 100644
--- a/include/editeng/ulspitem.hxx
+++ b/include/editeng/ulspitem.hxx
@@ -47,6 +47,8 @@ public:
 
     // "pure virtual Methods" from SfxPoolItem
     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;
@@ -63,11 +65,11 @@ public:
     inline void SetUpper( const sal_uInt16 nU, const sal_uInt16 nProp = 100 );
     inline void SetLower( const sal_uInt16 nL, const sal_uInt16 nProp = 100 );
 
-    void SetUpperValue( const sal_uInt16 nU ) { nUpper = nU; }
-    void SetLowerValue( const sal_uInt16 nL ) { nLower = nL; }
-    void SetContextValue( const bool bC )     { bContext = bC; }
-    void SetPropUpper( const sal_uInt16 nU )  { nPropUpper = nU; }
-    void SetPropLower( const sal_uInt16 nL )  { nPropLower = nL; }
+    void SetUpperValue( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; 
nUpper = nU; }
+    void SetLowerValue( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; 
nLower = nL; }
+    void SetContextValue( const bool bC )     { ASSERT_CHANGE_REFCOUNTED_ITEM; 
bContext = bC; }
+    void SetPropUpper( const sal_uInt16 nU )  { ASSERT_CHANGE_REFCOUNTED_ITEM; 
nPropUpper = nU; }
+    void SetPropLower( const sal_uInt16 nL )  { ASSERT_CHANGE_REFCOUNTED_ITEM; 
nPropLower = nL; }
 
     sal_uInt16 GetUpper() const { return nUpper; }
     sal_uInt16 GetLower() const { return nLower; }
@@ -81,10 +83,12 @@ public:
 
 inline void SvxULSpaceItem::SetUpper( const sal_uInt16 nU, const sal_uInt16 
nProp )
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     nUpper = sal_uInt16((sal_uInt32(nU) * nProp ) / 100); nPropUpper = nProp;
 }
 inline void SvxULSpaceItem::SetLower( const sal_uInt16 nL, const sal_uInt16 
nProp )
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     nLower = sal_uInt16((sal_uInt32(nL) * nProp ) / 100); nPropLower = nProp;
 }
 

Reply via email to