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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Dec 7 13:57:29 UTC 2016


 sw/inc/frmfmt.hxx                            |    9 +++++++++
 sw/source/core/doc/DocumentLayoutManager.cxx |   24 +++++-------------------
 sw/source/core/draw/dcontact.cxx             |   14 ++++++++++++++
 sw/source/core/layout/atrfrm.cxx             |    1 +
 4 files changed, 29 insertions(+), 19 deletions(-)

New commits:
commit 45cd3f505a02ba48171bcbb8e319fedc6f868b10
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Tue Dec 6 15:00:45 2016 +0100

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

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 0d3cac0..18a5f0a 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -234,6 +234,8 @@ public:
 
 //The DrawFrame-Format
 
+
+class SwDrawFrameFormat;
 namespace sw
 {
     enum class DrawFrameFormatHintId {
@@ -264,6 +266,13 @@ namespace sw
         ContactChangedHint(SdrObject** ppObject) : m_ppObject(ppObject) {};
         virtual ~ContactChangedHint() override;
     };
+    struct SW_DLLPUBLIC DrawFormatLayoutCopyHint final : SfxHint
+    {
+        SwDrawFrameFormat& m_rDestFormat;
+        SwDoc& m_rDestDoc;
+        DrawFormatLayoutCopyHint(SwDrawFrameFormat& rDestFormat, SwDoc& rDestDoc) : m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
+        virtual ~DrawFormatLayoutCopyHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx
index 8134c6f..08e1cff 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -445,28 +445,14 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
     {
         OSL_ENSURE( RES_DRAWFRMFMT == rSource.Which(), "Neither Fly nor Draw." );
         // #i52780# - Note: moving object to visible layer not needed.
-        const SwDrawContact* pSourceContact = static_cast<const SwDrawContact *>(rSource.FindContactObj());
-
-        SwDrawContact* pContact = new SwDrawContact( static_cast<SwDrawFrameFormat*>(pDest),
-                                m_rDoc.CloneSdrObj( *pSourceContact->GetMaster(),
-                                        m_rDoc.IsCopyIsMove() && &m_rDoc == pSrcDoc ) );
-        // #i49730# - notify draw frame format that position attributes are
-        // already set, if the position attributes are already set at the
-        // source draw frame format.
-        if ( dynamic_cast<const SwDrawFrameFormat*>( pDest) !=  nullptr &&
-             dynamic_cast<const SwDrawFrameFormat*>( &rSource) !=  nullptr &&
-             static_cast<const SwDrawFrameFormat&>(rSource).IsPosAttrSet() )
-        {
-            static_cast<SwDrawFrameFormat*>(pDest)->PosAttrSet();
-        }
+        rSource.CallSwClientNotify(sw::DrawFormatLayoutCopyHint(static_cast<SwDrawFrameFormat&>(*pDest), m_rDoc));
 
-        if( pDest->GetAnchor() == rNewAnchor )
+        if(pDest->GetAnchor() == rNewAnchor)
         {
             // Do *not* connect to layout, if a <MakeFrames> will not be called.
-            if ( bMakeFrames )
-            {
-                pContact->ConnectToLayout( &rNewAnchor );
-            }
+            if(bMakeFrames)
+                pDest->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::MAKE_FRAMES));
+
         }
         else
             pDest->SetFormatAttr( rNewAnchor );
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 8e4ebb50..b8aaa40 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1525,6 +1525,20 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         auto pObject = *pContactChangedHint->m_ppObject;
         Changed(*pObject, SdrUserCallType::Delete, pObject->GetLastBoundRect());
     }
+    else if (auto pDrawFormatLayoutCopyHint = dynamic_cast<const sw::DrawFormatLayoutCopyHint*>(&rHint))
+    {
+        const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod);
+        new SwDrawContact(
+                &pDrawFormatLayoutCopyHint->m_rDestFormat,
+                pDrawFormatLayoutCopyHint->m_rDestDoc.CloneSdrObj(
+                        *GetMaster(),
+                        pDrawFormatLayoutCopyHint->m_rDestDoc.IsCopyIsMove() && &pDrawFormatLayoutCopyHint->m_rDestDoc == rFormat.GetDoc()));
+        // #i49730# - notify draw frame format that position attributes are
+        // already set, if the position attributes are already set at the
+        // source draw frame format.
+        if(rFormat.IsPosAttrSet())
+            pDrawFormatLayoutCopyHint->m_rDestFormat.PosAttrSet();
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index f9944e7..7211fc5 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3331,6 +3331,7 @@ namespace sw
     DrawFrameFormatHint::~DrawFrameFormatHint() {}
     CheckDrawFrameFormatLayerHint::~CheckDrawFrameFormatLayerHint() {}
     ContactChangedHint::~ContactChangedHint() {}
+    DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()


More information about the Libreoffice-commits mailing list