Kaydet (Commit) 720dc84b authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

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/34733Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 7e8bef55
......@@ -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;
......
......@@ -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
{
......
......@@ -70,7 +70,6 @@ class SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
using SwLayoutFrame::CalcRel;
sal_uInt32 GetOrdNumForNewRef( const SwFlyDrawContact* );
SwVirtFlyDrawObj* CreateNewRef( SwFlyDrawContact* );
protected:
......
......@@ -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#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment