make SvxMarginItem hashable
Change-Id: I9e0d23a81186231ebe314c14993b93e7c8a9d844 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170149 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
This commit is contained in:
parent
d05a451fcd
commit
6e560140d9
2 changed files with 23 additions and 0 deletions
|
@ -77,6 +77,8 @@ public:
|
|||
MapUnit ePresMetric,
|
||||
OUString &rText, const IntlWrapper& ) const override;
|
||||
|
||||
virtual bool isHashable() const override;
|
||||
virtual size_t hashCode() const override;
|
||||
virtual bool operator==( const SfxPoolItem& ) const override;
|
||||
virtual SvxMarginItem* Clone( SfxItemPool *pPool = nullptr ) const override;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <editeng/itemtype.hxx>
|
||||
#include <editeng/eerdll.hxx>
|
||||
#include <svx/unomid.hxx>
|
||||
#include <o3tl/hash_combine.hxx>
|
||||
|
||||
#include <climits>
|
||||
|
||||
|
@ -216,6 +217,21 @@ bool SvxMarginItem::GetPresentation
|
|||
}
|
||||
|
||||
|
||||
bool SvxMarginItem::isHashable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t SvxMarginItem::hashCode() const
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
o3tl::hash_combine(seed, nLeftMargin);
|
||||
o3tl::hash_combine(seed, nTopMargin);
|
||||
o3tl::hash_combine(seed, nRightMargin);
|
||||
o3tl::hash_combine(seed, nBottomMargin);
|
||||
return seed;
|
||||
}
|
||||
|
||||
bool SvxMarginItem::operator==( const SfxPoolItem& rItem ) const
|
||||
{
|
||||
assert(SfxPoolItem::operator==(rItem));
|
||||
|
@ -260,6 +276,7 @@ bool SvxMarginItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
|
|||
|
||||
bool SvxMarginItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
|
||||
{
|
||||
ASSERT_CHANGE_REFCOUNTED_ITEM;
|
||||
bool bConvert = ( ( nMemberId & CONVERT_TWIPS ) != 0 );
|
||||
tools::Long nMaxVal = bConvert ? convertTwipToMm100(SHRT_MAX) : SHRT_MAX; // members are sal_Int16
|
||||
sal_Int32 nVal = 0;
|
||||
|
@ -290,24 +307,28 @@ bool SvxMarginItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
|
|||
|
||||
void SvxMarginItem::SetLeftMargin( sal_Int16 nLeft )
|
||||
{
|
||||
ASSERT_CHANGE_REFCOUNTED_ITEM;
|
||||
nLeftMargin = nLeft;
|
||||
}
|
||||
|
||||
|
||||
void SvxMarginItem::SetTopMargin( sal_Int16 nTop )
|
||||
{
|
||||
ASSERT_CHANGE_REFCOUNTED_ITEM;
|
||||
nTopMargin = nTop;
|
||||
}
|
||||
|
||||
|
||||
void SvxMarginItem::SetRightMargin( sal_Int16 nRight )
|
||||
{
|
||||
ASSERT_CHANGE_REFCOUNTED_ITEM;
|
||||
nRightMargin = nRight;
|
||||
}
|
||||
|
||||
|
||||
void SvxMarginItem::SetBottomMargin( sal_Int16 nBottom )
|
||||
{
|
||||
ASSERT_CHANGE_REFCOUNTED_ITEM;
|
||||
nBottomMargin = nBottom;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue