diff options
Diffstat (limited to 'sw/source/core/draw/dpage.cxx')
-rw-r--r-- | sw/source/core/draw/dpage.cxx | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx index 716e41c433a6..d50a7f5780cf 100644 --- a/sw/source/core/draw/dpage.cxx +++ b/sw/source/core/draw/dpage.cxx @@ -49,58 +49,38 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::frame; -SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) : - FmFormPage(rNewModel, bMasterPage), +SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) +: FmFormPage(rNewModel, bMasterPage), pGridLst( nullptr ), pDoc(&rNewModel.GetDoc()) { } -SwDPage::SwDPage(const SwDPage& rSrcPage) : - FmFormPage( rSrcPage ), - pDoc( nullptr ) -{ - if ( rSrcPage.pGridLst ) - { - pGridLst.reset( new SdrPageGridFrameList ); - for ( sal_uInt16 i = 0; i != rSrcPage.pGridLst->GetCount(); ++i ) - pGridLst->Insert( ( *rSrcPage.pGridLst )[ i ] ); - } -} - SwDPage::~SwDPage() { } -void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel) +void SwDPage::lateInit(const SwDPage& rSrcPage) { - FmFormPage::lateInit( rPage, pNewModel ); + FmFormPage::lateInit( rSrcPage ); - SwDrawModel* pSwDrawModel = pNewModel; - if (!pSwDrawModel) + if ( rSrcPage.pGridLst ) { - pSwDrawModel = &dynamic_cast<SwDrawModel&>(*GetModel()); - assert( pSwDrawModel ); + pGridLst.reset( new SdrPageGridFrameList ); + for ( sal_uInt16 i = 0; i != rSrcPage.pGridLst->GetCount(); ++i ) + pGridLst->Insert( ( *rSrcPage.pGridLst )[ i ] ); } - pDoc = &pSwDrawModel->GetDoc(); -} - -SwDPage* SwDPage::Clone() const -{ - return Clone( nullptr ); } SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const { - SwDPage* const pNewPage = new SwDPage( *this ); - SwDrawModel* pSwDrawModel = nullptr; - if ( pNewModel ) - { - pSwDrawModel = &dynamic_cast<SwDrawModel&>(*pNewModel); - assert( pSwDrawModel ); - } - pNewPage->lateInit( *this, pSwDrawModel ); - return pNewPage; + SwDrawModel& rSwDrawModel(static_cast< SwDrawModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel)); + SwDPage* pClonedSwDPage( + new SwDPage( + rSwDrawModel, + IsMasterPage())); + pClonedSwDPage->lateInit(*this); + return pClonedSwDPage; } SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum ) @@ -126,7 +106,7 @@ void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrame *pPg ) const SdrPageGridFrameList* SwDPage::GetGridFrameList( const SdrPageView* pPV, const tools::Rectangle *pRect ) const { - SwViewShell* pSh = static_cast< SwDrawModel* >(GetModel())->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); + SwViewShell* pSh = static_cast< SwDrawModel& >(getSdrModelFromSdrPage()).GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); if(pSh) { for(SwViewShell& rShell : pSh->GetRingContainer()) |