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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Dec 14 10:42:24 UTC 2016


 sw/inc/frmfmt.hxx                |    9 ++++++++-
 sw/source/core/draw/dcontact.cxx |   14 ++++++++++++++
 sw/source/core/layout/atrfrm.cxx |    1 +
 sw/source/core/undo/unattr.cxx   |   21 +++++----------------
 4 files changed, 28 insertions(+), 17 deletions(-)

New commits:
commit 5a7e754fa9ca42fb673f240563cdcc1bf2aef006
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Tue Dec 13 04:14:43 2016 +0100

    use proper message passing
    
    Change-Id: I0bfe65fa6870b243f927004d4de0da010b338c64
    Reviewed-on: https://gerrit.libreoffice.org/31929
    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 14a50be..900f00d 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -245,7 +245,8 @@ namespace sw
         PREP_DELETE_FLY,
         PAGE_OUT_OF_BOUNDS,
         MAKE_FRAMES,
-        DELETE_FRAMES
+        DELETE_FRAMES,
+        POST_RESTORE_FLY_ANCHOR,
     };
     struct SW_DLLPUBLIC DrawFrameFormatHint final: SfxHint
     {
@@ -296,6 +297,12 @@ namespace sw
         WW8AnchorConvHint(WW8AnchorConvResult& rResult) : m_rResult(rResult) {};
         virtual ~WW8AnchorConvHint() override;
     };
+    struct SW_DLLPUBLIC RestoreFlyAnchorHint final : SfxHint
+    {
+        const Point m_aPos;
+        RestoreFlyAnchorHint(Point aPos) : m_aPos(aPos) {};
+        virtual ~RestoreFlyAnchorHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 2ef6e6d..431bc11 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1512,6 +1512,9 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
             case sw::DrawFrameFormatHintId::MAKE_FRAMES:
                  ConnectToLayout();
                  break;
+            case sw::DrawFrameFormatHintId::POST_RESTORE_FLY_ANCHOR:
+                GetAnchoredObj(GetMaster())->MakeObjPos();
+                break;
             default:
                 SAL_WARN("sw.core", "unhandled DrawFrameFormatHintId");
         }
@@ -1569,6 +1572,17 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getY());
         rResult.m_bConverted = true;
     }
+    else if (auto pRestoreFlyAnchorHint = dynamic_cast<const sw::RestoreFlyAnchorHint*>(&rHint))
+    {
+        SdrObject* pObj = GetMaster();
+        if(GetAnchorFrame() && !pObj->IsInserted())
+        {
+            auto pDrawModel = const_cast<SwDrawFrameFormat&>(static_cast<const SwDrawFrameFormat&>(rMod)).GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+            assert(pDrawModel);
+            pDrawModel->GetPage(0)->InsertObject(pObj);
+        }
+        pObj->SetRelativePos(pRestoreFlyAnchorHint->m_aPos);
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 9351312..230b5ed 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3333,6 +3333,7 @@ namespace sw
     ContactChangedHint::~ContactChangedHint() {}
     DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {}
     WW8AnchorConvHint::~WW8AnchorConvHint() {}
+    RestoreFlyAnchorHint::~RestoreFlyAnchorHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 4641aa0..47228ee4 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -481,24 +481,14 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
         }
     }
 
-    SwDrawContact *pCont = nullptr;
-    if ( RES_DRAWFRMFMT == pFrameFormat->Which() ) {
-        pCont = static_cast<SwDrawContact*>(pFrameFormat->FindContactObj());
+    if ( RES_DRAWFRMFMT == pFrameFormat->Which() )
+    {
         // The Draw model also prepared an Undo object for its right positioning
         // which unfortunately is relative. Therefore block here a position
         // change of the Contact object by setting the anchor.
-        SdrObject* pObj = pCont->GetMaster();
-
-        if( pCont->GetAnchorFrame() && !pObj->IsInserted() ) {
-            OSL_ENSURE( pDoc->getIDocumentDrawModelAccess().GetDrawModel(),
-                        "RestoreFlyAnchor without DrawModel" );
-            pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )->InsertObject( pObj );
-        }
-        pObj->SetRelativePos( aDrawSavePt );
-
+        pFrameFormat->CallSwClientNotify(sw::RestoreFlyAnchorHint(aDrawSavePt));
         // cache the old value again
-        m_pOldSet->Put(
-            SwFormatFrameSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) );
+        m_pOldSet->Put(SwFormatFrameSize(ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y()));
     }
 
     if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) {
@@ -513,8 +503,7 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
         pFrameFormat->MakeFrames();
     else
     {
-        SdrObject* pSdrObj = pFrameFormat->FindSdrObject();
-        pCont->GetAnchoredObj(pSdrObj)->MakeObjPos();
+        pFrameFormat->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::POST_RESTORE_FLY_ANCHOR));
     }
 
     rContext.SetSelections(pFrameFormat, nullptr);


More information about the Libreoffice-commits mailing list