editeng/source/items/frmitems.cxx |   12 ++++++++++++
 include/editeng/lrspitem.hxx      |    2 ++
 2 files changed, 14 insertions(+)

New commits:
commit ba0f68732ed89e11157dc618a697bfeb173c6252
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 22 20:54:34 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 23 09:59:44 2024 +0200

    tdf#158556 make SvxTextLeftMarginItem hashable
    
    Change-Id: Idc91bf66e8ba050fcd133ef98f8364fbbb2e8efa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172294
    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 3a02201b65f0..93c4a9fe646f 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -532,6 +532,7 @@ void SvxTextLeftMarginItem::SetLeft(SvxFirstLineIndentItem 
const& rFirstLine,
 
 void SvxTextLeftMarginItem::SetTextLeft(const tools::Long nL, const sal_uInt16 
nProp)
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     m_nTextLeftMargin = (nL * nProp) / 100;
     m_nPropLeftMargin = nProp;
 }
@@ -784,6 +785,7 @@ bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, 
sal_uInt8 nMemberId) cons
 
 bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
     nMemberId &= ~CONVERT_TWIPS;
 
@@ -830,6 +832,15 @@ bool SvxTextLeftMarginItem::operator==(const SfxPoolItem& 
rAttr) const
         && m_nPropLeftMargin == rOther.GetPropLeft());
 }
 
+size_t SvxTextLeftMarginItem::hashCode() const
+{
+    std::size_t seed(0);
+    o3tl::hash_combine(seed, m_nTextLeftMargin);
+    o3tl::hash_combine(seed, m_nPropLeftMargin);
+    return seed;
+}
+
+
 SvxTextLeftMarginItem* SvxTextLeftMarginItem::Clone(SfxItemPool *) const
 {
     return new SvxTextLeftMarginItem(*this);
@@ -881,6 +892,7 @@ bool SvxTextLeftMarginItem::GetPresentation
 
 void SvxTextLeftMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long 
const nDiv)
 {
+    ASSERT_CHANGE_REFCOUNTED_ITEM;
     m_nTextLeftMargin = BigInt::Scale(m_nTextLeftMargin, nMult, nDiv);
 }
 
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index edab3ef23d73..ca46cd0dfc15 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -111,6 +111,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;

Reply via email to