diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-10-16 12:06:21 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-10-16 12:12:28 +0200 |
commit | adeefc6295b1cf411b47b9b4213c16effea9d832 (patch) | |
tree | 04eb6620ab4bc1ed72b7c187994c13be30726f52 /include | |
parent | 20248b82be361279f2b4814280b0371658ca27c0 (diff) |
sfx items: Kill the unreadable & misplaced SFX_ITEMSET_ARG too.
Change-Id: I1e0f96dce2b9cf9da32f4f577cf76e1d8824d37a
Diffstat (limited to 'include')
-rw-r--r-- | include/sfx2/request.hxx | 13 | ||||
-rw-r--r-- | include/svl/itemset.hxx | 13 |
2 files changed, 11 insertions, 15 deletions
diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx index 05e89100d1d6..a59a49e3b59e 100644 --- a/include/sfx2/request.hxx +++ b/include/sfx2/request.hxx @@ -78,10 +78,6 @@ public: void AppendItem(const SfxPoolItem &); void RemoveItem( sal_uInt16 nSlotId ); - static const SfxPoolItem* GetItem( const SfxItemSet*, sal_uInt16 nSlotId, - bool bDeep = false, - std::function<bool ( const SfxPoolItem* )> isItemType = nullptr ); - /** Templatized access to the individual parameters of the SfxRequest. Use like: const SfxInt32Item *pPosItem = rReq.GetArg<SfxInt32Item>(SID_POS); @@ -121,15 +117,6 @@ private: const SfxRequest& operator=(const SfxRequest &) = delete; }; -template<class T> bool checkSfxPoolItem(const SfxPoolItem* pItem) -{ - return dynamic_cast<const T*>(pItem) != nullptr; -} - -#define SFX_ITEMSET_ARG(pArgs, pItem, ItemType, nSlotId) \ - const ItemType *pItem = static_cast<const ItemType*>( \ - SfxRequest::GetItem( pArgs, nSlotId, false, checkSfxPoolItem<ItemType> ) ) - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 4685441ecbf1..52d4d7a7f688 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -87,12 +87,21 @@ public: const SfxPoolItem* GetItem( sal_uInt16 nWhich, bool bSearchInParent = true, TypeId aItemType = 0 ) const; - /// Templatized version of the GetItem(). - template<class T> const T* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const + /// Templatized version to directly return the correct type. + template<class T> const T* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const { return dynamic_cast<const T*>(GetItem(nWhich, bSearchInParent)); } + /// Templatized static version to directly return the correct type if the SfxItemSet is available. + template<class T> static const T* GetItem(const SfxItemSet* pItemSet, sal_uInt16 nWhich, bool bSearchInParent = true) + { + if (pItemSet) + return pItemSet->GetItem<T>(nWhich, bSearchInParent); + + return nullptr; + } + // Get Which-value of the item at position nPos sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const; |