From af046d12d27bc4f87a3c0142dba749d21c8eec7d Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Mon, 29 Sep 2014 23:33:31 +0900 Subject: fdo#75757: remove inheritance to std::map from SfxItemPtrMap. Change-Id: Id7e9667f9b918afaf92d9e71bf0e2c2e9c296474 Reviewed-on: https://gerrit.libreoffice.org/11696 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sfx2/source/control/shell.cxx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 29b2d1a3ee86..9ad1b8ada695 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -44,19 +44,11 @@ #include #include -#include +#include #include // Maps the Which() field to a pointer to a SfxPoolItem -class SfxItemPtrMap : public std::map -{ -public: - ~SfxItemPtrMap() - { - for(iterator it = begin(); it != end(); ++it) - delete it->second; - } -}; +typedef boost::ptr_map SfxItemPtrMap; TYPEINIT0(SfxShell); @@ -164,7 +156,7 @@ const SfxPoolItem* SfxShell::GetItem sal_uInt16 nSlotId // Slot-Id of the querying s ) const { - SfxItemPtrMap::iterator it = pImp->aItems.find( nSlotId ); + SfxItemPtrMap::const_iterator it = pImp->aItems.find( nSlotId ); if( it != pImp->aItems.end() ) return it->second; return 0; @@ -183,15 +175,14 @@ void SfxShell::PutItem // MSC made a mess here of WNT/W95, beware of changes SfxPoolItem *pItem = rItem.Clone(); SfxPoolItemHint aItemHint( pItem ); - const sal_uInt16 nWhich = rItem.Which(); + sal_uInt16 nWhich = rItem.Which(); SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich ); if( it != pImp->aItems.end() ) { - SfxPoolItem *pLoopItem = it->second; // Replace Item - delete pLoopItem; - it->second = pItem; + pImp->aItems.erase( it ); + pImp->aItems.insert( nWhich, pItem ); // if active, notify Bindings SfxDispatcher *pDispat = GetDispatcher(); @@ -212,7 +203,7 @@ void SfxShell::PutItem else { Broadcast( aItemHint ); - pImp->aItems[ pItem->Which() ] = pItem; + pImp->aItems.insert( nWhich, pItem ); } } -- cgit v1.2.3