sw/inc/dcontact.hxx              |   26 ---------------
 sw/source/core/draw/dcontact.cxx |   65 ++++++++++++++++++---------------------
 2 files changed, 31 insertions(+), 60 deletions(-)

New commits:
commit 7e8bef556184851edd7a716cf3284cd1ae3b3366
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Tue Feb 28 11:12:36 2017 +0100

    move predicates into only using compilation unit
    
    - also refactor and simplify
    
    Change-Id: I0fe0c043b72d7664a0fe27baf13ab029aed41eab
    Reviewed-on: https://gerrit.libreoffice.org/34726
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michael...@canonical.com>

diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 468a866..781257d 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -337,32 +337,6 @@ class SwDrawContact final : public SwContact
 
         friend class NestedUserCallHdl;
 
-        /** unary function used by <list> iterator to find a disconnected 
'virtual'
-         drawing object */
-        struct UsedOrUnusedVirtObjPred
-        {
-            bool mbUsedPred;
-            UsedOrUnusedVirtObjPred( bool _bUsed ) : mbUsedPred( _bUsed ) {};
-            bool operator() ( const std::unique_ptr<SwDrawVirtObj>& 
_pDrawVirtObj )
-            {
-                if ( mbUsedPred )
-                {
-                    return _pDrawVirtObj->IsConnected();
-                }
-                else
-                {
-                    return !_pDrawVirtObj->IsConnected();
-                }
-            }
-        };
-
-        /** unary function used to find a 'virtual' drawing object anchored at 
a given frame */
-        struct VirtObjAnchoredAtFramePred
-        {
-            const SwFrame* mpAnchorFrame;
-            VirtObjAnchoredAtFramePred( const SwFrame& _rAnchorFrame );
-            bool operator() ( const std::unique_ptr<SwDrawVirtObj>& 
_pDrawVirtObj );
-        };
 
         void RemoveAllVirtObjs();
 
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 6192fd2..107fdad 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -73,6 +73,36 @@
 
 using namespace ::com::sun::star;
 
+namespace
+{
+    /** unary function used to find a disconnected 'virtual' drawing object */
+    struct UsedOrUnusedVirtObjPred
+    {
+        bool m_bUsedPred;
+        UsedOrUnusedVirtObjPred(bool bUsed) : m_bUsedPred(bUsed) {};
+        bool operator()(const std::unique_ptr<SwDrawVirtObj>& pDrawVirtObj)
+                { return pDrawVirtObj->IsConnected() == m_bUsedPred; };
+    };
+
+    /** unary function used to find a 'virtual' drawing object anchored at a 
given frame */
+    struct VirtObjAnchoredAtFramePred
+    {
+        const SwFrame* m_pAnchorFrame;
+        // #i26791# - compare with master frame
+        static const SwFrame* FindFrame(const SwFrame* pFrame)
+        {
+            if(!pFrame || !pFrame->IsContentFrame())
+                return pFrame;
+            auto pContentFrame = static_cast<const SwContentFrame*>(pFrame);
+            while(pContentFrame->IsFollow())
+                pContentFrame = pContentFrame->FindMaster();
+            return pContentFrame;
+        };
+        VirtObjAnchoredAtFramePred(const SwFrame* pAnchorFrame) : 
m_pAnchorFrame(FindFrame(pAnchorFrame)) {};
+        bool operator()(const std::unique_ptr<SwDrawVirtObj>& rpDrawVirtObj)
+            { return FindFrame(rpDrawVirtObj->GetAnchorFrame()) == 
m_pAnchorFrame; };
+    };
+}
 
 void setContextWritingMode(SdrObject* pObj, SwFrame* pAnchor)
 {
@@ -763,39 +793,6 @@ void SwDrawContact::RemoveAllVirtObjs()
     maDrawVirtObjs.clear();
 }
 
-SwDrawContact::VirtObjAnchoredAtFramePred::VirtObjAnchoredAtFramePred(
-                                                const SwFrame& _rAnchorFrame )
-    : mpAnchorFrame( &_rAnchorFrame )
-{
-    if ( mpAnchorFrame->IsContentFrame() )
-    {
-        const SwContentFrame* pTmpFrame =
-                            static_cast<const SwContentFrame*>( mpAnchorFrame 
);
-        while ( pTmpFrame->IsFollow() )
-        {
-            pTmpFrame = pTmpFrame->FindMaster();
-        }
-        mpAnchorFrame = pTmpFrame;
-    }
-}
-
-// #i26791# - compare with master frame
-bool SwDrawContact::VirtObjAnchoredAtFramePred::operator() ( const 
std::unique_ptr<SwDrawVirtObj>& _pDrawVirtObj )
-{
-    const SwFrame* pObjAnchorFrame = _pDrawVirtObj->GetAnchorFrame();
-    if ( pObjAnchorFrame && pObjAnchorFrame->IsContentFrame() )
-    {
-        const SwContentFrame* pTmpFrame =
-                            static_cast<const SwContentFrame*>( 
pObjAnchorFrame );
-        while ( pTmpFrame->IsFollow() )
-        {
-            pTmpFrame = pTmpFrame->FindMaster();
-        }
-        pObjAnchorFrame = pTmpFrame;
-    }
-
-    return ( pObjAnchorFrame == mpAnchorFrame );
-}
 
 /// get drawing object ('master' or 'virtual') by frame.
 SdrObject* SwDrawContact::GetDrawObjectByAnchorFrame( const SwFrame& 
_rAnchorFrame )
@@ -834,7 +831,7 @@ SdrObject* SwDrawContact::GetDrawObjectByAnchorFrame( const 
SwFrame& _rAnchorFra
     else
     {
         const auto ppFoundVirtObj(std::find_if(maDrawVirtObjs.begin(), 
maDrawVirtObjs.end(),
-                VirtObjAnchoredAtFramePred(*pProposedAnchorFrame)));
+                VirtObjAnchoredAtFramePred(pProposedAnchorFrame)));
         if(ppFoundVirtObj != maDrawVirtObjs.end())
             pRetDrawObj = ppFoundVirtObj->get();
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to