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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Tue Jan 3 10:52:22 UTC 2017


 sw/inc/dcontact.hxx              |    3 ++-
 sw/inc/frmfmt.hxx                |    6 ++++++
 sw/source/core/doc/docdraw.cxx   |   39 ++++++---------------------------------
 sw/source/core/draw/dcontact.cxx |   19 +++++++++++++++++++
 sw/source/core/inc/flyfrm.hxx    |    1 +
 sw/source/core/layout/atrfrm.cxx |    1 +
 sw/source/core/layout/fly.cxx    |   14 ++++++++++++++
 7 files changed, 49 insertions(+), 34 deletions(-)

New commits:
commit 2f01d2a42a5afecd7827a939cd0f5d6793cba47e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Tue Jan 3 02:01:48 2017 +0100

    use proper message passing
    
    Change-Id: Id0ac2e87344fdab4db97357158c5cc60eed70898
    Reviewed-on: https://gerrit.libreoffice.org/32663
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index ae84eee..36f2410 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -186,10 +186,11 @@ public:
 /** ContactObject for connection between frames (or their formats respectively)
  in SwClient and the drawobjects of Drawing (DsrObjUserCall). */
 
-class SW_DLLPUBLIC SwFlyDrawContact : public SwContact
+class SW_DLLPUBLIC SwFlyDrawContact final : public SwContact
 {
 private:
     SwFlyDrawObj* mpMasterObj;
+    void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
 
 
 public:
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index c9f869e..6c1e2da 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -329,6 +329,12 @@ namespace sw
         CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects) : m_rTextObjects(rTextObjects) {};
         virtual ~CollectTextObjectsHint() override;
     };
+    struct SW_DLLPUBLIC GetZOrderHint final : SfxHint
+    {
+        sal_uInt32& m_rnZOrder;
+        GetZOrderHint(sal_uInt32& rnZOrder) : m_rnZOrder(rnZOrder) {};
+        virtual ~GetZOrderHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index f628efd..fad1edb 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -478,40 +478,13 @@ bool SwDoc::DeleteSelection( SwDrawView& rDrawView )
     return bCallBase;
 }
 
-ZSortFly::ZSortFly( const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAn,
-                      sal_uInt32 nArrOrdNum )
-    : pFormat( pFrameFormat ), pAnchor( pFlyAn ), nOrdNum( nArrOrdNum )
+ZSortFly::ZSortFly(const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAn, sal_uInt32 nArrOrdNum)
+    : pFormat(pFrameFormat)
+    , pAnchor(pFlyAn)
+    , nOrdNum(nArrOrdNum)
 {
-    // #i11176#
-    // This also needs to work when no layout exists. Thus, for
-    // FlyFrames an alternative method is used now in that case.
-    if( RES_FLYFRMFMT == pFormat->Which() )
-    {
-        if( pFormat->getIDocumentLayoutAccess().GetCurrentViewShell() )
-        {
-            // See if there is an SdrObject for it
-            SwFlyFrame* pFly = SwIterator<SwFlyFrame,SwFormat>( *pFrameFormat ).First();
-            if( pFly )
-                nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
-        }
-        else
-        {
-            // See if there is an SdrObject for it
-            SwFlyDrawContact* pContact = SwIterator<SwFlyDrawContact,SwFormat>( *pFrameFormat ).First();
-            if( pContact )
-                nOrdNum = pContact->GetMaster()->GetOrdNum();
-        }
-    }
-    else if( RES_DRAWFRMFMT == pFormat->Which() )
-    {
-        // See if there is an SdrObject for it
-        SwDrawContact* pContact = SwIterator<SwDrawContact,SwFormat>( *pFrameFormat ).First();
-        if( pContact )
-            nOrdNum = pContact->GetMaster()->GetOrdNum();
-    }
-    else {
-        OSL_ENSURE( false, "what kind of format is this?" );
-    }
+    SAL_WARN_IF(pFormat->Which() != RES_FLYFRMFMT && pFormat->Which() != RES_DRAWFRMFMT, "sw.core", "What kind of format is this?");
+    pFormat->CallSwClientNotify(sw::GetZOrderHint(nOrdNum));
 }
 
 /// In the Outliner, set a link to the method for field display in edit objects.
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index fcc98d3..dab09e8 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -578,6 +578,19 @@ void SwFlyDrawContact::GetAnchoredObjs( std::list<SwAnchoredObject*>& _roAnchore
     const SwFrameFormat* pFormat = GetFormat();
     SwFlyFrame::GetAnchoredObjects( _roAnchoredObjs, *pFormat );
 }
+void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
+{
+    SwContact::SwClientNotify(rMod, rHint);
+    if(auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
+    {
+        // #i11176#
+        // This also needs to work when no layout exists. Thus, for
+        // FlyFrames an alternative method is used now in that case.
+        auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
+        if(pFormat->Which() == RES_FLYFRMFMT && !pFormat->getIDocumentLayoutAccess().GetCurrentViewShell())
+            pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
+    }
+}
 
 // SwDrawContact
 
@@ -1590,6 +1603,12 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
                 pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
         }
     }
+    else if (auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
+    {
+        auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
+        if(pFormat->Which() == RES_DRAWFRMFMT)
+            pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 808b14a..12a3ec8 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -141,6 +141,7 @@ protected:
 
     virtual const SwRect GetObjBoundRect() const override;
     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+    virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
 
     virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index fe18ee4..8df92d3 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3324,6 +3324,7 @@ namespace sw
     CreatePortionHint::~CreatePortionHint() {}
     FindSdrObjectHint::~FindSdrObjectHint() {}
     CollectTextObjectsHint::~CollectTextObjectsHint() {}
+    GetZOrderHint::~GetZOrderHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 30d6930..651dbcc 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -673,6 +673,20 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize &rFrameSize )
     return bRet;
 }
 
+void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
+{
+    if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
+    {
+        Modify(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
+    }
+    else if(auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
+    {
+        auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
+        if(pFormat->Which() == RES_FLYFRMFMT && pFormat->getIDocumentLayoutAccess().GetCurrentViewShell()) // #i11176#
+            pGetZOrdnerHint->m_rnZOrder = GetVirtDrawObj()->GetOrdNum();
+     }
+};
+
 void SwFlyFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
 {
     sal_uInt8 nInvFlags = 0;


More information about the Libreoffice-commits mailing list