diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2017-03-01 02:57:05 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2017-03-01 13:18:52 +0000 |
commit | 720dc84b855b6f200d97882157ac07d96207ffab (patch) | |
tree | 8a0305ce60ce67dd756d401764c1914b69ee913f /sw | |
parent | 7e8bef556184851edd7a716cf3284cd1ae3b3366 (diff) |
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@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/dcontact.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 52 | ||||
-rw-r--r-- | sw/source/core/inc/flyfrm.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 64 |
4 files changed, 55 insertions, 65 deletions
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 781257df184b..351d59824f9f 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 107fdadc8eaf..78e67105190a 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 12a3ec80b8ba..4fbb81868b7f 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 02b32b028efe..add94cdd7d1a 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# |