diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-15 14:19:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-16 07:54:24 +0100 |
commit | 13b89618c49adfd77d184f22e23420a7b6d4678b (patch) | |
tree | 089702c613bd099b478fbeb28ba04a09eef6b8b1 /include/svl | |
parent | Removed duplicated include (diff) | |
download | core-13b89618c49adfd77d184f22e23420a7b6d4678b.tar.gz core-13b89618c49adfd77d184f22e23420a7b6d4678b.zip |
use implict conversion operator in TypedWhichId
instead of spreading calls to Which() everywhere.
Change-Id: Ie32d106e44f5cb583908eeebe254ab8b8168ae61
Reviewed-on: https://gerrit.libreoffice.org/44760
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svl')
-rw-r--r-- | include/svl/itempool.hxx | 10 | ||||
-rw-r--r-- | include/svl/itemset.hxx | 15 | ||||
-rw-r--r-- | include/svl/poolitem.hxx | 6 | ||||
-rw-r--r-- | include/svl/typedwhich.hxx | 11 |
4 files changed, 12 insertions, 30 deletions
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 22ea12cf4e24..f4f5d86f3a08 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -105,7 +105,7 @@ public: const SfxPoolItem* GetPoolDefaultItem( sal_uInt16 nWhich ) const; template<class T> const T* GetPoolDefaultItem( TypedWhichId<T> nWhich ) const - { return static_cast<const T*>(GetPoolDefaultItem(nWhich.Which())); } + { return static_cast<const T*>(GetPoolDefaultItem(sal_uInt16(nWhich))); } void ResetPoolDefaultItem( sal_uInt16 nWhich ); @@ -155,17 +155,17 @@ public: const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; template<class T> const T& GetDefaultItem( TypedWhichId<T> nWhich ) const - { return static_cast<const T&>(GetDefaultItem(nWhich.Which())); } + { return static_cast<const T&>(GetDefaultItem(sal_uInt16(nWhich))); } bool CheckItemInPool(const SfxPoolItem *) const; const SfxPoolItem * GetItem2(sal_uInt16 nWhich, sal_uInt32 nSurrogate) const; template<class T> const T* GetItem2( TypedWhichId<T> nWhich, sal_uInt32 nSurrogate ) const - { return dynamic_cast<const T*>(GetItem2(nWhich.Which(), nSurrogate)); } + { return dynamic_cast<const T*>(GetItem2(sal_uInt16(nWhich), nSurrogate)); } const SfxPoolItem * GetItem2Default(sal_uInt16 nWhich) const; template<class T> const T* GetItem2Default( TypedWhichId<T> nWhich ) const - { return static_cast<const T*>(GetItem2Default(nWhich.Which())); } + { return static_cast<const T*>(GetItem2Default(sal_uInt16(nWhich))); } sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; @@ -184,8 +184,6 @@ public: { return IsItemPoolable( rItem.Which() ); } void SetItemInfos( const SfxItemInfo *pInfos ); sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const; - template<class T> sal_uInt16 GetWhich( TypedWhichId<T> nSlot, bool bDeep = true ) const - { return GetWhich(nSlot.Which(), bDeep); } sal_uInt16 GetSlotId( sal_uInt16 nWhich ) const; sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, bool bDeep = true ) const; sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich ) const; diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 3254263c38ab..9291fd430421 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -135,7 +135,7 @@ public: template<class T> const T& Get( TypedWhichId<T> nWhich, bool bSrchInParent = true ) const { - return static_cast<const T&>(Get(nWhich.Which(), bSrchInParent)); + return static_cast<const T&>(Get(sal_uInt16(nWhich), bSrchInParent)); } /** This method eases accessing single Items in the SfxItemSet. @@ -157,7 +157,7 @@ public: } template<class T> const T* GetItem( TypedWhichId<T> nWhich, bool bSearchInParent = true ) const { - const SfxPoolItem* pItem = GetItem(nWhich.Which(), bSearchInParent); + const SfxPoolItem* pItem = GetItem(sal_uInt16(nWhich), bSearchInParent); const T* pCastedItem = dynamic_cast<const T*>(pItem); assert(!pItem || pCastedItem); // if it exists, must have the correct type @@ -181,23 +181,12 @@ public: SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true, const SfxPoolItem **ppItem = nullptr ) const; - template<class T> - SfxItemState GetItemState( TypedWhichId<T> nWhich, - bool bSrchInParent = true, - const SfxPoolItem **ppItem = nullptr ) const - { return GetItemState(nWhich.Which(), bSrchInParent, ppItem); } bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = nullptr) const; void DisableItem(sal_uInt16 nWhich); - template<class T> void DisableItem( TypedWhichId<T> nWhich ) - { DisableItem(nWhich.Which()); } void InvalidateItem( sal_uInt16 nWhich ); - template<class T> void InvalidateItem( TypedWhichId<T> nWhich ) - { InvalidateItem(nWhich.Which()); } sal_uInt16 ClearItem( sal_uInt16 nWhich = 0); - template<class T> sal_uInt16 ClearItem( TypedWhichId<T> nWhich ) - { return ClearItem(nWhich.Which()); } void ClearInvalidItems(); void InvalidateAllItems(); // HACK(via nWhich = 0) ??? diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 2d5a6f567c0b..1f49b16400a5 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -150,10 +150,6 @@ public: assert(m_nRefCount==0); m_nWhich = nId; } - template<class T> void SetWhich( TypedWhichId<T> nId ) - { - SetWhich(nId.Which()); - } sal_uInt16 Which() const { return m_nWhich; } virtual bool operator==( const SfxPoolItem& ) const = 0; bool operator!=( const SfxPoolItem& rItem ) const @@ -180,7 +176,7 @@ public: SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const; template<class T> T* CloneSetWhich( TypedWhichId<T> nId ) const { - return static_cast<T*>(CloneSetWhich(nId.Which())); + return static_cast<T*>(CloneSetWhich(sal_uInt16(nId))); } sal_uInt32 GetRefCount() const { return m_nRefCount; } diff --git a/include/svl/typedwhich.hxx b/include/svl/typedwhich.hxx index c9cb3d8e3667..2c2141250d02 100644 --- a/include/svl/typedwhich.hxx +++ b/include/svl/typedwhich.hxx @@ -23,27 +23,26 @@ public: : mnWhich(nWhich) { } - constexpr sal_uInt16 Which() const { return mnWhich; } - //constexpr operator sal_uInt16() const { return mnWhich; } + constexpr operator sal_uInt16() const { return mnWhich; } private: sal_uInt16 const mnWhich; }; template <class T> constexpr bool operator==(sal_uInt16 lhs, TypedWhichId<T> const& rhs) { - return lhs == rhs.Which(); + return lhs == sal_uInt16(rhs); } template <class T> constexpr bool operator!=(sal_uInt16 lhs, TypedWhichId<T> const& rhs) { - return lhs != rhs.Which(); + return lhs != sal_uInt16(rhs); } template <class T> constexpr bool operator==(TypedWhichId<T> const& lhs, sal_uInt16 rhs) { - return lhs.Which() == rhs; + return sal_uInt16(lhs) == rhs; } template <class T> constexpr bool operator!=(TypedWhichId<T> const& lhs, sal_uInt16 rhs) { - return lhs.Which() != rhs; + return sal_uInt16(lhs) != rhs; } #endif // INCLUDED_SVL_TYPEDWHICH_HXX |