diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 10:27:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-29 13:44:02 +0200 |
commit | 8611f6e259b807b4f19c8dc0eab86ca648891ce3 (patch) | |
tree | fa2b0e463aafb51df754768f916ca9104969a557 /cui | |
parent | 25a997c15d39fb30676a375df8ea4ce1ed2e1acd (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 'cui')
-rw-r--r-- | cui/source/tabpages/tpline.cxx | 32 | ||||
-rw-r--r-- | cui/source/tabpages/tplneend.cxx | 6 |
2 files changed, 19 insertions, 19 deletions
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 04eaa41b92c9..85efe01a1c2f 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -828,7 +828,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) if(m_pSymbolList->GetObjCount()) { nSymTmp %= m_pSymbolList->GetObjCount(); // Treat list as cyclic! - SdrObject *pObj=m_pSymbolList->GetObj(nSymTmp); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(nSymTmp); if(pObj) { // directly clone to target SdrModel @@ -843,16 +843,16 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) pObj->SetMergedItemSet(m_rOutAttrs); } - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); // Generate invisible square to give all symbol types a // bitmap size, which is independent from specific glyph - SdrObject* pInvisibleSquare(m_pSymbolList->GetObj(0)); + rtl::Reference<SdrObject> pInvisibleSquare(m_pSymbolList->GetObj(0)); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); @@ -868,10 +868,10 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) bIgnoreGraphic=true; aView.UnmarkAll(); - pInvisibleSquare=pPage->RemoveObject(1); - SdrObject::Free( pInvisibleSquare); - pObj=pPage->RemoveObject(0); - SdrObject::Free( pObj ); + pPage->RemoveObject(1); + pInvisibleSquare.clear(); + pPage->RemoveObject(0); + pObj.clear(); } } } @@ -1455,25 +1455,25 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) // Generate invisible square to give all symbols a // bitmap size, which is independent from specific glyph - SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0); + rtl::Reference<SdrObject> pInvisibleSquare=m_pSymbolList->GetObj(0); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); for(size_t i=0; i < m_pSymbolList->GetObjCount(); ++i) { - SdrObject *pObj=m_pSymbolList->GetObj(i); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(i); assert(pObj); // directly clone to target SdrModel pObj = pObj->CloneSdrObject(*pModel); m_aGrfNames.emplace_back(""); - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); if(m_xSymbolAttr) { pObj->SetMergedItemSet(*m_xSymbolAttr); @@ -1486,8 +1486,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) BitmapEx aBitmapEx(aView.GetMarkedObjBitmapEx()); GDIMetaFile aMeta(aView.GetMarkedObjMetaFile()); aView.UnmarkAll(); - pObj=pPage->RemoveObject(1); - SdrObject::Free(pObj); + pPage->RemoveObject(1); + pObj.clear(); SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); @@ -1507,8 +1507,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) pVD->DrawBitmapEx(Point(), aBitmapEx); m_xSymbolsMenu->append(pInfo->sItemId, "", *pVD); } - pInvisibleSquare=pPage->RemoveObject(0); - SdrObject::Free(pInvisibleSquare); + pPage->RemoveObject(0); + pInvisibleSquare.clear(); if (m_aGrfNames.empty()) m_xSymbolMB->set_item_sensitive("symbols", false); diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index 951b27632c0b..fe7bc13158ea 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -109,7 +109,7 @@ void SvxLineEndDefTabPage::Construct() { SdrObjTransformInfoRec aInfoRec; pPolyObj->TakeObjInfo( aInfoRec ); - SdrObjectUniquePtr pNewObj; + rtl::Reference<SdrObject> pNewObj; if( aInfoRec.bCanConvToPath ) pNewObj = pPolyObj->ConvertToPolyObj( true, false ); @@ -341,7 +341,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) if( pPolyObj ) { const SdrObject* pNewObj; - SdrObjectUniquePtr pConvPolyObj; + rtl::Reference<SdrObject> pConvPolyObj; if( nullptr != dynamic_cast<const SdrPathObj*>( pPolyObj) ) { @@ -370,7 +370,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) // normalize aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( -aNewRange.getMinX(), -aNewRange.getMinY())); - pConvPolyObj.reset(); + pConvPolyObj.clear(); OUString aNewName(SvxResId(RID_SVXSTR_LINEEND)); OUString aDesc(CuiResId(RID_CUISTR_DESC_LINEEND)); |