[Libreoffice-commits] core.git: sw/inc sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Fri Dec 30 04:13:54 UTC 2016


 sw/inc/frmfmt.hxx                |    8 +++++
 sw/source/core/draw/dcontact.cxx |   60 +++++++++++++++++----------------------
 sw/source/core/layout/atrfrm.cxx |    1 
 3 files changed, 36 insertions(+), 33 deletions(-)

New commits:
commit bd9009bdadb2a35c0271f7c12384bb96831a9bf3
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Dec 28 02:20:31 2016 +0100

    use proper message passing
    
    - also skip extra GetMaster() null-check as it is only used for
      nullchecked dynamic_casts
    
    Change-Id: Iab51a6a3d5e40aa96f8f252d4ef5dce7d805549f
    Reviewed-on: https://gerrit.libreoffice.org/32466
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index fafa003..c9f869e 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -24,6 +24,7 @@
 #include <tools/gen.hxx>
 #include <format.hxx>
 #include "swdllapi.h"
+#include <list>
 
 class SwFlyFrame;
 class SwAnchoredObject;
@@ -248,6 +249,7 @@ public:
 
 class SwDrawFrameFormat;
 class SwDrawContact;
+class SdrTextObj;
 
 namespace sw
 {
@@ -321,6 +323,12 @@ namespace sw
         CreatePortionHint(SwDrawContact** ppContact) : m_ppContact(ppContact) {};
         virtual ~CreatePortionHint() override;
     };
+    struct SW_DLLPUBLIC CollectTextObjectsHint final : SfxHint
+    {
+        std::list<SdrTextObj*>& m_rTextObjects;
+        CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
+        virtual ~CollectTextObjectsHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 86bae3e..fcc98d3 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -657,41 +657,12 @@ SwDrawContact::~SwDrawContact()
     }
 }
 
-void SwDrawContact::GetTextObjectsFromFormat( std::list<SdrTextObj*>& rTextObjects, SwDoc* pDoc )
+void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc* pDoc)
 {
-    for( sal_Int32 n=0; n<(sal_Int32)pDoc->GetSpzFrameFormats()->size(); n++ )
+    for(auto& rpFly : *pDoc->GetSpzFrameFormats())
     {
-        const SwFrameFormat* pFly = (*pDoc->GetSpzFrameFormats())[n];
-        if( dynamic_cast<const SwDrawFrameFormat*>( pFly ) !=  nullptr )
-        {
-            SwDrawContact* pContact = SwIterator<SwDrawContact,SwFrameFormat>(*pFly).First();
-            if( pContact )
-            {
-                SdrObject* pSdrO = pContact->GetMaster();
-                if ( pSdrO )
-                {
-                    if ( dynamic_cast<const SdrObjGroup*>(pSdrO) !=  nullptr )
-                    {
-                        SdrObjListIter aListIter( *pSdrO, SdrIterMode::DeepNoGroups );
-                        //iterate inside of a grouped object
-                        while( aListIter.IsMore() )
-                        {
-                            SdrObject* pSdrOElement = aListIter.Next();
-                            if( pSdrOElement && dynamic_cast<const SdrTextObj*>(pSdrOElement) !=  nullptr &&
-                                static_cast<SdrTextObj*>( pSdrOElement)->HasText() )
-                            {
-                                rTextObjects.push_back(static_cast<SdrTextObj*>( pSdrOElement ));
-                            }
-                        }
-                    }
-                    else if( dynamic_cast<const SdrTextObj*>(pSdrO) !=  nullptr &&
-                            static_cast<SdrTextObj*>( pSdrO )->HasText() )
-                    {
-                        rTextObjects.push_back(static_cast<SdrTextObj*>( pSdrO ));
-                    }
-                }
-            }
-        }
+        if(dynamic_cast<const SwDrawFrameFormat*>(rpFly))
+            rpFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects));
     }
 }
 
@@ -1596,6 +1567,29 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
             MoveObjToVisibleLayer(GetMaster());
         }
     }
+    else if (auto pCollectTextObjectsHint = dynamic_cast<const sw::CollectTextObjectsHint*>(&rHint))
+    {
+        auto pSdrO = GetMaster();
+        if(!pSdrO)
+            return;
+        if(dynamic_cast<const SdrObjGroup*>(pSdrO))
+        {
+            SdrObjListIter aListIter(*pSdrO, SdrIterMode::DeepNoGroups);
+            //iterate inside of a grouped object
+            while(aListIter.IsMore())
+            {
+                SdrObject* pSdrOElement = aListIter.Next();
+                auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrOElement));
+                if(pTextObj && pTextObj->HasText())
+                    pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
+            }
+        }
+        else if(auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrO)))
+        {
+            if(pTextObj->HasText())
+                pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
+        }
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index ee141ab..fe18ee4 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3323,6 +3323,7 @@ namespace sw
     RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
     CreatePortionHint::~CreatePortionHint() {}
     FindSdrObjectHint::~FindSdrObjectHint() {}
+    CollectTextObjectsHint::~CollectTextObjectsHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()


More information about the Libreoffice-commits mailing list