summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-06-05 11:45:19 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-08 22:52:30 +0200
commit2186e7cbb03be308c1b02fae881e5e64d3afc36e (patch)
tree7488e26417df121382f2d30868b0c619d8979db7 /sfx2
parent99093b9c6cb45ce834cc76c8917a3c77805fd536 (diff)
Convert SV_DECL_PTRARR_DEL(SfxItemPtrArray) to std::map
- Convert it to a map because that is a more natural structure given how it's accessing the data - Cleanup an old typedef alias that doesn't seem to be used anymore. Change-Id: I46816d7270d165ddde381af0639169aaf009a16b
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/dispatch.hxx16
-rw-r--r--sfx2/source/control/dispatch.cxx1
-rw-r--r--sfx2/source/control/shell.cxx61
3 files changed, 41 insertions, 37 deletions
diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx
index 5aa01d9b5709..e2b9607634f6 100644
--- a/sfx2/inc/sfx2/dispatch.hxx
+++ b/sfx2/inc/sfx2/dispatch.hxx
@@ -36,6 +36,7 @@
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
+#include <map>
class SfxSlotServer;
class SfxShell;
@@ -72,11 +73,16 @@ namespace com
//=========================================================================
-typedef SfxPoolItem* SfxPoolItemPtr;
-SV_DECL_PTRARR_DEL( SfxItemPtrArray, SfxPoolItemPtr, 4 )
-
-// fuer shell.cxx
-typedef SfxItemPtrArray SfxItemArray_Impl;
+// Maps the Which() field to a pointer to a SfxPoolItem
+class SfxItemPtrMap : public std::map<sal_uInt16, SfxPoolItem*>
+{
+public:
+ ~SfxItemPtrMap()
+ {
+ for(iterator it = begin(); it != end(); ++it)
+ delete it->second;
+ }
+};
class SFX2_DLLPUBLIC SfxDispatcher
{
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 676e02839154..1e1bd682a60e 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -76,7 +76,6 @@ DBG_NAME(SfxDispatcherFillState)
typedef boost::ptr_vector<SfxRequest> SfxRequestPtrArray;
-SV_IMPL_PTRARR( SfxItemPtrArray, SfxPoolItemPtr );
DECL_PTRSTACK(SfxShellStack_Impl, SfxShell*, 8, 4 );
struct SfxToDo_Impl
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 5ba4ad65f48a..838c59a7cd80 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -79,7 +79,7 @@ using namespace com::sun::star;
struct SfxShell_Impl: public SfxBroadcaster
{
String aObjectName; // Name of Sbx-Objects
- SfxItemArray_Impl aItems; // Data exchange on Item level
+ SfxItemPtrMap aItems; // Data exchange on Item level
SfxViewShell* pViewSh; // SfxViewShell if Shell is
// ViewFrame/ViewShell/SubShell list
SfxViewFrame* pFrame; // Frame, if <UI-active>
@@ -305,9 +305,9 @@ const SfxPoolItem* SfxShell::GetItem
*/
{
- for ( sal_uInt16 nPos = 0; nPos < pImp->aItems.Count(); ++nPos )
- if ( pImp->aItems.GetObject(nPos)->Which() == nSlotId )
- return pImp->aItems.GetObject(nPos);
+ SfxItemPtrMap::iterator it = pImp->aItems.find( nSlotId );
+ if( it != pImp->aItems.end() )
+ return it->second;
return 0;
}
@@ -340,40 +340,39 @@ void SfxShell::PutItem
"items with Which-Ids aren't allowed here" );
// MSC made a mess here of WNT/W95, beware of changes
- const SfxPoolItem *pItem = rItem.Clone();
- SfxPoolItemHint aItemHint( (SfxPoolItem*) pItem );
+ SfxPoolItem *pItem = rItem.Clone();
+ SfxPoolItemHint aItemHint( pItem );
const sal_uInt16 nWhich = rItem.Which();
- SfxPoolItem **ppLoopItem = (SfxPoolItem**) pImp->aItems.GetData();
- sal_uInt16 nPos;
- for ( nPos = 0; nPos < pImp->aItems.Count(); ++nPos, ++ppLoopItem )
+
+ SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich );
+ if( it != pImp->aItems.end() )
{
- if ( (*ppLoopItem)->Which() == nWhich )
+ SfxPoolItem *pLoopItem = it->second;
+ // Replace Item
+ delete pLoopItem;
+ it->second = pItem;
+
+ // if active, notify Bindings
+ SfxDispatcher *pDispat = GetDispatcher();
+ if ( pDispat )
{
- // Replace Item
- delete *ppLoopItem;
- pImp->aItems.Remove(nPos);
- pImp->aItems.Insert( (SfxPoolItemPtr) pItem, nPos );
-
- // if active, notify Bindings
- SfxDispatcher *pDispat = GetDispatcher();
- if ( pDispat )
+ SfxBindings* pBindings = pDispat->GetBindings();
+ pBindings->Broadcast( aItemHint );
+ sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
+ SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
+ if ( pCache )
{
- SfxBindings* pBindings = pDispat->GetBindings();
- pBindings->Broadcast( aItemHint );
- sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
- SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
- if ( pCache )
- {
- pCache->SetState( SFX_ITEM_AVAILABLE, pItem->Clone(), sal_True );
- pCache->SetCachedState( sal_True );
- }
+ pCache->SetState( SFX_ITEM_AVAILABLE, pItem->Clone(), sal_True );
+ pCache->SetCachedState( sal_True );
}
- return;
}
+ return;
+ }
+ else
+ {
+ Broadcast( aItemHint );
+ pImp->aItems[ pItem->Which() ] = pItem;
}
-
- Broadcast( aItemHint );
- pImp->aItems.Insert((SfxPoolItemPtr)pItem, nPos );
}
//--------------------------------------------------------------------