SfxItemSet::HasItem method

Lubos Lunak l.lunak at suse.cz
Tue Feb 7 04:56:23 PST 2012


On Monday 06 of February 2012, Kohei Yoshida wrote:
> Hi there,
>
> I've just added a new method to SfxItemSet to provide an easy way to
> check whether or not an item is already set, and if it's already set,
> get that item.  Here is what I've added:
>
> bool SfxItemSet::HasItem(sal_uInt16 nWhich, const SfxPoolItem*& rpItem)
> const {
>     return SFX_ITEM_SET == GetItemState(nWhich, true, &rpItem);
> }

 I would suggest to make the second argument 'const SfxPoolItem **ppItem = 0', 
not only to keep it consistent with GetItemState(), but also to make it more 
visible that it is an out argument. The intuitive reading of "if( 
set.HasItem( which, item ))" to me is "does 'set' have an item of 
type 'which' that is 'item'?".

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list