summaryrefslogtreecommitdiff
path: root/include/svl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-10-19 08:43:28 +0200
committerJan Holesovsky <kendy@collabora.com>2015-10-19 10:14:03 +0200
commitf6f32e8eabb2e09fbe2b70dfb540bb1ea1ee75a9 (patch)
treec209bbe8553133fc32bb986473795f2441517f48 /include/svl
parent6be5ed60e1823d909511c6af48e6bdc2817cce7c (diff)
sfx items: Get rid of the TypeId check, nobody uses that any more.
And introduce the appropriate assert() in the templatized version instead. Change-Id: I3e5b01e5e5ee49049fa6f35e3d05ef65a1890dc1
Diffstat (limited to 'include/svl')
-rw-r--r--include/svl/itemset.hxx20
1 files changed, 15 insertions, 5 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 7520d0de5fb6..a070eab2dfc1 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -80,16 +80,26 @@ public:
sal_uInt16 TotalCount() const;
const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const;
- const SfxPoolItem* GetItem( sal_uInt16 nWhich, bool bSearchInParent = true,
- TypeId aItemType = 0 ) const;
- /// Templatized version to directly return the correct type.
+ /** This method eases accessing single Items in the SfxItemSet.
+
+ @param nId SlotId or the Item's WhichId
+ @param bSearchInParent also search in parent ItemSets
+ @returns 0 if the ItemSet does not contain an Item with the Id 'nWhich'
+ */
+ const SfxPoolItem* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const;
+
+ /// Templatized version of GetItem() 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));
+ const SfxPoolItem* pItem = GetItem(nWhich, bSearchInParent);
+ const T* pCastedItem = dynamic_cast<const T*>(pItem);
+
+ assert(!pItem || pCastedItem); // if it exists, must have the correct type
+ return pCastedItem;
}
- /// Templatized static version to directly return the correct type if the SfxItemSet is available.
+ /// Templatized static version of GetItem() 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)