diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-21 11:23:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-21 12:56:21 +0200 |
commit | d78a07573eac1960c8c6c736e6c05bf304f96cb1 (patch) | |
tree | 7dbc12268fc1e529c9e678076f0b931cbb61211b /editeng/source/items/paraitem.cxx | |
parent | 4a5b52f8bcb7b5d4eb2fc4ba6560ba1e88c36503 (diff) |
tdf#158556 make SvxTabStopItem hashable
speeds up searching for it in the item pool
Change-Id: I37e8889e41d63a41e1a4bf2a35b4aa303745e15c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172171
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/items/paraitem.cxx')
-rw-r--r-- | editeng/source/items/paraitem.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index f70ff274e787..4019a6ce2c6b 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -50,6 +50,7 @@ #include <editeng/memberids.h> #include <editeng/itemtype.hxx> #include <editeng/eerdll.hxx> +#include <o3tl/hash_combine.hxx> using namespace ::com::sun::star; @@ -877,6 +878,7 @@ sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const void SvxTabStopItem::SetDefaultDistance(sal_Int32 nDefaultDistance) { + ASSERT_CHANGE_REFCOUNTED_ITEM; mnDefaultDistance = nDefaultDistance; } @@ -933,6 +935,7 @@ bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); nMemberId &= ~CONVERT_TWIPS; switch ( nMemberId ) @@ -1059,6 +1062,15 @@ bool SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const return true; } +size_t SvxTabStopItem::hashCode() const +{ + std::size_t seed(0); + o3tl::hash_combine(seed, Which()); + o3tl::hash_combine(seed, mnDefaultDistance); + o3tl::hash_combine(seed, maTabStops.size()); + return seed; +} + SvxTabStopItem* SvxTabStopItem::Clone( SfxItemPool * ) const { return new SvxTabStopItem( *this ); @@ -1098,6 +1110,7 @@ bool SvxTabStopItem::GetPresentation bool SvxTabStopItem::Insert( const SvxTabStop& rTab ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; sal_uInt16 nTabPos = GetPos(rTab); if(SVX_TAB_NOTFOUND != nTabPos ) Remove(nTabPos); @@ -1106,6 +1119,7 @@ bool SvxTabStopItem::Insert( const SvxTabStop& rTab ) void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; for( sal_uInt16 i = 0; i < pTabs->Count(); i++ ) { const SvxTabStop& rTab = (*pTabs)[i]; |