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

Takeshi Abe tabe at fixedpoint.jp
Fri Sep 26 01:20:46 PDT 2014


 include/sfx2/bindings.hxx        |   21 ++++++++++++--
 sfx2/source/control/bindings.cxx |   57 ++++++++-------------------------------
 2 files changed, 31 insertions(+), 47 deletions(-)

New commits:
commit b75b473e2ce6120d58023ee740b41cda35299d00
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Fri Sep 26 11:59:04 2014 +0900

    fdo#75757: remove inheritance to std::vector
    
    from SfxFoundCacheArr_Impl, by typedef'ing it as
    boost::ptr_vector<SfxFoundCache_Impl>.
    
    Change-Id: Id0e50370b440fb53dbb56dabca9743b27a08b90d
    Reviewed-on: https://gerrit.libreoffice.org/11650
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx
index b1f1f0a..0bccd70 100644
--- a/include/sfx2/bindings.hxx
+++ b/include/sfx2/bindings.hxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
 #include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
 
 
 //  some other includes
@@ -50,8 +51,6 @@ class SfxDispatcher;
 class SfxBindings;
 class SfxBindings_Impl;
 class Timer;
-struct SfxFoundCache_Impl;
-class SfxFoundCacheArr_Impl;
 class SfxWorkWindow;
 class SfxUnoControllerItem;
 
@@ -74,6 +73,22 @@ enum SfxPopupAction
     SFX_POPUP_SHOW
 };
 
+struct SfxFoundCache_Impl
+{
+    sal_uInt16      nSlotId;   // the Slot-Id
+    sal_uInt16      nWhichId;  // If available: Which-Id, else: nSlotId
+    const SfxSlot*  pSlot;     // Pointer to <Master-Slot>
+    SfxStateCache*  pCache;    // Pointer to StatusCache, if possible NULL
+
+    SfxFoundCache_Impl(sal_uInt16 nS, sal_uInt16 nW, const SfxSlot *pS, SfxStateCache *pC ):
+        nSlotId(nS),
+        nWhichId(nW),
+        pSlot(pS),
+        pCache(pC)
+    {}
+};
+
+typedef boost::ptr_vector<SfxFoundCache_Impl> SfxFoundCacheArr_Impl;
 
 class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster
 
@@ -117,7 +132,7 @@ private:
     SAL_DLLPRIVATE void Update_Impl( SfxStateCache* pCache );
     SAL_DLLPRIVATE void UpdateControllers_Impl(
                             const SfxInterface* pIF,
-                            const SfxFoundCache_Impl* pFound,
+                            const SfxFoundCache_Impl& rFound,
                             const SfxPoolItem *pItem,
                             SfxItemState eItemState );
     SAL_DLLPRIVATE SfxStateCache* GetStateCache( sal_uInt16 nId, sal_uInt16 *pPos);
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 4184c34..ea6a329 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -146,37 +146,6 @@ public:
     InvalidateSlotMap       m_aInvalidateSlots; // store slots which are invalidated while in update
 };
 
-
-
-struct SfxFoundCache_Impl
-{
-    sal_uInt16      nSlotId;   // the Slot-Id
-    sal_uInt16      nWhichId;  // If available: Which-Id, else: nSlotId
-    const SfxSlot*  pSlot;     // Pointer to <Master-Slot>
-    SfxStateCache*  pCache;    // Pointer to StatusCache, if possible NULL
-
-    SfxFoundCache_Impl(sal_uInt16 nS, sal_uInt16 nW, const SfxSlot *pS, SfxStateCache *pC ):
-        nSlotId(nS),
-        nWhichId(nW),
-        pSlot(pS),
-        pCache(pC)
-    {}
-};
-
-
-
-class SfxFoundCacheArr_Impl : public std::vector<SfxFoundCache_Impl*>
-{
-public:
-    ~SfxFoundCacheArr_Impl()
-    {
-        for(const_iterator it = begin(); it != end(); ++it)
-            delete *it;
-    }
-};
-
-
-
 SfxBindings::SfxBindings()
 :   pImp(new SfxBindings_Impl),
     pDispatcher(0),
@@ -378,8 +347,8 @@ void SfxBindings::Update_Impl
                 rDispat.GetShell(pMsgServer->GetShellLevel())->GetInterface();
             for ( sal_uInt16 nPos = 0; nPos < aFound.size(); ++nPos )
             {
-                const SfxFoundCache_Impl *pFound = aFound[nPos];
-                sal_uInt16 nWhich = pFound->nWhichId;
+                const SfxFoundCache_Impl& rFound = aFound[nPos];
+                sal_uInt16 nWhich = rFound.nWhichId;
                 const SfxPoolItem *pItem = 0;
                 SfxItemState eState = pSet->GetItemState(nWhich, true, &pItem);
                 if ( eState == SfxItemState::DEFAULT && SfxItemPool::IsWhich(nWhich) )
@@ -400,7 +369,7 @@ void SfxBindings::Update_Impl
         SfxFoundCache_Impl aFoundCache(
                             pCache->GetId(), 0,
                             pRealSlot, pCache );
-        UpdateControllers_Impl( 0, &aFoundCache, 0, SfxItemState::DISABLED);
+        UpdateControllers_Impl( 0, aFoundCache, 0, SfxItemState::DISABLED);
     }
 }
 
@@ -1390,12 +1359,12 @@ SfxItemSet* SfxBindings::CreateSet_Impl
     sal_uInt16 i = 0;
     while ( i < rFound.size() )
     {
-        pRanges[j++] = rFound[i]->nWhichId;
+        pRanges[j++] = rFound[i].nWhichId;
             // consecutive numbers
         for ( ; i < rFound.size()-1; ++i )
-            if ( rFound[i]->nWhichId+1 != rFound[i+1]->nWhichId )
+            if ( rFound[i].nWhichId+1 != rFound[i+1].nWhichId )
                 break;
-        pRanges[j++] = rFound[i++]->nWhichId;
+        pRanges[j++] = rFound[i++].nWhichId;
     }
     pRanges[j] = 0; // terminating NULL
     SfxItemSet *pSet = new SfxItemSet(rPool, pRanges.get());
@@ -1408,16 +1377,16 @@ SfxItemSet* SfxBindings::CreateSet_Impl
 void SfxBindings::UpdateControllers_Impl
 (
     const SfxInterface*         pIF,    // Id of the current serving Interface
-    const SfxFoundCache_Impl*   pFound, // Cache, Slot, Which etc.
+    const SfxFoundCache_Impl&   rFound, // Cache, Slot, Which etc.
     const SfxPoolItem*          pItem,  // item to send to controller
     SfxItemState                eState  // state of item
 )
 {
-    DBG_ASSERT( !pFound->pSlot || SFX_KIND_ENUM != pFound->pSlot->GetKind(),
+    DBG_ASSERT( !rFound.pSlot || SFX_KIND_ENUM != rFound.pSlot->GetKind(),
                 "direct update of enum slot isn't allowed" );
 
-    SfxStateCache* pCache = pFound->pCache;
-    const SfxSlot* pSlot = pFound->pSlot;
+    SfxStateCache* pCache = rFound.pCache;
+    const SfxSlot* pSlot = rFound.pSlot;
     DBG_ASSERT( !pCache || !pSlot || pCache->GetId() == pSlot->GetSlotId(), "SID mismatch" );
 
     // bound until now, the Controller to update the Slot.
@@ -1429,7 +1398,7 @@ void SfxBindings::UpdateControllers_Impl
             pCache->SetState( SfxItemState::DONTCARE, (SfxPoolItem *)-1 );
         }
         else if ( SfxItemState::DEFAULT == eState &&
-                    pFound->nWhichId > SFX_WHICH_MAX )
+                    rFound.nWhichId > SFX_WHICH_MAX )
         {
             // no Status or Default but without Pool
             SfxVoidItem aVoid(0);
@@ -1471,7 +1440,7 @@ void SfxBindings::UpdateControllers_Impl
                 pEnumCache->Invalidate(false);
 
                 // HACK(CONTROL/SELECT Kram) ???
-                if ( eState == SfxItemState::DONTCARE && pFound->nWhichId == 10144 )
+                if ( eState == SfxItemState::DONTCARE && rFound.nWhichId == 10144 )
                 {
                     SfxVoidItem aVoid(0);
                     pEnumCache->SetState( SfxItemState::UNKNOWN, &aVoid );
@@ -1491,7 +1460,7 @@ void SfxBindings::UpdateControllers_Impl
                 {
                     // Determine enum value
                     sal_uInt16 nValue = pEnumItem->GetEnumValue();
-                    SfxBoolItem aBool( pFound->nWhichId, pSlave->GetValue() == nValue );
+                    SfxBoolItem aBool( rFound.nWhichId, pSlave->GetValue() == nValue );
                     pEnumCache->SetState(SfxItemState::DEFAULT, &aBool);
                 }
                 else


More information about the Libreoffice-commits mailing list