summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-03-05 10:47:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-03-07 13:24:51 +0100
commit1d2773807f6d2deb1181ef4b14fbdd49ca1d5c14 (patch)
tree788ef3ef220549c9785bcf1f5b35becc176300d4 /sd
parente4e80ed313882f9ea1b309054e5aa3e839586516 (diff)
ref-count SdrPage
which simplifies ownership handling, particularly with regard to undo/redo Change-Id: Ie8f300ebfdae6db3c06f78a87e35a07497d6b825 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111991 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/drawdoc.hxx8
-rw-r--r--sd/inc/sdpage.hxx2
-rw-r--r--sd/inc/undo/undoobjects.hxx9
-rw-r--r--sd/qa/unit/uimpress.cxx9
-rw-r--r--sd/source/core/drawdoc.cxx4
-rw-r--r--sd/source/core/drawdoc2.cxx60
-rw-r--r--sd/source/core/drawdoc3.cxx40
-rw-r--r--sd/source/core/sdpage2.cxx4
-rw-r--r--sd/source/core/stlfamily.cxx16
-rw-r--r--sd/source/core/undo/undoobjects.cxx34
-rw-r--r--sd/source/filter/ppt/pptin.cxx51
-rw-r--r--sd/source/ui/dlg/animobjs.cxx4
-rw-r--r--sd/source/ui/func/fuexpand.cxx8
-rw-r--r--sd/source/ui/func/fusumry.cxx8
-rw-r--r--sd/source/ui/inc/DrawController.hxx4
-rw-r--r--sd/source/ui/sidebar/DocumentHelper.cxx20
-rw-r--r--sd/source/ui/unoidl/DrawController.cxx11
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx34
-rw-r--r--sd/source/ui/view/outlview.cxx10
-rw-r--r--sd/source/ui/view/sdview3.cxx4
20 files changed, 163 insertions, 177 deletions
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index ba88b47b6005..e51886931fd7 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -224,8 +224,8 @@ public:
SAL_DLLPRIVATE SdDrawDocument* AllocSdDrawDocument() const;
SAL_DLLPRIVATE virtual SdrModel* AllocModel() const override; //forwards to AllocSdDrawDocument
- SAL_DLLPRIVATE SdPage* AllocSdPage(bool bMasterPage);
- SAL_DLLPRIVATE virtual SdrPage* AllocPage(bool bMasterPage) override; //forwards to AllocSdPage
+ SAL_DLLPRIVATE rtl::Reference<SdPage> AllocSdPage(bool bMasterPage);
+ SAL_DLLPRIVATE virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override; //forwards to AllocSdPage
SAL_DLLPRIVATE virtual bool IsReadOnly() const override;
SAL_DLLPRIVATE virtual void SetChanged(bool bFlag = true) override;
@@ -262,10 +262,10 @@ public:
SAL_DLLPRIVATE void MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos) override;
SAL_DLLPRIVATE void InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF) override;
SAL_DLLPRIVATE void DeletePage(sal_uInt16 nPgNum) override;
- SAL_DLLPRIVATE SdrPage* RemovePage(sal_uInt16 nPgNum) override;
+ SAL_DLLPRIVATE rtl::Reference<SdrPage> RemovePage(sal_uInt16 nPgNum) override;
SAL_DLLPRIVATE virtual void InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF) override;
- SAL_DLLPRIVATE virtual SdrPage* RemoveMasterPage(sal_uInt16 nPgNum) override;
+ SAL_DLLPRIVATE virtual rtl::Reference<SdrPage> RemoveMasterPage(sal_uInt16 nPgNum) override;
SAL_DLLPRIVATE void RemoveUnnecessaryMasterPages( SdPage* pMaster=nullptr, bool bOnlyDuplicatePages=false, bool bUndo=true );
void SetMasterPage(sal_uInt16 nSdPageNum, std::u16string_view rLayoutName,
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index cca449bcce8d..d1662ee43308 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -154,7 +154,7 @@ public:
SdPage(SdDrawDocument& rNewDoc, bool bMasterPage);
virtual ~SdPage() override;
- virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const override;
virtual void SetSize(const Size& aSize) override;
virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override;
diff --git a/sd/inc/undo/undoobjects.hxx b/sd/inc/undo/undoobjects.hxx
index 5670002345f2..b7eae9b85d66 100644
--- a/sd/inc/undo/undoobjects.hxx
+++ b/sd/inc/undo/undoobjects.hxx
@@ -24,6 +24,7 @@
#include <svx/svdundo.hxx>
#include <pres.hxx>
#include <tools/weakbase.hxx>
+#include <unotools/weakref.hxx>
class SdrObjUserCall;
class SdPage;
@@ -125,7 +126,7 @@ public:
private:
PresObjKind meOldKind;
PresObjKind meNewKind;
- ::tools::WeakReference<SdPage> mxPage;
+ ::unotools::WeakReference<SdPage> mxPage;
::tools::WeakReference<SdrObject> mxSdrObject;
};
@@ -141,7 +142,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdPage> mxPage;
+ ::unotools::WeakReference<SdPage> mxPage;
};
class UndoGeoObject final : public SdrUndoGeoObj
@@ -153,7 +154,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdPage> mxPage;
+ ::unotools::WeakReference<SdPage> mxPage;
::tools::WeakReference<SdrObject> mxSdrObject;
};
@@ -166,7 +167,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdPage> mxPage;
+ ::unotools::WeakReference<SdPage> mxPage;
::tools::WeakReference<SdrObject> mxSdrObject;
};
diff --git a/sd/qa/unit/uimpress.cxx b/sd/qa/unit/uimpress.cxx
index 0732f93be8ae..bd6bb16a75b5 100644
--- a/sd/qa/unit/uimpress.cxx
+++ b/sd/qa/unit/uimpress.cxx
@@ -17,6 +17,7 @@
#include <comphelper/processfactory.hxx>
#include <vcl/svapp.hxx>
+#include <svx/svdpage.hxx>
#include <sddll.hxx>
#include <drawdoc.hxx>
@@ -77,16 +78,16 @@ void Test::tearDown()
void Test::testAddPage()
{
- SdrPage* pPage = m_pDoc->AllocPage(false);
- m_pDoc->InsertPage(pPage);
+ rtl::Reference<SdrPage> pPage = m_pDoc->AllocPage(false);
+ m_pDoc->InsertPage(pPage.get());
CPPUNIT_ASSERT_EQUAL_MESSAGE("added one page to model",
static_cast<sal_uInt16>(1), m_pDoc->GetPageCount());
m_pDoc->DeletePage(0);
CPPUNIT_ASSERT_EQUAL_MESSAGE("removed one page to model",
static_cast<sal_uInt16>(0), m_pDoc->GetPageCount());
- SdrPage* pMasterPage = m_pDoc->AllocPage(true);
- m_pDoc->InsertMasterPage(pMasterPage);
+ rtl::Reference<SdrPage> pMasterPage = m_pDoc->AllocPage(true);
+ m_pDoc->InsertMasterPage(pMasterPage.get());
CPPUNIT_ASSERT_EQUAL_MESSAGE("added one master page to model",
static_cast<sal_uInt16>(1), m_pDoc->GetMasterPageCount());
m_pDoc->DeleteMasterPage(0);
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 69f746150d64..c257fa909ae2 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -639,7 +639,7 @@ SdDrawDocument* SdDrawDocument::AllocSdDrawDocument() const
return pNewModel;
}
-SdPage* SdDrawDocument::AllocSdPage(bool bMasterPage)
+rtl::Reference<SdPage> SdDrawDocument::AllocSdPage(bool bMasterPage)
{
return new SdPage(*this, bMasterPage);
}
@@ -647,7 +647,7 @@ SdPage* SdDrawDocument::AllocSdPage(bool bMasterPage)
// This method creates a new page (SdPage) and returns a pointer to said page.
// The drawing engine uses this method to create pages (whose types it does
// not know, as they are _derivatives_ of SdrPage) when loading.
-SdrPage* SdDrawDocument::AllocPage(bool bMasterPage)
+rtl::Reference<SdrPage> SdDrawDocument::AllocPage(bool bMasterPage)
{
return AllocSdPage(bMasterPage);
}
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index f9af8c83b2ba..3c3d4988d236 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -406,21 +406,21 @@ void SdDrawDocument::DeletePage(sal_uInt16 nPgNum)
}
// Remove page
-SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
+rtl::Reference<SdrPage> SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
{
- SdrPage* pPage = FmFormModel::RemovePage(nPgNum);
+ rtl::Reference<SdrPage> pPage = FmFormModel::RemovePage(nPgNum);
bool bLast = ((nPgNum+1)/2 == (GetPageCount()+1)/2);
- auto pSdPage = static_cast<SdPage*>(pPage);
+ auto pSdPage = static_cast<SdPage*>(pPage.get());
pSdPage->DisconnectLink();
ReplacePageInCustomShows( pSdPage, nullptr );
UpdatePageObjectsInNotes(nPgNum);
if (!bLast)
- UpdatePageRelativeURLs(static_cast<SdPage*>(pPage), nPgNum, -1);
+ UpdatePageRelativeURLs(pSdPage, nPgNum, -1);
- if (comphelper::LibreOfficeKit::isActive() && static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard)
+ if (comphelper::LibreOfficeKit::isActive() && pSdPage->GetPageKind() == PageKind::Standard)
{
SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
@@ -443,7 +443,7 @@ void SdDrawDocument::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos )
}
}
-SdrPage* SdDrawDocument::RemoveMasterPage(sal_uInt16 nPgNum)
+rtl::Reference<SdrPage> SdDrawDocument::RemoveMasterPage(sal_uInt16 nPgNum)
{
SdPage* pPage = static_cast<SdPage*>(GetMasterPage(nPgNum ));
if( pPage && pPage->IsMasterPage() && (pPage->GetPageKind() == PageKind::Standard) )
@@ -502,7 +502,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* =
Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
// Insert handout page
- SdPage* pHandoutPage = AllocSdPage(false);
+ rtl::Reference<SdPage> pHandoutPage = AllocSdPage(false);
SdPage* pRefPage = nullptr;
@@ -522,23 +522,23 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* =
pHandoutPage->SetPageKind(PageKind::Handout);
pHandoutPage->SetName( SdResId(STR_HANDOUT) );
- InsertPage(pHandoutPage, 0);
+ InsertPage(pHandoutPage.get(), 0);
// Insert master page and register this with the handout page
- SdPage* pHandoutMPage = AllocSdPage(true);
+ rtl::Reference<SdPage> pHandoutMPage = AllocSdPage(true);
pHandoutMPage->SetSize( pHandoutPage->GetSize() );
pHandoutMPage->SetPageKind(PageKind::Handout);
pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(),
pHandoutPage->GetUpperBorder(),
pHandoutPage->GetRightBorder(),
pHandoutPage->GetLowerBorder() );
- InsertMasterPage(pHandoutMPage, 0);
+ InsertMasterPage(pHandoutMPage.get(), 0);
pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
// Insert page
// If nPageCount==1 is, the model for the clipboard was created, thus a
// default page must already exist
- SdPage* pPage;
+ rtl::Reference<SdPage> pPage;
bool bClipboard = false;
if( pRefDocument )
@@ -591,7 +591,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* =
pPage->SetBorder(0, 0, 0, 0);
}
- InsertPage(pPage, 1);
+ InsertPage(pPage.get(), 1);
}
else
{
@@ -600,19 +600,19 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* =
}
// Insert master page, then register this with the page
- SdPage* pMPage = AllocSdPage(true);
+ rtl::Reference<SdPage> pMPage = AllocSdPage(true);
pMPage->SetSize( pPage->GetSize() );
pMPage->SetBorder( pPage->GetLeftBorder(),
pPage->GetUpperBorder(),
pPage->GetRightBorder(),
pPage->GetLowerBorder() );
- InsertMasterPage(pMPage, 1);
+ InsertMasterPage(pMPage.get(), 1);
pPage->TRG_SetMasterPage( *pMPage );
if( bClipboard )
pMPage->SetLayoutName( pPage->GetLayoutName() );
// Insert notes page
- SdPage* pNotesPage = AllocSdPage(false);
+ rtl::Reference<SdPage> pNotesPage = AllocSdPage(false);
if( pRefDocument )
pRefPage = pRefDocument->GetSdPage( 0, PageKind::Notes );
@@ -637,19 +637,19 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* =
pNotesPage->SetBorder(0, 0, 0, 0);
}
pNotesPage->SetPageKind(PageKind::Notes);
- InsertPage(pNotesPage, 2);
+ InsertPage(pNotesPage.get(), 2);
if( bClipboard )
pNotesPage->SetLayoutName( pPage->GetLayoutName() );
// Insert master page, then register this with the notes page
- SdPage* pNotesMPage = AllocSdPage(true);
+ rtl::Reference<SdPage> pNotesMPage = AllocSdPage(true);
pNotesMPage->SetSize( pNotesPage->GetSize() );
pNotesMPage->SetPageKind(PageKind::Notes);
pNotesMPage->SetBorder( pNotesPage->GetLeftBorder(),
pNotesPage->GetUpperBorder(),
pNotesPage->GetRightBorder(),
pNotesPage->GetLowerBorder() );
- InsertMasterPage(pNotesMPage, 2);
+ InsertMasterPage(pNotesMPage.get(), 2);
pNotesPage->TRG_SetMasterPage( *pNotesMPage );
if( bClipboard )
pNotesMPage->SetLayoutName( pPage->GetLayoutName() );
@@ -1089,7 +1089,7 @@ void SdDrawDocument::CheckMasterPages()
if( nFound == nMaxPages )
pRefNotesPage = nullptr;
- SdPage* pNewNotesPage = AllocSdPage(true);
+ rtl::Reference<SdPage> pNewNotesPage = AllocSdPage(true);
pNewNotesPage->SetPageKind(PageKind::Notes);
if( pRefNotesPage )
{
@@ -1099,7 +1099,7 @@ void SdDrawDocument::CheckMasterPages()
pRefNotesPage->GetRightBorder(),
pRefNotesPage->GetLowerBorder() );
}
- InsertMasterPage(pNewNotesPage, nPage );
+ InsertMasterPage(pNewNotesPage.get(), nPage );
pNewNotesPage->SetLayoutName( pPage->GetLayoutName() );
pNewNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true );
nMaxPages++;
@@ -1138,8 +1138,8 @@ sal_uInt16 SdDrawDocument::CreatePage (
{
SdPage* pPreviousStandardPage;
SdPage* pPreviousNotesPage;
- SdPage* pStandardPage;
- SdPage* pNotesPage;
+ rtl::Reference<SdPage> pStandardPage;
+ rtl::Reference<SdPage> pNotesPage;
// From the given page determine the standard page and notes page of which
// to take the layout and the position where to insert the new pages.
@@ -1207,8 +1207,8 @@ sal_uInt16 SdDrawDocument::CreatePage (
sNotesPageName,
bIsPageBack,
bIsPageObj,
- pStandardPage,
- pNotesPage,
+ pStandardPage.get(),
+ pNotesPage.get(),
nInsertPosition);
}
@@ -1244,8 +1244,8 @@ sal_uInt16 SdDrawDocument::DuplicatePage (
{
SdPage* pPreviousStandardPage;
SdPage* pPreviousNotesPage;
- SdPage* pStandardPage;
- SdPage* pNotesPage;
+ rtl::Reference<SdPage> pStandardPage;
+ rtl::Reference<SdPage> pNotesPage;
// From the given page determine the standard page and the notes page
// of which to make copies.
@@ -1263,8 +1263,8 @@ sal_uInt16 SdDrawDocument::DuplicatePage (
}
// Create duplicates of a standard page and the associated notes page
- pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*this) );
- pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*this) );
+ pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*this).get() );
+ pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*this).get() );
return InsertPageSet (
pActualPage,
@@ -1273,8 +1273,8 @@ sal_uInt16 SdDrawDocument::DuplicatePage (
sNotesPageName,
bIsPageBack,
bIsPageObj,
- pStandardPage,
- pNotesPage,
+ pStandardPage.get(),
+ pNotesPage.get(),
nInsertPosition);
}
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index e48117625dfe..fe99838bd31c 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -721,9 +721,6 @@ bool SdDrawDocument::InsertBookmarkAsPage(
AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
RemovePage(nDestPageNum);
-
- if( !bUndo )
- delete pStandardPage;
}
SdPage* pNotesPage = nullptr;
@@ -747,9 +744,6 @@ bool SdDrawDocument::InsertBookmarkAsPage(
AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
RemovePage(nDestPageNum);
-
- if( !bUndo )
- delete pNotesPage;
}
nReplacedStandardPages++;
@@ -787,8 +781,6 @@ bool SdDrawDocument::InsertBookmarkAsPage(
RemoveMasterPage(nPage);
- if( !bUndo )
- delete pRefPage;
nNewMPageCount--;
break;
}
@@ -1253,17 +1245,11 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, bool bOnl
RemoveMasterPage( pNotesMaster->GetPageNum() );
- if( !bUndo )
- delete pNotesMaster;
-
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster));
RemoveMasterPage( pMaster->GetPageNum() );
- if( !bUndo )
- delete pMaster;
-
if( bUndo )
EndUndo(); // do this here already, so Joe's actions happen _between_ our own
@@ -1394,8 +1380,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
SdPage* pNotes = static_cast<SdPage*>( GetPage(pSelectedPage->GetPageNum()+1) );
SdPage& rOldMaster = static_cast<SdPage&>(pSelectedPage->TRG_GetMasterPage());
SdPage& rOldNotesMaster = static_cast<SdPage&>(pNotes->TRG_GetMasterPage());
- SdPage* pMaster = nullptr;
- SdPage* pNotesMaster = nullptr;
+ rtl::Reference<SdPage> pMaster;
+ rtl::Reference<SdPage> pNotesMaster;
OUString aOldPageLayoutName(pSelectedPage->GetLayoutName());
OUString aOldLayoutName(aOldPageLayoutName);
sal_Int32 nIndex = aOldLayoutName.indexOf( SD_LT_SEPARATOR );
@@ -1465,8 +1451,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
if (pSourceDoc != this)
{
// #i121863# clone masterpages, they are from another model (!)
- std::unique_ptr<SdPage> pNewNotesMaster(dynamic_cast< SdPage* >(pNotesMaster->CloneSdrPage(*this)));
- std::unique_ptr<SdPage> pNewMaster(dynamic_cast< SdPage* >(pMaster->CloneSdrPage(*this)));
+ rtl::Reference<SdPage> pNewNotesMaster(dynamic_cast< SdPage* >(pNotesMaster->CloneSdrPage(*this).get()));
+ rtl::Reference<SdPage> pNewMaster(dynamic_cast< SdPage* >(pMaster->CloneSdrPage(*this).get()));
if(!pNewNotesMaster || !pNewMaster)
{
@@ -1474,8 +1460,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
return;
}
- pNotesMaster = pNewNotesMaster.release();
- pMaster = pNewMaster.release();
+ pNotesMaster = pNewNotesMaster;
+ pMaster = pNewMaster;
// layout name needs to be unique
aTargetNewLayoutName = pMaster->GetLayoutName();
@@ -1648,14 +1634,14 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
if (!bLayoutReloaded)
nInsertPos = 0xFFFF;
- InsertMasterPage(pMaster, nInsertPos);
+ InsertMasterPage(pMaster.get(), nInsertPos);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
nInsertPos++;
if (!bLayoutReloaded)
nInsertPos = 0xFFFF;
- InsertMasterPage(pNotesMaster, nInsertPos);
+ InsertMasterPage(pNotesMaster.get(), nInsertPos);
if( bUndo )
{
AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
@@ -1665,7 +1651,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
}
// Fill list with pages
- std::vector<SdPage*> aPageList;
+ std::vector<rtl::Reference<SdPage>> aPageList;
// #98456, this has to be removed according to CL (KA 07/08/2002)
// #109884# but we need them again to restore the styles of the presentation objects while undo
@@ -1691,7 +1677,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
aPageList.push_back(pNotes);
}
- for (SdPage* pPage : aPageList)
+ for (rtl::Reference<SdPage>& pPage : aPageList)
{
AutoLayout eAutoLayout = pPage->GetAutoLayout();
@@ -1701,7 +1687,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
(this,
pPage->IsMasterPage() ? aLayoutName : aOldLayoutName,
aLayoutName,
- eAutoLayout, eAutoLayout, false, pPage));
+ eAutoLayout, eAutoLayout, false, pPage.get()));
}
pPage->SetPresentationLayout(aLayoutName);
pPage->SetAutoLayout(eAutoLayout);
@@ -1776,7 +1762,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
pSelectedPage->GetLowerBorder() );
pMaster->SetName(aName);
pMaster->SetLayoutName(aPageLayoutName);
- InsertMasterPage(pMaster);
+ InsertMasterPage(pMaster.get());
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
@@ -1792,7 +1778,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
pNotes->GetLowerBorder() );
pNotesMaster->SetName(aName);
pNotesMaster->SetLayoutName(aPageLayoutName);
- InsertMasterPage(pNotesMaster);
+ InsertMasterPage(pNotesMaster.get());
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 6680bdde7fc6..dcb63d5e51ea 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -418,10 +418,10 @@ void SdPage::lateInit(const SdPage& rSrcPage)
|*
\************************************************************************/
-SdrPage* SdPage::CloneSdrPage(SdrModel& rTargetModel) const
+rtl::Reference<SdrPage> SdPage::CloneSdrPage(SdrModel& rTargetModel) const
{
SdDrawDocument& rSdDrawDocument(static_cast< SdDrawDocument& >(rTargetModel));
- SdPage* pClonedSdPage(
+ rtl::Reference<SdPage> pClonedSdPage(
new SdPage(
rSdDrawDocument,
IsMasterPage()));
diff --git a/sd/source/core/stlfamily.cxx b/sd/source/core/stlfamily.cxx
index 164fb7814b41..a396bd1701ba 100644
--- a/sd/source/core/stlfamily.cxx
+++ b/sd/source/core/stlfamily.cxx
@@ -27,7 +27,7 @@
#include <svl/style.hxx>
#include <tools/debug.hxx>
-#include <tools/weakbase.hxx>
+#include <unotools/weakref.hxx>
#include <strings.hrc>
#include <stlfamily.hxx>
@@ -49,7 +49,7 @@ typedef std::map< OUString, rtl::Reference< SdStyleSheet > > PresStyleMap;
struct SdStyleFamilyImpl
{
- tools::WeakReference<SdPage> mxMasterPage;
+ unotools::WeakReference<SdPage> mxMasterPage;
OUString maLayoutName;
PresStyleMap& getStyleSheets();
@@ -61,9 +61,13 @@ private:
PresStyleMap& SdStyleFamilyImpl::getStyleSheets()
{
- if( mxMasterPage.is() && (mxMasterPage->GetLayoutName() != maLayoutName) )
+ auto pMasterPage = mxMasterPage.get();
+ if (!pMasterPage)
+ return maStyleSheets;
+
+ if (pMasterPage->GetLayoutName() != maLayoutName )
{
- maLayoutName = mxMasterPage->GetLayoutName();
+ maLayoutName = pMasterPage->GetLayoutName();
OUString aLayoutName( maLayoutName );
const sal_Int32 nLen = aLayoutName.indexOf(SD_LT_SEPARATOR ) + 4;
@@ -102,7 +106,7 @@ SdStyleFamily::SdStyleFamily( const rtl::Reference< SfxStyleSheetPool >& xPool,
, mxPool( xPool )
, mpImpl( new SdStyleFamilyImpl )
{
- mpImpl->mxMasterPage.reset( const_cast< SdPage* >( pMasterPage ) );
+ mpImpl->mxMasterPage = const_cast< SdPage* >( pMasterPage );
mpImpl->mxPool = xPool;
}
@@ -183,7 +187,7 @@ OUString SAL_CALL SdStyleFamily::getName()
{
if( mnFamily == SfxStyleFamily::Page )
{
- SdPage* pPage = mpImpl->mxMasterPage.get();
+ rtl::Reference<SdPage> pPage = mpImpl->mxMasterPage.get();
if( pPage == nullptr )
throw DisposedException();
diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx
index b00fc68aa8d9..f586dac21f64 100644
--- a/sd/source/core/undo/undoobjects.cxx
+++ b/sd/source/core/undo/undoobjects.cxx
@@ -257,17 +257,18 @@ UndoObjectPresentationKind::UndoObjectPresentationKind(SdrObject& rObject)
, mxPage( static_cast<SdPage*>(rObject.getSdrPageFromSdrObject()) )
, mxSdrObject( &rObject )
{
- DBG_ASSERT( mxPage.is(), "sd::UndoObjectPresentationKind::UndoObjectPresentationKind(), does not work for shapes without a slide!" );
+ DBG_ASSERT( mxPage.get(), "sd::UndoObjectPresentationKind::UndoObjectPresentationKind(), does not work for shapes without a slide!" );
- if( mxPage.is() )
- meOldKind = mxPage->GetPresObjKind( &rObject );
+ if( auto pPage = mxPage.get() )
+ meOldKind = pPage->GetPresObjKind( &rObject );
}
void UndoObjectPresentationKind::Undo()
{
- if( mxPage.is() && mxSdrObject.is() )
+ if( !mxSdrObject.is() )
+ return;
+ if( rtl::Reference<SdPage> pPage = mxPage.get() )
{
- SdPage* pPage = mxPage.get();
meNewKind = pPage->GetPresObjKind( mxSdrObject.get() );
if( meNewKind != PresObjKind::NONE )
pPage->RemovePresObj( mxSdrObject.get() );
@@ -278,9 +279,10 @@ void UndoObjectPresentationKind::Undo()
void UndoObjectPresentationKind::Redo()
{
- if( mxPage.is() && mxSdrObject.is() )
+ if( !mxSdrObject.is() )
+ return;
+ if( rtl::Reference<SdPage> pPage = mxPage.get() )
{
- SdPage* pPage = mxPage.get();
if( meOldKind != PresObjKind::NONE )
pPage->RemovePresObj( mxSdrObject.get() );
if( meNewKind != PresObjKind::NONE )
@@ -300,7 +302,7 @@ void UndoAutoLayoutPosAndSize::Undo()
void UndoAutoLayoutPosAndSize::Redo()
{
- SdPage* pPage = mxPage.get();
+ rtl::Reference<SdPage> pPage = mxPage.get();
if( pPage )
pPage->SetAutoLayout( pPage->GetAutoLayout() );
}
@@ -317,9 +319,9 @@ void UndoGeoObject::Undo()
DBG_ASSERT( mxSdrObject.is(), "sd::UndoGeoObject::Undo(), object already dead!" );
if( mxSdrObject.is() )
{
- if( mxPage.is() )
+ if( auto pPage = mxPage.get() )
{
- ScopeLockGuard aGuard( mxPage->maLockAutoLayoutArrangement );
+ ScopeLockGuard aGuard( pPage->maLockAutoLayoutArrangement );
SdrUndoGeoObj::Undo();
}
else
@@ -334,9 +336,9 @@ void UndoGeoObject::Redo()
DBG_ASSERT( mxSdrObject.is(), "sd::UndoGeoObject::Redo(), object already dead!" );
if( mxSdrObject.is() )
{
- if( mxPage.is() )
+ if( auto pPage = mxPage.get() )
{
- ScopeLockGuard aGuard( mxPage->maLockAutoLayoutArrangement );
+ ScopeLockGuard aGuard( pPage->maLockAutoLayoutArrangement );
SdrUndoGeoObj::Redo();
}
else
@@ -358,9 +360,9 @@ void UndoAttrObject::Undo()
DBG_ASSERT( mxSdrObject.is(), "sd::UndoAttrObject::Undo(), object already dead!" );
if( mxSdrObject.is() )
{
- if( mxPage.is() )
+ if( auto pPage = mxPage.get() )
{
- ScopeLockGuard aGuard( mxPage->maLockAutoLayoutArrangement );
+ ScopeLockGuard aGuard( pPage->maLockAutoLayoutArrangement );
SdrUndoAttrObj::Undo();
}
else
@@ -375,9 +377,9 @@ void UndoAttrObject::Redo()
DBG_ASSERT( mxSdrObject.is(), "sd::UndoAttrObject::Redo(), object already dead!" );
if( mxSdrObject.is() )
{
- if( mxPage.is() )
+ if( auto pPage = mxPage.get() )
{
- ScopeLockGuard aGuard( mxPage->maLockAutoLayoutArrangement );
+ ScopeLockGuard aGuard( pPage->maLockAutoLayoutArrangement );
SdrUndoAttrObj::Redo();
}
else
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 55e0f4bd2962..e4bd9b24bb42 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -595,7 +595,7 @@ bool ImplSdPPTImport::Import()
for ( sal_uInt16 nMasterNum = 0; nMasterNum < nMasterCnt; nMasterNum++ )
{
SetPageNum( nMasterNum, PPT_MASTERPAGE );
- SdPage* pPage = static_cast<SdPage*>(MakeBlankPage( true ));
+ rtl::Reference<SdPage> pPage = static_cast<SdPage*>(MakeBlankPage( true ).get());
if ( pPage )
{
bool bNotesMaster = (*GetPageList( m_eCurrentPageKind ) )[ m_nCurrentPageNum ].bNotesMaster;
@@ -607,7 +607,7 @@ bool ImplSdPPTImport::Import()
ePgKind = PageKind::Handout;
pPage->SetPageKind( ePgKind );
- pSdrModel->InsertMasterPage( static_cast<SdrPage*>(pPage) );
+ pSdrModel->InsertMasterPage( pPage.get() );
if ( bNotesMaster && bStarDrawFiller )
pPage->SetAutoLayout( AUTOLAYOUT_NOTES, true );
if ( nMasterNum )
@@ -754,13 +754,14 @@ bool ImplSdPPTImport::Import()
if ( pPersist->bStarDrawFiller && pPersist->bNotesMaster && ( m_nCurrentPageNum > 2 ) && ( ( m_nCurrentPageNum & 1 ) == 0 ) )
{
pSdrModel->DeleteMasterPage( m_nCurrentPageNum );
- SdrPage* pNotesClone = static_cast<SdPage*>(pSdrModel->GetMasterPage( 2 ))->CloneSdrPage(*pSdrModel);
- pSdrModel->InsertMasterPage( pNotesClone, m_nCurrentPageNum );
+ SdPage* pMasterPage2 = static_cast<SdPage*>(pSdrModel->GetMasterPage( 2 ));
+ rtl::Reference<SdPage> pNotesClone = static_cast<SdPage*>(pMasterPage2->CloneSdrPage(*pSdrModel).get());
+ pSdrModel->InsertMasterPage( pNotesClone.get(), m_nCurrentPageNum );
if ( pNotesClone )
{
OUString aLayoutName( static_cast<SdPage*>(pSdrModel->GetMasterPage( m_nCurrentPageNum - 1 ))->GetLayoutName() );
- static_cast<SdPage*>(pNotesClone)->SetPresentationLayout( aLayoutName, false, false );
- static_cast<SdPage*>(pNotesClone)->SetLayoutName( aLayoutName );
+ pNotesClone->SetPresentationLayout( aLayoutName, false, false );
+ pNotesClone->SetLayoutName( aLayoutName );
}
}
else if ( !pPersist->bStarDrawFiller )
@@ -923,9 +924,9 @@ bool ImplSdPPTImport::Import()
PptPageKind ePageKind = m_eCurrentPageKind;
sal_uInt16 nPageNum = m_nCurrentPageNum;
- SdPage* pHandoutPage = static_cast<SdPage*>(MakeBlankPage( false ));
+ rtl::Reference<SdPage> pHandoutPage = static_cast<SdPage*>(MakeBlankPage( false ).get());
pHandoutPage->SetPageKind( PageKind::Handout );
- pSdrModel->InsertPage( pHandoutPage );
+ pSdrModel->InsertPage( pHandoutPage.get() );
sal_uInt16 nPageCnt = GetPageCount();
if ( nPageCnt )
@@ -934,7 +935,7 @@ bool ImplSdPPTImport::Import()
{
mePresChange = PresChange::SemiAuto;
SetPageNum( nPage );
- SdPage* pPage = static_cast<SdPage*>(MakeBlankPage( false ));
+ rtl::Reference<SdPage> pPage = static_cast<SdPage*>(MakeBlankPage( false ).get());
PptSlidePersistEntry* pMasterPersist = nullptr;
if ( HasMasterPage( nPage ) ) // try to get the LayoutName from the masterpage
{
@@ -946,9 +947,9 @@ bool ImplSdPPTImport::Import()
pPage->SetLayoutName(static_cast<SdPage&>(pPage->TRG_GetMasterPage()).GetLayoutName());
}
pPage->SetPageKind( PageKind::Standard );
- pSdrModel->InsertPage( pPage ); // SJ: #i29625# because of form controls, the
- ImportPage( pPage, pMasterPersist ); // page must be inserted before importing
- SetHeaderFooterPageSettings( pPage, pMasterPersist );
+ pSdrModel->InsertPage( pPage.get() ); // SJ: #i29625# because of form controls, the
+ ImportPage( pPage.get(), pMasterPersist ); // page must be inserted before importing
+ SetHeaderFooterPageSettings( pPage.get(), pMasterPersist );
// CWS preseng01: pPage->SetPageKind( PageKind::Standard );
DffRecordHeader aPageHd;
@@ -1006,12 +1007,12 @@ bool ImplSdPPTImport::Import()
if (!aHd.SeekToEndOfRecord(rStCtrl))
break;
}
- ImportPageEffect( pPage, bNewAnimationsUsed );
+ ImportPageEffect( pPage.get(), bNewAnimationsUsed );
}
// creating the corresponding note page
m_eCurrentPageKind = PPT_NOTEPAGE;
- SdPage* pNotesPage = static_cast<SdPage*>(MakeBlankPage( false ));
+ rtl::Reference<SdPage> pNotesPage = static_cast<SdPage*>(MakeBlankPage( false ).get());
sal_uInt16 nNotesMasterNum = GetMasterPageIndex( nPage ) + 1;
sal_uInt32 nNotesPageId = GetNotesPageId( nPage );
if ( nNotesPageId )
@@ -1032,9 +1033,9 @@ bool ImplSdPPTImport::Import()
}
pNotesPage->SetPageKind( PageKind::Notes );
pNotesPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nNotesMasterNum));
- pSdrModel->InsertPage( pNotesPage ); // SJ: #i29625# because of form controls, the
- ImportPage( pNotesPage, pMasterPersist2 ); // page must be inserted before importing
- SetHeaderFooterPageSettings( pNotesPage, pMasterPersist2 );
+ pSdrModel->InsertPage( pNotesPage.get() ); // SJ: #i29625# because of form controls, the
+ ImportPage( pNotesPage.get(), pMasterPersist2 ); // page must be inserted before importing
+ SetHeaderFooterPageSettings( pNotesPage.get(), pMasterPersist2 );
pNotesPage->SetAutoLayout( AUTOLAYOUT_NOTES );
}
else
@@ -1042,7 +1043,7 @@ bool ImplSdPPTImport::Import()
pNotesPage->SetPageKind( PageKind::Notes );
pNotesPage->TRG_SetMasterPage(*pSdrModel->GetMasterPage(nNotesMasterNum));
pNotesPage->SetAutoLayout( AUTOLAYOUT_NOTES, true );
- pSdrModel->InsertPage( pNotesPage );
+ pSdrModel->InsertPage( pNotesPage.get() );
SdrObject* pPageObj = pNotesPage->GetPresObj( PresObjKind::Page );
if ( pPageObj )
static_cast<SdrPageObj*>(pPageObj)->SetReferencedPage(pSdrModel->GetPage(( nPage << 1 ) + 1));
@@ -1056,8 +1057,8 @@ bool ImplSdPPTImport::Import()
{
// that can happen by document templates
m_eCurrentPageKind = PPT_SLIDEPAGE;
- SdrPage* pPage = MakeBlankPage( false );
- pSdrModel->InsertPage( pPage );
+ rtl::Reference<SdPage> pPage = static_cast<SdPage*>(MakeBlankPage( false ).get());
+ pSdrModel->InsertPage( pPage.get() );
// #i37397#, trying to set the title master for the first page
sal_uInt16 nMaster, nMasterCount = pSdrModel->GetMasterPageCount();
@@ -1078,14 +1079,14 @@ bool ImplSdPPTImport::Import()
}
if ( pFoundMaster )
{
- static_cast<SdPage*>(pPage)->TRG_SetMasterPage( *pFoundMaster );
- static_cast<SdPage*>(pPage)->SetLayoutName( pFoundMaster->GetLayoutName() );
+ pPage->TRG_SetMasterPage( *pFoundMaster );
+ pPage->SetLayoutName( pFoundMaster->GetLayoutName() );
}
- static_cast<SdPage*>(pPage)->SetAutoLayout( AUTOLAYOUT_TITLE, true, true );
+ pPage->SetAutoLayout( AUTOLAYOUT_TITLE, true, true );
m_eCurrentPageKind = PPT_NOTEPAGE;
- SdrPage* pNPage = MakeBlankPage( false );
- pSdrModel->InsertPage( pNPage );
+ rtl::Reference<SdrPage> pNPage = MakeBlankPage( false );
+ pSdrModel->InsertPage( pNPage.get() );
}
SetPageNum( nPageNum, ePageKind );
rStCtrl.Seek( nOldFPos );
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index e900ffb45e88..1ef08386396b 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -158,8 +158,8 @@ AnimationWindow::AnimationWindow(SfxBindings* pInBindings, SfxChildWindow *pCW,
// create new document with page
pMyDoc.reset( new SdDrawDocument(DocumentType::Impress, nullptr) );
- SdPage* pPage = pMyDoc->AllocSdPage(false);
- pMyDoc->InsertPage(pPage);
+ rtl::Reference<SdPage> pPage = pMyDoc->AllocSdPage(false);
+ pMyDoc->InsertPage(pPage.get());
pControllerItem.reset( new AnimationControllerItem( SID_ANIMATOR_STATE, this, pInBindings ) );
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index b95ad8515b67..ebaa0ee5d944 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -133,7 +133,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
if ( nDepth == 0 )
{
// page with title & structuring!
- SdPage* pPage = mpDoc->AllocSdPage(false);
+ rtl::Reference<SdPage> pPage = mpDoc->AllocSdPage(false);
pPage->SetSize(pActualPage->GetSize() );
pPage->SetBorder(pActualPage->GetLeftBorder(),
pActualPage->GetUpperBorder(),
@@ -142,7 +142,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
pPage->SetName(OUString());
// insert page after current page
- mpDoc->InsertPage(pPage, nActualPageNum + nPos);
+ mpDoc->InsertPage(pPage.get(), nActualPageNum + nPos);
nPos++;
if( bUndo )
@@ -155,7 +155,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
// notes-page
- SdPage* pNotesPage = mpDoc->AllocSdPage(false);
+ rtl::Reference<SdPage> pNotesPage = mpDoc->AllocSdPage(false);
pNotesPage->SetSize(pActualNotesPage->GetSize());
pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
pActualNotesPage->GetUpperBorder(),
@@ -165,7 +165,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
pNotesPage->SetName(OUString());
// insert page after current page
- mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos);
+ mpDoc->InsertPage(pNotesPage.get(), nActualPageNum + nPos);
nPos++;
if( bUndo )
diff --git a/sd/source/ui/func/fusumry.cxx b/sd/source/ui/func/fusumry.cxx
index 5984ffa19d44..5e97176ccc18 100644
--- a/sd/source/ui/func/fusumry.cxx
+++ b/sd/source/ui/func/fusumry.cxx
@@ -63,7 +63,7 @@ rtl::Reference<FuPoor> FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window*
void FuSummaryPage::DoExecute( SfxRequest& )
{
std::unique_ptr<SdOutliner> pOutl;
- SdPage* pSummaryPage = nullptr;
+ rtl::Reference<SdPage> pSummaryPage;
sal_uInt16 i = 0;
sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND;
sal_uInt16 nSelectedPages = 0;
@@ -126,7 +126,7 @@ void FuSummaryPage::DoExecute( SfxRequest& )
pActualPage->GetLowerBorder() );
// insert page at the back
- mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
+ mpDoc->InsertPage(pSummaryPage.get(), nCount * 2 + 1);
if( bUndo )
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
@@ -138,7 +138,7 @@ void FuSummaryPage::DoExecute( SfxRequest& )
pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
// notes-page
- SdPage* pNotesPage = mpDoc->AllocSdPage(false);
+ rtl::Reference<SdPage> pNotesPage = mpDoc->AllocSdPage(false);
pNotesPage->SetSize(pActualNotesPage->GetSize());
pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
pActualNotesPage->GetUpperBorder(),
@@ -147,7 +147,7 @@ void FuSummaryPage::DoExecute( SfxRequest& )
pNotesPage->SetPageKind(PageKind::Notes);
// insert page at the back
- mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
+ mpDoc->InsertPage(pNotesPage.get(), nCount * 2 + 2);
if( bUndo )
mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
diff --git a/sd/source/ui/inc/DrawController.hxx b/sd/source/ui/inc/DrawController.hxx
index 71d61908152b..5adf9fa50206 100644
--- a/sd/source/ui/inc/DrawController.hxx
+++ b/sd/source/ui/inc/DrawController.hxx
@@ -30,7 +30,7 @@
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <comphelper/uno3.hxx>
#include <cppuhelper/implbase.hxx>
-#include <tools/weakbase.h>
+#include <unotools/weakref.hxx>
#include <tools/gen.hxx>
#include <memory>
#include <vector>
@@ -289,7 +289,7 @@ private:
ViewShellBase* mpBase;
::tools::Rectangle maLastVisArea;
- ::tools::WeakReference<SdPage> mpCurrentPage;
+ ::unotools::WeakReference<SdPage> mpCurrentPage;
bool mbMasterPageMode;
bool mbLayerMode;
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx
index c3a848712f51..00c0288689f9 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -202,25 +202,25 @@ SdPage* DocumentHelper::AddMasterPage (
SdDrawDocument& rTargetDocument,
SdPage const * pMasterPage)
{
- SdPage* pClonedMasterPage = nullptr;
+ rtl::Reference<SdPage> pClonedMasterPage;
if (pMasterPage!=nullptr)
{
try
{
// Duplicate the master page.
- pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument));
+ pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument).get());
// Copy the necessary styles.
SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
- ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage);
+ ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage.get());
// Copy the precious flag.
pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
// Now that the styles are available we can insert the cloned
// master page.
- rTargetDocument.InsertMasterPage (pClonedMasterPage);
+ rTargetDocument.InsertMasterPage (pClonedMasterPage.get());
}
catch(const uno::Exception&)
{
@@ -239,7 +239,7 @@ SdPage* DocumentHelper::AddMasterPage (
}
}
- return pClonedMasterPage;
+ return pClonedMasterPage.get();
}
void DocumentHelper::ProvideStyles (
@@ -341,23 +341,23 @@ SdPage* DocumentHelper::AddMasterPage (
SdPage const * pMasterPage,
sal_uInt16 nInsertionIndex)
{
- SdPage* pClonedMasterPage = nullptr;
+ rtl::Reference<SdPage> pClonedMasterPage;
if (pMasterPage!=nullptr)
{
// Duplicate the master page.
- pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument));
+ pClonedMasterPage = static_cast<SdPage*>(pMasterPage->CloneSdrPage(rTargetDocument).get());
// Copy the precious flag.
pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
// Copy the necessary styles.
SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
- ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage);
+ ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage.get());
// Now that the styles are available we can insert the cloned
// master page.
- rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex);
+ rTargetDocument.InsertMasterPage (pClonedMasterPage.get(), nInsertionIndex);
// Adapt the size of the new master page to that of the pages in
// the document.
@@ -372,7 +372,7 @@ SdPage* DocumentHelper::AddMasterPage (
pClonedMasterPage->CreateTitleAndLayout(true);
}
- return pClonedMasterPage;
+ return pClonedMasterPage.get();
}
/** In here we have to handle three cases:
diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx
index a82460b7fb7c..4f61f2cf1afa 100644
--- a/sd/source/ui/unoidl/DrawController.cxx
+++ b/sd/source/ui/unoidl/DrawController.cxx
@@ -318,8 +318,9 @@ Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage()
// When there is not yet a sub controller (during initialization) then fall back
// to the current page in mpCurrentPage.
- if ( ! xPage.is() && mpCurrentPage.is())
- xPage.set(mpCurrentPage->getUnoPage(), UNO_QUERY);
+ if ( ! xPage.is() )
+ if (rtl::Reference<SdPage> pPage = mpCurrentPage.get())
+ xPage.set(pPage->getUnoPage(), UNO_QUERY);
return xPage;
}
@@ -403,8 +404,8 @@ void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
{
- SdrPage* pCurrentPage = mpCurrentPage.get();
- if (pNewCurrentPage == pCurrentPage)
+ rtl::Reference<SdrPage> pCurrentPage = mpCurrentPage.get();
+ if (pNewCurrentPage == pCurrentPage.get())
return;
try
@@ -421,7 +422,7 @@ void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
- mpCurrentPage.reset(pNewCurrentPage);
+ mpCurrentPage = pNewCurrentPage;
}
catch (const uno::Exception&)
{
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 6051e07fe8f3..411af888513f 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -453,7 +453,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
- SdPage* pStandardPage = nullptr;
+ rtl::Reference<SdPage> pStandardPage;
if( 0 == nPageCount )
{
@@ -462,7 +462,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
Size aDefSize(21000, 29700); // A4 portrait orientation
pStandardPage->SetSize( aDefSize );
- mpDoc->InsertPage(pStandardPage, 0);
+ mpDoc->InsertPage(pStandardPage.get(), 0);
}
else
{
@@ -487,7 +487,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
* standard page
**************************************************************/
if( bDuplicate )
- pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*mpDoc) );
+ pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*mpDoc).get() );
else
pStandardPage = mpDoc->AllocSdPage(false);
@@ -500,7 +500,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
pStandardPage->SetName(OUString());
// insert page after current page
- mpDoc->InsertPage(pStandardPage, nStandardPageNum);
+ mpDoc->InsertPage(pStandardPage.get(), nStandardPageNum);
if( !bDuplicate )
{
@@ -519,10 +519,10 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
/**************************************************************
* notes page
**************************************************************/
- SdPage* pNotesPage = nullptr;
+ rtl::Reference<SdPage> pNotesPage;
if( bDuplicate )
- pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*mpDoc) );
+ pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*mpDoc).get() );
else
pNotesPage = mpDoc->AllocSdPage(false);
@@ -536,7 +536,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
pNotesPage->SetPageKind(PageKind::Notes);
// insert page after current page
- mpDoc->InsertPage(pNotesPage, nNotesPageNum);
+ mpDoc->InsertPage(pNotesPage.get(), nNotesPageNum);
if( !bDuplicate )
{
@@ -549,7 +549,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
SetModified();
- return pStandardPage;
+ return pStandardPage.get();
}
void SdXImpressDocument::SetModified() throw()
@@ -2962,11 +2962,6 @@ void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPag
{
rDoc.EndUndo();
}
- else
- {
- delete pNotesPage;
- delete pPage;
- }
}
}
}
@@ -3135,14 +3130,14 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIn
SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( sal_uInt16(0), PageKind::Notes);
// create and insert new draw masterpage
- SdPage* pMPage = mpModel->mpDoc->AllocSdPage(true);
+ rtl::Reference<SdPage> pMPage = mpModel->mpDoc->AllocSdPage(true);
pMPage->SetSize( pPage->GetSize() );
pMPage->SetBorder( pPage->GetLeftBorder(),
pPage->GetUpperBorder(),
pPage->GetRightBorder(),
pPage->GetLowerBorder() );
pMPage->SetLayoutName( aLayoutName );
- pDoc->InsertMasterPage(pMPage, static_cast<sal_uInt16>(nInsertPos));
+ pDoc->InsertMasterPage(pMPage.get(), static_cast<sal_uInt16>(nInsertPos));
{
// ensure default MasterPage fill
@@ -3152,7 +3147,7 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIn
xDrawPage.set( pMPage->getUnoPage(), uno::UNO_QUERY );
// create and insert new notes masterpage
- SdPage* pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
+ rtl::Reference<SdPage> pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
pMNotesPage->SetSize( pRefNotesPage->GetSize() );
pMNotesPage->SetPageKind(PageKind::Notes);
pMNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(),
@@ -3160,7 +3155,7 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIn
pRefNotesPage->GetRightBorder(),
pRefNotesPage->GetLowerBorder() );
pMNotesPage->SetLayoutName( aLayoutName );
- pDoc->InsertMasterPage(pMNotesPage, static_cast<sal_uInt16>(nInsertPos) + 1);
+ pDoc->InsertMasterPage(pMNotesPage.get(), static_cast<sal_uInt16>(nInsertPos) + 1);
pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
mpModel->SetModified();
}
@@ -3219,11 +3214,6 @@ void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawP
{
rDoc.EndUndo();
}
- else
- {
- delete pNotesPage;
- delete pPage;
- }
}
// XServiceInfo
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 8abad53cccc6..9c0c16ed9462 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -390,12 +390,12 @@ SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
// this page is exemplary
SdPage* pExample = mrDoc.GetSdPage(static_cast<sal_uInt16>(nExample), PageKind::Standard);
- SdPage* pPage = mrDoc.AllocSdPage(false);
+ rtl::Reference<SdPage> pPage = mrDoc.AllocSdPage(false);
pPage->SetLayoutName(pExample->GetLayoutName());
// insert (page)
- mrDoc.InsertPage(pPage, static_cast<sal_uInt16>(nTarget) * 2 + 1);
+ mrDoc.InsertPage(pPage.get(), static_cast<sal_uInt16>(nTarget) * 2 + 1);
if( isRecordingUndo() )
AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pPage));
@@ -427,14 +427,14 @@ SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
|* now the notes page
\*********************************************************************/
pExample = mrDoc.GetSdPage(static_cast<sal_uInt16>(nExample), PageKind::Notes);
- SdPage* pNotesPage = mrDoc.AllocSdPage(false);
+ rtl::Reference<SdPage> pNotesPage = mrDoc.AllocSdPage(false);
pNotesPage->SetLayoutName(pExample->GetLayoutName());
pNotesPage->SetPageKind(PageKind::Notes);
// insert (notes page)
- mrDoc.InsertPage(pNotesPage, static_cast<sal_uInt16>(nTarget) * 2 + 2);
+ mrDoc.InsertPage(pNotesPage.get(), static_cast<sal_uInt16>(nTarget) * 2 + 2);
if( isRecordingUndo() )
AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
@@ -453,7 +453,7 @@ SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
mrOutliner.UpdateFields();
- return pPage;
+ return pPage.get();
}
/**
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index d334cb7a2254..90a1f599d2fe 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -677,7 +677,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
xShell->DoInitNew();
SdDrawDocument* pModel = xShell->GetDoc();
- pModel->InsertPage(pModel->AllocPage(false));
+ pModel->InsertPage(pModel->AllocPage(false).get());
Reference< XComponent > xComponent = xShell->GetModel();
xStm->Seek( 0 );
@@ -1530,7 +1530,7 @@ bool View::PasteRTFTable( const ::tools::SvRef<SotTempStream>& xStm, SdrPage* pP
std::unique_ptr<SdDrawDocument> pModel(new SdDrawDocument( DocumentType::Impress, mpDocSh ));
pModel->NewOrLoadCompleted(DocCreationMode::New);
pModel->GetItemPool().SetDefaultMetric(MapUnit::Map100thMM);
- pModel->InsertPage(pModel->AllocPage(false));
+ pModel->InsertPage(pModel->AllocPage(false).get());
Reference< XComponent > xComponent( new SdXImpressDocument( pModel.get(), true ) );
pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );