sfx items: Introduce a templatized version of SfxItemSet::GetItem().

Change-Id: I821622fc1f8415f2ddd14744f33b46fa76f00039
This commit is contained in:
Jan Holesovsky 2015-10-16 09:41:46 +02:00
parent e5be07f516
commit 20248b82be
2 changed files with 11 additions and 2 deletions

View file

@ -88,7 +88,10 @@ public:
*/
template<class T> const T* GetArg(sal_uInt16 nSlotId) const
{
return dynamic_cast<const T*>(GetItem(pArgs, nSlotId));
if (pArgs)
return pArgs->GetItem<T>(nSlotId, false);
return nullptr;
}
void ReleaseArgs();

View file

@ -84,9 +84,15 @@ public:
sal_uInt16 TotalCount() const;
const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const;
const SfxPoolItem* GetItem( sal_uInt16 nWhich, bool bSrchInParent = true,
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
{
return dynamic_cast<const T*>(GetItem(nWhich, bSearchInParent));
}
// Get Which-value of the item at position nPos
sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const;