summaryrefslogtreecommitdiff
path: root/basctl/source/dlged/dlged.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 /basctl/source/dlged/dlged.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 'basctl/source/dlged/dlged.cxx')
-rw-r--r--basctl/source/dlged/dlged.cxx30
1 files changed, 15 insertions, 15 deletions
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index d0ac5611566c..306555489df5 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -342,8 +342,8 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
pDlgEdForm = new DlgEdForm(*pDlgEdModel, *this);
uno::Reference< awt::XControlModel > xDlgMod( m_xUnoControlDialogModel , uno::UNO_QUERY );
pDlgEdForm->SetUnoControlModel(xDlgMod);
- static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm );
- pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm );
+ static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm.get() );
+ pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm.get() );
AdjustPageSize();
pDlgEdForm->SetRectFromProps();
pDlgEdForm->UpdateTabIndices(); // for backward compatibility
@@ -382,11 +382,11 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
Any aCtrl = m_xUnoControlDialogModel->getByName( indexToName.second );
Reference< css::awt::XControlModel > xCtrlModel;
aCtrl >>= xCtrlModel;
- DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
+ rtl::Reference<DlgEdObj> pCtrlObj = new DlgEdObj(*pDlgEdModel);
pCtrlObj->SetUnoControlModel( xCtrlModel );
- pCtrlObj->SetDlgEdForm( pDlgEdForm );
- pDlgEdForm->AddChild( pCtrlObj );
- pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetDlgEdForm( pDlgEdForm.get() );
+ pDlgEdForm->AddChild( pCtrlObj.get() );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj.get() );
pCtrlObj->SetRectFromProps();
pCtrlObj->UpdateStep();
pCtrlObj->StartListening();
@@ -400,7 +400,7 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
void DlgEditor::ResetDialog ()
{
- DlgEdForm* pOldDlgEdForm = pDlgEdForm;
+ DlgEdForm* pOldDlgEdForm = pDlgEdForm.get();
DlgEdPage* pPage = static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0));
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
bool bWasMarked = pDlgEdView->IsObjMarked( pOldDlgEdForm );
@@ -412,7 +412,7 @@ void DlgEditor::ResetDialog ()
pPage->SetDlgEdForm( nullptr );
SetDialog( m_xUnoControlDialogModel );
if( bWasMarked )
- pDlgEdView->MarkObj( pDlgEdForm, pPgView );
+ pDlgEdView->MarkObj( pDlgEdForm.get(), pPgView );
}
@@ -603,12 +603,12 @@ void DlgEditor::SetInsertObj(SdrObjKind eObj)
void DlgEditor::CreateDefaultObject()
{
// create object by factory
- SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj = SdrObjFactory::MakeNewObject(
*pDlgEdModel,
pDlgEdView->GetCurrentObjInventor(),
pDlgEdView->GetCurrentObjIdentifier());
- DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
+ DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get());
if (!pDlgEdObj)
return;
@@ -914,9 +914,9 @@ void DlgEditor::Paste()
Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
- DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
- pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
- pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
+ rtl::Reference<DlgEdObj> pCtrlObj = new DlgEdObj(*pDlgEdModel);
+ pCtrlObj->SetDlgEdForm(pDlgEdForm.get()); // set parent form
+ pDlgEdForm->AddChild(pCtrlObj.get()); // add child to parent form
pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
// set new name
@@ -950,7 +950,7 @@ void DlgEditor::Paste()
m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
// insert object into drawing page
- pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj.get() );
pCtrlObj->SetRectFromProps();
pCtrlObj->UpdateStep();
pDlgEdForm->UpdateTabOrderAndGroups();
@@ -958,7 +958,7 @@ void DlgEditor::Paste()
// mark object
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
- pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true);
+ pDlgEdView->MarkObj( pCtrlObj.get(), pPgView, false, true);
}
// center marked objects in dialog editor form