summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2012-01-16 20:21:02 -0500
committerAugust Sodora <augsod@gmail.com>2012-01-16 20:23:32 -0500
commit4f8efe5ca7e6075acbb8014a221a260f9ab81474 (patch)
treed26dedaf33b87f5cf59328b14bff4c403a9dde02 /sfx2
parentd72e62066079c894d7275d60fecf4ef19f9fa01c (diff)
Remove *_OBJSTACK, *_OBJARRAY
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/minarray.hxx266
-rw-r--r--sfx2/inc/sfx2/minstack.hxx33
-rw-r--r--sfx2/source/control/dispatch.cxx87
3 files changed, 40 insertions, 346 deletions
diff --git a/sfx2/inc/sfx2/minarray.hxx b/sfx2/inc/sfx2/minarray.hxx
index a4195884b483..44df91212981 100644
--- a/sfx2/inc/sfx2/minarray.hxx
+++ b/sfx2/inc/sfx2/minarray.hxx
@@ -36,272 +36,6 @@
#include <tools/solar.h>
#include <tools/debug.hxx>
-#define DECL_OBJARRAY( ARR, T, nI, nG ) \
-class ARR\
-{\
-private:\
- T* pData;\
- sal_uInt16 nUsed;\
- sal_uInt8 nGrow;\
- sal_uInt8 nUnused;\
-public:\
- ARR( sal_uInt8 nInitSize = nI, sal_uInt8 nGrowSize = nG );\
- ARR( const ARR& rOrig );\
- ~ARR();\
-\
- ARR& operator= ( const ARR& rOrig );\
-\
- const T& GetObject( sal_uInt16 nPos ) const; \
- T& GetObject( sal_uInt16 nPos ); \
-\
- void Insert( sal_uInt16 nPos, const T& rElem );\
- void Insert( sal_uInt16 nPos, const T& rElems, sal_uInt16 nLen );\
- void Append( const T& rElem );\
-\
- sal_Bool Remove( const T& rElem );\
- sal_uInt16 Remove( sal_uInt16 nPos, sal_uInt16 nLen );\
-\
- sal_uInt16 Count() const { return nUsed; }\
- T* operator*();\
- const T& operator[]( sal_uInt16 nPos ) const;\
- T& operator[]( sal_uInt16 nPos );\
-\
- sal_Bool Contains( const T& rItem ) const;\
- void Clear() { Remove( 0, Count() ); }\
-};\
-\
-inline void ARR::Insert( sal_uInt16 nPos, const T& rElem )\
-{\
- Insert( nPos, rElem, 1 );\
-}\
-\
-inline T* ARR::operator*()\
-{\
- return ( nUsed==0 ? 0 : pData );\
-} \
-inline const T& ARR::operator[]( sal_uInt16 nPos ) const\
-{\
- DBG_ASSERT( nPos < nUsed, "" ); \
- return *(pData+nPos);\
-} \
-inline T& ARR::operator [] (sal_uInt16 nPos) \
-{\
- DBG_ASSERT( nPos < nUsed, "" ); \
- return *(pData+nPos); \
-} \
-inline const T& ARR::GetObject( sal_uInt16 nPos ) const { return operator[](nPos); } \
-inline T& ARR::GetObject( sal_uInt16 nPos ) { return operator[](nPos); } \
-
-#ifndef _lint
-// String too long
-
-#define IMPL_OBJARRAY( ARR, T ) \
-ARR::ARR( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ): \
- nUsed(0), \
- nGrow( nGrowSize ? nGrowSize : 1 ), \
- nUnused(nInitSize) \
-{ \
- if ( nInitSize != 0 ) \
- { \
- size_t nBytes = nInitSize * sizeof(T); \
- pData = (T*) new char[ nBytes ]; \
- memset( pData, 0, nBytes ); \
- } \
- else \
- pData = 0; \
-} \
-\
-ARR::ARR( const ARR& rOrig ) \
-{ \
- nUsed = rOrig.nUsed; \
- nGrow = rOrig.nGrow; \
- nUnused = rOrig.nUnused; \
-\
- if ( rOrig.pData != 0 ) \
- { \
- size_t nBytes = (nUsed + nUnused) * sizeof(T); \
- pData = (T*) new char [ nBytes ]; \
- memset( pData, 0, nBytes ); \
- for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
- *(pData+n) = *(rOrig.pData+n); \
- } \
- else \
- pData = 0; \
-} \
-\
-ARR::~ARR() \
-{ \
- for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
- ( pData+n )->T::~T(); \
- delete[] (char*) pData;\
-} \
-\
-ARR& ARR::operator= ( const ARR& rOrig )\
-{ \
- for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
- ( pData+n )->T::~T(); \
- delete[] (char*) pData;\
-\
- nUsed = rOrig.nUsed; \
- nGrow = rOrig.nGrow; \
- nUnused = rOrig.nUnused; \
-\
- if ( rOrig.pData != 0 ) \
- { \
- size_t nBytes = (nUsed + nUnused) * sizeof(T); \
- pData = (T*) new char[ nBytes ]; \
- memset( pData, 0, nBytes ); \
- for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
- *(pData+n) = *(rOrig.pData+n); \
- } \
- else \
- pData = 0; \
- return *this; \
-} \
-\
-void ARR::Append( const T& aElem ) \
-{ \
- \
- if ( nUnused == 0 ) \
- { \
- sal_uInt16 nNewSize = (nUsed == 1) ? (nGrow==1 ? 2 : nGrow) : nUsed+nGrow; \
- size_t nBytes = nNewSize * sizeof(T); \
- T* pNewData = (T*) new char[ nBytes ]; \
- memset( pNewData, 0, nBytes ); \
- if ( pData ) \
- { \
- memcpy( pNewData, pData, nUsed * sizeof(T) ); \
- delete[] (char*) pData;\
- } \
- nUnused = (sal_uInt8)(nNewSize-nUsed); \
- pData = pNewData; \
- } \
-\
- \
- pData[nUsed] = aElem; \
- ++nUsed; \
- --nUnused; \
-} \
-\
-sal_uInt16 ARR::Remove( sal_uInt16 nPos, sal_uInt16 nLen ) \
-{ \
- DBG_ASSERT( (nPos+nLen) < (nUsed+1), "" ); \
- DBG_ASSERT( nLen > 0, "" ); \
-\
- nLen = Min( (sal_uInt16)(nUsed-nPos), (sal_uInt16)nLen ); \
-\
- if ( nLen == 0 ) \
- return 0; \
-\
- for ( sal_uInt16 n = nPos; n < (nPos+nLen); ++n ) \
- ( pData+n )->T::~T(); \
-\
- if ( (nUsed-nLen) == 0 ) \
- { \
- delete[] (char*) pData;\
- pData = 0; \
- nUsed = 0; \
- nUnused = 0; \
- return nLen; \
- } \
-\
- if ( (nUnused+nLen) >= nGrow ) \
- { \
- sal_uInt16 nNewUsed = nUsed-nLen; \
- sal_uInt16 nNewSize = ((nNewUsed+nGrow-1)/nGrow) * nGrow; \
- DBG_ASSERT( nNewUsed <= nNewSize && nNewUsed+nGrow > nNewSize, \
- "shrink size computation failed" ); \
- size_t nBytes = nNewSize * sizeof(T); \
- T* pNewData = (T*) new char[ nBytes ]; \
- memset( pNewData, 0, nBytes ); \
- if ( nPos > 0 ) \
- memcpy( pNewData, pData, nPos * sizeof(T) ); \
- if ( nNewUsed != nPos ) \
- memcpy(pNewData+nPos, pData+nPos+nLen, (nNewUsed-nPos) * sizeof(T) ); \
- delete[] (char*) pData;\
- pData = pNewData; \
- nUsed = nNewUsed; \
- nUnused = (sal_uInt8)(nNewSize - nNewUsed); \
- return nLen; \
- } \
-\
- \
- if ( nUsed-nPos-nLen > 0 ) \
- { \
- memmove(pData+nPos, pData+nPos+nLen, (nUsed-nPos-nLen) * sizeof(T));\
- } \
- nUsed = nUsed - nLen; \
- nUnused = sal::static_int_cast< sal_uInt8 >(nUnused + nLen); \
- return nLen; \
-} \
-\
-sal_Bool ARR::Remove( const T& aElem ) \
-{ \
- if ( nUsed == 0 ) \
- return sal_False; \
-\
- const T *pIter = pData + nUsed - 1; \
- for ( sal_uInt16 n = 0; n < nUsed; ++n, --pIter ) \
- if ( *pIter == aElem ) \
- { \
- Remove(nUsed-n-1, 1); \
- return sal_True; \
- } \
- return sal_False; \
-} \
-\
-sal_Bool ARR::Contains( const T& rItem ) const \
-{ \
- if ( !nUsed ) \
- return sal_False; \
- for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
- { \
- const T& r2ndItem = GetObject(n); \
- if ( r2ndItem == rItem ) \
- return sal_True; \
- } \
- return sal_False; \
-} \
-\
-void ARR::Insert( sal_uInt16 nPos, const T& rElems, sal_uInt16 nLen ) \
-{ \
- DBG_ASSERT( nPos <= nUsed, "" ); \
- \
- if ( nUnused == 0 ) \
- { \
- \
- /* increase (round up) to the next Grow-limit */ \
- sal_uInt16 nNewSize; \
- for ( nNewSize = nUsed+nGrow; nNewSize < (nUsed + nLen); ++nNewSize ) \
- /* empty loop */; \
- size_t nBytes = nNewSize * sizeof(T); \
- T* pNewData = (T*) new char[ nBytes ]; \
- memset( pNewData, 0, nBytes ); \
- \
- if ( pData ) \
- { \
- DBG_ASSERT( nUsed < nNewSize, "" ); \
- memcpy( pNewData, pData, nUsed * sizeof(T) ); \
- delete (char*) pData;\
- } \
- nUnused = (sal_uInt8)(nNewSize-nUsed); \
- pData = pNewData; \
- } \
-\
- \
- if ( nPos < nUsed ) \
- { \
- memmove(pData+nPos+nLen-1, pData+nPos-1, sizeof(T) * (nUsed-nPos)); \
- } \
-\
- memmove(pData+nPos, &rElems, sizeof(T) * nLen); \
- nUsed = nUsed + nLen; \
- nUnused = sal::static_int_cast< sal_uInt8 >(nUnused - nLen); \
-}
-
-// _lint
-#endif
-
class SFX2_DLLPUBLIC SfxPtrArr
{
private:
diff --git a/sfx2/inc/sfx2/minstack.hxx b/sfx2/inc/sfx2/minstack.hxx
index 5a64e31cbee1..361c3043220a 100644
--- a/sfx2/inc/sfx2/minstack.hxx
+++ b/sfx2/inc/sfx2/minstack.hxx
@@ -30,39 +30,6 @@
#include <sfx2/minarray.hxx>
-#define DECL_OBJSTACK( ARR, T, nI, nG ) \
-DECL_OBJARRAY( ARR##arr_, T, nI, nG ); \
-class ARR: private ARR##arr_ \
-{ \
-public: \
- ARR( sal_uInt8 nInitSize = nI, sal_uInt8 nGrowSize = nG ): \
- ARR##arr_( nInitSize, nGrowSize ) \
- {} \
-\
- ARR( const ARR& rOrig ): \
- ARR##arr_( rOrig ) \
- {} \
-\
- sal_uInt16 Count() const { return ARR##arr_::Count(); } \
- void Push( const T& rElem ) { Append( rElem ); } \
- const T& Top( sal_uInt16 nLevel = 0 ) const \
- { return (*this)[Count()-nLevel-1]; } \
- const T& Bottom() const { return (*this)[0]; } \
- T Pop(); \
- void Clear() { ARR##arr_::Clear(); } \
- sal_Bool Contains( const T& rItem ) const \
- { return ARR##arr_::Contains( rItem ); } \
-}
-
-#define IMPL_OBJSTACK( ARR, T ) \
-IMPL_OBJARRAY( ARR##arr_, T ); \
-\
-T ARR::Pop() \
-{ T aRet = (*this)[Count()-1]; \
- Remove( Count()-1, 1 ); \
- return aRet; \
-}
-
#define DECL_PTRSTACK( ARR, T, nI, nG ) \
DECL_PTRARRAY( ARR##arr_, T, nI, nG ) \
class ARR: private ARR##arr_ \
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 0fc008a32eab..4d3f2d798a15 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -71,6 +71,8 @@
#include "workwin.hxx"
#include <rtl/strbuf.hxx>
+#include <deque>
+
namespace css = ::com::sun::star;
//==================================================================
@@ -111,9 +113,6 @@ struct SfxToDo_Impl
{ return pCluster==rWith.pCluster && bPush==rWith.bPush; }
};
-DECL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl, 8, 4);
-IMPL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl);
-
struct SfxObjectBars_Impl
{
sal_uInt32 nResId; // Resource - and ConfigId of the Toolbox
@@ -135,7 +134,7 @@ struct SfxDispatcher_Impl
const SfxSlotServer* pCachedServ2; // penultimate called Message
SfxShellStack_Impl aStack; // active functionality
Timer aTimer; // for Flush
- SfxToDoStack_Impl aToDoStack; // not processed Push/Pop
+ std::deque<SfxToDo_Impl> aToDoStack; // not processed Push/Pop
SfxViewFrame* pFrame; // NULL or associated Frame
SfxDispatcher* pParent; // AppDispatcher, NULL if possible
SfxHintPosterRef xPoster; // Execute asynchronous
@@ -481,11 +480,11 @@ void SfxDispatcher::Pop
<< (bUntil ? " (up to)" : ""));
// same shell as on top of the to-do stack?
- if ( pImp->aToDoStack.Count() && pImp->aToDoStack.Top().pCluster == &rShell )
+ if(pImp->aToDoStack.size() && pImp->aToDoStack.front().pCluster == &rShell)
{
// cancel inverse actions
- if ( pImp->aToDoStack.Top().bPush != bPush )
- pImp->aToDoStack.Pop();
+ if ( pImp->aToDoStack.front().bPush != bPush )
+ pImp->aToDoStack.pop_front();
else
{
DBG_ASSERT( bPush, "SfxInterface pushed more than once" );
@@ -495,7 +494,7 @@ void SfxDispatcher::Pop
else
{
// Remember ::com::sun::star::chaos::Action
- pImp->aToDoStack.Push( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
+ pImp->aToDoStack.push_front( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
if ( bFlushed )
{
OSL_TRACE("Unflushed dispatcher!");
@@ -509,7 +508,7 @@ void SfxDispatcher::Pop
}
}
- if ( !pSfxApp->IsDowning() && pImp->aToDoStack.Count() )
+ if(!pSfxApp->IsDowning() && !pImp->aToDoStack.empty())
{
// No immediate update is requested
pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
@@ -522,7 +521,7 @@ void SfxDispatcher::Pop
pImp->aTimer.Stop();
// Bindings may wake up again
- if ( !pImp->aToDoStack.Count() )
+ if(pImp->aToDoStack.empty())
{
SfxBindings* pBindings = GetBindings();
if ( pBindings )
@@ -573,21 +572,20 @@ sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDee
SFX_STACK(SfxDispatcher::CheckVirtualStack);
SfxShellStack_Impl aStack( pImp->aStack );
- for ( short nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
+ for(std::deque<SfxToDo_Impl>::const_reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
{
- SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
- if ( aToDo.bPush )
- aStack.Push( (SfxShell*) aToDo.pCluster );
+ if(i->bPush)
+ aStack.Push(static_cast<SfxShell*>(i->pCluster));
else
{
- SfxShell* pPopped = 0;
+ SfxShell* pPopped(NULL);
do
{
DBG_ASSERT( aStack.Count(), "popping from empty stack" );
pPopped = aStack.Pop();
}
- while ( aToDo.bUntil && pPopped != aToDo.pCluster );
- DBG_ASSERT( pPopped == aToDo.pCluster, "popping unpushed SfxInterface" );
+ while(i->bUntil && pPopped != i->pCluster);
+ DBG_ASSERT(pPopped == i->pCluster, "popping unpushed SfxInterface");
}
}
@@ -757,7 +755,7 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_False, sal_False, 1 );
}
- if ( pImp->aToDoStack.Count() )
+ if(!pImp->aToDoStack.empty())
{
// No immediate update is requested
pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
@@ -929,7 +927,7 @@ void SfxDispatcher::_Execute
{
DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
- DBG_ASSERT( !pImp->aToDoStack.Count(), "unprepared InPlace _Execute" );
+ DBG_ASSERT( pImp->aToDoStack.empty(), "unprepared InPlace _Execute" );
if ( IsLocked( rSlot.GetSlotId() ) )
return;
@@ -1609,24 +1607,22 @@ void SfxDispatcher::FlushImpl()
SfxApplication *pSfxApp = SFX_APP();
// Re-build the true stack in the first round
- SfxToDoStack_Impl aToDoCopy;
+ std::deque<SfxToDo_Impl> aToDoCopy;
sal_Bool bModify = sal_False;
- short nToDo;
- for ( nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
+ for(std::deque<SfxToDo_Impl>::reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
{
bModify = sal_True;
- SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
- if ( aToDo.bPush )
+ if(i->bPush)
{
// Actually push
- DBG_ASSERT( !pImp->aStack.Contains( aToDo.pCluster ),
- "pushed SfxShell already on stack" );
- pImp->aStack.Push( aToDo.pCluster );
- aToDo.pCluster->SetDisableFlags( pImp->nDisableFlags );
+ DBG_ASSERT(!pImp->aStack.Contains(i->pCluster),
+ "pushed SfxShell already on stack" );
+ pImp->aStack.Push(i->pCluster);
+ i->pCluster->SetDisableFlags(pImp->nDisableFlags);
// Mark the moved shell
- aToDoCopy.Push( aToDo );
+ aToDoCopy.push_front(*i);
}
else
{
@@ -1638,18 +1634,16 @@ void SfxDispatcher::FlushImpl()
DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" );
pPopped = pImp->aStack.Pop();
pPopped->SetDisableFlags( 0 );
- bFound = pPopped == aToDo.pCluster;
+ bFound = (pPopped == i->pCluster);
// Mark the moved Shell
- aToDoCopy.Push( SfxToDo_Impl( sal_False, aToDo.bDelete, sal_False, *pPopped) );
+ aToDoCopy.push_front(SfxToDo_Impl(sal_False, i->bDelete, sal_False, *pPopped));
}
- while ( aToDo.bUntil && !bFound );
+ while(i->bUntil && !bFound);
DBG_ASSERT( bFound, "wrong SfxShell popped" );
}
-
- if ( nToDo == 0 )
- pImp->aToDoStack.Clear();
}
+ pImp->aToDoStack.clear();
// Invalidate bindings, if possible
if ( !pSfxApp->IsDowning() )
@@ -1669,26 +1663,25 @@ void SfxDispatcher::FlushImpl()
OSL_TRACE("Successfully flushed dispatcher!");
// Activate the Shells and possible delete them in the 2nd round
- for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
+ for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
{
- SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
- if ( aToDo.bPush )
+ if(i->bPush)
{
if ( pImp->bActive )
- aToDo.pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
+ i->pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
}
- else
- if ( pImp->bActive )
- aToDo.pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
+ else if ( pImp->bActive )
+ i->pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
}
- for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
+
+ for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
{
- SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
- if ( aToDo.bDelete ) delete aToDo.pCluster;
+ if(i->bDelete)
+ delete i->pCluster;
}
- sal_Bool bAwakeBindings = aToDoCopy.Count() != 0;
+ sal_Bool bAwakeBindings = !aToDoCopy.empty();
if( bAwakeBindings )
- aToDoCopy.Clear();
+ aToDoCopy.clear();
// If more changes have occured on the stach when
// Activate/Deactivate/Delete: