basic/source/basmgr/basmgr.cxx | 4 - sfx2/Package_inc.mk | 1 sfx2/inc/sfx2/dispatch.hxx | 9 +- sfx2/inc/sfx2/minstack.hxx | 65 ++++++++++++++++++++ sfx2/source/control/dispatch.cxx | 123 ++++++++++++++++++++------------------- sfx2/source/menu/mnumgr.cxx | 1 6 files changed, 137 insertions(+), 66 deletions(-)
New commits: commit 6accc1e65a8ab566db16c07dd76cf5f74c0bf792 Author: August Sodora <aug...@gmail.com> Date: Fri Jan 20 17:50:02 2012 -0500 Revert "DECL_PTRSTACK->std::stack" This reverts commit 56208a1b367b25eea8bd7df5507cf4fa1fe8fb1d. diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx index 0867aa5..de65742 100644 --- a/sfx2/inc/sfx2/dispatch.hxx +++ b/sfx2/inc/sfx2/dispatch.hxx @@ -37,11 +37,10 @@ #include <sfx2/bindings.hxx> #include <sfx2/viewfrm.hxx> -#include <deque> - class SfxSlotServer; class SfxShell; class SfxRequest; +class SfxShellStack_Impl; class SfxHintPoster; class SfxViewFrame; class SfxBindings; @@ -65,18 +64,20 @@ namespace com } } +//========================================================================= + #define SFX_SHELL_POP_UNTIL 4 #define SFX_SHELL_POP_DELETE 2 #define SFX_SHELL_PUSH 1 +//========================================================================= + typedef SfxPoolItem* SfxPoolItemPtr; SV_DECL_PTRARR_DEL( SfxItemPtrArray, SfxPoolItemPtr, 4, 4 ) // fuer shell.cxx typedef SfxItemPtrArray SfxItemArray_Impl; -typedef std::deque<SfxShell*> SfxShellStack_Impl; - class SFX2_DLLPUBLIC SfxDispatcher { SfxDispatcher_Impl* pImp; diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 88dfc70..7b26105 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -75,14 +75,19 @@ namespace css = ::com::sun::star; +//================================================================== DBG_NAME(SfxDispatcherFlush) DBG_NAME(SfxDispatcherFillState) +//================================================================== typedef SfxRequest* SfxRequestPtr; SV_IMPL_PTRARR( SfxItemPtrArray, SfxPoolItemPtr ); SV_DECL_PTRARR_DEL( SfxRequestPtrArray, SfxRequestPtr, 4, 4 ) SV_IMPL_PTRARR( SfxRequestPtrArray, SfxRequestPtr ); +DECL_PTRSTACK(SfxShellStack_Impl, SfxShell*, 8, 4 ); +//================================================================== + struct SfxToDo_Impl { SfxShell* pCluster; @@ -570,15 +575,14 @@ sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDee for(std::deque<SfxToDo_Impl>::reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i) { if(i->bPush) - aStack.push_front(i->pCluster); + aStack.Push(i->pCluster); else { SfxShell* pPopped(NULL); do { - DBG_ASSERT( aStack.size(), "popping from empty stack" ); - pPopped = aStack.front(); - aStack.pop_front(); + DBG_ASSERT( aStack.Count(), "popping from empty stack" ); + pPopped = aStack.Pop(); } while(i->bUntil && pPopped != i->pCluster); DBG_ASSERT(pPopped == i->pCluster, "popping unpushed SfxInterface"); @@ -587,12 +591,9 @@ sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDee sal_Bool bReturn; if ( bDeep ) - { - SfxShellStack_Impl::const_iterator i = std::find(aStack.begin(), aStack.end(), &rShell); - bReturn = (i != aStack.end()); - } + bReturn = aStack.Contains(&rShell); else - bReturn = aStack.front() == &rShell; + bReturn = aStack.Top() == &rShell; return bReturn; } @@ -618,15 +619,15 @@ sal_uInt16 SfxDispatcher::GetShellLevel( const SfxShell& rShell ) SFX_STACK(SfxDispatcher::GetShellLevel); Flush(); - for(size_t n = 0; n < pImp->aStack.size(); ++n) - if ( pImp->aStack[n] == &rShell ) + for ( sal_uInt16 n = 0; n < pImp->aStack.Count(); ++n ) + if ( pImp->aStack.Top( n ) == &rShell ) return n; if ( pImp->pParent ) { sal_uInt16 nRet = pImp->pParent->GetShellLevel(rShell); if ( nRet == USHRT_MAX ) return nRet; - return nRet + pImp->aStack.size(); + return nRet + pImp->aStack.Count(); } return USHRT_MAX; @@ -646,9 +647,9 @@ SfxShell *SfxDispatcher::GetShell(sal_uInt16 nIdx) const */ { - sal_uInt16 nShellCount = pImp->aStack.size(); + sal_uInt16 nShellCount = pImp->aStack.Count(); if ( nIdx < nShellCount ) - return pImp->aStack[nIdx]; + return pImp->aStack.Top(nIdx); else if ( pImp->pParent ) return pImp->pParent->GetShell( nIdx - nShellCount ); return 0; @@ -739,8 +740,8 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ ) if ( IsAppDispatcher() ) return; - for(size_t i = 0; i < pImp->aStack.size(); ++i) - pImp->aStack[i]->DoActivate_Impl(pImp->pFrame, bMDI); + for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i ) + pImp->aStack.Top( (sal_uInt16) i )->DoActivate_Impl(pImp->pFrame, bMDI); if ( bMDI && pImp->pFrame ) { @@ -765,8 +766,8 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ ) void SfxDispatcher::DoParentActivate_Impl() { - for(size_t i = 0; i < pImp->aStack.size(); ++i) - pImp->aStack[i]->ParentActivate(); + for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i ) + pImp->aStack.Top( (sal_uInt16) i )->ParentActivate(); } //-------------------------------------------------------------------- @@ -820,8 +821,8 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) if ( IsAppDispatcher() && !pSfxApp->IsDowning() ) return; - for ( sal_uInt16 i = 0; i < pImp->aStack.size(); ++i ) - pImp->aStack[i]->DoDeactivate_Impl(pImp->pFrame, bMDI); + for ( sal_uInt16 i = 0; i < pImp->aStack.Count(); ++i ) + pImp->aStack.Top(i)->DoDeactivate_Impl(pImp->pFrame, bMDI); sal_Bool bHidePopups = bMDI && pImp->pFrame; if ( pNew && pImp->pFrame ) @@ -853,8 +854,8 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) void SfxDispatcher::DoParentDeactivate_Impl() { - for(size_t i = 0; i < pImp->aStack.size(); ++i) - pImp->aStack[i]->ParentDeactivate(); + for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i ) + pImp->aStack.Top( (sal_uInt16) i )->ParentDeactivate(); } //-------------------------------------------------------------------- @@ -891,7 +892,7 @@ int SfxDispatcher::GetShellAndSlot_Impl SfxSlotServer aSvr; if ( _FindServer(nSlot, aSvr, bModal) ) { - if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.size() ) + if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.Count() ) return sal_False; *ppShell = GetShell(aSvr.GetShellLevel()); @@ -938,10 +939,10 @@ void SfxDispatcher::_Execute SfxDispatcher *pDispat = this; while ( pDispat ) { - sal_uInt16 nShellCount = pDispat->pImp->aStack.size(); - for ( sal_uInt16 n=0; n<nShellCount; ++n ) + sal_uInt16 nShellCount = pDispat->pImp->aStack.Count(); + for ( sal_uInt16 n=0; n<nShellCount; n++ ) { - if ( &rShell == pDispat->pImp->aStack[n] ) + if ( &rShell == pDispat->pImp->aStack.Top(n) ) { if ( eCallMode & SFX_CALLMODE_RECORD ) rReq.AllowRecording( sal_True ); @@ -985,13 +986,13 @@ const SfxSlot* SfxDispatcher::GetSlot( const String& rCommand ) { // Count the number of Shells on the linked Dispatcher Flush(); - sal_uInt16 nTotCount = pImp->aStack.size(); + sal_uInt16 nTotCount = pImp->aStack.Count(); if ( pImp->pParent ) { SfxDispatcher *pParent = pImp->pParent; while ( pParent ) { - nTotCount += pParent->pImp->aStack.size(); + nTotCount = nTotCount + pParent->pImp->aStack.Count(); pParent = pParent->pImp->pParent; } } @@ -1439,7 +1440,7 @@ void SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, sal_Bo SfxShell *pStatusBarShell = NULL; SfxSlotPool* pSlotPool = &SfxSlotPool::GetSlotPool( GetFrame() ); - sal_uInt16 nTotCount = pImp->aStack.size(); + sal_uInt16 nTotCount = pImp->aStack.Count(); for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell ) { SfxShell *pShell = GetShell( nShell-1 ); @@ -1615,11 +1616,9 @@ void SfxDispatcher::FlushImpl() if(i->bPush) { // Actually push - { - SfxShellStack_Impl::const_iterator it = std::find(pImp->aStack.begin(), pImp->aStack.end(), i->pCluster); - DBG_ASSERT(it != pImp->aStack.end(), "pushed SfxShell already on stack" ); - } - pImp->aStack.push_front(i->pCluster); + 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 @@ -1632,9 +1631,8 @@ void SfxDispatcher::FlushImpl() bool bFound = false; do { - DBG_ASSERT( !pImp->aStack.empty(), "popping from empty stack" ); - pPopped = pImp->aStack.front(); - pImp->aStack.pop_front(); + DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" ); + pPopped = pImp->aStack.Pop(); pPopped->SetDisableFlags( 0 ); bFound = (pPopped == i->pCluster); @@ -1817,7 +1815,7 @@ sal_Bool SfxDispatcher::_TryIntercept_Impl { // Maybe the parent is also belongs to a component SfxDispatcher *pParent = pImp->pParent; - sal_uInt16 nLevels = pImp->aStack.size(); + sal_uInt16 nLevels = pImp->aStack.Count(); while ( pParent && pParent->pImp->pFrame ) { if ( pParent->pImp->pFrame->GetFrame().HasComponent() ) @@ -1834,7 +1832,7 @@ sal_Bool SfxDispatcher::_TryIntercept_Impl break; } else - nLevels += pParent->pImp->aStack.size(); + nLevels = nLevels + pParent->pImp->aStack.Count(); pParent = pParent->pImp->pParent; } @@ -1897,13 +1895,13 @@ sal_Bool SfxDispatcher::_FindServer // Count the number of Shells in the linked dispatchers. Flush(); - sal_uInt16 nTotCount = pImp->aStack.size(); + sal_uInt16 nTotCount = pImp->aStack.Count(); if ( pImp->pParent ) { SfxDispatcher *pParent = pImp->pParent; while ( pParent ) { - nTotCount += pParent->pImp->aStack.size(); + nTotCount = nTotCount + pParent->pImp->aStack.Count(); pParent = pParent->pImp->pParent; } } @@ -1945,7 +1943,7 @@ sal_Bool SfxDispatcher::_FindServer { sal_Bool bRet = pImp->pParent->_FindServer( nSlot, rServer, bModal ); rServer.SetShellLevel - ( rServer.GetShellLevel() + pImp->aStack.size() ); + ( rServer.GetShellLevel() + pImp->aStack.Count() ); return bRet; } else @@ -1956,7 +1954,7 @@ sal_Bool SfxDispatcher::_FindServer // search through all the shells of the chained dispatchers // from top to bottom - sal_uInt16 nFirstShell = pImp->bModal && !bModal ? pImp->aStack.size() : 0; + sal_uInt16 nFirstShell = pImp->bModal && !bModal ? pImp->aStack.Count() : 0; for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i ) { SfxShell *pObjShell = GetShell(i); @@ -2106,7 +2104,7 @@ SfxPopupMenuManager* SfxDispatcher::Popup( sal_uInt16 nConfigId,Window *pWin, co if ( rDisp.pImp->bQuiet ) { nConfigId = 0; - nShLevel = rDisp.pImp->aStack.size(); + nShLevel = rDisp.pImp->aStack.Count(); } Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow(); @@ -2133,7 +2131,7 @@ void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Poin if ( rDisp.pImp->bQuiet ) { nConfigId = 0; - nShLevel = rDisp.pImp->aStack.size(); + nShLevel = rDisp.pImp->aStack.Count(); } Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow(); @@ -2309,10 +2307,10 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, ::com::sun::star::uno:: sal_Bool SfxDispatcher::IsReadOnlyShell_Impl( sal_uInt16 nShell ) const { - sal_uInt16 nShellCount = pImp->aStack.size(); - if(nShell < nShellCount) + sal_uInt16 nShellCount = pImp->aStack.Count(); + if ( nShell < nShellCount ) { - SfxShell* pShell = pImp->aStack[nShell]; + SfxShell* pShell = pImp->aStack.Top( nShell ); if( pShell->ISA( SfxModule ) || pShell->ISA( SfxApplication ) || pShell->ISA( SfxViewFrame ) ) return sal_False; else @@ -2323,19 +2321,27 @@ sal_Bool SfxDispatcher::IsReadOnlyShell_Impl( sal_uInt16 nShell ) const return sal_True; } +// A dirty trick, to get hold of the methods of the private base class +// SfxShellStack_Impl +class StackAccess_Impl : public SfxShellStack_Implarr_ +{}; + void SfxDispatcher::RemoveShell_Impl( SfxShell& rShell ) { Flush(); - for(SfxShellStack_Impl::iterator i = pImp->aStack.begin(); i != pImp->aStack.end(); ++i) + // The cast is because SfxShellStack_Impl member has non of its own + StackAccess_Impl& rStack = *((StackAccess_Impl*) (&pImp->aStack)); + sal_uInt16 nCount = rStack.Count(); + for ( sal_uInt16 n=0; n<nCount; ++n ) { - if(*i != &rShell) - continue; - - pImp->aStack.erase(i); - rShell.SetDisableFlags( 0 ); - rShell.DoDeactivate_Impl(pImp->pFrame, sal_True); - break; + if ( rStack[n] == &rShell ) + { + rStack.Remove( n ); + rShell.SetDisableFlags( 0 ); + rShell.DoDeactivate_Impl(pImp->pFrame, sal_True); + break; + } } if ( !SFX_APP()->IsDowning() ) @@ -2438,8 +2444,8 @@ sal_Bool SfxDispatcher::IsUpdated_Impl() const void SfxDispatcher::SetDisableFlags( sal_uInt32 nFlags ) { pImp->nDisableFlags = nFlags; - for(SfxShellStack_Impl::const_iterator i = pImp->aStack.begin(); i != pImp->aStack.end(); ++i) - (*i)->SetDisableFlags(nFlags); + for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i ) + pImp->aStack.Top( (sal_uInt16) i )->SetDisableFlags( nFlags ); } sal_uInt32 SfxDispatcher::GetDisableFlags() const commit f9424e58a3e32f3bf1112206ad23b6922fdc010c Author: August Sodora <aug...@gmail.com> Date: Fri Jan 20 17:49:45 2012 -0500 Revert "Remove DECL_PTRSTACK" This reverts commit fabf6aa20117fb1132fc7e730e5eeecd0378e67e. diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index 3714d21..4dd559d 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -83,6 +83,7 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mgetempl.hxx,sfx2/mgetempl.h $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mieclip.hxx,sfx2/mieclip.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/minarray.hxx,sfx2/minarray.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/minfitem.hxx,sfx2/minfitem.hxx)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/minstack.hxx,sfx2/minstack.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mnuitem.hxx,sfx2/mnuitem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/mnumgr.hxx,sfx2/mnumgr.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/module.hxx,sfx2/module.hxx)) diff --git a/sfx2/inc/sfx2/minstack.hxx b/sfx2/inc/sfx2/minstack.hxx new file mode 100644 index 0000000..361c304 --- /dev/null +++ b/sfx2/inc/sfx2/minstack.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SFXMINSTACK_HXX +#define _SFXMINSTACK_HXX + +#include <sfx2/minarray.hxx> + +#define DECL_PTRSTACK( ARR, T, nI, nG ) \ +DECL_PTRARRAY( 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( T rElem ) { Append( rElem ); } \ + T Top( sal_uInt16 nLevel = 0 ) const \ + { return (*this)[Count()-nLevel-1]; } \ + T Bottom() const { return (*this)[0]; } \ + T Pop() \ + { T aRet = (*this)[Count()-1]; \ + Remove( Count()-1, 1 ); \ + return aRet; \ + } \ + T* operator*() \ + { return &(*this)[Count()-1]; } \ + void Clear() { ARR##arr_::Clear(); } \ + sal_Bool Contains( const T pItem ) const \ + { return ARR##arr_::Contains( pItem ); } \ +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 9a8e607..88dfc70 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -48,6 +48,7 @@ #include "appdata.hxx" #include "sfx2/sfxhelp.hxx" #include <sfx2/dispatch.hxx> +#include <sfx2/minstack.hxx> #include <sfx2/msg.hxx> #include <sfx2/objface.hxx> #include <sfx2/bindings.hxx> diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx index c46c5e9..8b87238 100644 --- a/sfx2/source/menu/mnumgr.cxx +++ b/sfx2/source/menu/mnumgr.cxx @@ -62,6 +62,7 @@ #include "virtmenu.hxx" #include <sfx2/msg.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/minstack.hxx> #include <sfx2/app.hxx> #include "sfxtypes.hxx" #include <sfx2/bindings.hxx> commit 6ffc885952d898df4266ad79ba0b4fba351a8bb6 Author: August Sodora <aug...@gmail.com> Date: Fri Jan 20 15:24:20 2012 -0500 Unused define diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index ad7ae6a..df20c20 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -89,8 +89,6 @@ typedef WeakImplHelper1< XStarBasicDialogInfo > DialogInfoHelper; typedef WeakImplHelper1< XStarBasicLibraryInfo > LibraryInfoHelper; typedef WeakImplHelper1< XStarBasicAccess > StarBasicAccessHelper; -#define CURR_VER 2 - // Version 1 // sal_uIntPtr nEndPos // sal_uInt16 nId commit c6bf2fa2b2925cadabc735d12b8d0c030c328baf Author: August Sodora <aug...@gmail.com> Date: Fri Jan 20 15:23:53 2012 -0500 Remove unused typedef diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 234a196..ad7ae6a 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -88,8 +88,6 @@ typedef WeakImplHelper1< XStarBasicModuleInfo > ModuleInfoHelper; typedef WeakImplHelper1< XStarBasicDialogInfo > DialogInfoHelper; typedef WeakImplHelper1< XStarBasicLibraryInfo > LibraryInfoHelper; typedef WeakImplHelper1< XStarBasicAccess > StarBasicAccessHelper; -typedef vector< BasicError* > BasErrorLst; - #define CURR_VER 2 _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits