[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source

Michael Stahl mstahl at redhat.com
Wed Dec 4 06:45:20 PST 2013


 include/sfx2/dispatch.hxx        |  146 ---------------------------------------
 sfx2/source/control/dispatch.cxx |  125 ++++++++++++++++++++++++++++-----
 sfx2/source/control/shell.cxx    |   14 +++
 3 files changed, 124 insertions(+), 161 deletions(-)

New commits:
commit d1539f91810cb4b426f3c823c25ab6ac25f6283e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 4 15:22:00 2013 +0100

    sfx2: SfxItemPtrMap is used only in shell.cxx
    
    Change-Id: I9f76a114fcdf761ddaaf40666e4330d20ca72b98

diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index cb48a84..49e4c1d 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -27,7 +27,6 @@
 
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewfrm.hxx>
-#include <map>
 #include <boost/scoped_ptr.hpp>
 
 class SfxSlotServer;
@@ -63,17 +62,6 @@ namespace com
 
 //=========================================================================
 
-// 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
 {
     boost::scoped_ptr<SfxDispatcher_Impl> pImp;
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index eaed943..2b9c7f4 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -44,6 +44,20 @@
 #include <sfx2/msgpool.hxx>
 #include <sfx2/sidebar/ContextChangeBroadcaster.hxx>
 
+#include <map>
+
+
+// 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;
+    }
+};
+
 //====================================================================
 
 DBG_NAME(SfxShell)
commit 5e4c26918a0c8130515ee7af0cf2cd2dfe42534d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 4 15:20:08 2013 +0100

    SfxDispatcher: move implementation details out of header file
    
    Change-Id: Ia831da45c00554086dc692997130688c0b3e28f5

diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 151d483..cb48a84 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -27,9 +27,8 @@
 
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewfrm.hxx>
-#include <deque>
 #include <map>
-#include <vector>
+#include <boost/scoped_ptr.hpp>
 
 class SfxSlotServer;
 class SfxShell;
@@ -42,8 +41,6 @@ class SfxPopupMenuManager;
 class SfxModule;
 struct SfxDispatcher_Impl;
 
-typedef std::vector<SfxShell*> SfxShellStack_Impl;
-
 namespace com
 {
     namespace sun
@@ -77,38 +74,9 @@ public:
     }
 };
 
-struct SfxToDo_Impl
-{
-    SfxShell*  pCluster;
-    bool       bPush;
-    bool       bDelete;
-    bool       bDeleted;
-    bool       bUntil;
-
-    SfxToDo_Impl()
-        : pCluster(0)
-        , bPush(false)
-        , bDelete(false)
-        , bDeleted(false)
-        , bUntil(false)
-                {}
-    SfxToDo_Impl( bool bOpPush, bool bOpDelete, bool bOpUntil, SfxShell& rCluster )
-        : pCluster(&rCluster)
-        , bPush(bOpPush)
-        , bDelete(bOpDelete)
-        , bDeleted(false)
-        , bUntil(bOpUntil)
-                {}
-
-    bool operator==( const SfxToDo_Impl& rWith ) const
-    { return pCluster==rWith.pCluster && bPush==rWith.bPush; }
-};
-
 class SFX2_DLLPUBLIC SfxDispatcher
 {
-    SfxDispatcher_Impl*      pImp;
-    sal_Bool                 bFlushed;
-    std::deque< std::deque<SfxToDo_Impl> > aToDoCopyStack;
+    boost::scoped_ptr<SfxDispatcher_Impl> pImp;
 
 private:
     // Search for temporary evaluated Todos
@@ -199,7 +167,7 @@ public:
                               Window *pWin = 0, const Point *pPosPixel = 0 );
 
     sal_Bool            IsAppDispatcher() const;
-    sal_Bool            IsFlushed() const;
+    bool                IsFlushed() const;
     void                Flush();
     void                Lock( sal_Bool bLock );
     sal_Bool                IsLocked( sal_uInt16 nSID = 0 ) const;
@@ -236,102 +204,6 @@ public:
     SAL_DLLPRIVATE sal_uInt16 GetNextToolBox_Impl( sal_uInt16 nPos, sal_uInt16 nType, OUString *pStr );
 };
 
-//--------------------------------------------------------------------
-
-inline sal_Bool SfxDispatcher::IsFlushed() const
-
-/*  [Description]
-
-    This method checks if the stack of the SfxDispatchers is flushed, or if
-    push- or pop- commands are pending.
-*/
-
-{
-     return bFlushed;
-}
-
-//--------------------------------------------------------------------
-
-inline void SfxDispatcher::Flush()
-
-/*  [Description]
-
-    This method performs outstanding push- and pop- commands. For <SfxShell>s,
-    which are new on the stack, the <SfxShell::Activate(sal_Bool)> is invoked with
-    bMDI == sal_True, for SfxShells that are removed from the stack, the
-    <SfxShell::Deactivate(sal_Bool)> is invoked with bMDI == sal_True
-*/
-
-{
-    if ( !bFlushed ) FlushImpl();
-}
-
-//--------------------------------------------------------------------
-
-inline void SfxDispatcher::Push( SfxShell& rShell )
-
-/*  [Description]
-
-    With this method, a <SfxShell> pushed on to the SfxDispatcher.
-    The SfxShell is first marked for push and a timer is set up.
-    First when the timer has couted down to zero the push
-    ( <SfxDispatcher::Flush()> ) is actually performed and the
-    <SfxBindings> is invalidated. While the timer is counting down
-    the opposing push and pop commands on the same SfxShell are
-    leveled out.
-*/
-
-{
-    Pop( rShell, SFX_SHELL_PUSH );
-}
-
-//--------------------------------------------------------------------
-
-inline sal_Bool SfxDispatcher::IsActive( const SfxShell& rShell )
-
-/*  [Description]
-
-    This method checks whether a particular <SfxShell> instance is
-    on the SfxDispatcher.
-
-    [Return value]
-
-    sal_Bool                sal_True
-                        The SfxShell instance is on the SfxDispatcher.
-
-                        sal_False
-                        The SfxShell instance is not on the SfxDispatcher.
-*/
-
-{
-    return CheckVirtualStack( rShell, sal_True );
-}
-//--------------------------------------------------------------------
-
-inline sal_Bool SfxDispatcher::IsOnTop( const SfxShell& rShell )
-
-/*  [Description]
-
-    This method checks whether a particular <SfxShell> instance is on
-    top of the SfxDispatcher.
-
-    [Return value]
-
-    sal_Bool                sal_True
-                        The SfxShell instance is on the top of
-                        the SfxDispatcher.
-
-                        sal_False
-                        The SfxShell instance is not on the top of
-                        the SfxDispatcher.
-*/
-
-{
-    return CheckVirtualStack( rShell, sal_False );
-}
-
-//--------------------------------------------------------------------
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 934a6cb..308c91d 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -67,8 +67,37 @@
 DBG_NAME(SfxDispatcherFlush)
 DBG_NAME(SfxDispatcherFillState)
 
+typedef std::vector<SfxShell*> SfxShellStack_Impl;
+
 typedef std::vector<SfxRequest*> SfxRequestPtrArray;
 
+struct SfxToDo_Impl
+{
+    SfxShell*  pCluster;
+    bool       bPush;
+    bool       bDelete;
+    bool       bDeleted;
+    bool       bUntil;
+
+    SfxToDo_Impl()
+        : pCluster(0)
+        , bPush(false)
+        , bDelete(false)
+        , bDeleted(false)
+        , bUntil(false)
+                {}
+    SfxToDo_Impl( bool bOpPush, bool bOpDelete, bool bOpUntil, SfxShell& rCluster )
+        : pCluster(&rCluster)
+        , bPush(bOpPush)
+        , bDelete(bOpDelete)
+        , bDeleted(false)
+        , bUntil(bOpUntil)
+                {}
+
+    bool operator==( const SfxToDo_Impl& rWith ) const
+    { return pCluster==rWith.pCluster && bPush==rWith.bPush; }
+};
+
 struct SfxObjectBars_Impl
 {
     sal_uInt32     nResId;  // Resource - and ConfigId of the Toolbox
@@ -122,12 +151,73 @@ struct SfxDispatcher_Impl
     sal_uInt16           nFilterCount;  // Number of SIDs in pFilterSIDs
     const sal_uInt16*    pFilterSIDs;   // sorted Array of SIDs
     sal_uInt32           nDisableFlags;
+    bool                 bFlushed;
+    std::deque< std::deque<SfxToDo_Impl> > aToDoCopyStack;
 };
 
 //------------------------------------------------------------------
 
 #define SFX_FLUSH_TIMEOUT    50
 
+//--------------------------------------------------------------------
+
+/** This method checks if the stack of the SfxDispatchers is flushed, or if
+    push- or pop- commands are pending.
+*/
+bool SfxDispatcher::IsFlushed() const
+{
+     return pImp->bFlushed;
+}
+
+/** This method performs outstanding push- and pop- commands. For <SfxShell>s,
+    which are new on the stack, the <SfxShell::Activate(sal_Bool)> is invoked
+    with bMDI == sal_True, for SfxShells that are removed from the stack, the
+    <SfxShell::Deactivate(sal_Bool)> is invoked with bMDI == sal_True
+*/
+void SfxDispatcher::Flush()
+{
+    if (!pImp->bFlushed) FlushImpl();
+}
+
+/** With this method, a <SfxShell> pushed on to the SfxDispatcher.
+    The SfxShell is first marked for push and a timer is set up.
+    First when the timer has couted down to zero the push
+    ( <SfxDispatcher::Flush()> ) is actually performed and the
+    <SfxBindings> is invalidated. While the timer is counting down
+    the opposing push and pop commands on the same SfxShell are
+    leveled out.
+*/
+void SfxDispatcher::Push(SfxShell& rShell)
+
+{
+    Pop( rShell, SFX_SHELL_PUSH );
+}
+
+/*  This method checks whether a particular <SfxShell> instance is
+    on the SfxDispatcher.
+
+    @returns sal_True   The SfxShell instance is on the SfxDispatcher.
+             sal_False  The SfxShell instance is not on the SfxDispatcher.
+*/
+sal_Bool SfxDispatcher::IsActive(const SfxShell& rShell)
+
+{
+    return CheckVirtualStack(rShell, sal_True);
+}
+
+/*  This method checks whether a particular <SfxShell> instance is on
+    top of the SfxDispatcher.
+
+    @returns sal_True   The SfxShell instance is on the top of
+                        the SfxDispatcher.
+             sal_False  The SfxShell instance is not on the top of
+                        the SfxDispatcher.
+*/
+sal_Bool SfxDispatcher::IsOnTop(const SfxShell& rShell)
+{
+    return CheckVirtualStack(rShell, sal_False);
+}
+
 //====================================================================
 sal_Bool SfxDispatcher::IsLocked( sal_uInt16 ) const
 
@@ -269,8 +359,8 @@ int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest
 //====================================================================
 void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
 {
-    pImp = new SfxDispatcher_Impl;
-    bFlushed = sal_True;
+    pImp.reset(new SfxDispatcher_Impl);
+    pImp->bFlushed = true;
 
     pImp->pCachedServ1 = 0;
     pImp->pCachedServ2 = 0;
@@ -363,7 +453,7 @@ SfxDispatcher::~SfxDispatcher()
     SfxBindings* pBindings = GetBindings();
 
     // When not flushed, revive the bindings
-    if ( pBindings && !pSfxApp->IsDowning() && !bFlushed )
+    if (pBindings && !pSfxApp->IsDowning() && !pImp->bFlushed)
         pBindings->DLEAVEREGISTRATIONS();
 
     // may unregister the bindings
@@ -373,8 +463,6 @@ SfxDispatcher::~SfxDispatcher()
             pBindings->SetDispatcher(0);
         pBindings = pBindings->GetSubBindings_Impl();
     }
-
-    delete pImp;
 }
 
 //====================================================================
@@ -437,10 +525,10 @@ void SfxDispatcher::Pop
     {
         // Remember ::com::sun::star::chaos::Action
         pImp->aToDoStack.push_front( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
-        if ( bFlushed )
+        if (pImp->bFlushed)
         {
             OSL_TRACE("Unflushed dispatcher!");
-            bFlushed = sal_False;
+            pImp->bFlushed = false;
             pImp->bUpdated = sal_False;
 
             // Put bindings to sleep
@@ -1599,15 +1687,15 @@ void SfxDispatcher::FlushImpl()
 
     pImp->bFlushing = sal_False;
     pImp->bUpdated = sal_False; // not only when bModify, if Doc/Template-Config
-    bFlushed = sal_True;
+    pImp->bFlushed = true;
     OSL_TRACE("Successfully flushed dispatcher!");
 
     //fdo#70703 FlushImpl may call back into itself so use aToDoCopyStack to talk
     //to outer levels of ourself. If DoActivate_Impl/DoDeactivate_Impl deletes
     //an entry, then they will walk back up aToDoCopyStack and set outer
     //levels's entries to bDeleted
-    aToDoCopyStack.push_back(aToDoCopy);
-    std::deque<SfxToDo_Impl>& rToDoCopy = aToDoCopyStack.back();
+    pImp->aToDoCopyStack.push_back(aToDoCopy);
+    std::deque<SfxToDo_Impl>& rToDoCopy = pImp->aToDoCopyStack.back();
     // Activate the Shells and possible delete them in the 2nd round
     for(std::deque<SfxToDo_Impl>::reverse_iterator i = rToDoCopy.rbegin(); i != rToDoCopy.rend(); ++i)
     {
@@ -1621,19 +1709,19 @@ void SfxDispatcher::FlushImpl()
             i->pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
     }
 
-    aToDoCopy = aToDoCopyStack.back();
-    aToDoCopyStack.pop_back();
+    aToDoCopy = pImp->aToDoCopyStack.back();
+    pImp->aToDoCopyStack.pop_back();
 
     for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
     {
         if (i->bDelete && !i->bDeleted)
         {
-            if (!aToDoCopyStack.empty())
+            if (!pImp->aToDoCopyStack.empty())
             {
                 //fdo#70703 if there is an outer FlushImpl then inform it that
                 //we have deleted this cluster
-                for (std::deque< std::deque<SfxToDo_Impl> >::iterator aI = aToDoCopyStack.begin();
-                    aI != aToDoCopyStack.end(); ++aI)
+                for (std::deque< std::deque<SfxToDo_Impl> >::iterator aI = pImp->aToDoCopyStack.begin();
+                    aI != pImp->aToDoCopyStack.end(); ++aI)
                 {
                     std::deque<SfxToDo_Impl> &v = *aI;
                     for(std::deque<SfxToDo_Impl>::iterator aJ = v.begin(); aJ != v.end(); ++aJ)
@@ -1652,7 +1740,7 @@ void SfxDispatcher::FlushImpl()
 
     // If more changes have occurred on the stach when
     // Activate/Deactivate/Delete:
-    if (!bFlushed)
+    if (!pImp->bFlushed)
         // If Push/Pop hs been called by someone, theb also EnterReg was called!
         FlushImpl();
 
@@ -2004,8 +2092,9 @@ sal_Bool SfxDispatcher::_FillState
 
     if ( pSlot )
     {
-        DBG_ASSERT(bFlushed, "Dispatcher not flushed after retrieving slot servers!");
-        if ( !bFlushed )
+        DBG_ASSERT(pImp->bFlushed,
+                "Dispatcher not flushed after retrieving slot servers!");
+        if (!pImp->bFlushed)
             return sal_False;
 
         // Determine the object and call the Message of this object


More information about the Libreoffice-commits mailing list