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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Mar 1 13:19:28 UTC 2017


 sw/inc/dcontact.hxx              |    3 +
 sw/source/core/draw/dcontact.cxx |   52 +++++++++++++++++++++++++++++++
 sw/source/core/inc/flyfrm.hxx    |    1 
 sw/source/core/layout/fly.cxx    |   64 ---------------------------------------
 4 files changed, 55 insertions(+), 65 deletions(-)

New commits:
commit 720dc84b855b6f200d97882157ac07d96207ffab
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Mar 1 02:57:05 2017 +0100

    move GetOrdNumForNewRef() and CreateNewRef() ...
    
    ... from SwFlyFrame to SwFlyDrawContact as that is the object they are
    doing most of the work. Also refactor a bit while at it.
    
    Change-Id: I9a08592afb15be32c2c36408e4126807871f77c8
    Reviewed-on: https://gerrit.libreoffice.org/34733
    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 781257d..351d598 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -191,12 +191,13 @@ class SW_DLLPUBLIC SwFlyDrawContact final : public SwContact
 private:
     std::unique_ptr<SwFlyDrawObj> mpMasterObj;
     void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
-
+    sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly);
 
 public:
 
     /// Creates DrawObject and registers it with the Model.
     SwFlyDrawContact( SwFlyFrameFormat* pToRegisterIn, SdrModel* pMod );
+    SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly);
     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 107fdad..78e6710 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -488,6 +488,58 @@ SwFlyDrawContact::~SwFlyDrawContact()
     }
 }
 
+sal_uInt32 SwFlyDrawContact::GetOrdNumForNewRef(const SwFlyFrame* pFly)
+{
+    // search for another Writer fly frame registered at same frame format
+    SwIterator<SwFlyFrame,SwFormat> aIter(*GetFormat());
+    const SwFlyFrame* pFlyFrame(nullptr);
+    for(pFlyFrame = aIter.First(); pFlyFrame; pFlyFrame = aIter.Next())
+    {
+        if(pFlyFrame != pFly)
+            break;
+    }
+
+    if(pFlyFrame)
+    {
+        // another Writer fly frame found. Take its order number
+        return pFlyFrame->GetVirtDrawObj()->GetOrdNum();
+    }
+    // no other Writer fly frame found. Take order number of 'master' object
+    // #i35748# - use method <GetOrdNumDirect()> instead
+    // of method <GetOrdNum()> to avoid a recalculation of the order number,
+    // which isn't intended.
+    return GetMaster()->GetOrdNumDirect();
+}
+
+SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly)
+{
+    SwVirtFlyDrawObj* pDrawObj(new SwVirtFlyDrawObj(*GetMaster(), pFly));
+    pDrawObj->SetModel(GetMaster()->GetModel());
+    pDrawObj->SetUserCall(this);
+
+    // 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()))
+    {
+        const size_t nOrdNum = 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));
+    }
+    // #i38889# - assure, that new <SwVirtFlyDrawObj> instance
+    // is in a visible layer.
+    MoveObjToVisibleLayer(pDrawObj);
+    return pDrawObj;
+}
+
 // #i26791#
 const SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj(const SdrObject* pSdrObj) const
 {
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 12a3ec8..4fbb818 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -70,7 +70,6 @@ class SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
 
     using SwLayoutFrame::CalcRel;
 
-    sal_uInt32 GetOrdNumForNewRef( const SwFlyDrawContact* );
     SwVirtFlyDrawObj* CreateNewRef( SwFlyDrawContact* );
 
 protected:
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 02b32b0..add94cd 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -330,67 +330,6 @@ void SwFlyFrame::DeleteCnt()
     InvalidatePage();
 }
 
-sal_uInt32 SwFlyFrame::GetOrdNumForNewRef( const SwFlyDrawContact* pContact )
-{
-    sal_uInt32 nOrdNum( 0L );
-
-    // search for another Writer fly frame registered at same frame format
-    SwIterator<SwFlyFrame,SwFormat> aIter( *pContact->GetFormat() );
-    const SwFlyFrame* pFlyFrame( nullptr );
-    for ( pFlyFrame = aIter.First(); pFlyFrame; pFlyFrame = aIter.Next() )
-    {
-        if ( pFlyFrame != this )
-        {
-            break;
-        }
-    }
-
-    if ( pFlyFrame )
-    {
-        // another Writer fly frame found. Take its order number
-        nOrdNum = pFlyFrame->GetVirtDrawObj()->GetOrdNum();
-    }
-    else
-    {
-        // no other Writer fly frame found. Take order number of 'master' object
-        // #i35748# - use method <GetOrdNumDirect()> instead
-        // of method <GetOrdNum()> to avoid a recalculation of the order number,
-        // which isn't intended.
-        nOrdNum = pContact->GetMaster()->GetOrdNumDirect();
-    }
-
-    return nOrdNum;
-}
-
-SwVirtFlyDrawObj* SwFlyFrame::CreateNewRef( SwFlyDrawContact *pContact )
-{
-    SwVirtFlyDrawObj *pDrawObj = new SwVirtFlyDrawObj( *pContact->GetMaster(), this );
-    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 = pContact->GetMaster()->GetPage() ) )
-    {
-        const size_t nOrdNum = pContact->GetMaster()->GetOrdNum();
-        pPg->ReplaceObject( pDrawObj, nOrdNum );
-    }
-    // #i27030# - insert new <SwVirtFlyDrawObj> instance
-    // into drawing page with correct order number
-    else
-    {
-        pContact->GetFormat()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )->
-                        InsertObject( pDrawObj, GetOrdNumForNewRef( pContact ) );
-    }
-    // #i38889# - assure, that new <SwVirtFlyDrawObj> instance
-    // is in a visible layer.
-    pContact->MoveObjToVisibleLayer( pDrawObj );
-    return pDrawObj;
-}
-
 void SwFlyFrame::InitDrawObj()
 {
     // Find ContactObject from the Format. If there's already one, we just
@@ -404,9 +343,8 @@ void SwFlyFrame::InitDrawObj()
         pContact = new SwFlyDrawContact( GetFormat(),
                                           rIDDMA.GetOrCreateDrawModel() );
     }
-    OSL_ENSURE( pContact, "InitDrawObj failed" );
     // OD 2004-03-22 #i26791#
-    SetDrawObj( *(CreateNewRef( pContact )) );
+    SetDrawObj(*pContact->CreateNewRef(this));
 
     // Set the right Layer
     // OD 2004-01-19 #110582#


More information about the Libreoffice-commits mailing list