fdo#75757: remove inheritance to std::map

from SfxItemPtrMap.

Change-Id: Id7e9667f9b918afaf92d9e71bf0e2c2e9c296474
Reviewed-on: https://gerrit.libreoffice.org/11696
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
This commit is contained in:
Takeshi Abe
2014-09-29 23:33:31 +09:00
committed by Michael Stahl
parent 8eae6dc82e
commit af046d12d2

View File

@@ -44,19 +44,11 @@
#include <sfx2/msgpool.hxx> #include <sfx2/msgpool.hxx>
#include <sidebar/ContextChangeBroadcaster.hxx> #include <sidebar/ContextChangeBroadcaster.hxx>
#include <map> #include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
// Maps the Which() field to a pointer to a SfxPoolItem // Maps the Which() field to a pointer to a SfxPoolItem
class SfxItemPtrMap : public std::map<sal_uInt16, SfxPoolItem*> typedef boost::ptr_map<sal_uInt16, SfxPoolItem> SfxItemPtrMap;
{
public:
~SfxItemPtrMap()
{
for(iterator it = begin(); it != end(); ++it)
delete it->second;
}
};
TYPEINIT0(SfxShell); TYPEINIT0(SfxShell);
@@ -164,7 +156,7 @@ const SfxPoolItem* SfxShell::GetItem
sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s
) const ) const
{ {
SfxItemPtrMap::iterator it = pImp->aItems.find( nSlotId ); SfxItemPtrMap::const_iterator it = pImp->aItems.find( nSlotId );
if( it != pImp->aItems.end() ) if( it != pImp->aItems.end() )
return it->second; return it->second;
return 0; return 0;
@@ -183,15 +175,14 @@ void SfxShell::PutItem
// MSC made a mess here of WNT/W95, beware of changes // MSC made a mess here of WNT/W95, beware of changes
SfxPoolItem *pItem = rItem.Clone(); SfxPoolItem *pItem = rItem.Clone();
SfxPoolItemHint aItemHint( pItem ); SfxPoolItemHint aItemHint( pItem );
const sal_uInt16 nWhich = rItem.Which(); sal_uInt16 nWhich = rItem.Which();
SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich ); SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich );
if( it != pImp->aItems.end() ) if( it != pImp->aItems.end() )
{ {
SfxPoolItem *pLoopItem = it->second;
// Replace Item // Replace Item
delete pLoopItem; pImp->aItems.erase( it );
it->second = pItem; pImp->aItems.insert( nWhich, pItem );
// if active, notify Bindings // if active, notify Bindings
SfxDispatcher *pDispat = GetDispatcher(); SfxDispatcher *pDispat = GetDispatcher();
@@ -212,7 +203,7 @@ void SfxShell::PutItem
else else
{ {
Broadcast( aItemHint ); Broadcast( aItemHint );
pImp->aItems[ pItem->Which() ] = pItem; pImp->aItems.insert( nWhich, pItem );
} }
} }