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

Bjoern Michaelsen bjoern.michaelsen at libreoffice.org
Mon Apr 24 07:32:12 UTC 2017


 sw/inc/dcontact.hxx              |    2 +-
 sw/source/core/draw/dcontact.cxx |   26 +++++++++++++++-----------
 sw/source/core/layout/fly.cxx    |   14 ++------------
 3 files changed, 18 insertions(+), 24 deletions(-)

New commits:
commit b29b68ab4075d7b511f0d94df562118d4f1c76f9
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date:   Wed Apr 19 02:39:17 2017 +0200

    move SwDrawFlyContract creation into CreateNewRef
    
    Change-Id: Ied86e1fd9424fc28e95215e60bed95069b7b51a6
    Reviewed-on: https://gerrit.libreoffice.org/36869
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 5276f52ba680..f4741c1e9f3f 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -197,7 +197,7 @@ public:
 
     /// Creates DrawObject and registers it with the Model.
     SwFlyDrawContact( SwFlyFrameFormat* pToRegisterIn, SdrModel* pMod );
-    SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly);
+    static SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat);
     virtual ~SwFlyDrawContact() override;
 
     virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 4854824d7300..65a3cb2bead2 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -502,32 +502,36 @@ sal_uInt32 SwFlyDrawContact::GetOrdNumForNewRef(const SwFlyFrame* pFly)
     return GetMaster()->GetOrdNumDirect();
 }
 
-SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly)
+SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat)
 {
-    SwVirtFlyDrawObj* pDrawObj(new SwVirtFlyDrawObj(*GetMaster(), pFly));
-    pDrawObj->SetModel(GetMaster()->GetModel());
-    pDrawObj->SetUserCall(this);
+    // Find ContactObject from the Format. If there's already one, we just
+    // need to create a new Ref, else we create the Contact now.
+
+    IDocumentDrawModelAccess& rIDDMA = pFormat->getIDocumentDrawModelAccess();
+    SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFormat>( *pFormat ).First();
+    if ( !pContact )
+        pContact = new SwFlyDrawContact(pFormat, rIDDMA.GetOrCreateDrawModel());
+    SwVirtFlyDrawObj* pDrawObj(new SwVirtFlyDrawObj(*pContact->GetMaster(), pFly));
+    pDrawObj->SetModel(pContact->GetMaster()->GetModel());
+    pDrawObj->SetUserCall(pContact);
 
     // The Reader creates the Masters and inserts them into the Page in
     // order to transport the z-order.
     // After creating the first Reference the Masters are removed from the
     // List and are not important anymore.
     SdrPage* pPg(nullptr);
-    if(nullptr != (pPg = GetMaster()->GetPage()))
+    if(nullptr != (pPg = pContact->GetMaster()->GetPage()))
     {
-        const size_t nOrdNum = GetMaster()->GetOrdNum();
+        const size_t nOrdNum = pContact->GetMaster()->GetOrdNum();
         pPg->ReplaceObject(pDrawObj, nOrdNum);
     }
     // #i27030# - insert new <SwVirtFlyDrawObj> instance
     // into drawing page with correct order number
     else
-    {
-        GetFormat()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0)->
-                InsertObject(pDrawObj, GetOrdNumForNewRef(pFly));
-    }
+        rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj, pContact->GetOrdNumForNewRef(pFly));
     // #i38889# - assure, that new <SwVirtFlyDrawObj> instance
     // is in a visible layer.
-    MoveObjToVisibleLayer(pDrawObj);
+    pContact->MoveObjToVisibleLayer(pDrawObj);
     return pDrawObj;
 }
 
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 13fe44ad08dc..5afdad4b5296 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -332,22 +332,12 @@ void SwFlyFrame::DeleteCnt()
 
 void SwFlyFrame::InitDrawObj()
 {
-    // Find ContactObject from the Format. If there's already one, we just
-    // need to create a new Ref, else we create the Contact now.
-
-    IDocumentDrawModelAccess& rIDDMA = GetFormat()->getIDocumentDrawModelAccess();
-    SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFormat>( *GetFormat() ).First();
-    if ( !pContact )
-    {
-        // #i52858# - method name changed
-        pContact = new SwFlyDrawContact( GetFormat(),
-                                          rIDDMA.GetOrCreateDrawModel() );
-    }
     // OD 2004-03-22 #i26791#
-    SetDrawObj(*pContact->CreateNewRef(this));
+    SetDrawObj(*SwFlyDrawContact::CreateNewRef(this, GetFormat()));
 
     // Set the right Layer
     // OD 2004-01-19 #110582#
+    IDocumentDrawModelAccess& rIDDMA = GetFormat()->getIDocumentDrawModelAccess();
     SdrLayerID nHeavenId = rIDDMA.GetHeavenId();
     SdrLayerID nHellId = rIDDMA.GetHellId();
     // OD 2004-03-22 #i26791#


More information about the Libreoffice-commits mailing list