summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdxcgv.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-27 10:27:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-29 13:44:02 +0200
commit8611f6e259b807b4f19c8dc0eab86ca648891ce3 (patch)
treefa2b0e463aafb51df754768f916ca9104969a557 /svx/source/svdraw/svdxcgv.cxx
parent25a997c15d39fb30676a375df8ea4ce1ed2e1acd (diff)
ref-count SdrObject
Which means we can get rid of the majestic hack of ScCaptionPtr Previously, SdrObject was manually managed, and the ownership passed around in very complicated fashion. Notes: (*) SvxShape has a strong reference to SdrObject, where previously it had a weak reference. It is now strong since otherwise the SdrObject will go away very eagerly. (*) SdrObject still has a weak reference to SvxShape (*) In the existing places that an SdrObject is being deleted, we now just clear the reference (*) instead of SwVirtFlyDrawObj removing itself from the page that contains inside it's destructor, make the call site do the removing from the page. (*) Needed to take the SolarMutex in UndoManagerHelper_Impl::impl_clear because this can be called from UNO (e.g. sfx2_complex JUnit test) and the SdrObjects need the SolarMutex when destructing. (*) handle a tricky situation with SwDrawVirtObj in the SwDrawModel destructor because the existing code wants mpDrawObj in SwAnchoredObject to be sometimes owning, sometimes not, which results in a cycle with the new code. Change-Id: I4d79df1660e386388e5d51030653755bca02a163 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138837 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/svdraw/svdxcgv.cxx')
-rw-r--r--svx/source/svdraw/svdxcgv.cxx26
1 files changed, 13 insertions, 13 deletions
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index a9b720f300d8..90723501be91 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -142,7 +142,7 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList*
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(
getSdrModelFromSdrView(),
SdrObjKind::Text,
aTextRect);
@@ -163,7 +163,7 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList*
Size aSiz(pObj->GetLogicRect().GetSize());
MapUnit eMap=mpModel->GetScaleUnit();
Fraction aMap=mpModel->GetScaleFraction();
- ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
+ ImpPasteObject(pObj.get(),*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
return true;
}
@@ -182,7 +182,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(
getSdrModelFromSdrView(),
SdrObjKind::Text,
aTextRect);
@@ -203,7 +203,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
Size aSiz(pObj->GetLogicRect().GetSize());
MapUnit eMap=mpModel->GetScaleUnit();
Fraction aMap=mpModel->GetScaleFraction();
- ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
+ ImpPasteObject(pObj.get(),*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
// b4967543
if(pObj->GetOutlinerParaObject())
@@ -301,7 +301,7 @@ bool SdrExchangeView::Paste(
{
const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
- SdrObject* pNewObj(pSrcOb->CloneSdrObject(*mpModel));
+ rtl::Reference<SdrObject> pNewObj(pSrcOb->CloneSdrObject(*mpModel));
if (pNewObj!=nullptr)
{
@@ -323,7 +323,7 @@ bool SdrExchangeView::Paste(
const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
SdrLayerID nLayer(0);
- if(dynamic_cast<const FmFormObj*>( pNewObj) != nullptr)
+ if(dynamic_cast<const FmFormObj*>( pNewObj.get()) != nullptr)
{
// for FormControls, force to form layer
nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
@@ -341,7 +341,7 @@ bool SdrExchangeView::Paste(
pNewObj->SetLayer(nLayer);
}
- pDstLst->InsertObjectThenMakeNameUnique(pNewObj, aNameSet);
+ pDstLst->InsertObjectThenMakeNameUnique(pNewObj.get(), aNameSet);
if( bUndo )
AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
@@ -349,11 +349,11 @@ bool SdrExchangeView::Paste(
if (bMark) {
// Don't already set Markhandles!
// That is instead being done by ModelHasChanged in MarkView.
- MarkObj(pNewObj,pMarkPV,false,true);
+ MarkObj(pNewObj.get(),pMarkPV,false,true);
}
// #i13033#
- aCloneList.AddPair(pSrcOb, pNewObj);
+ aCloneList.AddPair(pSrcOb, pNewObj.get());
}
else
{
@@ -729,7 +729,7 @@ std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
for(SdrObject* pObj : aSdrObjects)
{
- SdrObject* pNewObj(nullptr);
+ rtl::Reference<SdrObject> pNewObj;
if(nullptr != dynamic_cast< const SdrPageObj* >(pObj))
{
@@ -750,7 +750,7 @@ std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
}
}
- if(nullptr == pNewObj)
+ if(!pNewObj)
{
// not cloned yet
if(pObj->GetObjIdentifier() == SdrObjKind::OLE2 && nullptr == mpModel->GetPersist())
@@ -767,10 +767,10 @@ std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const
if(pNewObj)
{
- pNewPage->InsertObject(pNewObj, SAL_MAX_SIZE);
+ pNewPage->InsertObject(pNewObj.get(), SAL_MAX_SIZE);
// #i13033#
- aCloneList.AddPair(pObj, pNewObj);
+ aCloneList.AddPair(pObj, pNewObj.get());
}
}