32#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
33#include <com/sun/star/drawing/XDrawPages.hpp>
49 SdPage* pNewMasterPage =
nullptr;
53 if (pMasterPage ==
nullptr)
61 if (&rSourceDocument == &rTargetDocument)
63 pNewMasterPage = pMasterPage;
72 if (nSourceMasterPageCount%2 == 0)
78 if (nSourceMasterPageCount <=
nIndex+1)
81 if (pMasterPage !=
static_cast<SdPage*
>(
87 if (pNotesMasterPage ==
nullptr)
92 bool bPageExists (
false);
94 for (sal_uInt16 nMaster=0; nMaster<nMasterPageCount; nMaster++)
100 pNewMasterPage = pCandidate;
108 uno::Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
110 if ( ! xSlideSupplier.is())
112 uno::Reference<drawing::XDrawPages> xSlides =
113 xSlideSupplier->getDrawPages();
116 xSlides->insertNewByIndex (xSlides->getCount());
122 if (pSlide ==
nullptr)
128 pNewMasterPage =
AddMasterPage(rTargetDocument, pMasterPage);
129 if (pNewMasterPage==
nullptr)
131 SdPage* pNewNotesMasterPage
133 if (pNewNotesMasterPage==
nullptr)
152 return pNewMasterPage;
157 SdPage* pCandidate =
nullptr;
160 if (pMasterPage !=
nullptr)
176 if (pCandidate !=
nullptr)
195 pCandidate =
nullptr;
203 SdPage const * pMasterPage)
207 if (pMasterPage!=
nullptr)
212 pClonedMasterPage =
static_cast<SdPage*
>(pMasterPage->
CloneSdrPage(rTargetDocument).get());
216 ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage.get());
219 pClonedMasterPage->SetPrecious(pMasterPage->
IsPrecious());
225 catch(
const uno::Exception&)
228 pClonedMasterPage =
nullptr;
230 catch(const ::std::exception& e)
232 pClonedMasterPage =
nullptr;
233 SAL_WARN(
"sd",
"caught general exception " << e.what());
237 pClonedMasterPage =
nullptr;
238 SAL_WARN(
"sd",
"caught general exception");
242 return pClonedMasterPage.get();
254 sLayoutName = sLayoutName.copy(0,
nIndex);
264 *pSourceStyleSheetPool,
268 if( !aCreatedStyles.empty() )
271 if (pUndoManager !=
nullptr)
274 std::make_unique<SdMoveStyleSheetsUndoAction>(
285 const std::shared_ptr<std::vector<SdPage*> >& rpPageList)
287 if (pMasterPage ==
nullptr || !pMasterPage->
IsMasterPage())
293 OUString sBaseLayoutName (sFullLayoutName);
296 sBaseLayoutName = sBaseLayoutName.copy(0,
nIndex);
298 if (rpPageList->empty())
303 ::std::vector<SdPage*> aCleanedList;
304 for (
const auto& rpPage : *rpPageList)
306 OSL_ASSERT(rpPage!=
nullptr && &rpPage->getSdrModelFromSdrPage() == &rTargetDocument);
307 if (rpPage !=
nullptr && rpPage->GetLayoutName() != sFullLayoutName)
309 aCleanedList.push_back(rpPage);
312 if (aCleanedList.empty() )
317 nViewShellId = pViewShell->GetViewShellBase().GetViewShellId();
323 if (pMasterPageInDocument ==
nullptr)
327 for (
const auto& rpPage : aCleanedList)
330 pMasterPageInDocument,
341 SdPage const * pMasterPage,
342 sal_uInt16 nInsertionIndex)
346 if (pMasterPage!=
nullptr)
349 pClonedMasterPage =
static_cast<SdPage*
>(pMasterPage->
CloneSdrPage(rTargetDocument).get());
352 pClonedMasterPage->SetPrecious(pMasterPage->
IsPrecious());
356 ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage.get());
360 rTargetDocument.
InsertMasterPage (pClonedMasterPage.get(), nInsertionIndex);
366 pClonedMasterPage->GetLeftBorder(),
367 pClonedMasterPage->GetUpperBorder(),
368 pClonedMasterPage->GetRightBorder(),
369 pClonedMasterPage->GetLowerBorder());
370 pClonedMasterPage->ScaleObjects(aNewSize, aBorders,
true);
371 pClonedMasterPage->SetSize(aNewSize);
372 pClonedMasterPage->CreateTitleAndLayout(
true);
375 return pClonedMasterPage.get();
392 SdPage const * pMasterPage,
393 std::u16string_view rsBaseLayoutName,
397 if (pPage ==
nullptr || pMasterPage ==
nullptr)
407 rDocument.
GetDocSh()->GetUndoManager()->AddUndoAction(
408 std::make_unique<SdBackgroundObjUndoAction>(
425 for (sal_uInt16 nPage=0; nPage<nPageCount&&pSlide==
nullptr; nPage++)
428 if (pCandidate !=
nullptr
432 pSlide =
static_cast<SdPage*
>(pCandidate);
436 if (pSlide !=
nullptr)
460 const std::shared_ptr<std::vector<SdPage*> >& rpPageList)
465 if (pMasterPage ==
nullptr)
468 OSL_ASSERT(pMasterPage !=
nullptr);
474 if (pNotesMasterPage ==
nullptr)
482 SdPage* pMasterPageInDocument =
nullptr;
485 const OUString sMasterPageLayoutName (pMasterPage->
GetLayoutName());
489 if (pCandidate && sMasterPageLayoutName == pCandidate->
GetLayoutName())
505 if (rpPageList->front()->IsMasterPage())
507 nInsertionIndex = rpPageList->back()->GetPageNum();
513 pMasterPageInDocument =
AddMasterPage (rTargetDocument, pMasterPage, nInsertionIndex);
519 pMasterPageInDocument = pMasterPage;
524 SdPage* pClonedNotesMasterPage
525 =
AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1);
531 return pMasterPageInDocument;
sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const
virtual SAL_DLLPRIVATE void InsertMasterPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF) override
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
void SetMasterPage(sal_uInt16 nSdPageNum, std::u16string_view rLayoutName, SdDrawDocument *pSourceDoc, bool bMaster, bool bCheckMasters)
SAL_DLLPRIVATE void RemoveUnnecessaryMasterPages(SdPage *pMaster=nullptr, bool bOnlyDuplicatePages=false, bool bUndo=true)
virtual SAL_DLLPRIVATE void SetChanged(bool bFlag=true) override
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
PageKind GetPageKind() const
bool IsPrecious() const
The "precious" flag is used for master pages to prevent some unused master pages from being deleted a...
void SetAutoLayout(AutoLayout eLayout, bool bInit=false, bool bCreate=false)
virtual OUString GetLayoutName() const override
const OUString & GetName() const
virtual rtl::Reference< SdrPage > CloneSdrPage(SdrModel &rTargetModel) const override
void CopyLayoutSheets(std::u16string_view rLayoutName, SdStyleSheetPool &rSourcePool, StyleSheetCopyResultVector &rCreatedSheets)
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
sal_uInt16 GetMasterPageCount() const
SfxStyleSheetBasePool * GetStyleSheetPool() const
SdrUndoFactory & GetSdrUndoFactory() const
css::uno::Reference< css::uno::XInterface > const & getUnoModel()
bool IsUndoEnabled() const
const SfxItemSet & GetItemSet() const
void PutItem(const SfxPoolItem &rItem)
SdrPage & TRG_GetMasterPage() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
bool TRG_HasMasterPage() const
SdrPageProperties & getSdrPageProperties()
SdrModel & getSdrModelFromSdrPage() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoNewPage(SdrPage &rPage)
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
Base class of the stacked shell hierarchy.
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral SD_LT_SEPARATOR
#define SAL_WARN(area, stream)
OUString SdResId(TranslateId aId)
std::vector< StyleSheetCopyResult > StyleSheetCopyResultVector