diff options
Diffstat (limited to 'sd/source/ui/sidebar/DocumentHelper.cxx')
-rw-r--r-- | sd/source/ui/sidebar/DocumentHelper.cxx | 96 |
1 files changed, 42 insertions, 54 deletions
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx index dc76d90a4777..b9336124f9e1 100644 --- a/sd/source/ui/sidebar/DocumentHelper.cxx +++ b/sd/source/ui/sidebar/DocumentHelper.cxx @@ -53,14 +53,11 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument ( break; // Check the presence of the source document. - SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>( - pMasterPage->GetModel()); - if (pSourceDocument == nullptr) - break; + SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage())); // When the given master page already belongs to the target document // then there is nothing more to do. - if (pSourceDocument == &rTargetDocument) + if (&rSourceDocument == &rTargetDocument) { pNewMasterPage = pMasterPage; break; @@ -70,7 +67,7 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument ( // present. This is not the case when we are called during the // creation of the slide master page because then the notes master // page is not there. - sal_uInt16 nSourceMasterPageCount = pSourceDocument->GetMasterPageCount(); + sal_uInt16 nSourceMasterPageCount = rSourceDocument.GetMasterPageCount(); if (nSourceMasterPageCount%2 == 0) // There should be 1 handout page + n slide masters + n notes // masters = 2*n+1. An even value indicates that a new slide @@ -81,11 +78,11 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument ( break; // Get the slide master page. if (pMasterPage != static_cast<SdPage*>( - pSourceDocument->GetMasterPage(nIndex))) + rSourceDocument.GetMasterPage(nIndex))) break; // Get the notes master page. SdPage* pNotesMasterPage = static_cast<SdPage*>( - pSourceDocument->GetMasterPage(nIndex+1)); + rSourceDocument.GetMasterPage(nIndex+1)); if (pNotesMasterPage == nullptr) break; @@ -161,7 +158,7 @@ SdPage* DocumentHelper::GetSlideForMasterPage (SdPage const * pMasterPage) SdDrawDocument* pDocument = nullptr; if (pMasterPage != nullptr) - pDocument = dynamic_cast<SdDrawDocument*>(pMasterPage->GetModel()); + pDocument = dynamic_cast< SdDrawDocument* >(&pMasterPage->getSdrModelFromSdrPage()); // Iterate over all pages and check if it references the given master // page. @@ -215,10 +212,8 @@ SdPage* DocumentHelper::AddMasterPage ( pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone()); // Copy the necessary styles. - SdDrawDocument* pSourceDocument - = static_cast<SdDrawDocument*>(pMasterPage->GetModel()); - if (pSourceDocument != nullptr) - ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage); + SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage())); + ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage); // Copy the precious flag. pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious()); @@ -310,7 +305,7 @@ void DocumentHelper::AssignMasterPageToPageList ( ::std::vector<SdPage*> aCleanedList; for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage) { - OSL_ASSERT(*iPage!=nullptr && (*iPage)->GetModel() == &rTargetDocument); + OSL_ASSERT(*iPage!=nullptr && &(*iPage)->getSdrModelFromSdrPage() == &rTargetDocument); if (*iPage != nullptr && (*iPage)->GetLayoutName() != sFullLayoutName) { aCleanedList.push_back(*iPage); @@ -358,28 +353,24 @@ SdPage* DocumentHelper::AddMasterPage ( pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious()); // Copy the necessary styles. - SdDrawDocument* pSourceDocument - = static_cast<SdDrawDocument*>(pMasterPage->GetModel()); - if (pSourceDocument != nullptr) - { - ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage); - - // Now that the styles are available we can insert the cloned - // master page. - rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex); - - // Adapt the size of the new master page to that of the pages in - // the document. - Size aNewSize (rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind())->GetSize()); - ::tools::Rectangle aBorders ( - pClonedMasterPage->GetLeftBorder(), - pClonedMasterPage->GetUpperBorder(), - pClonedMasterPage->GetRightBorder(), - pClonedMasterPage->GetLowerBorder()); - pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true); - pClonedMasterPage->SetSize(aNewSize); - pClonedMasterPage->CreateTitleAndLayout(true); - } + SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage())); + ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage); + + // Now that the styles are available we can insert the cloned + // master page. + rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex); + + // Adapt the size of the new master page to that of the pages in + // the document. + Size aNewSize (rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind())->GetSize()); + ::tools::Rectangle aBorders ( + pClonedMasterPage->GetLeftBorder(), + pClonedMasterPage->GetUpperBorder(), + pClonedMasterPage->GetRightBorder(), + pClonedMasterPage->GetLowerBorder()); + pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true); + pClonedMasterPage->SetSize(aNewSize); + pClonedMasterPage->CreateTitleAndLayout(true); } return pClonedMasterPage; @@ -406,25 +397,24 @@ void DocumentHelper::AssignMasterPageToPage ( // Leave early when the parameters are invalid. if (pPage == nullptr || pMasterPage == nullptr) return; - SdDrawDocument* pDocument = dynamic_cast<SdDrawDocument*>(pPage->GetModel()); - if (pDocument == nullptr) - return; + + SdDrawDocument& rDocument(dynamic_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage())); if ( ! pPage->IsMasterPage()) { // 1. Remove the background object (so that, if it exists, does // not override the new master page) and assign the master page to // the regular slide. - pDocument->GetDocSh()->GetUndoManager()->AddUndoAction( + rDocument.GetDocSh()->GetUndoManager()->AddUndoAction( new SdBackgroundObjUndoAction( - *pDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()), + rDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()), true); pPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE)); - pDocument->SetMasterPage ( + rDocument.SetMasterPage ( (pPage->GetPageNum()-1)/2, rsBaseLayoutName, - pDocument, + &rDocument, false, false); } @@ -432,10 +422,10 @@ void DocumentHelper::AssignMasterPageToPage ( { // Find first slide that uses the master page. SdPage* pSlide = nullptr; - sal_uInt16 nPageCount = pDocument->GetSdPageCount(PageKind::Standard); + sal_uInt16 nPageCount = rDocument.GetSdPageCount(PageKind::Standard); for (sal_uInt16 nPage=0; nPage<nPageCount&&pSlide==nullptr; nPage++) { - SdrPage* pCandidate = pDocument->GetSdPage(nPage,PageKind::Standard); + SdrPage* pCandidate = rDocument.GetSdPage(nPage,PageKind::Standard); if (pCandidate != nullptr && pCandidate->TRG_HasMasterPage() && &(pCandidate->TRG_GetMasterPage()) == pPage) @@ -448,10 +438,10 @@ void DocumentHelper::AssignMasterPageToPage ( { // 2. Assign the given master pages to the first slide that was // found above that uses the master page. - pDocument->SetMasterPage ( + rDocument.SetMasterPage ( (pSlide->GetPageNum()-1)/2, rsBaseLayoutName, - pDocument, + &rDocument, false, false); } @@ -459,7 +449,7 @@ void DocumentHelper::AssignMasterPageToPage ( { // 3. Replace the master page A by a copy of the given master // page B. - pDocument->RemoveUnnecessaryMasterPages ( + rDocument.RemoveUnnecessaryMasterPages ( pPage); } } @@ -479,11 +469,9 @@ SdPage* DocumentHelper::ProvideMasterPage ( OSL_ASSERT(pMasterPage != nullptr); return nullptr; } - SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>(pMasterPage->GetModel()); - if (pSourceDocument == nullptr) - return nullptr; + SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage())); SdPage* pNotesMasterPage = static_cast<SdPage*>( - pSourceDocument->GetMasterPage(pMasterPage->GetPageNum()+1)); + rSourceDocument.GetMasterPage(pMasterPage->GetPageNum()+1)); if (pNotesMasterPage == nullptr) { // The model is not in a valid state. Maybe a new master page @@ -521,7 +509,7 @@ SdPage* DocumentHelper::ProvideMasterPage ( } // Clone the master page. - if (pMasterPage->GetModel() != &rTargetDocument) + if (&pMasterPage->getSdrModelFromSdrPage() != &rTargetDocument) { pMasterPageInDocument = AddMasterPage (rTargetDocument, pMasterPage, nInsertionIndex); if( rTargetDocument.IsUndoEnabled() ) @@ -532,7 +520,7 @@ SdPage* DocumentHelper::ProvideMasterPage ( pMasterPageInDocument = pMasterPage; // Clone the notes master. - if (pNotesMasterPage->GetModel() != &rTargetDocument) + if (&pNotesMasterPage->getSdrModelFromSdrPage() != &rTargetDocument) { SdPage* pClonedNotesMasterPage = AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1); |