summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-08-22 19:45:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-08-23 12:01:27 +0200
commitf2b6a04f37e24e47984eb2539771a86cf7b08d4b (patch)
treee5b05c5e41f6061b27e192eb4780de8c54a563c0
parent4d8fdb32e7f054f2d8704121a60f830524fe7796 (diff)
tdf#158556 make SvxFirstLineIndentItem hashable
Change-Id: Ic23d0956b87eefb575696dad7af775a37cd50b10 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172289 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--editeng/source/items/frmitems.cxx23
-rw-r--r--include/editeng/lrspitem.hxx8
-rw-r--r--include/editeng/shaditem.hxx8
3 files changed, 33 insertions, 6 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 93c4a9fe646f..25ac10818176 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -497,6 +497,7 @@ void SvxLRSpaceItem::SetRight(const tools::Long nR, const sal_uInt16 nProp)
void SvxFirstLineIndentItem::SetTextFirstLineOffset(
const short nF, const sal_uInt16 nProp)
{
+ ASSERT_CHANGE_REFCOUNTED_ITEM;
m_nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100);
m_nPropFirstLineOffset = nProp;
}
@@ -967,6 +968,7 @@ bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) con
bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
+ ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -1018,6 +1020,15 @@ bool SvxFirstLineIndentItem::operator==(const SfxPoolItem& rAttr) const
&& m_bAutoFirst == rOther.IsAutoFirst());
}
+size_t SvxFirstLineIndentItem::hashCode() const
+{
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, m_nFirstLineOffset);
+ o3tl::hash_combine(seed, m_nPropFirstLineOffset);
+ o3tl::hash_combine(seed, m_bAutoFirst);
+ return seed;
+}
+
SvxFirstLineIndentItem* SvxFirstLineIndentItem::Clone(SfxItemPool *) const
{
return new SvxFirstLineIndentItem(*this);
@@ -1070,6 +1081,7 @@ bool SvxFirstLineIndentItem::GetPresentation
void SvxFirstLineIndentItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv)
{
+ ASSERT_CHANGE_REFCOUNTED_ITEM;
m_nFirstLineOffset = static_cast<short>(BigInt::Scale(m_nFirstLineOffset, nMult, nDiv));
}
@@ -2108,6 +2120,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
+ ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -2178,6 +2191,15 @@ bool SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
( eLocation == rItem.GetLocation() ) );
}
+size_t SvxShadowItem::hashCode() const
+{
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, sal_Int32(aShadowColor));
+ o3tl::hash_combine(seed, nWidth);
+ o3tl::hash_combine(seed, static_cast<int>(eLocation));
+ return seed;
+}
+
SvxShadowItem* SvxShadowItem::Clone( SfxItemPool* ) const
{
return new SvxShadowItem( *this );
@@ -2277,6 +2299,7 @@ bool SvxShadowItem::GetPresentation
void SvxShadowItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv )
{
+ ASSERT_CHANGE_REFCOUNTED_ITEM;
nWidth = static_cast<sal_uInt16>(BigInt::Scale( nWidth, nMult, nDiv ));
}
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index ca46cd0dfc15..4f69ce21639a 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -142,16 +142,16 @@ private:
public:
bool IsAutoFirst() const { return m_bAutoFirst; }
- void SetAutoFirst(const bool bNew) { m_bAutoFirst = bNew; }
+ void SetAutoFirst(const bool bNew) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_bAutoFirst = bNew; }
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
short GetTextFirstLineOffset() const { return m_nFirstLineOffset; }
void SetPropTextFirstLineOffset(const sal_uInt16 nProp)
- { m_nPropFirstLineOffset = nProp; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nPropFirstLineOffset = nProp; }
sal_uInt16 GetPropTextFirstLineOffset() const
{ return m_nPropFirstLineOffset; }
void SetTextFirstLineOffsetValue(const short nValue)
- { m_nFirstLineOffset = nValue; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nFirstLineOffset = nValue; }
explicit SvxFirstLineIndentItem(const sal_uInt16 nId);
SvxFirstLineIndentItem(const short nOffset, const sal_uInt16 nId);
@@ -159,6 +159,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;
diff --git a/include/editeng/shaditem.hxx b/include/editeng/shaditem.hxx
index bed848215985..549c2f5fc2ec 100644
--- a/include/editeng/shaditem.hxx
+++ b/include/editeng/shaditem.hxx
@@ -49,6 +49,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;
@@ -62,13 +64,13 @@ public:
virtual bool HasMetrics() const override;
const Color& GetColor() const { return aShadowColor;}
- void SetColor( const Color &rNew ) { aShadowColor = rNew; }
+ void SetColor( const Color &rNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; aShadowColor = rNew; }
sal_uInt16 GetWidth() const { return nWidth; }
SvxShadowLocation GetLocation() const { return eLocation; }
- void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
- void SetLocation( SvxShadowLocation eNew ) { eLocation = eNew; }
+ void SetWidth( sal_uInt16 nNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nWidth = nNew; }
+ void SetLocation( SvxShadowLocation eNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; eLocation = eNew; }
// Calculate width of the shadow on the page.
sal_uInt16 CalcShadowSpace( SvxShadowItemSide nShadow ) const;