[Libreoffice-commits] .: 2 commits - sfx2/inc sfx2/source

August Sodora augsod at kemper.freedesktop.org
Fri Jan 20 11:45:09 PST 2012


 sfx2/inc/sfx2/dispatch.hxx       |    9 +-
 sfx2/inc/sfx2/msgpool.hxx        |    1 
 sfx2/source/control/dispatch.cxx |  122 ++++++++++++++++++---------------------
 3 files changed, 63 insertions(+), 69 deletions(-)

New commits:
commit 6dc58d6c28b20d8dfb12673c3e733417e0644090
Author: August Sodora <augsod at gmail.com>
Date:   Fri Jan 20 14:44:41 2012 -0500

    Fix build

diff --git a/sfx2/inc/sfx2/msgpool.hxx b/sfx2/inc/sfx2/msgpool.hxx
index a110b58..bd65772 100644
--- a/sfx2/inc/sfx2/msgpool.hxx
+++ b/sfx2/inc/sfx2/msgpool.hxx
@@ -37,6 +37,7 @@
 #include <svl/svarray.hxx>
 
 #include <string>
+#include <vector>
 
 class SfxInterface;
 class SfxSlot;
commit 56208a1b367b25eea8bd7df5507cf4fa1fe8fb1d
Author: August Sodora <augsod at gmail.com>
Date:   Fri Jan 20 14:37:00 2012 -0500

    DECL_PTRSTACK->std::stack

diff --git a/sfx2/inc/sfx2/dispatch.hxx b/sfx2/inc/sfx2/dispatch.hxx
index de65742..0867aa5 100644
--- a/sfx2/inc/sfx2/dispatch.hxx
+++ b/sfx2/inc/sfx2/dispatch.hxx
@@ -37,10 +37,11 @@
 #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;
@@ -64,20 +65,18 @@ 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 7b26105..88dfc70 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -75,19 +75,14 @@
 
 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;
@@ -575,14 +570,15 @@ 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(i->pCluster);
+            aStack.push_front(i->pCluster);
         else
         {
             SfxShell* pPopped(NULL);
             do
             {
-                DBG_ASSERT( aStack.Count(), "popping from empty stack" );
-                pPopped = aStack.Pop();
+                DBG_ASSERT( aStack.size(), "popping from empty stack" );
+                pPopped = aStack.front();
+                aStack.pop_front();
             }
             while(i->bUntil && pPopped != i->pCluster);
             DBG_ASSERT(pPopped == i->pCluster, "popping unpushed SfxInterface");
@@ -591,9 +587,12 @@ sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDee
 
     sal_Bool bReturn;
     if ( bDeep )
-        bReturn = aStack.Contains(&rShell);
+    {
+        SfxShellStack_Impl::const_iterator i = std::find(aStack.begin(), aStack.end(), &rShell);
+        bReturn = (i != aStack.end());
+    }
     else
-        bReturn = aStack.Top() == &rShell;
+        bReturn = aStack.front() == &rShell;
     return bReturn;
 }
 
@@ -619,15 +618,15 @@ sal_uInt16 SfxDispatcher::GetShellLevel( const SfxShell& rShell )
     SFX_STACK(SfxDispatcher::GetShellLevel);
     Flush();
 
-    for ( sal_uInt16 n = 0; n < pImp->aStack.Count(); ++n )
-        if ( pImp->aStack.Top( n ) == &rShell )
+    for(size_t n = 0; n < pImp->aStack.size(); ++n)
+        if ( pImp->aStack[n] == &rShell )
             return n;
     if ( pImp->pParent )
     {
         sal_uInt16 nRet = pImp->pParent->GetShellLevel(rShell);
         if ( nRet == USHRT_MAX )
             return nRet;
-        return  nRet + pImp->aStack.Count();
+        return  nRet + pImp->aStack.size();
     }
 
     return USHRT_MAX;
@@ -647,9 +646,9 @@ SfxShell *SfxDispatcher::GetShell(sal_uInt16 nIdx) const
 */
 
 {
-    sal_uInt16 nShellCount = pImp->aStack.Count();
+    sal_uInt16 nShellCount = pImp->aStack.size();
     if ( nIdx < nShellCount )
-        return pImp->aStack.Top(nIdx);
+        return pImp->aStack[nIdx];
     else if ( pImp->pParent )
         return pImp->pParent->GetShell( nIdx - nShellCount );
     return 0;
@@ -740,8 +739,8 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
     if ( IsAppDispatcher() )
         return;
 
-    for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
-        pImp->aStack.Top( (sal_uInt16) i )->DoActivate_Impl(pImp->pFrame, bMDI);
+    for(size_t i = 0; i < pImp->aStack.size(); ++i)
+        pImp->aStack[i]->DoActivate_Impl(pImp->pFrame, bMDI);
 
     if ( bMDI && pImp->pFrame )
     {
@@ -766,8 +765,8 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
 
 void SfxDispatcher::DoParentActivate_Impl()
 {
-    for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
-        pImp->aStack.Top( (sal_uInt16) i )->ParentActivate();
+    for(size_t i = 0; i < pImp->aStack.size(); ++i)
+        pImp->aStack[i]->ParentActivate();
 }
 
 //--------------------------------------------------------------------
@@ -821,8 +820,8 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew )
     if ( IsAppDispatcher() && !pSfxApp->IsDowning() )
         return;
 
-    for ( sal_uInt16 i = 0; i < pImp->aStack.Count(); ++i )
-        pImp->aStack.Top(i)->DoDeactivate_Impl(pImp->pFrame, bMDI);
+    for ( sal_uInt16 i = 0; i < pImp->aStack.size(); ++i )
+        pImp->aStack[i]->DoDeactivate_Impl(pImp->pFrame, bMDI);
 
     sal_Bool bHidePopups = bMDI && pImp->pFrame;
     if ( pNew && pImp->pFrame )
@@ -854,8 +853,8 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew )
 
 void SfxDispatcher::DoParentDeactivate_Impl()
 {
-    for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
-        pImp->aStack.Top( (sal_uInt16) i )->ParentDeactivate();
+    for(size_t i = 0; i < pImp->aStack.size(); ++i)
+        pImp->aStack[i]->ParentDeactivate();
 }
 
 //--------------------------------------------------------------------
@@ -892,7 +891,7 @@ int SfxDispatcher::GetShellAndSlot_Impl
     SfxSlotServer aSvr;
     if ( _FindServer(nSlot, aSvr, bModal) )
     {
-        if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.Count() )
+        if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.size() )
             return sal_False;
 
         *ppShell = GetShell(aSvr.GetShellLevel());
@@ -939,10 +938,10 @@ void SfxDispatcher::_Execute
         SfxDispatcher *pDispat = this;
         while ( pDispat )
         {
-            sal_uInt16 nShellCount = pDispat->pImp->aStack.Count();
-            for ( sal_uInt16 n=0; n<nShellCount; n++ )
+            sal_uInt16 nShellCount = pDispat->pImp->aStack.size();
+            for ( sal_uInt16 n=0; n<nShellCount; ++n )
             {
-                if ( &rShell == pDispat->pImp->aStack.Top(n) )
+                if ( &rShell == pDispat->pImp->aStack[n] )
                 {
                     if ( eCallMode & SFX_CALLMODE_RECORD )
                         rReq.AllowRecording( sal_True );
@@ -986,13 +985,13 @@ const SfxSlot* SfxDispatcher::GetSlot( const String& rCommand )
 {
     // Count the number of Shells on the linked Dispatcher
     Flush();
-    sal_uInt16 nTotCount = pImp->aStack.Count();
+    sal_uInt16 nTotCount = pImp->aStack.size();
     if ( pImp->pParent )
     {
         SfxDispatcher *pParent = pImp->pParent;
         while ( pParent )
         {
-            nTotCount = nTotCount + pParent->pImp->aStack.Count();
+            nTotCount += pParent->pImp->aStack.size();
             pParent = pParent->pImp->pParent;
         }
     }
@@ -1440,7 +1439,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.Count();
+    sal_uInt16 nTotCount = pImp->aStack.size();
     for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell )
     {
         SfxShell *pShell = GetShell( nShell-1 );
@@ -1616,9 +1615,11 @@ void SfxDispatcher::FlushImpl()
         if(i->bPush)
         {
             // Actually push
-            DBG_ASSERT(!pImp->aStack.Contains(i->pCluster),
-                       "pushed SfxShell already on stack" );
-            pImp->aStack.Push(i->pCluster);
+            {
+                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);
             i->pCluster->SetDisableFlags(pImp->nDisableFlags);
 
             // Mark the moved shell
@@ -1631,8 +1632,9 @@ void SfxDispatcher::FlushImpl()
             bool bFound = false;
             do
             {
-                DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" );
-                pPopped = pImp->aStack.Pop();
+                DBG_ASSERT( !pImp->aStack.empty(), "popping from empty stack" );
+                pPopped = pImp->aStack.front();
+                pImp->aStack.pop_front();
                 pPopped->SetDisableFlags( 0 );
                 bFound = (pPopped == i->pCluster);
 
@@ -1815,7 +1817,7 @@ sal_Bool SfxDispatcher::_TryIntercept_Impl
 {
     // Maybe the parent is also belongs to a component
     SfxDispatcher *pParent = pImp->pParent;
-    sal_uInt16 nLevels = pImp->aStack.Count();
+    sal_uInt16 nLevels = pImp->aStack.size();
     while ( pParent && pParent->pImp->pFrame )
     {
         if ( pParent->pImp->pFrame->GetFrame().HasComponent() )
@@ -1832,7 +1834,7 @@ sal_Bool SfxDispatcher::_TryIntercept_Impl
                 break;
         }
         else
-            nLevels = nLevels + pParent->pImp->aStack.Count();
+            nLevels += pParent->pImp->aStack.size();
 
         pParent = pParent->pImp->pParent;
     }
@@ -1895,13 +1897,13 @@ sal_Bool SfxDispatcher::_FindServer
 
     // Count the number of Shells in the linked dispatchers.
     Flush();
-    sal_uInt16 nTotCount = pImp->aStack.Count();
+    sal_uInt16 nTotCount = pImp->aStack.size();
     if ( pImp->pParent )
     {
         SfxDispatcher *pParent = pImp->pParent;
         while ( pParent )
         {
-            nTotCount = nTotCount + pParent->pImp->aStack.Count();
+            nTotCount += pParent->pImp->aStack.size();
             pParent = pParent->pImp->pParent;
         }
     }
@@ -1943,7 +1945,7 @@ sal_Bool SfxDispatcher::_FindServer
         {
             sal_Bool bRet = pImp->pParent->_FindServer( nSlot, rServer, bModal );
             rServer.SetShellLevel
-                ( rServer.GetShellLevel() + pImp->aStack.Count() );
+                ( rServer.GetShellLevel() + pImp->aStack.size() );
             return bRet;
         }
         else
@@ -1954,7 +1956,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.Count() : 0;
+    sal_uInt16 nFirstShell = pImp->bModal && !bModal ? pImp->aStack.size() : 0;
     for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
     {
         SfxShell *pObjShell = GetShell(i);
@@ -2104,7 +2106,7 @@ SfxPopupMenuManager* SfxDispatcher::Popup( sal_uInt16 nConfigId,Window *pWin, co
     if ( rDisp.pImp->bQuiet )
     {
         nConfigId = 0;
-        nShLevel = rDisp.pImp->aStack.Count();
+        nShLevel = rDisp.pImp->aStack.size();
     }
 
     Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
@@ -2131,7 +2133,7 @@ void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Poin
     if ( rDisp.pImp->bQuiet )
     {
         nConfigId = 0;
-        nShLevel = rDisp.pImp->aStack.Count();
+        nShLevel = rDisp.pImp->aStack.size();
     }
 
     Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
@@ -2307,10 +2309,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.Count();
-    if ( nShell < nShellCount )
+    sal_uInt16 nShellCount = pImp->aStack.size();
+    if(nShell < nShellCount)
     {
-        SfxShell* pShell = pImp->aStack.Top( nShell );
+        SfxShell* pShell = pImp->aStack[nShell];
         if( pShell->ISA( SfxModule ) || pShell->ISA( SfxApplication ) || pShell->ISA( SfxViewFrame ) )
             return sal_False;
         else
@@ -2321,27 +2323,19 @@ 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();
 
-    // 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 )
+    for(SfxShellStack_Impl::iterator i = pImp->aStack.begin(); i != pImp->aStack.end(); ++i)
     {
-        if ( rStack[n] == &rShell )
-        {
-            rStack.Remove( n );
-            rShell.SetDisableFlags( 0 );
-            rShell.DoDeactivate_Impl(pImp->pFrame, sal_True);
-            break;
-        }
+        if(*i != &rShell)
+            continue;
+
+        pImp->aStack.erase(i);
+        rShell.SetDisableFlags( 0 );
+        rShell.DoDeactivate_Impl(pImp->pFrame, sal_True);
+        break;
     }
 
     if ( !SFX_APP()->IsDowning() )
@@ -2444,8 +2438,8 @@ sal_Bool SfxDispatcher::IsUpdated_Impl() const
 void SfxDispatcher::SetDisableFlags( sal_uInt32 nFlags )
 {
     pImp->nDisableFlags = nFlags;
-    for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
-        pImp->aStack.Top( (sal_uInt16) i )->SetDisableFlags( nFlags );
+    for(SfxShellStack_Impl::const_iterator i = pImp->aStack.begin(); i != pImp->aStack.end(); ++i)
+        (*i)->SetDisableFlags(nFlags);
 }
 
 sal_uInt32 SfxDispatcher::GetDisableFlags() const


More information about the Libreoffice-commits mailing list