editeng/source/items/frmitems.cxx | 14 ++++++++++++++ include/editeng/boxitem.hxx | 9 ++++++++- include/svl/intitem.hxx | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit 086fd5d0de83e5dbff8b69ed86b85274d9fa1c7a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 22 16:25:56 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Aug 22 21:59:12 2024 +0200 tdf#158556 make SfxInt16Item hashable Change-Id: Id4e6feb4d0072a204d68e5dc834c6828221ea617 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172263 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx index 0d3adcf0a750..1197ed5de085 100644 --- a/include/svl/intitem.hxx +++ b/include/svl/intitem.hxx @@ -51,6 +51,8 @@ public: {} virtual bool operator ==(const SfxPoolItem & rItem) const override; + virtual bool supportsHashCode() const override { return true; } + virtual size_t hashCode() const override { return m_nValue; } virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, commit fc37b184eeaecee2f4d1d5cc7d6d032e59802cae Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 22 16:06:58 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Aug 22 21:59:03 2024 +0200 tdf#158556 make SvxBoxItem hashable Change-Id: I33557df66341ec0d201b66f97ed33c1c61155d7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172262 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 d2a788370e77..ee8c84888c45 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -2377,6 +2377,15 @@ bool SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const CompareBorderLine(mpRightBorderLine, rBoxItem.GetRight())); } +size_t SvxBoxItem::hashCode() const +{ + std::size_t seed(0); + o3tl::hash_combine(seed, mnTopDistance); + o3tl::hash_combine(seed, mnBottomDistance); + o3tl::hash_combine(seed, mnLeftDistance); + o3tl::hash_combine(seed, mnRightDistance); + return seed; +} table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, bool bConvert) { @@ -2617,6 +2626,7 @@ lcl_setLine(const uno::Any& rAny, Item& rItem, Line nLine, const bool bConvert) bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); SvxBoxItemLine nLine = SvxBoxItemLine::TOP; bool bDistMember = false; @@ -3009,6 +3019,7 @@ bool SvxBoxItem::GetPresentation void SvxBoxItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; if (mpTopBorderLine) mpTopBorderLine->ScaleMetrics( nMult, nDiv ); if (mpBottomBorderLine) @@ -3060,6 +3071,7 @@ const SvxBorderLine *SvxBoxItem::GetLine( SvxBoxItemLine nLine ) const void SvxBoxItem::SetLine( const SvxBorderLine* pNew, SvxBoxItemLine nLine ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; std::unique_ptr<SvxBorderLine> pTmp( pNew ? new SvxBorderLine( *pNew ) : nullptr ); switch ( nLine ) @@ -3128,6 +3140,7 @@ sal_Int16 SvxBoxItem::GetDistance( SvxBoxItemLine nLine, bool bAllowNegative ) c void SvxBoxItem::SetDistance( sal_Int16 nNew, SvxBoxItemLine nLine ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; switch ( nLine ) { case SvxBoxItemLine::TOP: @@ -3218,6 +3231,7 @@ sal_Int16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine, b void SvxBoxItem::tryMigrateComplexColor(SvxBoxItemLine eLine) { + ASSERT_CHANGE_REFCOUNTED_ITEM; if (!GetLine(eLine)) return; diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx index 6ceff99268c3..60a6d09c5b92 100644 --- a/include/editeng/boxitem.hxx +++ b/include/editeng/boxitem.hxx @@ -82,6 +82,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; @@ -114,18 +116,22 @@ public: editeng::SvxBorderLine* GetTop() { + ASSERT_CHANGE_REFCOUNTED_ITEM; return mpTopBorderLine.get(); } editeng::SvxBorderLine* GetBottom() { + ASSERT_CHANGE_REFCOUNTED_ITEM; return mpBottomBorderLine.get(); } editeng::SvxBorderLine* GetLeft() { + ASSERT_CHANGE_REFCOUNTED_ITEM; return mpLeftBorderLine.get(); } editeng::SvxBorderLine* GetRight() { + ASSERT_CHANGE_REFCOUNTED_ITEM; return mpRightBorderLine.get(); } @@ -142,10 +148,11 @@ public: void SetDistance( sal_Int16 nNew, SvxBoxItemLine nLine ); void SetAllDistances(sal_Int16 nNew) { + ASSERT_CHANGE_REFCOUNTED_ITEM; mnTopDistance = mnBottomDistance = mnLeftDistance = mnRightDistance = nNew; } - void SetRemoveAdjacentCellBorder( bool bSet ) { mbRemoveAdjCellBorder = bSet; } + void SetRemoveAdjacentCellBorder( bool bSet ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mbRemoveAdjCellBorder = bSet; } // Line width plus Space plus inward distance // bEvenIfNoLine = TRUE -> Also return distance, when no Line is set