diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-10-16 08:42:39 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-10-16 12:12:27 +0200 |
commit | e5be07f5167d4103b4620201df350b1d9e795393 (patch) | |
tree | a100ca13a792d765caf75decd2b47104bf3a9f41 /include/sfx2 | |
parent | 427c5dc6e0f817253b2f8cd7727e447ac4f4d656 (diff) |
sfx items: Kill the unreadable SFX_REQUEST_ARG, use a template param instead.
Change-Id: I7130f7a84077a63cdc0ca1e131a4d90469eac90d
Diffstat (limited to 'include/sfx2')
-rw-r--r-- | include/sfx2/request.hxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx index 9b6e54dd9409..8f03849378f9 100644 --- a/include/sfx2/request.hxx +++ b/include/sfx2/request.hxx @@ -81,7 +81,15 @@ public: static const SfxPoolItem* GetItem( const SfxItemSet*, sal_uInt16 nSlotId, bool bDeep = false, std::function<bool ( const SfxPoolItem* )> isItemType = nullptr ); - const SfxPoolItem* GetArg( sal_uInt16 nSlotId, bool bDeep = false, std::function<bool ( const SfxPoolItem* )> isItemType = nullptr ) const; + + /** Templatized access to the individual parameters of the SfxRequest. + + Use like: const SfxInt32Item *pPosItem = rReq.GetArg<SfxInt32Item>(SID_POS); + */ + template<class T> const T* GetArg(sal_uInt16 nSlotId) const + { + return dynamic_cast<const T*>(GetItem(pArgs, nSlotId)); + } void ReleaseArgs(); void SetReturnValue(const SfxPoolItem &); @@ -115,9 +123,6 @@ template<class T> bool checkSfxPoolItem(const SfxPoolItem* pItem) return dynamic_cast<const T*>(pItem) != nullptr; } -#define SFX_REQUEST_ARG(rReq, pItem, ItemType, nSlotId) \ - const ItemType *pItem = static_cast<const ItemType*>( \ - rReq.GetArg( nSlotId, false, checkSfxPoolItem<ItemType> ) ) #define SFX_ITEMSET_ARG(pArgs, pItem, ItemType, nSlotId) \ const ItemType *pItem = static_cast<const ItemType*>( \ SfxRequest::GetItem( pArgs, nSlotId, false, checkSfxPoolItem<ItemType> ) ) |