summaryrefslogtreecommitdiff
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
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>
-rw-r--r--basctl/source/dlged/dlged.cxx30
-rw-r--r--basctl/source/dlged/dlgedfac.cxx20
-rw-r--r--basctl/source/dlged/dlgedobj.cxx10
-rw-r--r--basctl/source/inc/dlged.hxx2
-rw-r--r--basctl/source/inc/dlgedfac.hxx2
-rw-r--r--basctl/source/inc/dlgedobj.hxx8
-rw-r--r--chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx1
-rw-r--r--chart2/source/controller/drawinglayer/ViewElementListProvider.cxx10
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx6
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.cxx18
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.hxx3
-rw-r--r--chart2/source/view/main/ChartView.cxx3
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx4
-rw-r--r--compilerplugins/clang/refcounting.cxx13
-rw-r--r--compilerplugins/clang/test/refcounting.cxx17
-rw-r--r--compilerplugins/clang/weakobject.cxx1
-rw-r--r--cui/source/tabpages/tpline.cxx32
-rw-r--r--cui/source/tabpages/tplneend.cxx6
-rw-r--r--filter/source/msfilter/escherex.cxx4
-rw-r--r--filter/source/msfilter/msdffimp.cxx119
-rw-r--r--filter/source/msfilter/svdfppt.cxx101
-rw-r--r--filter/source/svg/svgexport.cxx4
-rw-r--r--filter/source/svg/svgfilter.cxx8
-rw-r--r--framework/source/fwe/helper/undomanagerhelper.cxx2
-rw-r--r--include/filter/msfilter/msdffimp.hxx19
-rw-r--r--include/filter/msfilter/svdfppt.hxx14
-rw-r--r--include/svx/EnhancedCustomShape2d.hxx8
-rw-r--r--include/svx/compressgraphicdialog.hxx2
-rw-r--r--include/svx/connctrl.hxx2
-rw-r--r--include/svx/cube3d.hxx4
-rw-r--r--include/svx/dlgctl3d.hxx10
-rw-r--r--include/svx/dlgctrl.hxx12
-rw-r--r--include/svx/extedit.hxx6
-rw-r--r--include/svx/fmdpage.hxx2
-rw-r--r--include/svx/fmobjfac.hxx4
-rw-r--r--include/svx/fmpage.hxx2
-rw-r--r--include/svx/fmview.hxx10
-rw-r--r--include/svx/fontworkgallery.hxx4
-rw-r--r--include/svx/lathe3d.hxx6
-rw-r--r--include/svx/measctrl.hxx2
-rw-r--r--include/svx/obj3d.hxx6
-rw-r--r--include/svx/objfac3d.hxx4
-rw-r--r--include/svx/scene3d.hxx10
-rw-r--r--include/svx/sdr/table/tablecontroller.hxx8
-rw-r--r--include/svx/selectioncontroller.hxx3
-rw-r--r--include/svx/sphere3d.hxx4
-rw-r--r--include/svx/svdcrtv.hxx4
-rw-r--r--include/svx/svddrgmt.hxx4
-rw-r--r--include/svx/svdedtv.hxx2
-rw-r--r--include/svx/svdedxv.hxx5
-rw-r--r--include/svx/svdetc.hxx4
-rw-r--r--include/svx/svdmodel.hxx7
-rw-r--r--include/svx/svdoashp.hxx10
-rw-r--r--include/svx/svdobj.hxx59
-rw-r--r--include/svx/svdocapt.hxx4
-rw-r--r--include/svx/svdocirc.hxx4
-rw-r--r--include/svx/svdoedge.hxx6
-rw-r--r--include/svx/svdograf.hxx6
-rw-r--r--include/svx/svdogrp.hxx9
-rw-r--r--include/svx/svdomeas.hxx8
-rw-r--r--include/svx/svdomedia.hxx2
-rw-r--r--include/svx/svdoole2.hxx8
-rw-r--r--include/svx/svdopage.hxx2
-rw-r--r--include/svx/svdopath.hxx6
-rw-r--r--include/svx/svdorect.hxx4
-rw-r--r--include/svx/svdotable.hxx2
-rw-r--r--include/svx/svdotext.hxx14
-rw-r--r--include/svx/svdouno.hxx7
-rw-r--r--include/svx/svdoutl.hxx4
-rw-r--r--include/svx/svdovirt.hxx6
-rw-r--r--include/svx/svdpage.hxx11
-rw-r--r--include/svx/svdundo.hxx20
-rw-r--r--include/svx/unopage.hxx2
-rw-r--r--include/svx/unoshape.hxx14
-rw-r--r--include/svx/view3d.hxx2
-rw-r--r--include/unotools/weakref.hxx7
-rw-r--r--reportdesign/inc/RptObject.hxx22
-rw-r--r--reportdesign/inc/RptPage.hxx2
-rw-r--r--reportdesign/source/core/api/Shape.cxx2
-rw-r--r--reportdesign/source/core/inc/ReportDrawPage.hxx2
-rw-r--r--reportdesign/source/core/sdr/ReportDrawPage.cxx2
-rw-r--r--reportdesign/source/core/sdr/RptObject.cxx44
-rw-r--r--reportdesign/source/core/sdr/RptPage.cxx13
-rw-r--r--reportdesign/source/core/sdr/UndoActions.cxx6
-rw-r--r--reportdesign/source/ui/inc/UITools.hxx2
-rw-r--r--reportdesign/source/ui/inc/dlgedfac.hxx2
-rw-r--r--reportdesign/source/ui/misc/RptUndo.cxx7
-rw-r--r--reportdesign/source/ui/misc/UITools.cxx4
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx27
-rw-r--r--reportdesign/source/ui/report/ReportSection.cxx10
-rw-r--r--reportdesign/source/ui/report/ViewsWindow.cxx8
-rw-r--r--reportdesign/source/ui/report/dlgedfac.cxx6
-rw-r--r--sc/CppunitTest_sc_shapetest.mk1
-rw-r--r--sc/inc/postit.hxx109
-rw-r--r--sc/qa/extras/anchor.cxx5
-rw-r--r--sc/qa/unit/scshapetest.cxx12
-rw-r--r--sc/qa/unit/ucalc.cxx46
-rw-r--r--sc/qa/unit/ucalc_sort.cxx6
-rw-r--r--sc/source/core/data/documen9.cxx4
-rw-r--r--sc/source/core/data/drwlayer.cxx50
-rw-r--r--sc/source/core/data/postit.cxx422
-rw-r--r--sc/source/core/tool/detfunc.cxx34
-rw-r--r--sc/source/filter/excel/xiescher.cxx100
-rw-r--r--sc/source/filter/inc/xcl97rec.hxx2
-rw-r--r--sc/source/filter/inc/xiescher.hxx32
-rw-r--r--sc/source/filter/rtf/eeimpars.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconarc.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconcustomshape.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconpol.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconrec.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconuno.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuins1.cxx8
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx14
-rw-r--r--sc/source/ui/drawfunc/fupoor.cxx2
-rw-r--r--sc/source/ui/drawfunc/futext.cxx4
-rw-r--r--sc/source/ui/drawfunc/graphsh.cxx14
-rw-r--r--sc/source/ui/inc/fuconarc.hxx2
-rw-r--r--sc/source/ui/inc/fuconcustomshape.hxx2
-rw-r--r--sc/source/ui/inc/fuconpol.hxx2
-rw-r--r--sc/source/ui/inc/fuconrec.hxx2
-rw-r--r--sc/source/ui/inc/fuconuno.hxx2
-rw-r--r--sc/source/ui/inc/fupoor.hxx2
-rw-r--r--sc/source/ui/inc/futext.hxx2
-rw-r--r--sc/source/ui/inc/notemark.hxx2
-rw-r--r--sc/source/ui/undo/undocell.cxx5
-rw-r--r--sc/source/ui/unoobj/TablePivotCharts.cxx4
-rw-r--r--sc/source/ui/unoobj/chartuno.cxx4
-rw-r--r--sc/source/ui/view/drawview.cxx8
-rw-r--r--sc/source/ui/view/notemark.cxx3
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx4
-rw-r--r--sc/source/ui/view/tabvwshb.cxx4
-rw-r--r--sc/source/ui/view/tabvwshg.cxx6
-rw-r--r--sc/source/ui/view/viewfun5.cxx4
-rw-r--r--sc/source/ui/view/viewfun7.cxx14
-rw-r--r--sd/inc/CustomAnimationEffect.hxx3
-rw-r--r--sd/inc/Outliner.hxx2
-rw-r--r--sd/inc/OutlinerIterator.hxx4
-rw-r--r--sd/inc/sdpage.hxx10
-rw-r--r--sd/inc/undo/undoobjects.hxx16
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx3
-rw-r--r--sd/source/core/CustomAnimationEffect.cxx4
-rw-r--r--sd/source/core/sdpage.cxx79
-rw-r--r--sd/source/core/sdpage2.cxx1
-rw-r--r--sd/source/core/undo/undoobjects.cxx98
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx6
-rw-r--r--sd/source/filter/ppt/pptin.cxx40
-rw-r--r--sd/source/filter/ppt/pptin.hxx2
-rw-r--r--sd/source/ui/animations/motionpathtag.cxx36
-rw-r--r--sd/source/ui/animations/motionpathtag.hxx4
-rw-r--r--sd/source/ui/dlg/animobjs.cxx38
-rw-r--r--sd/source/ui/func/fucon3d.cxx30
-rw-r--r--sd/source/ui/func/fuconarc.cxx8
-rw-r--r--sd/source/ui/func/fuconbez.cxx4
-rw-r--r--sd/source/ui/func/fuconcs.cxx8
-rw-r--r--sd/source/ui/func/fuconrec.cxx16
-rw-r--r--sd/source/ui/func/fuconuno.cxx4
-rw-r--r--sd/source/ui/func/fuinsert.cxx16
-rw-r--r--sd/source/ui/func/fuinsfil.cxx4
-rw-r--r--sd/source/ui/func/fulinend.cxx4
-rw-r--r--sd/source/ui/func/fumorph.cxx22
-rw-r--r--sd/source/ui/func/fupoor.cxx2
-rw-r--r--sd/source/ui/func/futext.cxx106
-rw-r--r--sd/source/ui/func/fuvect.cxx4
-rw-r--r--sd/source/ui/inc/OutlinerIteratorImpl.hxx4
-rw-r--r--sd/source/ui/inc/fucon3d.hxx4
-rw-r--r--sd/source/ui/inc/fuconarc.hxx2
-rw-r--r--sd/source/ui/inc/fuconbez.hxx2
-rw-r--r--sd/source/ui/inc/fuconcs.hxx2
-rw-r--r--sd/source/ui/inc/fuconrec.hxx2
-rw-r--r--sd/source/ui/inc/fuconuno.hxx2
-rw-r--r--sd/source/ui/inc/fupoor.hxx2
-rw-r--r--sd/source/ui/inc/futext.hxx8
-rw-r--r--sd/source/ui/inc/unopage.hxx2
-rw-r--r--sd/source/ui/table/tablefunction.cxx16
-rw-r--r--sd/source/ui/unoidl/unoobj.cxx4
-rw-r--r--sd/source/ui/unoidl/unopage.cxx9
-rw-r--r--sd/source/ui/view/DocumentRenderer.cxx10
-rw-r--r--sd/source/ui/view/GraphicObjectBar.cxx4
-rw-r--r--sd/source/ui/view/Outliner.cxx10
-rw-r--r--sd/source/ui/view/OutlinerIterator.cxx45
-rw-r--r--sd/source/ui/view/drviews2.cxx18
-rw-r--r--sd/source/ui/view/drviews6.cxx5
-rw-r--r--sd/source/ui/view/drviews8.cxx4
-rw-r--r--sd/source/ui/view/drviews9.cxx8
-rw-r--r--sd/source/ui/view/drviewsa.cxx1
-rw-r--r--sd/source/ui/view/drviewse.cxx18
-rw-r--r--sd/source/ui/view/sdview.cxx21
-rw-r--r--sd/source/ui/view/sdview2.cxx4
-rw-r--r--sd/source/ui/view/sdview3.cxx31
-rw-r--r--sd/source/ui/view/sdview4.cxx36
-rw-r--r--sd/source/ui/view/viewoverlaymanager.cxx15
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx6
-rw-r--r--svx/inc/extrud3d.hxx4
-rw-r--r--svx/inc/polygn3d.hxx5
-rw-r--r--svx/inc/sdr/primitive2d/sdrolecontentprimitive2d.hxx4
-rw-r--r--svx/qa/unit/customshapes.cxx20
-rw-r--r--svx/qa/unit/svdraw.cxx7
-rw-r--r--svx/source/core/extedit.cxx10
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx64
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx33
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.hxx4
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx60
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx8
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.hxx3
-rw-r--r--svx/source/dialog/compressgraphicdialog.cxx4
-rw-r--r--svx/source/dialog/connctrl.cxx19
-rw-r--r--svx/source/dialog/contwnd.cxx4
-rw-r--r--svx/source/dialog/dlgctl3d.cxx36
-rw-r--r--svx/source/dialog/dlgctrl.cxx33
-rw-r--r--svx/source/dialog/imapwnd.cxx21
-rw-r--r--svx/source/dialog/imapwnd.hxx2
-rw-r--r--svx/source/dialog/measctrl.cxx2
-rw-r--r--svx/source/engine3d/cube3d.cxx4
-rw-r--r--svx/source/engine3d/extrud3d.cxx8
-rw-r--r--svx/source/engine3d/float3d.cxx1
-rw-r--r--svx/source/engine3d/lathe3d.cxx10
-rw-r--r--svx/source/engine3d/obj3d.cxx6
-rw-r--r--svx/source/engine3d/objfac3d.cxx2
-rw-r--r--svx/source/engine3d/polygn3d.cxx5
-rw-r--r--svx/source/engine3d/scene3d.cxx11
-rw-r--r--svx/source/engine3d/sphere3d.cxx4
-rw-r--r--svx/source/engine3d/view3d.cxx53
-rw-r--r--svx/source/engine3d/view3d1.cxx6
-rw-r--r--svx/source/form/fmdmod.cxx4
-rw-r--r--svx/source/form/fmdpage.cxx2
-rw-r--r--svx/source/form/fmobj.cxx2
-rw-r--r--svx/source/form/fmobjfac.cxx6
-rw-r--r--svx/source/form/fmpage.cxx6
-rw-r--r--svx/source/form/fmview.cxx10
-rw-r--r--svx/source/form/fmvwimp.cxx58
-rw-r--r--svx/source/gallery2/galtheme.cxx4
-rw-r--r--svx/source/inc/fmobj.hxx2
-rw-r--r--svx/source/inc/fmvwimp.hxx12
-rw-r--r--svx/source/inc/svdpdf.hxx2
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx6
-rw-r--r--svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx10
-rw-r--r--svx/source/svdraw/selectioncontroller.cxx3
-rw-r--r--svx/source/svdraw/svdcrtv.cxx43
-rw-r--r--svx/source/svdraw/svddrgmt.cxx6
-rw-r--r--svx/source/svdraw/svdedtv.cxx28
-rw-r--r--svx/source/svdraw/svdedtv2.cxx98
-rw-r--r--svx/source/svdraw/svdedxv.cxx127
-rw-r--r--svx/source/svdraw/svdetc.cxx2
-rw-r--r--svx/source/svdraw/svdfmtf.cxx178
-rw-r--r--svx/source/svdraw/svdfmtf.hxx2
-rw-r--r--svx/source/svdraw/svdmodel.cxx16
-rw-r--r--svx/source/svdraw/svdoashp.cxx19
-rw-r--r--svx/source/svdraw/svdobj.cxx167
-rw-r--r--svx/source/svdraw/svdocapt.cxx22
-rw-r--r--svx/source/svdraw/svdocirc.cxx6
-rw-r--r--svx/source/svdraw/svdoedge.cxx12
-rw-r--r--svx/source/svdraw/svdograf.cxx40
-rw-r--r--svx/source/svdraw/svdogrp.cxx10
-rw-r--r--svx/source/svdraw/svdomeas.cxx20
-rw-r--r--svx/source/svdraw/svdomedia.cxx2
-rw-r--r--svx/source/svdraw/svdoole2.cxx22
-rw-r--r--svx/source/svdraw/svdopage.cxx2
-rw-r--r--svx/source/svdraw/svdopath.cxx14
-rw-r--r--svx/source/svdraw/svdorect.cxx6
-rw-r--r--svx/source/svdraw/svdotext.cxx12
-rw-r--r--svx/source/svdraw/svdotxln.cxx4
-rw-r--r--svx/source/svdraw/svdotxtr.cxx41
-rw-r--r--svx/source/svdraw/svdouno.cxx2
-rw-r--r--svx/source/svdraw/svdoutl.cxx12
-rw-r--r--svx/source/svdraw/svdovirt.cxx146
-rw-r--r--svx/source/svdraw/svdpage.cxx65
-rw-r--r--svx/source/svdraw/svdpdf.cxx57
-rw-r--r--svx/source/svdraw/svdpoev.cxx11
-rw-r--r--svx/source/svdraw/svdundo.cxx303
-rw-r--r--svx/source/svdraw/svdxcgv.cxx26
-rw-r--r--svx/source/table/svdotable.cxx12
-rw-r--r--svx/source/table/tablecontroller.cxx101
-rw-r--r--svx/source/table/tableundo.cxx24
-rw-r--r--svx/source/table/tableundo.hxx4
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx12
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx9
-rw-r--r--svx/source/unodraw/gluepts.cxx79
-rw-r--r--svx/source/unodraw/unopage.cxx51
-rw-r--r--svx/source/unodraw/unoshap2.cxx9
-rw-r--r--svx/source/unodraw/unoshap3.cxx23
-rw-r--r--svx/source/unodraw/unoshape.cxx184
-rw-r--r--sw/inc/anchoredobject.hxx9
-rw-r--r--sw/inc/dcontact.hxx14
-rw-r--r--sw/inc/dobjfac.hxx2
-rw-r--r--sw/inc/dpage.hxx2
-rw-r--r--sw/inc/unodraw.hxx2
-rw-r--r--sw/source/core/doc/doclay.cxx16
-rw-r--r--sw/source/core/draw/dcontact.cxx70
-rw-r--r--sw/source/core/draw/dflyobj.cxx7
-rw-r--r--sw/source/core/draw/dobjfac.cxx2
-rw-r--r--sw/source/core/draw/dpage.cxx2
-rw-r--r--sw/source/core/draw/drawdoc.cxx22
-rw-r--r--sw/source/core/frmedt/fecopy.cxx19
-rw-r--r--sw/source/core/frmedt/feshview.cxx19
-rw-r--r--sw/source/core/inc/dflyobj.hxx2
-rw-r--r--sw/source/core/layout/anchoredobject.cxx1
-rw-r--r--sw/source/core/layout/fly.cxx11
-rw-r--r--sw/source/core/unocore/unodraw.cxx14
-rw-r--r--sw/source/filter/html/htmldrawreader.cxx10
-rw-r--r--sw/source/filter/html/htmltab.cxx2
-rw-r--r--sw/source/filter/html/swhtml.cxx1
-rw-r--r--sw/source/filter/html/swhtml.hxx2
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx9
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx6
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx131
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx18
-rw-r--r--sw/source/filter/ww8/ww8par.cxx25
-rw-r--r--sw/source/filter/ww8/ww8par.hxx28
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx10
-rw-r--r--sw/source/filter/xml/swxml.cxx5
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx8
-rw-r--r--sw/source/uibase/shells/drawsh.cxx6
-rw-r--r--sw/source/uibase/shells/grfshex.cxx2
-rw-r--r--sw/source/uibase/uiview/viewdraw.cxx4
314 files changed, 2512 insertions, 3376 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
diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx
index 03713c2b94ee..eed140560534 100644
--- a/basctl/source/dlged/dlgedfac.cxx
+++ b/basctl/source/dlged/dlgedfac.cxx
@@ -45,7 +45,7 @@ DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
}
-IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
+IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> )
{
static const uno::Reference<lang::XMultiServiceFactory> xDialogSFact = [] {
uno::Reference<lang::XMultiServiceFactory> xFact;
@@ -59,7 +59,7 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
return xFact;
}();
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
if( (aParams.nInventor == SdrInventor::BasicDialog) &&
(aParams.nObjIdentifier >= SdrObjKind::BasicDialogPushButton) &&
(aParams.nObjIdentifier <= SdrObjKind::BasicDialogFormHorizontalScroll) )
@@ -74,26 +74,26 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
break;
case SdrObjKind::BasicDialogFormRadio:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.RadioButton", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
case SdrObjKind::BasicDialogCheckbox:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
break;
case SdrObjKind::BasicDialogFormCheck:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.CheckBox", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
case SdrObjKind::BasicDialogListbox:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
break;
case SdrObjKind::BasicDialogFormList:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ListBox", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
case SdrObjKind::BasicDialogFormCombo:
case SdrObjKind::BasicDialogCombobox:
{
- DlgEdObj* pNew = nullptr;
+ rtl::Reference<DlgEdObj> pNew;
if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogCombobox )
pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
else
@@ -135,12 +135,12 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
break;
case SdrObjKind::BasicDialogFormHorizontalScroll:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
case SdrObjKind::BasicDialogFormVerticalScroll:
case SdrObjKind::BasicDialogVerticalScrollbar:
{
- DlgEdObj* pNew = nullptr;
+ rtl::Reference<DlgEdObj> pNew;
if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogVerticalScrollbar )
pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
else
@@ -167,7 +167,7 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
break;
case SdrObjKind::BasicDialogVerticalFixedLine:
{
- DlgEdObj* pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
+ rtl::Reference<DlgEdObj> pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
pNewObj = pNew;
// set vertical orientation
try
@@ -208,7 +208,7 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
break;
case SdrObjKind::BasicDialogFormSpin:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.SpinButton", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
case SdrObjKind::BasicDialogTreeControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 1d89210b7dd5..3e06307941da 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -70,7 +70,6 @@ DlgEditor& DlgEdObj::GetDialogEditor ()
DlgEdObj::DlgEdObj(SdrModel& rSdrModel)
: SdrUnoObj(rSdrModel, OUString())
,bIsListening(false)
- ,pDlgEdForm( nullptr )
{
}
@@ -118,7 +117,6 @@ DlgEdObj::DlgEdObj(
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac)
: SdrUnoObj(rSdrModel, rModelName, rxSFac)
,bIsListening(false)
- ,pDlgEdForm( nullptr )
{
}
@@ -906,16 +904,16 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const
}
}
-DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new DlgEdObj(rTargetModel, *this);
}
-SdrObjectUniquePtr DlgEdObj::getFullDragClone() const
+rtl::Reference<SdrObject> DlgEdObj::getFullDragClone() const
{
// no need to really add the clone for dragging, it's a temporary
// object
- return SdrObjectUniquePtr(new SdrUnoObj(getSdrModelFromSdrObject(), *this));
+ return rtl::Reference<SdrObject>(new SdrUnoObj(getSdrModelFromSdrObject(), *this));
}
void DlgEdObj::NbcMove( const Size& rSize )
@@ -961,7 +959,7 @@ bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
// implementation. For historical reasons, the SdrPage (which is the DlgEdPage) was
// already set. For now, get it from the SdrDragStat and use it to access and set
// the local pDlgEdForm
- if(nullptr == pDlgEdForm && nullptr != rStat.GetPageView())
+ if(!pDlgEdForm && nullptr != rStat.GetPageView())
{
const DlgEdPage* pDlgEdPage(dynamic_cast<const DlgEdPage*>(rStat.GetPageView()->GetPage()));
diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx
index 0d1c461ad106..c50faf51b36c 100644
--- a/basctl/source/inc/dlged.hxx
+++ b/basctl/source/inc/dlged.hxx
@@ -112,7 +112,7 @@ private:
std::unique_ptr<DlgEdModel> pDlgEdModel; // never nullptr
DlgEdPage* pDlgEdPage; // never nullptr
std::unique_ptr<DlgEdView> pDlgEdView; // never nullptr
- DlgEdForm* pDlgEdForm; // never nullptr
+ rtl::Reference<DlgEdForm> pDlgEdForm; // never nullptr
css::uno::Reference< css::container::XNameContainer > m_xUnoControlDialogModel;
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer;
css::uno::Sequence< css::datatransfer::DataFlavor > m_ClipboardDataFlavors;
diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx
index f200b01f84c9..5e583ada1729 100644
--- a/basctl/source/inc/dlgedfac.hxx
+++ b/basctl/source/inc/dlgedfac.hxx
@@ -35,7 +35,7 @@ public:
DlgEdFactory(css::uno::Reference<css::frame::XModel> xModel);
~DlgEdFactory() COVERITY_NOEXCEPT_FALSE;
- DECL_LINK(MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_LINK(MakeObject, SdrObjCreatorParams, rtl::Reference<SdrObject>);
};
} // namespace basctl
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index d5e29cf48caf..a8c249adec16 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -50,7 +50,7 @@ class DlgEdObj: public SdrUnoObj
private:
bool bIsListening;
- DlgEdForm* pDlgEdForm;
+ rtl::Reference<DlgEdForm> pDlgEdForm;
css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
css::uno::Reference< css::container::XContainerListener> m_xContainerListener;
@@ -94,15 +94,15 @@ protected:
public:
void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
- DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
+ DlgEdForm* GetDlgEdForm() const { return pDlgEdForm.get(); }
virtual SdrInventor GetObjInventor() const override;
virtual SdrObjKind GetObjIdentifier() const override;
- virtual DlgEdObj* CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet
// FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
bool supportsService( OUString const & serviceName ) const;
OUString GetDefaultName() const;
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
index 4459219965d8..7cb38e9e8b48 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
@@ -30,6 +30,7 @@
#include <svx/svx3ditems.hxx>
#include <svx/svddef.hxx>
#include <utility>
+#include <svx/obj3d.hxx>
#include <vcl/svapp.hxx>
#include <comphelper/diagnose_ex.hxx>
diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
index 1f0ef08578d3..0b3df1aa22ad 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -139,7 +139,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
nStandardSymbol*=-1;
if( o3tl::make_unsigned(nStandardSymbol) >= pSymbolList->GetObjCount() )
nStandardSymbol %= pSymbolList->GetObjCount();
- SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
+ rtl::Reference<SdrObject> pObj = pSymbolList->GetObj(nStandardSymbol);
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
@@ -158,8 +158,8 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
// directly clone to target SdrModel
pObj = pObj->CloneSdrObject(*pModel);
- pPage->NbcInsertObject(pObj);
- aView.MarkObj(pObj,pPageView);
+ pPage->NbcInsertObject(pObj.get());
+ aView.MarkObj(pObj.get(),pPageView);
if( pSymbolShapeProperties )
pObj->SetMergedItemSet(*pSymbolShapeProperties);
@@ -172,7 +172,9 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
aView.UnmarkAll();
pObj=pPage->RemoveObject(0);
- SdrObject::Free( pObj );
+ // these need to die before the associated SdrModel
+ pObj.clear();
+ pPage.clear();
return aGraph;
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 18771a553eaa..085f31e8b574 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -418,7 +418,9 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )
{
SdrObject* pObj(aIter.Next());
// Clone to new SdrModel
- SdrObject* pNewObj(pObj ? pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()) : nullptr);
+ rtl::Reference<SdrObject> pNewObj;
+ if (pObj)
+ pNewObj = pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel());
if ( pNewObj )
{
@@ -429,7 +431,7 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )
xShape->setPosition( awt::Point( 0, 0 ) );
}
- pDestPage->InsertObject( pNewObj );
+ pDestPage->InsertObject( pNewObj.get() );
m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pNewObj ) );
xSelShape = xShape;
}
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx
index c5cea4c5b6cd..9d896b75425e 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -362,11 +362,11 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea
if ( eDrawMode != CHARTDRAW_INSERT )
return;
- SdrObject* pObj = createDefaultObject( nFeatureId );
+ rtl::Reference<SdrObject> pObj = createDefaultObject( nFeatureId );
if ( pObj )
{
SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView();
- if (pDrawViewWrapper->InsertObjectAtView(pObj, *pPageView))
+ if (pDrawViewWrapper->InsertObjectAtView(pObj.get(), *pPageView))
m_pChartController->SetAndApplySelection(Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY));
if ( nFeatureId == COMMAND_ID_DRAW_TEXT )
{
@@ -402,9 +402,9 @@ void DrawCommandDispatch::setInsertObj(SdrObjKind eObj)
}
}
-SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
+rtl::Reference<SdrObject> DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
{
- SdrObject* pObj = nullptr;
+ rtl::Reference<SdrObject> pObj;
DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr );
@@ -435,7 +435,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
case COMMAND_ID_DRAW_LINE:
case COMMAND_ID_LINE_ARROW_END:
{
- if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj) )
+ if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) )
{
Point aStart = aRect.TopLeft();
Point aEnd = aRect.BottomRight();
@@ -452,7 +452,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
break;
case COMMAND_ID_DRAW_FREELINE_NOFILL:
{
- if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj) )
+ if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) )
{
basegfx::B2DPolygon aInnerPoly;
aInnerPoly.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom() ) );
@@ -473,7 +473,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
case COMMAND_ID_DRAW_TEXT:
case COMMAND_ID_DRAW_TEXT_VERTICAL:
{
- if ( SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( pObj) )
+ if ( SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( pObj.get()) )
{
pTextObj->SetLogicRect( aRect );
bool bVertical = ( nID == COMMAND_ID_DRAW_TEXT_VERTICAL );
@@ -493,7 +493,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
case COMMAND_ID_DRAW_CAPTION:
case COMMAND_ID_DRAW_CAPTION_VERTICAL:
{
- if ( SdrCaptionObj* pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj) )
+ if ( SdrCaptionObj* pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj.get()) )
{
bool bIsVertical( nID == COMMAND_ID_DRAW_CAPTION_VERTICAL );
pCaptionObj->SetVerticalWriting( bIsVertical );
@@ -514,7 +514,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
{
pObj->SetLogicRect( aRect );
SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
- setAttributes( pObj );
+ setAttributes( pObj.get() );
pObj->SetMergedItemSet( aSet );
}
break;
diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx
index febfa8338d40..6e707b102e68 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.hxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.hxx
@@ -20,6 +20,7 @@
#include <svx/svdobjkind.hxx>
#include "FeatureCommandDispatchBase.hxx"
+#include <rtl/ref.hxx>
class SfxItemSet;
class SdrObject;
@@ -60,7 +61,7 @@ protected:
private:
void setInsertObj(SdrObjKind eObj);
- SdrObject* createDefaultObject( const sal_uInt16 nID );
+ rtl::Reference<SdrObject> createDefaultObject( const sal_uInt16 nID );
bool parseCommandURL( const OUString& rCommandURL, sal_uInt16* pnFeatureId, OUString* pBaseCommand, OUString* pCustomShapeType );
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 8faa295d2492..584dfdb5ea72 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1310,8 +1310,7 @@ void lcl_removeEmptyGroupShapes( const SdrObject& rParent )
if (pChildObjList->GetObjCount() == 0)
{
//remove empty group shape
- SdrObject* pRemoved = pObjList->NbcRemoveObject(nIdx);
- SdrObject::Free( pRemoved );
+ pObjList->NbcRemoveObject(nIdx);
}
else
lcl_removeEmptyGroupShapes(*pChildSdrObject);
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 4a3d207a1edb..d1f73636c546 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -1115,8 +1115,8 @@ rtl::Reference<SvxShapePolyPolygon>
return nullptr;
//create shape
- SdrPathObj* pPath = new SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), SdrObjKind::Polygon);
- xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath);
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), SdrObjKind::Polygon);
+ xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath.get());
//set properties
try
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 61204b67a470..e65772f71e7d 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -505,6 +505,10 @@ bool RefCounting::VisitCXXDeleteExpr(const CXXDeleteExpr * cxxDeleteExpr)
compiler.getSourceManager().getSpellingLoc(cxxDeleteExpr->getBeginLoc()));
if (loplugin::isSamePathname(aFileName, SRCDIR "/cppuhelper/source/weak.cxx"))
return true;
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/include/svx/svdobj.hxx"))
+ return true;
+ if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/svdraw/svdobj.cxx"))
+ return true;
if (!cxxDeleteExpr->getArgument())
return true;
@@ -746,6 +750,15 @@ bool RefCounting::isCastingReference(const Expr* expr)
if (callMethod->getReturnType()->isReferenceType())
return false;
}
+ // Ignore
+ // WeakReference x;
+ // if (x.get.get())
+ // and similar stuff
+ if (auto memberCall2 = dyn_cast<CXXMemberCallExpr>(obj))
+ {
+ if (loplugin::TypeCheck(memberCall2->getImplicitObjectArgument()->getType()).Class("WeakReference"))
+ return false;
+ }
return true;
}
diff --git a/compilerplugins/clang/test/refcounting.cxx b/compilerplugins/clang/test/refcounting.cxx
index 7ab830fc913b..2b8ce94b42e6 100644
--- a/compilerplugins/clang/test/refcounting.cxx
+++ b/compilerplugins/clang/test/refcounting.cxx
@@ -13,16 +13,8 @@
#include <rtl/ref.hxx>
#include <boost/intrusive_ptr.hpp>
#include <com/sun/star/uno/XInterface.hpp>
-
-namespace cppu
-{
-class OWeakObject
-{
-public:
- void acquire();
- void release();
-};
-}
+#include <cppuhelper/weak.hxx>
+#include <unotools/weakref.hxx>
struct UnoObject : public cppu::OWeakObject
{
@@ -115,6 +107,11 @@ void foo7()
UnoSubObject* p3 = static_cast<UnoSubObject*>(getConstRef().get());
(void)p3;
p3 = static_cast<UnoSubObject*>(getConstRef().get());
+
+ // no warning expected, although, arguably, we should be assigning to a rtl::Reference temporary
+ unotools::WeakReference<UnoObject> weak1;
+ auto pTextObj = dynamic_cast<UnoSubObject*>(weak1.get().get());
+ (void)pTextObj;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/weakobject.cxx b/compilerplugins/clang/weakobject.cxx
index d021dd419d89..7f1a2986faa5 100644
--- a/compilerplugins/clang/weakobject.cxx
+++ b/compilerplugins/clang/weakobject.cxx
@@ -1,3 +1,4 @@
+
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
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));
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 52326112d994..3044762de92a 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4565,7 +4565,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
else if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::SEGMENTS )
{
tools::PolyPolygon aPolyPoly;
- SdrObjectUniquePtr pTemporaryConvertResultObject(pSdrObjCustomShape->DoConvertToPolyObj(true, true));
+ rtl::Reference<SdrObject> pTemporaryConvertResultObject(pSdrObjCustomShape->DoConvertToPolyObj(true, true));
SdrPathObj* pSdrPathObj(dynamic_cast< SdrPathObj* >(pTemporaryConvertResultObject.get()));
if(pSdrPathObj)
@@ -4576,7 +4576,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
}
// do *not* forget to delete the temporary used SdrObject - possible memory leak (!)
- pTemporaryConvertResultObject.reset();
+ pTemporaryConvertResultObject.clear();
pSdrPathObj = nullptr;
if(0 != aPolyPoly.Count())
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 58032e65ee7b..3705429218bd 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3819,9 +3819,9 @@ static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, Gra
}
}
-SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& rObjData )
+rtl::Reference<SdrObject> SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& rObjData )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString aLinkFileName;
tools::Rectangle aVisArea;
@@ -4018,7 +4018,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
{
pRet = new SdrGrafObj(*pSdrModel);
if( bGrfRead )
- static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraf );
+ static_cast<SdrGrafObj*>(pRet.get())->SetGraphic( aGraf );
if( bLinkGrf && !bGrfRead ) // sj: #i55484# if the graphic was embedded ( bGrfRead == true ) then
{ // we do not need to set a link. TODO: not to lose the information where the graphic is linked from
@@ -4057,7 +4057,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
}
pRet->NbcSetLogicRect( rObjData.aBoundRect );
- if (SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pRet))
+ if (SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pRet.get()))
{
if( aLinkFileName.getLength() )
{
@@ -4077,10 +4077,10 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
}
// PptSlidePersistEntry& rPersistEntry, SdPage* pPage
-SdrObject* SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect, int nCalledByGroup, sal_Int32* pShapeId )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
DffRecordHeader aObjHd;
bool bOk = ReadDffRecordHeader(rSt, aObjHd);
if (bOk && aObjHd.nRecType == DFF_msofbtSpgrContainer)
@@ -4095,7 +4095,7 @@ SdrObject* SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClien
return pRet;
}
-SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup, sal_Int32* pShapeId )
{
@@ -4105,7 +4105,7 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
if (!rHd.SeekToContent(rSt))
return nullptr;
- SdrObjectUniquePtr xRet;
+ rtl::Reference<SdrObject> xRet;
DffRecordHeader aRecHd; // the first atom has to be the SpContainer for the GroupObject
bool bOk = ReadDffRecordHeader(rSt, aRecHd);
@@ -4113,8 +4113,8 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
{
mnFix16Angle = 0_deg100;
if (!aRecHd.SeekToBegOfRecord(rSt))
- return xRet.release();
- xRet.reset(ImportObj(rSt, rClientData, rClientRect, rGlobalChildRect, nCalledByGroup + 1, pShapeId));
+ return xRet;
+ xRet = ImportObj(rSt, rClientData, rClientRect, rGlobalChildRect, nCalledByGroup + 1, pShapeId);
if (xRet)
{
Degree100 nGroupRotateAngle(0);
@@ -4145,7 +4145,7 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
// now importing the inner objects of the group
if (!aRecHd.SeekToEndOfRecord(rSt))
- return xRet.release();
+ return xRet;
while (rSt.good() && ( rSt.Tell() < rHd.GetRecEndFilePos()))
{
@@ -4157,43 +4157,43 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
tools::Rectangle aGroupClientAnchor, aGroupChildAnchor;
GetGroupAnchors( aRecHd2, rSt, aGroupClientAnchor, aGroupChildAnchor, aClientRect, aGlobalChildRect );
if (!aRecHd2.SeekToBegOfRecord(rSt))
- return xRet.release();
+ return xRet;
sal_Int32 nShapeId;
- SdrObject* pTmp = ImportGroup( aRecHd2, rSt, rClientData, aGroupClientAnchor, aGroupChildAnchor, nCalledByGroup + 1, &nShapeId );
+ rtl::Reference<SdrObject> pTmp = ImportGroup( aRecHd2, rSt, rClientData, aGroupClientAnchor, aGroupChildAnchor, nCalledByGroup + 1, &nShapeId );
if (pTmp)
{
SdrObjGroup* pGroup = dynamic_cast<SdrObjGroup*>(xRet.get());
if (pGroup && pGroup->GetSubList())
{
- pGroup->GetSubList()->NbcInsertObject(pTmp);
+ pGroup->GetSubList()->NbcInsertObject(pTmp.get());
if (nShapeId)
- insertShapeId(nShapeId, pTmp);
+ insertShapeId(nShapeId, pTmp.get());
}
else
- FreeObj(rClientData, pTmp);
+ FreeObj(rClientData, pTmp.get());
}
}
else if ( aRecHd2.nRecType == DFF_msofbtSpContainer )
{
if (!aRecHd2.SeekToBegOfRecord(rSt))
- return xRet.release();
+ return xRet;
sal_Int32 nShapeId;
- SdrObject* pTmp = ImportShape( aRecHd2, rSt, rClientData, aClientRect, aGlobalChildRect, nCalledByGroup + 1, &nShapeId );
+ rtl::Reference<SdrObject> pTmp = ImportShape( aRecHd2, rSt, rClientData, aClientRect, aGlobalChildRect, nCalledByGroup + 1, &nShapeId );
if (pTmp)
{
SdrObjGroup* pGroup = dynamic_cast<SdrObjGroup*>(xRet.get());
if (pGroup && pGroup->GetSubList())
{
- pGroup->GetSubList()->NbcInsertObject(pTmp);
+ pGroup->GetSubList()->NbcInsertObject(pTmp.get());
if (nShapeId)
- insertShapeId(nShapeId, pTmp);
+ insertShapeId(nShapeId, pTmp.get());
}
else
- FreeObj(rClientData, pTmp);
+ FreeObj(rClientData, pTmp.get());
}
}
if (!aRecHd2.SeekToEndOfRecord(rSt))
- return xRet.release();
+ return xRet;
}
if ( nGroupRotateAngle )
@@ -4215,13 +4215,13 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
if (o3tl::make_unsigned(nCalledByGroup) < maPendingGroupData.size())
{
// finalization for this group is pending, do it now
- xRet.reset(FinalizeObj(maPendingGroupData.back().first, xRet.release()));
+ xRet = FinalizeObj(maPendingGroupData.back().first, xRet.get());
maPendingGroupData.pop_back();
}
- return xRet.release();
+ return xRet;
}
-SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup, sal_Int32* pShapeId )
{
@@ -4335,7 +4335,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( aObjData.nSpFlags & ShapeFlag::Background )
aObjData.aBoundRect = tools::Rectangle( Point(), Size( 1, 1 ) );
- SdrObjectUniquePtr xRet;
+ rtl::Reference<SdrObject> xRet;
tools::Rectangle aTextRect;
if ( !aObjData.aBoundRect.IsEmpty() )
@@ -4361,7 +4361,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( aObjData.nSpFlags & ShapeFlag::Group )
{
- xRet.reset(new SdrObjGroup(*pSdrModel));
+ xRet = new SdrObjGroup(*pSdrModel);
/* After CWS aw033 has been integrated, an empty group object
cannot store its resulting bounding rectangle anymore. We have
to return this rectangle via rClientRect now, but only, if
@@ -4381,7 +4381,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( bGraphic )
{
if (!mbSkipImages) {
- xRet.reset(ImportGraphic(rSt, aSet, aObjData)); // SJ: #68396# is no longer true (fixed in ppt2000)
+ xRet = ImportGraphic(rSt, aSet, aObjData); // SJ: #68396# is no longer true (fixed in ppt2000)
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetMergedItemSet(aSet);
}
@@ -4391,10 +4391,10 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
basegfx::B2DPolygon aPoly;
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top()));
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Right(), aObjData.aBoundRect.Bottom()));
- xRet.reset(new SdrPathObj(
+ xRet = new SdrPathObj(
*pSdrModel,
SdrObjKind::Line,
- basegfx::B2DPolyPolygon(aPoly)));
+ basegfx::B2DPolyPolygon(aPoly));
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetMergedItemSet(aSet);
}
@@ -4405,7 +4405,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
ApplyAttributes( rSt, aSet, aObjData );
- xRet.reset(new SdrObjCustomShape(*pSdrModel));
+ xRet = new SdrObjCustomShape(*pSdrModel);
sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 );
bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0;
@@ -4797,7 +4797,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
basegfx::B2DPolyPolygon aPoly( static_cast<SdrObjCustomShape*>(xRet.get())->GetLineGeometry( true ) );
- xRet.reset(new SdrEdgeObj(*pSdrModel));
+ xRet = new SdrEdgeObj(*pSdrModel);
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetLogicRect( aObjData.aBoundRect );
xRet->SetMergedItemSet(aSet);
@@ -4914,7 +4914,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
xRet->SetName(aObjName);
}
- xRet.reset(ProcessObj(rSt, aObjData, rClientData, aTextRect, xRet.release()));
+ xRet = ProcessObj(rSt, aObjData, rClientData, aTextRect, xRet.get());
if (xRet)
{
@@ -4950,9 +4950,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
else
{
- xRet.reset(FinalizeObj(aObjData, xRet.release()));
+ xRet = FinalizeObj(aObjData, xRet.get());
}
- return xRet.release();
+ return xRet;
}
tools::Rectangle SvxMSDffManager::GetGlobalChildAnchor( const DffRecordHeader& rHd, SvStream& rSt, tools::Rectangle& aClientRect )
@@ -5114,7 +5114,7 @@ void SvxMSDffImportData::insert(std::unique_ptr<SvxMSDffImportRec> pImpRec)
if (bSuccess)
{
SvxMSDffImportRec* pRec = aRet.first->get();
- m_ObjToRecMap[pRec->pObj] = pRec;
+ m_ObjToRecMap[pRec->pObj.get()] = pRec;
}
}
@@ -5143,16 +5143,16 @@ void SvxMSDffManager::NotifyFreeObj(SvxMSDffClientData& rData, SdrObject* pObj)
void SvxMSDffManager::FreeObj(SvxMSDffClientData& rData, SdrObject* pObj)
{
NotifyFreeObj(rData, pObj);
- SdrObject::Free(pObj);
}
-SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
+rtl::Reference<SdrObject> SvxMSDffManager::ProcessObj(SvStream& rSt,
DffObjData& rObjData,
SvxMSDffClientData& rData,
tools::Rectangle& rTextRect,
- SdrObject* pObj
+ SdrObject* pObj1
)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if( !rTextRect.IsEmpty() )
{
SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
@@ -5229,8 +5229,8 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
}
// text frame, also Title or Outline
- SdrObject* pOrgObj = pObj;
- SdrRectObj* pTextObj = nullptr;
+ rtl::Reference<SdrObject> pOrgObj = pObj;
+ rtl::Reference<SdrRectObj> pTextObj;
sal_uInt32 nTextId = GetPropertyValue( DFF_Prop_lTxid, 0 );
if( nTextId )
{
@@ -5259,8 +5259,8 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
if (bTextFrame)
{
- SdrObject::Free( pObj );
- pObj = pOrgObj = nullptr;
+ pObj = nullptr;
+ pOrgObj = nullptr;
}
// Distance of Textbox to its surrounding Customshape
@@ -5497,20 +5497,20 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
if( !pObj )
{
- pObj = pTextObj;
+ pObj = pTextObj.get();
}
else
{
- if( pTextObj != pObj )
+ if( pTextObj.get() != pObj.get() )
{
- SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
- pGroup->GetSubList()->NbcInsertObject( pObj );
- pGroup->GetSubList()->NbcInsertObject( pTextObj );
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(*pSdrModel);
+ pGroup->GetSubList()->NbcInsertObject( pObj.get() );
+ pGroup->GetSubList()->NbcInsertObject( pTextObj.get() );
if (pOrgObj == pObj)
pOrgObj = pGroup;
else
pOrgObj = pObj;
- pObj = pGroup;
+ pObj = pGroup.get();
}
}
}
@@ -5623,7 +5623,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
// amend the import record list
if( pOrgObj )
{
- pImpRec->pObj = pOrgObj;
+ pImpRec->pObj = pOrgObj.get();
rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pImpRec));
bDeleteImpRec = false;
if (pImpRec == pTextImpRec)
@@ -5634,7 +5634,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
{
// Modify ShapeId (must be unique)
pImpRec->nShapeId |= 0x8000000;
- pTextImpRec->pObj = pTextObj;
+ pTextImpRec->pObj = pTextObj.get();
rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pTextImpRec));
bDeleteTextImpRec = false;
if (pTextImpRec == pImpRec)
@@ -5650,7 +5650,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
)
StoreShapeOrder( pImpRec->nShapeId,
( static_cast<sal_uLong>(pImpRec->aTextId.nTxBxS) << 16 )
- + pImpRec->aTextId.nSequence, pObj );
+ + pImpRec->aTextId.nSequence, pObj.get() );
}
if (bDeleteImpRec)
@@ -6354,7 +6354,7 @@ bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
Access to a shape at runtime (via the Shape-Id)
----------------------------
******************************************************************************/
-bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
+bool SvxMSDffManager::GetShape(sal_uLong nId, rtl::Reference<SdrObject>& rpShape,
SvxMSDffImportData& rData)
{
auto const pTmpRec = std::make_shared<SvxMSDffShapeInfo>(0, nId);
@@ -6384,7 +6384,7 @@ bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
rStCtrl.Seek( nOldPosCtrl );
if( &rStCtrl != pStData && pStData )
pStData->Seek( nOldPosData );
- return ( nullptr != rpShape );
+ return bool( rpShape );
}
@@ -6733,13 +6733,13 @@ bool SvxMSDffManager::ShapeHasText( sal_uLong /* nShapeId */, sal_uLong /* nFile
}
// #i32596# - add new parameter <_nCalledByGroup>
-SdrObject* SvxMSDffManager::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
const int /* _nCalledByGroup */ ) const
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString sStorageName;
tools::SvRef<SotStorage> xSrcStg;
ErrCode nError = ERRCODE_NONE;
@@ -7254,7 +7254,7 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo
}
// TODO/MBA: code review and testing!
-SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
+rtl::Reference<SdrOle2Obj> SvxMSDffManager::CreateSdrOLEFromStorage(
SdrModel& rSdrModel,
const OUString& rStorageName,
tools::SvRef<SotStorage> const & rSrcStorage,
@@ -7269,7 +7269,7 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
OUString const& rBaseURL)
{
sal_Int64 nAspect = nRecommendedAspect;
- SdrOle2Obj* pRet = nullptr;
+ rtl::Reference<SdrOle2Obj> pRet;
if( rSrcStorage.is() && xDestStorage.is() && rStorageName.getLength() )
{
comphelper::EmbeddedObjectContainer aCnt( xDestStorage );
@@ -7476,8 +7476,7 @@ bool SvxMSDffManager::SetPropValue( const uno::Any& rAny, const uno::Reference<
}
SvxMSDffImportRec::SvxMSDffImportRec()
- : pObj( nullptr ),
- nClientAnchorLen( 0 ),
+ : nClientAnchorLen( 0 ),
nClientDataLen( 0 ),
nXAlign( 0 ), // position n cm from left
nYAlign( 0 ), // position n cm below
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index d5ee7986b242..4511789b0586 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -494,7 +494,6 @@ PptSlidePersistEntry::PptSlidePersistEntry() :
nSlidePersistEndOffset ( 0 ),
nBackgroundOffset ( 0 ),
nDrawingDgId ( 0xffffffff ),
- pBObj ( nullptr ),
ePageKind ( PPT_MASTERPAGE ),
bNotesMaster ( false ),
bHandoutMaster ( false ),
@@ -729,13 +728,13 @@ void ProcessData::NotifyFreeObj(SdrObject* pObj)
The parameter pOriginalObj is the object as it was imported by our general escher import, it must either
be deleted or it can be returned to be inserted into the sdr page.
*/
-SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pOriginalObj )
+rtl::Reference<SdrObject> SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pOriginalObj )
{
if ( dynamic_cast<const SdrObjCustomShape* >(pOriginalObj) != nullptr )
pOriginalObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
// we are initializing our return value with the object that was imported by our escher import
- SdrObject* pRet = pOriginalObj;
+ rtl::Reference<SdrObject> pRet = pOriginalObj;
ProcessData& rData = static_cast<ProcessData&>(rClientData);
PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
@@ -780,7 +779,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
case PPT_PST_RecolorInfoAtom :
{
- if ( auto pSdrGrafObj = dynamic_cast<SdrGrafObj* >(pRet) )
+ if ( auto pSdrGrafObj = dynamic_cast<SdrGrafObj* >(pRet.get()) )
if ( pSdrGrafObj->HasGDIMetaFile() )
{
Graphic aGraphic( pSdrGrafObj->GetGraphic() );
@@ -801,7 +800,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
nPageNum--;
// replacing the object which we will return with a SdrPageObj
- SdrObject::Free( pRet );
pRet = new SdrPageObj(
*pSdrModel,
rObjData.aBoundRect,
@@ -849,10 +847,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
if ( pRet )
{
bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != nullptr;
- if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet) == nullptr // we are not allowed to get
- && dynamic_cast<const SdrObjGroup* >(pRet) == nullptr // grouped placeholder objects
- && dynamic_cast<const SdrOle2Obj* >(pRet) == nullptr )
- SdrObject::Free( pRet );
+ if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet.get()) == nullptr // we are not allowed to get
+ && dynamic_cast<const SdrObjGroup* >(pRet.get()) == nullptr // grouped placeholder objects
+ && dynamic_cast<const SdrOle2Obj* >(pRet.get()) == nullptr )
+ {
+ pRet = nullptr;
+ }
}
sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
@@ -1049,11 +1049,11 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
eTextKind = SdrObjKind::Rectangle;
}
}
- SdrObject* pTObj = nullptr;
+ rtl::Reference<SdrObject> pTObj;
bool bWordWrap = GetPropertyValue(DFF_Prop_WrapText, mso_wrapSquare) != mso_wrapNone;
bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape, 0 ) & 2 ) != 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr && ( eTextKind == SdrObjKind::Rectangle ) )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pRet.get()) != nullptr && ( eTextKind == SdrObjKind::Rectangle ) )
{
bAutoGrowHeight = bFitShapeToText;
bAutoGrowWidth = !bWordWrap;
@@ -1062,9 +1062,8 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
}
else
{
- if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pRet.get()) != nullptr )
{
- SdrObject::Free( pRet );
pRet = nullptr;
}
pTObj = new SdrRectObj(
@@ -1103,7 +1102,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
}
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
{
pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
@@ -1119,12 +1118,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
if ( nMinFrameHeight < 0 )
nMinFrameHeight = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
if ( nMinFrameWidth < 0 )
nMinFrameWidth = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
// set margins at the borders of the textbox
@@ -1134,9 +1133,9 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetSnapRect( rTextRect );
- pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
+ pTObj = ReadObjText( &aTextObj, pTObj.get(), rData.pPage );
if ( pTObj )
{
@@ -1146,9 +1145,9 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
snaprect of the object. Then we will use
ADJUST_CENTER instead of ADJUST_BLOCK.
*/
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr && !bFitShapeToText && !bWordWrap )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr && !bFitShapeToText && !bWordWrap )
{
- SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj );
+ SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj.get() );
if ( pText )
{
if ( bVerticalText )
@@ -1179,7 +1178,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
Degree100 nAngle = ( rObjData.nSpFlags & ShapeFlag::FlipV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
nAngle += nTextRotationAngle;
- if ( dynamic_cast< const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast< const SdrObjCustomShape* >(pTObj.get()) == nullptr )
{
if ( rObjData.nSpFlags & ShapeFlag::FlipV )
{
@@ -1192,13 +1191,13 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
}
if ( pRet )
{
- SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
- pGroup->GetSubList()->NbcInsertObject( pRet );
- pGroup->GetSubList()->NbcInsertObject( pTObj );
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(*pSdrModel);
+ pGroup->GetSubList()->NbcInsertObject( pRet.get() );
+ pGroup->GetSubList()->NbcInsertObject( pTObj.get() );
pRet = pGroup;
}
else
- pRet = pTObj;
+ pRet = pTObj.get();
}
}
}
@@ -1254,11 +1253,11 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
for (auto & pPtr : rPersistEntry.xSolverContainer->aCList)
{
if ( rObjData.nShapeId == pPtr->nShapeC )
- pPtr->pCObj = pRet;
+ pPtr->pCObj = pRet.get();
else
{
- SdrObject* pConnectObj = pRet;
- if ( pOriginalObj && dynamic_cast< const SdrObjGroup* >(pRet) != nullptr )
+ SdrObject* pConnectObj = pRet.get();
+ if ( pOriginalObj && dynamic_cast< const SdrObjGroup* >(pRet.get()) != nullptr )
{ /* check if the original object from the escherimport is part of the group object,
if this is the case, we will use the original object to connect to */
SdrObjListIter aIter( *pRet, SdrIterMode::DeepWithGroups );
@@ -1796,13 +1795,13 @@ static bool SdrPowerPointOLEDecompress( SvStream& rOutput, SvStream& rInput, sal
}
// #i32596# - add new parameter <_nCalledByGroup>
-SdrObject* SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGraf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
const int /*_nCalledByGroup*/ ) const
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
sal_uInt32 nOldPos = rStCtrl.Tell();
@@ -2908,16 +2907,16 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
aShapeHd.SeekToBegOfRecord( rStCtrl );
sal_Int32 nShapeId;
aProcessData.pTableRowProperties.reset();
- SdrObject* pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, 0, &nShapeId );
+ rtl::Reference<SdrObject> pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, 0, &nShapeId );
if ( pObj )
{
if ( aProcessData.pTableRowProperties )
- pObj = CreateTable(pObj, aProcessData.pTableRowProperties.get(), aProcessData.rPersistEntry.xSolverContainer.get(), aProcessData.aBackgroundColoredObjects);
+ pObj = CreateTable(pObj.get(), aProcessData.pTableRowProperties.get(), aProcessData.rPersistEntry.xSolverContainer.get(), aProcessData.aBackgroundColoredObjects);
- pRet->NbcInsertObject( pObj );
+ pRet->NbcInsertObject( pObj.get() );
if( nShapeId )
- insertShapeId( nShapeId, pObj );
+ insertShapeId( nShapeId, pObj.get() );
}
}
bool bSuccess = aShapeHd.SeekToEndOfRecord(rStCtrl);
@@ -2942,7 +2941,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
{
if (!rSlidePersist.pBObj)
{
- for (auto pObject : aProcessData.aBackgroundColoredObjects)
+ for (auto const & pObject : aProcessData.aBackgroundColoredObjects)
{
// The shape wants a background, but the slide doesn't have
// one: default to white.
@@ -2966,15 +2965,15 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
for (auto & pPtr : rSlidePersist.xSolverContainer->aCList)
{
// check connections to the group object
- if (pPtr->pAObj == rSlidePersist.pBObj)
+ if (pPtr->pAObj == rSlidePersist.pBObj.get())
pPtr->pAObj = nullptr;
- if (pPtr->pBObj == rSlidePersist.pBObj)
+ if (pPtr->pBObj == rSlidePersist.pBObj.get())
pPtr->pBObj = nullptr;
- if (pPtr->pCObj == rSlidePersist.pBObj)
+ if (pPtr->pCObj == rSlidePersist.pBObj.get())
pPtr->pCObj = nullptr;
}
}
- SdrObject::Free(rSlidePersist.pBObj);
+ rSlidePersist.pBObj.clear();
}
}
}
@@ -3048,9 +3047,9 @@ sal_uInt16 SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum, PptPage
return nIdx;
}
-SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset )
+rtl::Reference<SdrObject> SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
std::optional<SfxItemSet> pSet;
sal_uInt64 nOldFPos = rStCtrl.Tell(); // remember FilePos for restoring it later
DffRecordHeader aPageHd;
@@ -7517,9 +7516,12 @@ static void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >
}
}
-SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32* pTableArry, SvxMSDffSolverContainer* pSolverContainer, std::vector<SdrObject*>& rBackgroundColoredObjects)
+rtl::Reference<SdrObject> SdrPowerPointImport::CreateTable(
+ SdrObject* pGroup, const sal_uInt32* pTableArry,
+ SvxMSDffSolverContainer* pSolverContainer,
+ std::vector<rtl::Reference<SdrObject>>& rBackgroundColoredObjects)
{
- SdrObject* pRet = pGroup;
+ rtl::Reference<SdrObject> pRet = pGroup;
sal_uInt32 nRows = pTableArry[ 1 ];
if (!nRows)
@@ -7551,7 +7553,7 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
if (aRows.empty())
return pRet;
- sdr::table::SdrTableObj* pTable = new sdr::table::SdrTableObj(*pSdrModel);
+ rtl::Reference<sdr::table::SdrTableObj> pTable = new sdr::table::SdrTableObj(*pSdrModel);
pTable->uno_lock();
Reference< XTable > xTable( pTable->getTable() );
@@ -7656,9 +7658,9 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
//table when export by us. We should process this
//situation when importing.
if ( pPtr->pAObj == pGroup )
- pPtr->pAObj = pTable;
+ pPtr->pAObj = pTable.get();
if ( pPtr->pBObj == pGroup )
- pPtr->pBObj = pTable;
+ pPtr->pBObj = pTable.get();
}
}
pTable->uno_unlock();
@@ -7672,16 +7674,13 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
SdrObject* pPartObj = aIter.Next();
removeShapeId(pPartObj);
// ofz#41510 make sure rBackgroundColoredObjects doesn't contain deleted objects
- std::replace(rBackgroundColoredObjects.begin(), rBackgroundColoredObjects.end(), pPartObj, pRet);
+ std::replace(rBackgroundColoredObjects.begin(), rBackgroundColoredObjects.end(), pPartObj, pRet.get());
}
-
- SdrObject::Free( pGroup );
}
catch( const Exception& )
{
pTable->uno_unlock();
- SdrObject* pObj = pTable;
- SdrObject::Free( pObj );
+ pTable = nullptr;
}
return pRet;
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 295c9dedbd93..023486f01879 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -860,8 +860,8 @@ bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSu
if(pSvxDrawPage == nullptr || pSvxDrawPage->GetSdrPage() == nullptr)
return false;
- SdrGrafObj* pGraphicObj = new SdrGrafObj(pSvxDrawPage->GetSdrPage()->getSdrModelFromSdrPage(), aGraphic, tools::Rectangle( aPos, aSize ));
- uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject(pGraphicObj);
+ rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(pSvxDrawPage->GetSdrPage()->getSdrModelFromSdrPage(), aGraphic, tools::Rectangle( aPos, aSize ));
+ uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject(pGraphicObj.get());
uno::Reference< XPropertySet > xShapePropSet(xShape, uno::UNO_QUERY);
xShapePropSet->setPropertyValue("Graphic", uno::Any(xGraphic));
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index bb87989bab2f..963a9ae2c4d4 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -291,15 +291,15 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto
// create a SdrModel-GraphicObject to insert to page
SdrPage* pTargetSdrPage(pSvxDrawPage->GetSdrPage());
- std::unique_ptr< SdrGrafObj, SdrObjectFreeOp > aNewSdrGrafObj;
+ rtl::Reference< SdrGrafObj > aNewSdrGrafObj;
// tdf#118232 only add an SdrGrafObj when we have Geometry
if(!bContainsNoGeometry)
{
- aNewSdrGrafObj.reset(
+ aNewSdrGrafObj =
new SdrGrafObj(
pTargetSdrPage->getSdrModelFromSdrPage(),
- aGraphic));
+ aGraphic);
}
// Evtl. adapt the GraphicPrefSize to target-MapMode of target-Model
@@ -355,7 +355,7 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto
aGraphicSize));
// insert to page (owner change of SdrGrafObj)
- pTargetSdrPage->InsertObject(aNewSdrGrafObj.release());
+ pTargetSdrPage->InsertObject(aNewSdrGrafObj.get());
}
// done - set positive result now
diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index 536c3116715f..582335f3d71e 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -36,6 +36,7 @@
#include <svl/undo.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <osl/conditn.hxx>
+#include <vcl/svapp.hxx>
#include <functional>
#include <mutex>
@@ -687,6 +688,7 @@ namespace framework
{
::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning );
+ SolarMutexGuard aGuard2;
rUndoManager.Clear();
}
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 3dfd170bcb2a..492c64ebf724 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -37,6 +37,7 @@
#include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/msfilterdllapi.h>
#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
#include <sal/types.h>
#include <svx/msdffdef.hxx>
#include <vcl/errcode.hxx>
@@ -215,7 +216,7 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
{
static const int RELTO_DEFAULT = 2;
- SdrObject* pObj;
+ rtl::Reference<SdrObject> pObj;
std::optional<tools::Polygon>
pWrapPolygon;
std::unique_ptr<char[]>
@@ -480,11 +481,11 @@ protected:
sal_uInt64 nPosGroup,
sal_uInt16 nDrawingContainerId );
- SdrObject* ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
+ rtl::Reference<SdrObject> ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
// #i32596# - pass <nCalledByGroup> to method
// Needed in Writer's Microsoft Word import to avoid import of OLE objects
// inside groups. Instead a graphic object is created.
- virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
+ virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGraf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -508,7 +509,7 @@ protected:
sal_uInt32 nDatLen,
std::unique_ptr<char[]>& rpBuff,
sal_uInt32& rBuffLen );
- virtual SdrObject* ProcessObj( SvStream& rSt,
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt,
DffObjData& rData,
SvxMSDffClientData& rClientData,
tools::Rectangle& rTextRect,
@@ -662,22 +663,22 @@ public:
*/
static bool GetBLIPDirect(SvStream& rBLIPStream, Graphic& rData, tools::Rectangle* pVisArea = nullptr );
- bool GetShape(sal_uLong nId, SdrObject*& rpData, SvxMSDffImportData& rData);
+ bool GetShape(sal_uLong nId, rtl::Reference<SdrObject>& rpData, SvxMSDffImportData& rData);
- SdrObject* ImportObj( SvStream& rSt,
+ rtl::Reference<SdrObject> ImportObj( SvStream& rSt,
SvxMSDffClientData& rData,
tools::Rectangle& rClientRect,
const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup,
sal_Int32* pShapeId);
- SdrObject* ImportGroup( const DffRecordHeader& rHd,
+ rtl::Reference<SdrObject> ImportGroup( const DffRecordHeader& rHd,
SvStream& rSt,
SvxMSDffClientData& rData,
tools::Rectangle& rClientRect,
const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup,
sal_Int32* pShapeId );
- SdrObject* ImportShape( const DffRecordHeader& rHd,
+ rtl::Reference<SdrObject> ImportShape( const DffRecordHeader& rHd,
SvStream& rSt,
SvxMSDffClientData& rData,
tools::Rectangle& rClientRect,
@@ -712,7 +713,7 @@ public:
void RemoveFromShapeOrder( SdrObject const * pObject ) const;
- static SdrOle2Obj* CreateSdrOLEFromStorage(
+ static rtl::Reference<SdrOle2Obj> CreateSdrOLEFromStorage(
SdrModel& rSdrModel,
const OUString& rStorageName,
tools::SvRef<SotStorage> const & rSrcStorage,
diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx
index 6fa9ffaf4d59..6ac77727a2d7 100644
--- a/include/filter/msfilter/svdfppt.hxx
+++ b/include/filter/msfilter/svdfppt.hxx
@@ -374,7 +374,7 @@ struct PptSlidePersistEntry
std::unique_ptr<sal_uInt32[]>
pPresentationObjects; // if valid, this is a pointer to an array that includes the offsets to the presentation objects
// on this masterpage for each instance (0 - 8);
- SdrObject* pBObj;
+ rtl::Reference<SdrObject> pBObj;
PptPageKind ePageKind;
@@ -491,7 +491,7 @@ public:
const PptFontEntityAtom* GetFontEnityAtom( sal_uInt32 nNum ) const;
void RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic& rGraph );
virtual SdrObject* ReadObjText( PPTTextObj* pTextObj, SdrObject* pObj, SdPageCapsule pPage ) const;
- virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
virtual void ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, DffObjData& rObj ) override;
void ImportHeaderFooterContainer( DffRecordHeader const & rHeader, HeaderFooterEntry& rEntry );
};
@@ -542,7 +542,7 @@ struct MSFILTER_DLLPUBLIC ProcessData final : public SvxMSDffClientData
{
PptSlidePersistEntry& rPersistEntry;
SdPageCapsule pPage;
- ::std::vector< SdrObject* > aBackgroundColoredObjects;
+ ::std::vector< rtl::Reference<SdrObject> > aBackgroundColoredObjects;
std::unique_ptr<sal_uInt32[]> pTableRowProperties;
ProcessData( PptSlidePersistEntry& rP, SdPageCapsule pP ) :
@@ -605,7 +605,7 @@ protected:
virtual SdrObject* ReadObjText( PPTTextObj* pTextObj, SdrObject* pObj, SdPageCapsule pPage ) const override;
// #i32596# - new parameter <_nCalledByGroup>, which
// indicates, if the OLE object is imported inside a group object.
- virtual SdrObject* ImportOLE(
+ virtual rtl::Reference<SdrObject> ImportOLE(
sal_uInt32 nOLEId,
const Graphic& rGraf,
const tools::Rectangle& rBoundRect,
@@ -631,7 +631,7 @@ public:
sal_uInt16 GetPageCount( PptPageKind eKind = PPT_SLIDEPAGE ) const;
void SetPageNum( sal_uInt16 nPageNum, PptPageKind = PPT_SLIDEPAGE );
Size GetPageSize() const;
- SdrObject* ImportPageBackgroundObject(
+ rtl::Reference<SdrObject> ImportPageBackgroundObject(
const SdrPage& rPage,
sal_uInt32& nBgFileOffset
);
@@ -649,11 +649,11 @@ public:
virtual bool GetColorFromPalette(sal_uInt16 nNum, Color& rColor) const override;
virtual bool SeekToShape( SvStream& rSt, SvxMSDffClientData* pClientData, sal_uInt32 nId ) const override;
virtual const PptSlideLayoutAtom* GetSlideLayoutAtom() const override;
- SdrObject* CreateTable(
+ rtl::Reference<SdrObject> CreateTable(
SdrObject* pGroupObject,
const sal_uInt32* pTableArry,
SvxMSDffSolverContainer* pSolverContainer,
- std::vector<SdrObject*>& rBackgroundColoredObjects
+ std::vector<rtl::Reference<SdrObject>>& rBackgroundColoredObjects
);
virtual bool ReadFormControl( tools::SvRef<SotStorage>& rSrc1, css::uno::Reference< css::form::XFormComponent > & rFormComp ) const = 0;
};
diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx
index abe9319407ff..7855daacbeae 100644
--- a/include/svx/EnhancedCustomShape2d.hxx
+++ b/include/svx/EnhancedCustomShape2d.hxx
@@ -142,11 +142,11 @@ class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet
SAL_DLLPRIVATE void CreateSubPath(
sal_Int32& rSrcPt,
sal_Int32& rSegmentInd,
- std::vector< std::pair< SdrPathObjUniquePtr, double> >& rObjectList,
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double> >& rObjectList,
bool bLineGeometryNeededOnly,
bool bSortFilledObjectsToBack,
sal_Int32 nIndex);
- SAL_DLLPRIVATE SdrObjectUniquePtr CreatePathObj( bool bLineGeometryNeededOnly );
+ SAL_DLLPRIVATE rtl::Reference<SdrObject> CreatePathObj( bool bLineGeometryNeededOnly );
SAL_DLLPRIVATE void ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
SAL_DLLPRIVATE void SetPathSize( sal_Int32 nIndex = 0 );
@@ -187,8 +187,8 @@ class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet
SAL_DLLPRIVATE bool IsFlipHorz() const { return bFlipH; };
SAL_DLLPRIVATE Degree100 GetRotateAngle() const { return nRotateAngle; };
- SdrObjectUniquePtr CreateLineGeometry();
- SdrObjectUniquePtr CreateObject( bool bLineGeometryNeededOnly );
+ rtl::Reference<SdrObject> CreateLineGeometry();
+ rtl::Reference<SdrObject> CreateObject( bool bLineGeometryNeededOnly );
void ApplyGluePoints( SdrObject* pObj );
tools::Rectangle GetTextRect() const;
const tools::Rectangle& GetLogicRect() const { return aLogicRect; }
diff --git a/include/svx/compressgraphicdialog.hxx b/include/svx/compressgraphicdialog.hxx
index 073b330cda2d..3319a41a431c 100644
--- a/include/svx/compressgraphicdialog.hxx
+++ b/include/svx/compressgraphicdialog.hxx
@@ -95,7 +95,7 @@ public:
CompressGraphicsDialog( weld::Window* pParent, Graphic aGraphic, Size aViewSize100mm, tools::Rectangle const & rCropRectangle, SfxBindings& rBindings );
virtual ~CompressGraphicsDialog() override;
- SdrGrafObj* GetCompressedSdrGrafObj();
+ rtl::Reference<SdrGrafObj> GetCompressedSdrGrafObj();
Graphic GetCompressedGraphic();
tools::Rectangle GetScaledCropRectangle() const;
diff --git a/include/svx/connctrl.hxx b/include/svx/connctrl.hxx
index 44768922f317..8e416674b1b2 100644
--- a/include/svx/connctrl.hxx
+++ b/include/svx/connctrl.hxx
@@ -40,7 +40,7 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXConnectionPreview final : public weld::C
private:
MapMode aNewMapMode;
- SdrEdgeObj* pEdgeObj;
+ rtl::Reference<SdrEdgeObj> pEdgeObj;
rtl::Reference<SdrPage> mxSdrPage;
const SdrView* pView;
diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx
index 9842b26f0e55..b984a74c65d9 100644
--- a/include/svx/cube3d.hxx
+++ b/include/svx/cube3d.hxx
@@ -69,9 +69,9 @@ public:
E3dCubeObj(SdrModel& rSdrModel);
virtual SdrObjKind GetObjIdentifier() const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
- virtual E3dCubeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
// Set local parameters with geometry recreation
void SetCubePos(const basegfx::B3DPoint& rNew);
diff --git a/include/svx/dlgctl3d.hxx b/include/svx/dlgctl3d.hxx
index afa246b1601a..5d6449e63cee 100644
--- a/include/svx/dlgctl3d.hxx
+++ b/include/svx/dlgctl3d.hxx
@@ -41,8 +41,8 @@ protected:
std::unique_ptr<FmFormModel> mpModel;
rtl::Reference<FmFormPage> mxFmPage;
std::unique_ptr<E3dView> mp3DView;
- E3dScene* mpScene;
- E3dObject* mp3DObj;
+ rtl::Reference<E3dScene> mpScene;
+ rtl::Reference<E3dObject> mp3DObj;
SvxPreviewObjectType mnObjectType;
void Construct();
@@ -72,9 +72,9 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DLightControl final : public Svx3DPrevie
sal_uInt32 maSelectedLight;
// extra objects for light control
- E3dObject* mpExpansionObject;
- E3dObject* mpLampBottomObject;
- E3dObject* mpLampShaftObject;
+ rtl::Reference<E3dObject> mpExpansionObject;
+ rtl::Reference<E3dObject> mpLampBottomObject;
+ rtl::Reference<E3dObject> mpLampShaftObject;
std::vector< E3dObject* > maLightObjects;
// 3d rotations of object
diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx
index 9787e025f915..26371185c7f0 100644
--- a/include/svx/dlgctrl.hxx
+++ b/include/svx/dlgctrl.hxx
@@ -333,9 +333,9 @@ public:
class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview final : public SvxPreviewBase
{
private:
- SdrPathObj* mpLineObjA;
- SdrPathObj* mpLineObjB;
- SdrPathObj* mpLineObjC;
+ rtl::Reference<SdrPathObj> mpLineObjA;
+ rtl::Reference<SdrPathObj> mpLineObjB;
+ rtl::Reference<SdrPathObj> mpLineObjC;
Graphic* mpGraphic;
bool mbWithSymbol;
@@ -359,7 +359,7 @@ public:
class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXRectPreview final : public SvxPreviewBase
{
private:
- SdrObject* mpRectangleObject;
+ rtl::Reference<SdrObject> mpRectangleObject;
public:
SvxXRectPreview();
@@ -383,8 +383,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview final : public SvxPreviewB
private:
Point maShadowOffset;
- SdrObject* mpRectangleObject;
- SdrObject* mpRectangleShadow;
+ rtl::Reference<SdrObject> mpRectangleObject;
+ rtl::Reference<SdrObject> mpRectangleShadow;
public:
SvxXShadowPreview();
diff --git a/include/svx/extedit.hxx b/include/svx/extedit.hxx
index 0168068f66c8..04fd9dfb8e54 100644
--- a/include/svx/extedit.hxx
+++ b/include/svx/extedit.hxx
@@ -13,6 +13,7 @@
#include <svx/svxdllapi.h>
#include <svl/lstner.hxx>
#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
#include <memory>
class Graphic;
@@ -41,6 +42,7 @@ public:
class FmFormView;
class SdrObject;
+class SdrGrafObj;
class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SdrExternalToolEdit final
: public ExternalToolEdit
@@ -48,7 +50,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SdrExternalToolEdit final
{
private:
FmFormView* m_pView;
- SdrObject* m_pObj;
+ rtl::Reference<SdrGrafObj> m_pObj;
SAL_DLLPRIVATE virtual void Update(Graphic&) override;
SAL_DLLPRIVATE virtual void Notify(SfxBroadcaster&, const SfxHint&) override;
@@ -56,7 +58,7 @@ private:
public:
SdrExternalToolEdit(
FmFormView* pView,
- SdrObject* pObj);
+ SdrGrafObj* pObj);
};
#endif
diff --git a/include/svx/fmdpage.hxx b/include/svx/fmdpage.hxx
index ae864e611528..3842e8b0b02e 100644
--- a/include/svx/fmdpage.hxx
+++ b/include/svx/fmdpage.hxx
@@ -34,7 +34,7 @@ protected:
// Creating a SdrObject based on a Description. Can be used by derived classes to
// support own css::drawing::Shapes (for example Controls)
- virtual SdrObject *CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xShape ) override;
+ virtual rtl::Reference<SdrObject> CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xShape ) override;
// The following method is called when a SvxShape object should be created.
// Derived classes can create a derivation or an object aggregating SvxShape.
diff --git a/include/svx/fmobjfac.hxx b/include/svx/fmobjfac.hxx
index f165cf7b2247..003f6b258642 100644
--- a/include/svx/fmobjfac.hxx
+++ b/include/svx/fmobjfac.hxx
@@ -22,6 +22,7 @@
#include <tools/link.hxx>
#include <svx/svxdllapi.h>
+#include <rtl/ref.hxx>
class SdrObject;
struct SdrObjCreatorParams;
@@ -31,7 +32,8 @@ class SVX_DLLPUBLIC FmFormObjFactory
public:
FmFormObjFactory();
- DECL_DLLPRIVATE_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_DLLPRIVATE_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams,
+ rtl::Reference<SdrObject>);
};
#endif // _FM_FMOBJFAC_HXX
diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx
index f8b3c11cb72f..1f2978c05c75 100644
--- a/include/svx/fmpage.hxx
+++ b/include/svx/fmpage.hxx
@@ -54,7 +54,7 @@ public:
virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE) override;
- virtual SdrObject* RemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum) override;
// access to all forms
const css::uno::Reference< css::form::XForms>& GetForms( bool _bForceCreate = true ) const;
diff --git a/include/svx/fmview.hxx b/include/svx/fmview.hxx
index 77928837d7d7..2c2b26f20f41 100644
--- a/include/svx/fmview.hxx
+++ b/include/svx/fmview.hxx
@@ -71,15 +71,15 @@ public:
@deprecated
This method is deprecated. Use the version with an ODataAccessDescriptor instead.
*/
- SdrObjectUniquePtr CreateFieldControl(std::u16string_view rFieldDesc) const;
+ rtl::Reference<SdrObject> CreateFieldControl(std::u16string_view rFieldDesc) const;
/** create a control pair (label/bound control) for the database field description given.
*/
- SdrObjectUniquePtr CreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
+ rtl::Reference<SdrObject> CreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
/** create a control pair (label/bound control) for the xforms description given.
*/
- SdrObjectUniquePtr CreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
+ rtl::Reference<SdrObject> CreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
virtual void MarkListHasChanged() override;
virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) override;
@@ -99,8 +99,8 @@ public:
// demand clear, hand over a SdrMldel&
SdrModel& _rModel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl
+ rtl::Reference<SdrUnoObj>& _rpLabel,
+ rtl::Reference<SdrUnoObj>& _rpControl
);
virtual SdrPageView* ShowSdrPage(SdrPage* pPage) override;
diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx
index 78e0370dbac5..1eb90f6476e0 100644
--- a/include/svx/fontworkgallery.hxx
+++ b/include/svx/fontworkgallery.hxx
@@ -49,7 +49,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog final : public wel
SdrView& mrSdrView;
bool mbInsertIntoPage;
- SdrObject* mpSdrObject;
+ rtl::Reference<SdrObject> mxSdrObject;
SdrModel* mpDestModel;
std::vector<VclPtr< VirtualDevice >> maFavoritesHorizontal;
@@ -70,7 +70,7 @@ public:
// SJ: if the SdrObject** is set, the SdrObject is not inserted into the page when executing the dialog
void SetSdrObjectRef( SdrModel* pModel );
- SdrObject* GetSdrObjectRef() { return mpSdrObject; }
+ SdrObject* GetSdrObjectRef() { return mxSdrObject.get(); }
};
}
diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx
index 7b1396a68ac4..9bd17307ceee 100644
--- a/include/svx/lathe3d.hxx
+++ b/include/svx/lathe3d.hxx
@@ -101,9 +101,9 @@ public:
virtual SdrObjKind GetObjIdentifier() const override;
- virtual E3dLatheObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
// TakeObjName...() is for the display in the UI, for example "3 frames selected".
virtual OUString TakeObjNameSingul() const override;
@@ -115,7 +115,7 @@ public:
// break up
virtual bool IsBreakObjPossible() override;
- virtual std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> GetBreakObj() override;
+ virtual rtl::Reference<SdrAttrObj> GetBreakObj() override;
};
#endif // INCLUDED_SVX_LATHE3D_HXX
diff --git a/include/svx/measctrl.hxx b/include/svx/measctrl.hxx
index ccdcab46f5fd..a6f25718596b 100644
--- a/include/svx/measctrl.hxx
+++ b/include/svx/measctrl.hxx
@@ -35,7 +35,7 @@ class SVX_DLLPUBLIC SvxXMeasurePreview final : public weld::CustomWidgetControll
private:
MapMode m_aMapMode;
std::unique_ptr<SdrModel> pModel;
- std::unique_ptr<SdrMeasureObj, SdrObjectFreeOp> pMeasureObj;
+ rtl::Reference<SdrMeasureObj> pMeasureObj;
void ResizeImpl(const Size& rSize);
diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx
index 29feec983475..13ffc73c9879 100644
--- a/include/svx/obj3d.hxx
+++ b/include/svx/obj3d.hxx
@@ -125,7 +125,7 @@ public:
// TakeObjName...() is for the display in the UI, for example "3 frames selected".
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual E3dObject* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
@@ -137,7 +137,7 @@ public:
// break up
virtual bool IsBreakObjPossible();
- virtual std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> GetBreakObj();
+ virtual rtl::Reference<SdrAttrObj> GetBreakObj();
};
/*************************************************************************
@@ -180,7 +180,7 @@ public:
virtual SdrObjKind GetObjIdentifier() const override;
virtual void RecalcSnapRect() override;
- virtual E3dCompoundObject* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
};
#endif // INCLUDED_SVX_OBJ3D_HXX
diff --git a/include/svx/objfac3d.hxx b/include/svx/objfac3d.hxx
index 24b14de5a46b..084782e66069 100644
--- a/include/svx/objfac3d.hxx
+++ b/include/svx/objfac3d.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_SVX_OBJFAC3D_HXX
#define INCLUDED_SVX_OBJFAC3D_HXX
+#include <rtl/ref.hxx>
#include <svx/svxdllapi.h>
#include <tools/link.hxx>
@@ -37,7 +38,8 @@ class SVXCORE_DLLPUBLIC E3dObjFactory
public:
E3dObjFactory();
- DECL_DLLPRIVATE_STATIC_LINK(E3dObjFactory, MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_DLLPRIVATE_STATIC_LINK(E3dObjFactory, MakeObject, SdrObjCreatorParams,
+ rtl::Reference<SdrObject>);
};
#endif // INCLUDED_SVX_OBJFAC3D_HXX
diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx
index 8903e3bd4f2d..866edc612fc5 100644
--- a/include/svx/scene3d.hxx
+++ b/include/svx/scene3d.hxx
@@ -77,12 +77,10 @@ class SVXCORE_DLLPUBLIC E3dScene final : public E3dObject, public SdrObjList
void SetDefaultAttributes();
void ImpCleanup3DDepthMapper();
- // protected destructor
- virtual ~E3dScene() override;
-
public:
E3dScene(SdrModel& rSdrModel);
E3dScene(SdrModel& rSdrModel, E3dScene const &);
+ virtual ~E3dScene() override;
virtual void StructureChanged() override;
@@ -127,7 +125,7 @@ public:
const Camera3D& GetCamera() const { return aCamera; }
void removeAllNonSelectedObjects();
- virtual E3dScene* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
@@ -170,8 +168,8 @@ public:
// derived from SdrObjList
virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
- virtual SdrObject* NbcRemoveObject(size_t nObjNum) override;
- virtual SdrObject* RemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> NbcRemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum) override;
// needed for group functionality
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself = false, bool bRecursive = true) override;
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index ab9f1d28f0c6..e71eba7cf608 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -28,6 +28,8 @@
#include <svx/svdotable.hxx>
#include <svx/svdview.hxx>
#include <optional>
+#include <unotools/weakref.hxx>
+#include <memory>
struct ImplSVEvent;
class SdrView;
@@ -98,7 +100,7 @@ public:
SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const override;
SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) override;
- SVX_DLLPRIVATE virtual SdrObject* GetMarkedSdrObjClone( SdrModel& rTargetModel ) override;
+ SVX_DLLPRIVATE virtual rtl::Reference<SdrObject> GetMarkedSdrObjClone( SdrModel& rTargetModel ) override;
SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) override;
SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mrView.IsTextEdit(); }
@@ -124,7 +126,7 @@ public:
bool isColumnSelected( sal_Int32 nColumn );
bool isRowHeader();
bool isColumnHeader();
- sdr::table::SdrTableObj* GetTableObj() { return mxTableObj.get(); }
+ sdr::table::SdrTableObj* GetTableObj() { return mxTableObj.get().get(); }
private:
SvxTableController(SvxTableController const &) = delete;
SvxTableController& operator =(SvxTableController const &) = delete;
@@ -184,7 +186,7 @@ private:
bool mbLeftButtonDown;
std::optional<sdr::overlay::OverlayObjectList> mpSelectionOverlay;
SdrView& mrView;
- tools::WeakReference<SdrTableObj> mxTableObj;
+ unotools::WeakReference<SdrTableObj> mxTableObj;
css::uno::Reference< css::util::XModifyListener > mxModifyListener;
ImplSVEvent * mnUpdateEvent;
};
diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx
index 57dec07b9fd6..97adb57542c5 100644
--- a/include/svx/selectioncontroller.hxx
+++ b/include/svx/selectioncontroller.hxx
@@ -22,6 +22,7 @@
#include <svx/svxdllapi.h>
#include <cppuhelper/weak.hxx>
+#include <rtl/ref.hxx>
class KeyEvent;
class MouseEvent;
@@ -62,7 +63,7 @@ public:
virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
- virtual SdrObject* GetMarkedSdrObjClone( SdrModel& rTargetModel );
+ virtual rtl::Reference<SdrObject> GetMarkedSdrObjClone( SdrModel& rTargetModel );
virtual bool PasteObjModel( const SdrModel& rModel );
/** applies a format paint brush set from the current selection.
diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx
index 4de73c1aa87f..3e0ff95bba4e 100644
--- a/include/svx/sphere3d.hxx
+++ b/include/svx/sphere3d.hxx
@@ -68,9 +68,9 @@ public:
{ return GetObjectItemSet().Get(SDRATTR_3DOBJ_VERT_SEGS).GetValue(); }
virtual SdrObjKind GetObjIdentifier() const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
- virtual E3dSphereObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
const basegfx::B3DPoint& Center() const { return aCenter; }
const basegfx::B3DVector& Size() const { return aSize; }
diff --git a/include/svx/svdcrtv.hxx b/include/svx/svdcrtv.hxx
index b7f7a5938f97..12a291c23328 100644
--- a/include/svx/svdcrtv.hxx
+++ b/include/svx/svdcrtv.hxx
@@ -37,7 +37,7 @@ class SVXCORE_DLLPUBLIC SdrCreateView : public SdrDragView
friend class SdrPageView;
protected:
- SdrObject* mpCurrentCreate; // The currently being created object
+ rtl::Reference<SdrObject> mpCurrentCreate; // The currently being created object
SdrPageView* mpCreatePV; // Here, the creation is started
std::unique_ptr<ImplConnectMarkerOverlay> mpCoMaOverlay;
@@ -117,7 +117,7 @@ public:
void BckCreateObj(); // go back one polygon point
void BrkCreateObj();
bool IsCreateObj() const { return mpCurrentCreate != nullptr; }
- SdrObject* GetCreateObj() const { return mpCurrentCreate; }
+ SdrObject* GetCreateObj() const { return mpCurrentCreate.get(); }
/// Setup layer (eg. foreground / background) of the given object.
static void SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj);
diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx
index d871663ae0a0..19ee67b94ca7 100644
--- a/include/svx/svddrgmt.hxx
+++ b/include/svx/svddrgmt.hxx
@@ -65,7 +65,7 @@ class SdrDragEntrySdrObject final : public SdrDragEntry
{
private:
const SdrObject& maOriginal;
- SdrObjectUniquePtr mxClone;
+ rtl::Reference<SdrObject> mxClone;
bool mbModify;
public:
@@ -283,7 +283,7 @@ private:
// mechanism to modify wireframe visualisations, but uses the
// SdrObject::applySpecialDrag() method to change a clone of the
// SdrObject
- SdrObjectUniquePtr mxClone;
+ rtl::Reference<SdrObject> mxClone;
protected:
virtual void createSdrDragEntries() override;
diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 7a34a9d1b75c..1a6ba3897152 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -125,7 +125,7 @@ protected:
// converts an object, when positive it removes the old one from its List
// and inserts the new one instead. including Undo.
// Nor MarkEntry nor ModelChgBroadcast is created.
- SdrObject* ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea);
+ rtl::Reference<SdrObject> ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea);
// set both flags: bToTopPossible and bToBtmPossible.
// bToTopPossibleDirty and bToBtmPossibleDirty are reset at the same time
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 33cb757bfdc6..e22670ac88cd 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -26,6 +26,7 @@
#include <svx/svdglev.hxx>
#include <svx/selectioncontroller.hxx>
#include <editeng/editview.hxx>
+#include <unotools/weakref.hxx>
#include <memory>
class SdrOutliner;
@@ -80,7 +81,7 @@ class SVXCORE_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditView
protected:
// TextEdit
- tools::WeakReference<SdrTextObj> mxWeakTextEditObj; // current object in TextEdit
+ unotools::WeakReference<SdrTextObj> mxWeakTextEditObj; // current object in TextEdit
SdrPageView* mpTextEditPV;
std::unique_ptr<SdrOutliner> mpTextEditOutliner; // outliner for the TextEdit
OutlinerView* mpTextEditOutlinerView; // current view of the outliners
@@ -230,7 +231,7 @@ public:
bool IsTextEditInSelectionMode() const;
// If sb needs the object out of the TextEdit:
- SdrTextObj* GetTextEditObject() const { return mxWeakTextEditObj.get(); }
+ SdrTextObj* GetTextEditObject() const { return mxWeakTextEditObj.get().get(); }
// info about TextEditPageView. Default is 0L.
SdrPageView* GetTextEditPageView() const;
diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx
index 8bd6b744ec46..e6d448bfb691 100644
--- a/include/svx/svdetc.hxx
+++ b/include/svx/svdetc.hxx
@@ -152,7 +152,7 @@ public:
};
-std::vector<Link<SdrObjCreatorParams, SdrObject*>>& ImpGetUserMakeObjHdl();
+std::vector<Link<SdrObjCreatorParams, rtl::Reference<SdrObject>>>& ImpGetUserMakeObjHdl();
class SdrOle2Obj;
class AutoTimer;
@@ -184,7 +184,7 @@ class SVXCORE_DLLPUBLIC SdrGlobalData
{
const SvtSysLocale* pSysLocale; // follows always locale settings
public:
- std::vector<Link<SdrObjCreatorParams, SdrObject*>>
+ std::vector<Link<SdrObjCreatorParams, rtl::Reference<SdrObject>>>
aUserMakeObjHdl;
OLEObjCache aOLEObjCache;
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 62c9be0344e5..4e76bc4e1478 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -146,7 +146,6 @@ struct SdrModelImpl;
class SVXCORE_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase
{
-private:
#ifdef DBG_UTIL
// SdrObjectLifetimeWatchDog:
// Use maAllIncarnatedObjects to keep track of all SdrObjects incarnated using this SdrModel
@@ -165,9 +164,9 @@ private:
// be expensive. Nonetheless, only use with debug code. It may be seductive to use this in
// product code, too, especially if it will indeed trigger - but its intention is clearly
// to find/identify MemoryLeaks caused by SdrObjects
- friend void impAddIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
- friend void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
- std::unordered_set< const SdrObject* > maAllIncarnatedObjects;
+ friend void impAddIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel);
+ friend void impRemoveIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel);
+ std::unordered_set< SdrObject* > maAllIncarnatedObjects;
#endif
protected:
std::vector<rtl::Reference<SdrPage>> maMasterPages;
diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index e161db2a71ac..1a7521a2c764 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -93,7 +93,7 @@ public:
mutable css::uno::Reference< css::drawing::XCustomShapeEngine > mxCustomShapeEngine;
// #i37011# render geometry shadow
- SdrObject* mpLastShadowGeometry;
+ rtl::Reference<SdrObject> mpLastShadowGeometry;
css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const;
@@ -128,9 +128,6 @@ protected:
Size m_aSuggestedTextFrameSize;
- // protected destructor
- virtual ~SdrObjCustomShape() override;
-
virtual void InternalSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast ) override;
public:
@@ -146,6 +143,7 @@ public:
SdrObjCustomShape(SdrModel& rSdrModel);
SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape const & rSource);
+ virtual ~SdrObjCustomShape() override;
/* is merging default attributes from type-shape into the SdrCustomShapeGeometryItem. If pType
is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
@@ -210,7 +208,7 @@ public:
virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override;
virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText,
tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
- virtual SdrObjCustomShape* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -222,7 +220,7 @@ public:
virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 971eba741ec8..8ca06a36006c 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -31,9 +31,11 @@
#include <svx/svdobjkind.hxx>
#include <svx/svxdllapi.h>
#include <tools/link.hxx>
-#include <tools/weakbase.h>
#include <tools/gen.hxx>
#include <unotools/resmgr.hxx>
+#include <unotools/weakref.hxx>
+#include <osl/diagnose.h>
+#include <typeinfo>
#include <unordered_set>
@@ -91,12 +93,6 @@ namespace com::sun::star::drawing { class XShape; }
namespace svx::diagram { class IDiagramHelper; }
-struct SVXCORE_DLLPUBLIC SdrObjectFreeOp;
-
-// helper for constructing std::unique_ptr for SdrObjects where a
-// deleter is needed - here, SdrObject::Free needs to be used.
-typedef std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr;
-
enum class SdrInventor : sal_uInt32 {
Unknown = 0,
BasicDialog = sal_uInt32( 'D' | ('L' << 8) | ('G' << 16) | ('1' << 24) ),
@@ -257,7 +253,7 @@ public:
// SwFlyDrawObj
/// Abstract DrawObject
-class SVXCORE_DLLPUBLIC SdrObject : public SfxListener, public tools::WeakBase
+class SVXCORE_DLLPUBLIC SdrObject : public SfxListener, public cppu::OWeakObject
{
public:
// Basic DiagramHelper support
@@ -300,6 +296,9 @@ public:
// Copy constructor
SdrObject(SdrModel& rSdrModel, SdrObject const & rSource);
+ virtual void SAL_CALL acquire() noexcept override final;
+ virtual void SAL_CALL release() noexcept override final;
+
// SdrModel/SdrPage access on SdrObject level
SdrPage* getSdrPageFromSdrObject() const;
SdrModel& getSdrModelFromSdrObject() const;
@@ -344,11 +343,6 @@ public:
/// at the same time to avoid recomputation.
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself = false, bool bRecursive = true);
- // frees the SdrObject pointed to by the argument
- // In case the object has an SvxShape, which has the ownership of the object, it
- // is actually *not* deleted.
- static void Free( SdrObject*& _rpObject );
-
// this method is only for access from Property objects
virtual void SetBoundRectDirty();
@@ -445,7 +439,14 @@ public:
virtual bool HasLimitedRotation() const;
// Returns a copy of the object. Every inherited class must reimplement this.
- virtual SdrObject* CloneSdrObject(SdrModel& rTargetModel) const;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const;
+ // helper, since Clone always return the type of the current subclass
+ template<class T>
+ static rtl::Reference<T> Clone(T const & rObj, SdrModel& rTargetModel)
+ {
+ rtl::Reference<SdrObject> newObj = rObj.CloneSdrObject(rTargetModel);
+ return static_cast<T*>(newObj.get());
+ }
// Overwriting this object makes no sense, it is too complicated for that
SdrObject& operator=(const SdrObject& rObj) = delete;
@@ -503,7 +504,7 @@ public:
// part of the model, thus not changing anything since it's only a temporary
// helper object for interaction
virtual bool supportsFullDrag() const;
- virtual SdrObjectUniquePtr getFullDragClone() const;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const;
/// Every object must be able to create itself interactively.
/// On MouseDown first an object is created, and its BegCreate() method
@@ -720,15 +721,15 @@ public:
// In the case of the conversion from TextObj to PathObj,
// both modi (bLineToArea=true/false) would be identical.
// The methods' default implementations report "I'm unable to do this" (false/null).
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const;
- SdrObjectUniquePtr ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const;
+ rtl::Reference<SdrObject> ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
// convert this path object to contour object; bForceLineDash converts even
// when there is no filled new polygon created from line-to-polygon conversion,
// specially used for XLINE_DASH and 3D conversion
- SdrObject* ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const;
+ rtl::Reference<SdrObject> ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const;
private:
- SdrObject* ImpConvertToContourObj(bool bForceLineDash);
+ rtl::Reference<SdrObject> ImpConvertToContourObj(bool bForceLineDash);
public:
// if true, reference onto an object
@@ -977,10 +978,12 @@ private:
std::unique_ptr<sdr::contact::ViewContact>
mpViewContact;
- // do not use directly, always use getSvxShape() if you have to!
+ // do not use directly, always use getSvxShape() if you have to, because not all
+ // SdrObjects have an associated SvxShape subclass (e.g. reportdesign)
SvxShape* mpSvxShape;
css::uno::WeakReference< css::drawing::XShape >
maWeakUnoShape;
+
// HACK: Do not automatically insert newly created object into a page.
// The user needs to do it manually later.
bool mbDoNotInsertIntoPageAutomatically;
@@ -993,14 +996,6 @@ private:
SdrObject( const SdrObject& ) = delete;
};
-struct SVXCORE_DLLPUBLIC SdrObjectFreeOp
-{
- void operator()(SdrObject* obj)
- {
- SdrObject::Free(obj);
- }
-};
-
struct SdrObjCreatorParams
{
SdrInventor nInventor;
@@ -1019,17 +1014,17 @@ struct SdrObjCreatorParams
class SVXCORE_DLLPUBLIC SdrObjFactory
{
public:
- static SdrObject* MakeNewObject(
+ static rtl::Reference<SdrObject> MakeNewObject(
SdrModel& rSdrModel,
SdrInventor nInventor,
SdrObjKind nObjIdentifier,
const tools::Rectangle* pSnapRect = nullptr);
- static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink);
- static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink);
+ static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink);
+ static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink);
private:
- static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory(
+ static SVX_DLLPRIVATE rtl::Reference<SdrObject> CreateObjectFromFactory(
SdrModel& rSdrModel,
SdrInventor nInventor,
SdrObjKind nIdentifier);
diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx
index 28337b6631c4..2e1784bccf88 100644
--- a/include/svx/svdocapt.hxx
+++ b/include/svx/svdocapt.hxx
@@ -85,7 +85,7 @@ public:
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrObjKind GetObjIdentifier() const override;
- virtual SdrCaptionObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
// for calc: special shadow only for text box
void SetSpecialTextBoxShadow() { mbSpecialTextBoxShadow = true; }
@@ -135,7 +135,7 @@ private:
virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
public:
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
const Point& GetTailPos() const;
void SetTailPos(const Point& rPos);
diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx
index 5da739068aee..56a758b3a2be 100644
--- a/include/svx/svdocirc.hxx
+++ b/include/svx/svdocirc.hxx
@@ -99,7 +99,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrCircObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void RecalcSnapRect() override;
virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
@@ -128,7 +128,7 @@ public:
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
virtual void NbcShear (const Point& rRef, Degree100 nAngle, double tn, bool bVShear) override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
private:
virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index 6e3acb339797..1c578fda09c0 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -218,7 +218,7 @@ public:
virtual void RecalcSnapRect() override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrEdgeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -236,7 +236,7 @@ public:
virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
// FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
virtual void NbcMove(const Size& aSize) override;
@@ -257,7 +257,7 @@ public:
virtual void BrkCreate(SdrDragStat& rStat) override;
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
virtual PointerStyle GetCreatePointer() const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
virtual sal_uInt32 GetSnapPointCount() const override;
virtual Point GetSnapPoint(sal_uInt32 i) const override;
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 7c6f9865002e..cb88b4c2a770 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -167,7 +167,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual sal_uInt32 GetHdlCount() const override;
virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
@@ -186,7 +186,7 @@ public:
bool isEmbeddedVectorGraphicData() const;
GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
@@ -203,7 +203,7 @@ public:
css::uno::Reference< css::io::XInputStream > getInputStream() const;
// #i103116# FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
// add handles for crop mode when selected
virtual void addCropHandles(SdrHdlList& rTarget) const override;
diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx
index 4322d56dfc38..e5e1203ed5b7 100644
--- a/include/svx/svdogrp.hxx
+++ b/include/svx/svdogrp.hxx
@@ -43,13 +43,11 @@ private:
friend class svx::diagram::IDiagramHelper;
std::shared_ptr< svx::diagram::IDiagramHelper > mp_DiagramHelper;
- // protected destructor - due to final, make private
- virtual ~SdrObjGroup() override;
-
public:
SdrObjGroup(SdrModel& rSdrModel);
// Copy constructor
SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const& rSource);
+ virtual ~SdrObjGroup() override;
// derived from SdrObjList
virtual SdrPage* getSdrPageFromSdrObjList() const override;
@@ -73,7 +71,7 @@ public:
virtual const tools::Rectangle& GetCurrentBoundRect() const override;
virtual const tools::Rectangle& GetSnapRect() const override;
- virtual SdrObjGroup* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -113,7 +111,8 @@ public:
virtual void NbcReformatText() override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier,
+ bool bAddText) const override;
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index cd00b7d26d1c..cf0f06e3fb5b 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -77,9 +77,6 @@ private:
virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
- // protected destructor
- virtual ~SdrMeasureObj() override;
-
public:
SdrMeasureObj(SdrModel& rSdrModel);
// Copy constructor
@@ -88,11 +85,12 @@ public:
SdrModel& rSdrModel,
const Point& rPt1,
const Point& rPt2);
+ virtual ~SdrMeasureObj() override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrObjKind GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrMeasureObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -131,7 +129,7 @@ public:
virtual Point GetPoint(sal_uInt32 i) const override;
virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i) override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
virtual bool BegTextEdit(SdrOutliner& rOutl) override;
virtual const Size& GetTextSize() const override;
diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx
index d80ec5a577b9..020f4d56c947 100644
--- a/include/svx/svdomedia.hxx
+++ b/include/svx/svdomedia.hxx
@@ -54,7 +54,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrMediaObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index ae6ff818bdf6..4bbe38e451d5 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -56,7 +56,7 @@ private:
SVX_DLLPRIVATE void GetObjRef_Impl();
// #i118485# helper added
- SVX_DLLPRIVATE SdrObjectUniquePtr createSdrGrafObjReplacement(bool bAddText) const;
+ SVX_DLLPRIVATE rtl::Reference<SdrObject> createSdrGrafObjReplacement(bool bAddText) const;
SVX_DLLPRIVATE void ImpSetVisAreaSize();
SVX_DLLPRIVATE void Init();
@@ -133,14 +133,14 @@ public:
void SetClosedObj( bool bIsClosed );
// FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrObjKind GetObjIdentifier() const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void NbcMove(const Size& rSize) override;
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
@@ -181,7 +181,7 @@ public:
void SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow);
// #i118485# missing converter added
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
};
class SVXCORE_DLLPUBLIC SdrEmbedObjectLink final : public sfx2::SvBaseLink
diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx
index 3f521ca7a625..abb35d8239cd 100644
--- a/include/svx/svdopage.hxx
+++ b/include/svx/svdopage.hxx
@@ -60,7 +60,7 @@ public:
virtual SdrObjKind GetObjIdentifier() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
- virtual SdrPageObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index 5eb25ec7b0d1..d193b9bc1545 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -77,7 +77,7 @@ public:
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrObjKind GetObjIdentifier() const override;
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
- virtual SdrPathObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -127,7 +127,7 @@ public:
sal_uInt32 NbcInsPoint(const Point& rPos, bool bNewObj);
// rip at given point
- SdrObject* RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
+ rtl::Reference<SdrPathObj> RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
private:
virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
@@ -135,7 +135,7 @@ private:
virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
public:
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
// Bezier-polygon getter/setter
const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx
index ac7879cb5212..af02a907aa36 100644
--- a/include/svx/svdorect.hxx
+++ b/include/svx/svdorect.hxx
@@ -92,7 +92,7 @@ public:
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrRectObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void RecalcSnapRect() override;
virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
@@ -119,7 +119,7 @@ public:
virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const override;
virtual SdrGluePoint GetCornerGluePoint(sal_uInt16 nNum) const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
};
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index e71c8517bb3f..c12d7af6857c 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -206,7 +206,7 @@ public:
virtual bool AdjustTextFrameWidthAndHeight() override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrTableObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void RecalcSnapRect() override;
virtual const tools::Rectangle& GetSnapRect() const override;
virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 03c828db7493..2df27cb77b5c 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -120,8 +120,6 @@ namespace sdr::properties
// SdrTextObj
-typedef std::unique_ptr<SdrPathObj, SdrObjectFreeOp> SdrPathObjUniquePtr;
-
class SVXCORE_DLLPUBLIC SdrTextObj : public SdrAttrObj, public svx::ITextProvider
{
private:
@@ -197,7 +195,7 @@ protected:
// and maintaining the OutlinerView.
Point maTextEditOffset;
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
public:
@@ -252,7 +250,7 @@ private:
Fraction& aFitXCorrection ) const;
void ImpAutoFitText( SdrOutliner& rOutliner ) const;
void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting ) const;
- SVX_DLLPRIVATE SdrObjectUniquePtr ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const;
+ SVX_DLLPRIVATE rtl::Reference<SdrObject> ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const;
SVX_DLLPRIVATE void ImpRegisterLink();
SVX_DLLPRIVATE void ImpDeregisterLink();
SVX_DLLPRIVATE ImpSdrObjTextLinkUserData* GetLinkUserData() const;
@@ -265,8 +263,8 @@ private:
protected:
bool ImpCanConvTextToCurve() const;
- SdrPathObjUniquePtr ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier) const;
- SdrObjectUniquePtr ImpConvertAddText(SdrObjectUniquePtr pObj, bool bBezier) const;
+ rtl::Reference<SdrPathObj> ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier) const;
+ rtl::Reference<SdrObject> ImpConvertAddText(rtl::Reference<SdrObject> pObj, bool bBezier) const;
void ImpSetTextStyleSheetListeners();
static void ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXCorrection);
static void ImpJustifyRect(tools::Rectangle& rRect);
@@ -446,7 +444,7 @@ public:
virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
- virtual SdrTextObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
virtual basegfx::B2DPolyPolygon TakeContour() const override;
virtual void RecalcSnapRect() override;
@@ -499,7 +497,7 @@ public:
virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
bool bEdit, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, OUString& rRet) const;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
void SetTextEditOutliner(SdrOutliner* pOutl) { mpEditingOutliner = pOutl; }
diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx
index 2c81f47a185b..bb5ea5225887 100644
--- a/include/svx/svdouno.hxx
+++ b/include/svx/svdouno.hxx
@@ -58,10 +58,6 @@ private:
SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName,
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac );
-protected:
- // protected destructor
- virtual ~SdrUnoObj() override;
-
public:
explicit SdrUnoObj(
SdrModel& rSdrModel,
@@ -72,11 +68,12 @@ public:
SdrModel& rSdrModel,
const OUString& rModelName,
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac);
+ virtual ~SdrUnoObj() override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrObjKind GetObjIdentifier() const override;
- virtual SdrUnoObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
virtual void NbcSetLayer(SdrLayerID nLayer) override;
diff --git a/include/svx/svdoutl.hxx b/include/svx/svdoutl.hxx
index f706d85bdaa3..b9768b72c45a 100644
--- a/include/svx/svdoutl.hxx
+++ b/include/svx/svdoutl.hxx
@@ -21,14 +21,14 @@
#include <editeng/outliner.hxx>
#include <svx/svxdllapi.h>
-#include <tools/weakbase.h>
+#include <unotools/weakref.hxx>
class SdrTextObj;
class SdrPage;
class SVXCORE_DLLPUBLIC SdrOutliner : public Outliner
{
- tools::WeakReference<SdrTextObj> mxWeakTextObj;
+ ::unotools::WeakReference<SdrTextObj> mxWeakTextObj;
const SdrPage* mpVisualizedPage;
public:
diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx
index fa2f935f34e5..9f327d639bb1 100644
--- a/include/svx/svdovirt.hxx
+++ b/include/svx/svdovirt.hxx
@@ -36,7 +36,7 @@ public:
protected:
virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
- SdrObject& rRefObj; // Referenced drawing object
+ rtl::Reference<SdrObject> mxRefObj; // Referenced drawing object
tools::Rectangle aSnapRect;
protected:
@@ -66,7 +66,7 @@ public:
virtual const tools::Rectangle& GetCurrentBoundRect() const override;
virtual const tools::Rectangle& GetLastBoundRect() const override;
virtual void RecalcBoundRect() override;
- virtual SdrVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual OUString TakeObjNameSingul() const override;
virtual OUString TakeObjNamePlural() const override;
@@ -88,7 +88,7 @@ public:
// FullDrag support
virtual bool supportsFullDrag() const override;
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
virtual bool BegCreate(SdrDragStat& rStat) override;
virtual bool MovCreate(SdrDragStat& rStat) override;
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index dde46e1cc61f..5b6a1a434da0 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -31,6 +31,7 @@
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <svx/svdobj.hxx>
#include <svx/ColorSets.hxx>
+#include <unotools/weakref.hxx>
#include <memory>
#include <optional>
#include <vector>
@@ -109,13 +110,13 @@ public:
void InsertObjectThenMakeNameUnique(SdrObject* pObj, std::unordered_set<rtl::OUString>& rNameSet, size_t nPos=SAL_MAX_SIZE);
/// remove from list without delete
- virtual SdrObject* NbcRemoveObject(size_t nObjNum);
- virtual SdrObject* RemoveObject(size_t nObjNum);
+ virtual rtl::Reference<SdrObject> NbcRemoveObject(size_t nObjNum);
+ virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum);
/// Replace existing object by different one.
/// Same as Remove(old)+Insert(new) but faster because the order numbers
/// do not have to be set dirty.
- virtual SdrObject* ReplaceObject(SdrObject* pNewObj, size_t nObjNum);
+ virtual rtl::Reference<SdrObject> ReplaceObject(SdrObject* pNewObj, size_t nObjNum);
/// Modify ZOrder of an SdrObject
virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum);
@@ -226,10 +227,10 @@ public:
private:
tools::Rectangle maSdrObjListOutRect;
tools::Rectangle maSdrObjListSnapRect;
- std::deque<SdrObject*> maList;
+ std::deque<rtl::Reference<SdrObject>> maList;
/// This list, if it exists, defines the navigation order. If it does
/// not exist then maList defines the navigation order.
- std::optional<std::vector<tools::WeakReference<SdrObject>>> mxNavigationOrder;
+ std::optional<std::vector<unotools::WeakReference<SdrObject>>> mxNavigationOrder;
bool mbObjOrdNumsDirty;
bool mbRectsDirty;
/// This flag is <TRUE/> when the mpNavigation list has been changed but
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index c3b8bef914e8..e2c6b62524ed 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -127,10 +127,11 @@ public:
class SVXCORE_DLLPUBLIC SdrUndoObj : public SdrUndoAction
{
protected:
- SdrObject* pObj;
+ rtl::Reference<SdrObject> mxObj;
protected:
SdrUndoObj(SdrObject& rNewObj);
+ virtual ~SdrUndoObj() override;
OUString ImpGetDescriptionStr(TranslateId pStrCacheID, bool bRepeat = false) const;
@@ -255,9 +256,6 @@ class SVXCORE_DLLPUBLIC SdrUndoObjList : public SdrUndoObj {
class ObjListListener;
friend class ObjListListener;
-private:
- bool bOwner;
-
protected:
SdrObjList* pObjList;
sal_uInt32 nOrdNum;
@@ -265,9 +263,6 @@ protected:
protected:
SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect);
virtual ~SdrUndoObjList() override;
-
- bool IsOwner() const { return bOwner; }
- void SetOwner(bool bNew);
};
/**
@@ -351,11 +346,8 @@ public:
class SVXCORE_DLLPUBLIC SdrUndoReplaceObj : public SdrUndoObj
{
- bool bOldOwner;
- bool bNewOwner;
-
SdrObjList* pObjList;
- SdrObject* pNewObj;
+ rtl::Reference<SdrObject> mxNewObj;
public:
SdrUndoReplaceObj(SdrObject& rOldObj1, SdrObject& rNewObj1);
@@ -363,12 +355,6 @@ public:
virtual void Undo() override;
virtual void Redo() override;
-
- bool IsNewOwner() const { return bNewOwner; }
- void SetNewOwner(bool bNew);
-
- bool IsOldOwner() const { return bOldOwner; }
- void SetOldOwner(bool bNew);
};
/**
diff --git a/include/svx/unopage.hxx b/include/svx/unopage.hxx
index e69eb7ec8995..0008b5c38ad0 100644
--- a/include/svx/unopage.hxx
+++ b/include/svx/unopage.hxx
@@ -85,7 +85,7 @@ class SVXCORE_DLLPUBLIC SvxDrawPage : protected cppu::BaseMutex,
// Creating a SdrObject using it's Description.
// Can be used by derived classes to support their owen Shapes (e.g. Controls).
/// @throws css::uno::RuntimeException
- virtual SdrObject *CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape );
+ virtual rtl::Reference<SdrObject> CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape );
/// @throws css::uno::RuntimeException
static rtl::Reference<SvxShape> CreateShapeByTypeAndInventor( SdrObjKind nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *pPage = nullptr, OUString const & referer = OUString() );
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index 51b65e23ade9..0eb3ef33101c 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -43,7 +43,6 @@
#include <com/sun/star/drawing/XControlShape.hpp>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <sal/types.h>
-#include <tools/weakbase.hxx>
#include <svl/lstner.hxx>
#include <editeng/unoipset.hxx>
#include <svx/svxdllapi.h>
@@ -124,7 +123,7 @@ protected:
o3tl::span<const SfxItemPropertyMapEntry> maPropMapEntries;
private:
- ::tools::WeakReference< SdrObject > mpSdrObjectWeakReference;
+ rtl::Reference< SdrObject > mxSdrObject;
protected:
// translations for writer, which works in TWIPS
@@ -189,20 +188,13 @@ public:
// Internals
void ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet);
virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage );
- /** takes the ownership of the SdrObject.
-
- When the shape is disposed, and it has the ownership of its associated SdrObject, then
- it will delete this object.
- */
- void TakeSdrObjectOwnership();
- bool HasSdrObjectOwnership() const;
// used exclusively by SdrObject
void InvalidateSdrObject();
// Encapsulated access to SdrObject
- SdrObject* GetSdrObject() const { return mpSdrObjectWeakReference.get(); }
- bool HasSdrObject() const { return mpSdrObjectWeakReference.is(); }
+ SdrObject* GetSdrObject() const { return mxSdrObject.get(); }
+ bool HasSdrObject() const { return mxSdrObject.is(); }
void SetShapeType( const OUString& ShapeType ) { maShapeType = ShapeType; }
/// @throws css::uno::RuntimeException
diff --git a/include/svx/view3d.hxx b/include/svx/view3d.hxx
index 359b3aa31f55..fc7b818f795a 100644
--- a/include/svx/view3d.hxx
+++ b/include/svx/view3d.hxx
@@ -94,7 +94,7 @@ public:
// Means to create all Extrudes in a certain depth order.
static void DoDepthArrange(E3dScene const * pScene, double fDepth);
void ConvertMarkedToPolyObj();
- E3dScene* SetCurrent3DObj(E3dObject* p3DObj);
+ rtl::Reference<E3dScene> SetCurrent3DObj(E3dObject* p3DObj);
void Start3DCreation();
// Migration of overlay
diff --git a/include/unotools/weakref.hxx b/include/unotools/weakref.hxx
index 104737404054..023695dc14ae 100644
--- a/include/unotools/weakref.hxx
+++ b/include/unotools/weakref.hxx
@@ -30,11 +30,6 @@
#include <cppuhelper/weak.hxx>
#include <rtl/ref.hxx>
-namespace cppu
-{
-class OWeakObject;
-}
-
namespace unotools
{
/** The WeakReference<> holds a weak reference to an object.
@@ -64,7 +59,7 @@ public:
@param rRef another hard ref
*/
WeakReference(const rtl::Reference<interface_type>& rRef)
- : WeakReferenceHelper(rRef)
+ : WeakReferenceHelper(css::uno::Reference<css::uno::XWeak>(rRef))
{
}
diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx
index 2e53c1f7f29b..566dc20a13fc 100644
--- a/reportdesign/inc/RptObject.hxx
+++ b/reportdesign/inc/RptObject.hxx
@@ -66,7 +66,6 @@ protected:
mutable rtl::Reference<OPropertyMediator> m_xMediator;
mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
mutable css::uno::Reference< css::report::XReportComponent> m_xReportComponent;
- css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive;
OUString m_sComponentName;
bool m_bIsListening;
@@ -83,13 +82,9 @@ protected:
/** called by instances of derived classes to implement their overriding of getUnoShape
*/
- css::uno::Reference< css::drawing::XShape >
+ static css::uno::Reference< css::drawing::XShape >
getUnoShapeOf( SdrObject& _rSdrObject );
-private:
- static void ensureSdrObjectOwnership(
- const css::uno::Reference< css::uno::XInterface >& _rxShape );
-
public:
OObjectBase(const OObjectBase&) = delete;
OObjectBase& operator=(const OObjectBase&) = delete;
@@ -107,11 +102,7 @@ public:
css::uno::Reference< css::report::XSection> getSection() const;
const OUString& getServiceName() const { return m_sComponentName; }
- /** releases the reference to our UNO shape (m_xKeepShapeAlive)
- */
- void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
-
- static SdrObject* createObject(
+ static rtl::Reference<SdrObject> createObject(
SdrModel& rTargetModel,
const css::uno::Reference< css::report::XReportComponent>& _xComponent);
static SdrObjKind getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
@@ -129,7 +120,7 @@ private:
virtual ~OCustomShape() override;
public:
- static OCustomShape* Create(
+ static rtl::Reference<OCustomShape> Create(
SdrModel& rSdrModel,
const css::uno::Reference< css::report::XReportComponent>& _xComponent)
{
@@ -173,7 +164,7 @@ private:
virtual ~OOle2Obj() override;
public:
- static OOle2Obj* Create(
+ static rtl::Reference<OOle2Obj> Create(
SdrModel& rSdrModel,
const css::uno::Reference< css::report::XReportComponent>& _xComponent,
SdrObjKind _nType)
@@ -187,7 +178,7 @@ public:
virtual SdrObjKind GetObjIdentifier() const override;
virtual SdrInventor GetObjInventor() const override;
// Clone() should make a complete copy of the object.
- virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
virtual void initializeOle() override;
void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
@@ -269,10 +260,9 @@ public:
virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override;
virtual SdrObjKind GetObjIdentifier() const override;
virtual SdrInventor GetObjInventor() const override;
- virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
private:
- virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override;
void impl_initializeModel_nothrow();
};
diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx
index 1b5a5c332cfc..ea2b53f53a0e 100644
--- a/reportdesign/inc/RptPage.hxx
+++ b/reportdesign/inc/RptPage.hxx
@@ -57,7 +57,7 @@ public:
virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const override;
virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
- virtual SdrObject* RemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum) override;
/** returns the index inside the object list which belongs to the report component.
@param _xObject the report component
diff --git a/reportdesign/source/core/api/Shape.cxx b/reportdesign/source/core/api/Shape.cxx
index b97deeb1995e..6a52b032116a 100644
--- a/reportdesign/source/core/api/Shape.cxx
+++ b/reportdesign/source/core/api/Shape.cxx
@@ -298,7 +298,7 @@ uno::Reference< util::XCloneable > SAL_CALL OShape::createClone( )
SdrObject* pObject = SdrObject::getSdrObjectFromXShape( xSource );
if ( pObject )
{
- SdrObject* pClone(pObject->CloneSdrObject(pObject->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pClone(pObject->CloneSdrObject(pObject->getSdrModelFromSdrObject()));
if ( pClone )
{
xSet.set(pClone->getUnoShape(),uno::UNO_QUERY_THROW );
diff --git a/reportdesign/source/core/inc/ReportDrawPage.hxx b/reportdesign/source/core/inc/ReportDrawPage.hxx
index e1b432247e0d..b4c10d93eb6c 100644
--- a/reportdesign/source/core/inc/ReportDrawPage.hxx
+++ b/reportdesign/source/core/inc/ReportDrawPage.hxx
@@ -31,7 +31,7 @@ namespace reportdesign
OReportDrawPage(const OReportDrawPage&) = delete;
void operator =(const OReportDrawPage&) = delete;
protected:
- virtual SdrObject *CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xShape ) override;
+ virtual rtl::Reference<SdrObject> CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xShape ) override;
virtual css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override;
public:
OReportDrawPage(SdrPage* pPage,const css::uno::Reference< css::report::XSection >& _xSection);
diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx
index b36b9acaadfc..9c88a39990c1 100644
--- a/reportdesign/source/core/sdr/ReportDrawPage.cxx
+++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx
@@ -42,7 +42,7 @@ OReportDrawPage::OReportDrawPage(SdrPage* _pPage
{
}
-SdrObject* OReportDrawPage::CreateSdrObject_(const uno::Reference< drawing::XShape > & xDescr)
+rtl::Reference<SdrObject> OReportDrawPage::CreateSdrObject_(const uno::Reference< drawing::XShape > & xDescr)
{
uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
if ( xReportComponent.is() )
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 029359db63b0..dde0896855b2 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -86,17 +86,17 @@ SdrObjKind OObjectBase::getObjectType(const uno::Reference< report::XReportCompo
return SdrObjKind::OLE2;
}
-SdrObject* OObjectBase::createObject(
+rtl::Reference<SdrObject> OObjectBase::createObject(
SdrModel& rTargetModel,
const uno::Reference< report::XReportComponent>& _xComponent)
{
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
SdrObjKind nType = OObjectBase::getObjectType(_xComponent);
switch( nType )
{
case SdrObjKind::ReportDesignFixedText:
{
- OUnoObject* pUnoObj = new OUnoObject(
+ rtl::Reference<OUnoObject> pUnoObj = new OUnoObject(
rTargetModel,
_xComponent,
OUString("com.sun.star.form.component.FixedText"),
@@ -160,8 +160,6 @@ SdrObject* OObjectBase::createObject(
if ( pNewObj )
pNewObj->SetDoNotInsertIntoPageAutomatically( true );
- ensureSdrObjectOwnership( _xComponent );
-
return pNewObj;
}
@@ -415,27 +413,6 @@ bool OObjectBase::supportsService( const OUString& _sServiceName ) const
}
-void OObjectBase::ensureSdrObjectOwnership( const uno::Reference< uno::XInterface >& _rxShape )
-{
- // UNDO in the report designer is implemented at the level of the XShapes, not
- // at the level of SdrObjects. That is, if an object is removed from the report
- // design, then this happens by removing the XShape from the UNO DrawPage, and
- // putting this XShape (resp. the ReportComponent which wraps it) into an UNDO
- // action.
- // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects
- // which are removed from it, which is deadly for us. To prevent this,
- // we give the XShape implementation the ownership of the SdrObject, which
- // ensures the SvxDrawPage won't delete it.
- SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( _rxShape );
- OSL_ENSURE( pShape, "OObjectBase::ensureSdrObjectOwnership: can't access the SvxShape!" );
- if ( pShape )
- {
- OSL_ENSURE( !pShape->HasSdrObjectOwnership(), "OObjectBase::ensureSdrObjectOwnership: called twice?" );
- pShape->TakeSdrObjectOwnership();
- }
-}
-
-
uno::Reference< drawing::XShape > OObjectBase::getUnoShapeOf( SdrObject& _rSdrObject )
{
uno::Reference< drawing::XShape > xShape( _rSdrObject.getWeakUnoShape() );
@@ -446,9 +423,6 @@ uno::Reference< drawing::XShape > OObjectBase::getUnoShapeOf( SdrObject& _rSdrOb
if ( !xShape.is() )
return xShape;
- ensureSdrObjectOwnership( xShape );
-
- m_xKeepShapeAlive = xShape;
return xShape;
}
@@ -566,7 +540,6 @@ uno::Reference< drawing::XShape > OCustomShape::getUnoShape()
void OCustomShape::setUnoShape( const uno::Reference< drawing::XShape >& rxUnoShape )
{
SdrObjCustomShape::setUnoShape( rxUnoShape );
- releaseUnoShape();
m_xReportComponent.clear();
}
@@ -894,13 +867,7 @@ uno::Reference< drawing::XShape > OUnoObject::getUnoShape()
return OObjectBase::getUnoShapeOf( *this );
}
-void OUnoObject::setUnoShape( const uno::Reference< drawing::XShape >& rxUnoShape )
-{
- SdrUnoObj::setUnoShape( rxUnoShape );
- releaseUnoShape();
-}
-
-OUnoObject* OUnoObject::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> OUnoObject::CloneSdrObject(SdrModel& rTargetModel) const
{
return new OUnoObject(rTargetModel, *this);
}
@@ -1093,7 +1060,6 @@ uno::Reference< drawing::XShape > OOle2Obj::getUnoShape()
void OOle2Obj::setUnoShape( const uno::Reference< drawing::XShape >& rxUnoShape )
{
SdrOle2Obj::setUnoShape( rxUnoShape );
- releaseUnoShape();
m_xReportComponent.clear();
}
@@ -1114,7 +1080,7 @@ static uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider
}
// Clone() should make a complete copy of the object.
-OOle2Obj* OOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> OOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new OOle2Obj(rTargetModel, *this);
}
diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx
index 135d2e1ec21b..0132ccf725a2 100644
--- a/reportdesign/source/core/sdr/RptPage.cxx
+++ b/reportdesign/source/core/sdr/RptPage.cxx
@@ -82,9 +82,9 @@ void OReportPage::removeSdrObject(const uno::Reference< report::XReportComponent
}
}
-SdrObject* OReportPage::RemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> OReportPage::RemoveObject(size_t nObjNum)
{
- SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
+ rtl::Reference<SdrObject> pObj = SdrPage::RemoveObject(nObjNum);
if (getSpecialMode())
{
return pObj;
@@ -94,7 +94,7 @@ SdrObject* OReportPage::RemoveObject(size_t nObjNum)
reportdesign::OSection* pSection = comphelper::getFromUnoTunnel<reportdesign::OSection>(m_xSection);
uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY);
pSection->notifyElementRemoved(xShape);
- if (dynamic_cast< const OUnoObject *>( pObj ) != nullptr)
+ if (dynamic_cast< const OUnoObject *>( pObj.get() ) != nullptr)
{
OUnoObject& rUnoObj = dynamic_cast<OUnoObject&>(*pObj);
uno::Reference< container::XChild> xChild(rUnoObj.GetUnoControlModel(),uno::UNO_QUERY);
@@ -178,13 +178,6 @@ void OReportPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
reportdesign::OSection* pSection = comphelper::getFromUnoTunnel<reportdesign::OSection>(m_xSection);
uno::Reference< drawing::XShape> xShape(pObj->getUnoShape(),uno::UNO_QUERY);
pSection->notifyElementAdded(xShape);
-
- // now that the shape is inserted into its structures, we can allow the OObjectBase
- // to release the reference to it
- OObjectBase* pObjectBase = dynamic_cast< OObjectBase* >( pObj );
- OSL_ENSURE( pObjectBase, "OReportPage::NbcInsertObject: what is being inserted here?" );
- if ( pObjectBase )
- pObjectBase->releaseUnoShape();
}
} // rptui
diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx
index d4ff2d8f9d26..a63161a1b977 100644
--- a/reportdesign/source/core/sdr/UndoActions.cxx
+++ b/reportdesign/source/core/sdr/UndoActions.cxx
@@ -118,12 +118,6 @@ OUndoContainerAction::~OUndoContainerAction()
OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
rEnv.RemoveElement( m_xOwnElement );
-#if OSL_DEBUG_LEVEL > 0
- SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xChild );
- SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
- OSL_ENSURE( pObject == nullptr || (pShape->HasSdrObjectOwnership() && !pObject->IsInserted()),
- "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" );
-#endif
// -> dispose it
try
{
diff --git a/reportdesign/source/ui/inc/UITools.hxx b/reportdesign/source/ui/inc/UITools.hxx
index 13aafb14fc90..b86afa4a154e 100644
--- a/reportdesign/source/ui/inc/UITools.hxx
+++ b/reportdesign/source/ui/inc/UITools.hxx
@@ -139,7 +139,7 @@ namespace rptui
*/
SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects = false,SdrObject const * _pIgnore = nullptr, sal_Int16 _nIgnoreType=0);
- SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnoreList[], int _nIgnoreListLength);
+ SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, rtl::Reference<SdrUnoObj> _pIgnoreList[], int _nIgnoreListLength);
/** checks whether the given OUnoObject object rectangle overlapps another object in that view.
*
diff --git a/reportdesign/source/ui/inc/dlgedfac.hxx b/reportdesign/source/ui/inc/dlgedfac.hxx
index 6a79ef7805af..f98d9f9a4ee0 100644
--- a/reportdesign/source/ui/inc/dlgedfac.hxx
+++ b/reportdesign/source/ui/inc/dlgedfac.hxx
@@ -33,7 +33,7 @@ public:
DlgEdFactory();
~DlgEdFactory() COVERITY_NOEXCEPT_FALSE;
- DECL_STATIC_LINK(DlgEdFactory, MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_STATIC_LINK(DlgEdFactory, MakeObject, SdrObjCreatorParams, rtl::Reference<SdrObject>);
};
}
#endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_DLGEDFAC_HXX
diff --git a/reportdesign/source/ui/misc/RptUndo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx
index 3f9a752f6497..e4ec1d3817d5 100644
--- a/reportdesign/source/ui/misc/RptUndo.cxx
+++ b/reportdesign/source/ui/misc/RptUndo.cxx
@@ -131,13 +131,6 @@ OSectionUndo::~OSectionUndo()
for (uno::Reference<drawing::XShape>& xShape : m_aControls)
{
rEnv.RemoveElement(xShape);
-
-#if OSL_DEBUG_LEVEL > 0
- SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
- SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
- OSL_ENSURE( pShape && pShape->HasSdrObjectOwnership() && pObject && !pObject->IsInserted(),
- "OSectionUndo::~OSectionUndo: inconsistency in the shape/object ownership!" );
-#endif
try
{
comphelper::disposeComponent(xShape);
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index 9a7a74ffe343..57b4c32a7a7b 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -869,7 +869,7 @@ SdrObject* isOver(const tools::Rectangle& _rRect, SdrPage const & _rPage, SdrVie
return pOverlappedObj;
}
-static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnore[], int _nListLength)
+static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, rtl::Reference<SdrUnoObj> _pIgnore[], int _nListLength)
{
for(int i=0;i<_nListLength;i++)
{
@@ -882,7 +882,7 @@ static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, std::unique_
return false;
}
-SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnoreList[], int _nIgnoreListLength)
+SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, rtl::Reference<SdrUnoObj> _pIgnoreList[], int _nIgnoreListLength)
{
SdrObject* pOverlappedObj = nullptr;
SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index b74301e230a4..59bc64749bac 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3103,7 +3103,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
if ( aPos.X < nLeftMargin )
aPos.X = nLeftMargin;
- SdrObject* pNewControl = nullptr;
+ rtl::Reference<SdrObject> pNewControl;
uno::Reference< report::XReportComponent> xShapeProp;
if ( _nObjectId == SdrObjKind::CustomShape )
{
@@ -3115,7 +3115,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
OUString sCustomShapeType = getDesignView()->GetInsertObjString();
if ( sCustomShapeType.isEmpty() )
sCustomShapeType = "diamond";
- OReportSection::createDefault(sCustomShapeType,pNewControl);
+ OReportSection::createDefault(sCustomShapeType,pNewControl.get());
pNewControl->SetLogicRect(tools::Rectangle(3000,500,6000,3500)); // switch height and width
}
else if ( _nObjectId == SdrObjKind::OLE2 || SdrObjKind::ReportDesignSubReport == _nObjectId )
@@ -3127,7 +3127,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
pNewControl->SetLogicRect(tools::Rectangle(3000,500,8000,5500)); // switch height and width
xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
- OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
+ OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl.get());
if ( pObj && !pObj->IsEmpty() )
{
pObj->initializeChart(getModel());
@@ -3135,8 +3135,8 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
}
else
{
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
+ rtl::Reference<SdrUnoObj> pLabel;
+ rtl::Reference<SdrUnoObj> pControl;
FmFormView::createControlLabelPair(
getDesignView()->GetOutDev(),
@@ -3156,10 +3156,10 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
pLabel,
pControl);
- pLabel.reset();
+ pLabel.clear();
- pNewControl = pControl.release();
- OUnoObject* pObj = dynamic_cast<OUnoObject*>(pNewControl);
+ pNewControl = pControl;
+ OUnoObject* pObj = dynamic_cast<OUnoObject*>(pNewControl.get());
assert(pObj);
if(pObj)
{
@@ -3222,7 +3222,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
aPos.X = nPaperWidth - nShapeWidth;
xShapeProp->setPosition(aPos);
- correctOverlapping(pNewControl,pSectionWindow->getReportSection());
+ correctOverlapping(pNewControl.get(),pSectionWindow->getReportSection());
}
void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
@@ -3437,7 +3437,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
continue;
Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats());
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl[2];
+ rtl::Reference<SdrUnoObj> pControl[2];
const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
OSectionView* pSectionViews[2];
@@ -3472,7 +3472,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
{
OUString sDefaultName;
size_t i = 0;
- OUnoObject* pObjs[2];
+ rtl::Reference<OUnoObject> pObjs[2];
for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
{
pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i].get());
@@ -3547,7 +3547,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
}
xShapePropLabel->setPosition(aPosLabel);
}
- OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
+ rtl::Reference<OUnoObject> pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
assert(pObj);
uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
xShapeProp->setName(xShapeProp->getName() + sDefaultName );
@@ -3598,9 +3598,6 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
}
}
}
- // not sure where the ownership of these passes too...
- pControl[0].release();
- pControl[1].release();
}
}
}
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index cb0f1ee67cb0..1d9ccd42c4e9 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -252,15 +252,15 @@ void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyC
if ( pObject )
{
// Clone to target SdrModel
- SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel));
- m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE);
+ rtl::Reference<SdrObject> pNewObj(pObject->CloneSdrObject(*m_pModel));
+ m_pPage->InsertObject(pNewObj.get(), SAL_MAX_SIZE);
tools::Rectangle aRet(VCLPoint(rCopy->getPosition()),VCLSize(rCopy->getSize()));
aRet.setHeight(aRet.getOpenHeight() + 1);
aRet.setWidth(aRet.getOpenWidth() + 1);
bool bOverlapping = true;
while ( bOverlapping )
{
- bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj) != nullptr;
+ bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj.get()) != nullptr;
if ( bOverlapping )
{
aRet.Move(0,aRet.getOpenHeight()+1);
@@ -268,7 +268,7 @@ void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyC
}
}
m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
- m_pView->MarkObj( pNewObj, m_pView->GetSdrPageView() );
+ m_pView->MarkObj( pNewObj.get(), m_pView->GetSdrPageView() );
if ( m_xSection.is() && (o3tl::make_unsigned(aRet.getOpenHeight() + aRet.Top()) > m_xSection->getHeight()) )
m_xSection->setHeight(aRet.getOpenHeight() + aRet.Top());
}
@@ -340,7 +340,7 @@ void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedOb
{
try
{
- SdrObject* pNewObj(pSdrObject->CloneSdrObject(pSdrObject->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pNewObj(pSdrObject->CloneSdrObject(pSdrObject->getSdrModelFromSdrObject()));
aCopies.emplace_back(pNewObj->getUnoShape(),uno::UNO_QUERY);
if ( _bEraseAnddNoClone )
{
diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx
index 50269c10f4fc..996d2530a1e3 100644
--- a/reportdesign/source/ui/report/ViewsWindow.cxx
+++ b/reportdesign/source/ui/report/ViewsWindow.cxx
@@ -968,18 +968,18 @@ void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const tools::Recta
if ( &rView != &_rSection )
{
- SdrObject *pNewObj = new SdrUnoObj(
+ rtl::Reference<SdrObject> pNewObj = new SdrUnoObj(
rView.getSdrModelFromSdrView(),
"com.sun.star.form.component.FixedText");
pNewObj->SetLogicRect(_aRect);
pNewObj->Move(Size(0, aNewPos.Y()));
bool bChanged = rView.GetModel()->IsChanged();
- rReportSection.getPage()->InsertObject(pNewObj);
+ rReportSection.getPage()->InsertObject(pNewObj.get());
rView.GetModel()->SetChanged(bChanged);
- m_aBegDragTempList.push_back(pNewObj);
+ m_aBegDragTempList.push_back(pNewObj.get());
- rView.MarkObj( pNewObj, rView.GetSdrPageView() );
+ rView.MarkObj( pNewObj.get(), rView.GetSdrPageView() );
}
const tools::Long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
aNewPos.AdjustY( -nSectionHeight );
diff --git a/reportdesign/source/ui/report/dlgedfac.cxx b/reportdesign/source/ui/report/dlgedfac.cxx
index 7429d5517500..fe05fcdf2b97 100644
--- a/reportdesign/source/ui/report/dlgedfac.cxx
+++ b/reportdesign/source/ui/report/dlgedfac.cxx
@@ -40,9 +40,9 @@ DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
IMPL_STATIC_LINK(
- DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
+ DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> )
{
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
if ( aParams.nInventor == SdrInventor::ReportDesign )
{
@@ -66,7 +66,7 @@ IMPL_STATIC_LINK(
case SdrObjKind::ReportDesignVerticalFixedLine:
case SdrObjKind::ReportDesignHorizontalFixedLine:
{
- OUnoObject* pObj = new OUnoObject(aParams.rSdrModel, SERVICE_FIXEDLINE
+ rtl::Reference<OUnoObject> pObj = new OUnoObject(aParams.rSdrModel, SERVICE_FIXEDLINE
,OUString("com.sun.star.awt.UnoControlFixedLineModel")
,aParams.nObjIdentifier);
pNewObj = pObj;
diff --git a/sc/CppunitTest_sc_shapetest.mk b/sc/CppunitTest_sc_shapetest.mk
index 9a36083d48e8..9ca17f2512c0 100644
--- a/sc/CppunitTest_sc_shapetest.mk
+++ b/sc/CppunitTest_sc_shapetest.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_shapetest, \
$(eval $(call gb_CppunitTest_use_libraries,sc_shapetest, \
cppu \
+ cppuhelper \
sal \
sc \
sfx \
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 8a94402b88ad..36473542e1df 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -21,6 +21,7 @@
#include <rtl/ustring.hxx>
#include <svl/itemset.hxx>
+#include <rtl/ref.hxx>
#include "address.hxx"
#include "scdllapi.h"
@@ -36,110 +37,6 @@ class ScDocument;
namespace tools { class Rectangle; }
struct ScCaptionInitData;
-/** Some desperate attempt to fight against the caption object ownership mess,
- to which none of shared/weak/plain pointer is a cure.
- */
-class ScCaptionPtr
-{
-public:
- ScCaptionPtr();
- explicit ScCaptionPtr( SdrCaptionObj* p );
- ScCaptionPtr( const ScCaptionPtr& r );
- ScCaptionPtr(ScCaptionPtr&& r) noexcept;
- ~ScCaptionPtr();
-
- ScCaptionPtr& operator=( const ScCaptionPtr& r );
- ScCaptionPtr& operator=(ScCaptionPtr&& r) noexcept;
- explicit operator bool() const { return mpCaption != nullptr; }
- const SdrCaptionObj* get() const { return mpCaption; }
- SdrCaptionObj* get() { return mpCaption; }
- const SdrCaptionObj* operator->() const { return mpCaption; }
- SdrCaptionObj* operator->() { return mpCaption; }
- const SdrCaptionObj& operator*() const { return *mpCaption; }
- SdrCaptionObj& operator*() { return *mpCaption; }
-
- // Does not default to nullptr to make it visually obvious where such is used.
- void reset( SdrCaptionObj* p );
-
- /** Insert to draw page. The caption object is owned by the draw page then.
- */
- void insertToDrawPage( SdrPage& rDrawPage );
-
- /** Remove from draw page. The caption object is not owned anymore by the
- draw page then.
- */
- void removeFromDrawPage( SdrPage& rDrawPage );
-
- /** Remove from draw page and free caption object if no Undo recording.
- */
- void removeFromDrawPageAndFree( bool bIgnoreUndo = false );
-
- /** Release all management of the SdrCaptionObj* in all instances of this
- list and dissolve. The SdrCaptionObj pointer returned is ready to be
- managed elsewhere.
- */
- SdrCaptionObj* release();
-
- /** Forget the SdrCaptionObj pointer in this one instance.
- Decrements a use count but does not destroy the object, it's up to the
- caller to manage this mess...
- */
- void forget();
-
- /** Flag that this instance is in Undo, so drawing layer owns it. */
- void setNotOwner();
-
- oslInterlockedCount getRefs() const;
-
-private:
-
- struct Head
- {
- ScCaptionPtr* mpFirst; ///< first in list
- oslInterlockedCount mnRefs; ///< use count
-
- Head() = delete;
- explicit Head( ScCaptionPtr* );
- };
-
- Head* mpHead; ///< points to the "master" entry
- mutable ScCaptionPtr* mpNext; ///< next in list
- SdrCaptionObj* mpCaption; ///< the caption object, managed by head master
- bool mbNotOwner; ///< whether this caption object is owned by something else, e.g. held in Undo
- /* TODO: can that be moved to Head?
- * It's unclear when to reset, so
- * each instance has its own flag.
- * The last reference count
- * decrement automatically has the
- * then current state available.
- * */
-
- void newHead(); //< Allocate a new Head and init.
- void incRef() const;
- bool decRef() const; //< @returns <TRUE/> if the last reference was decremented.
- void decRefAndDestroy(); //< Destroys caption object if the last reference was decremented.
-
- /** Remove from current list and close gap.
-
- Usually there are only very few instances, so maintaining a doubly
- linked list isn't worth memory/performance wise and a simple walk does
- it.
- */
- void removeFromList();
-
- /** Replace this instance with pNew in a list, if any.
-
- Used by move-ctor and move assignment operator.
- */
- void replaceInList(ScCaptionPtr* pNew) noexcept;
-
- /** Dissolve list when the caption object is released or gone. */
- void dissolve();
-
- /** Just clear everything, while dissolving the list. */
- void clear();
-};
-
/** Internal data for a cell annotation. */
struct ScNoteData
{
@@ -148,7 +45,7 @@ struct ScNoteData
OUString maDate; /// Creation date of the note.
OUString maAuthor; /// Author of the note.
ScCaptionInitDataRef mxInitData; /// Initial data for invisible notes without SdrObject.
- ScCaptionPtr mxCaption; /// Drawing object representing the cell note.
+ rtl::Reference<SdrCaptionObj> mxCaption; /// Drawing object representing the cell note.
bool mbShown; /// True = note is visible.
explicit ScNoteData( bool bShown = false );
@@ -282,7 +179,7 @@ class SC_DLLPUBLIC ScNoteUtil
public:
/** Creates and returns a caption object for a temporary caption. */
- static ScCaptionPtr CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos,
+ static rtl::Reference<SdrCaptionObj> CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos,
SdrPage& rDrawPage, std::u16string_view rUserText,
const tools::Rectangle& rVisRect, bool bTailFront );
diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx
index 1e9aa498c67d..d00b7a3f91b5 100644
--- a/sc/qa/extras/anchor.cxx
+++ b/sc/qa/extras/anchor.cxx
@@ -173,8 +173,8 @@ void ScAnchorTest::testTdf76183()
// Add a circle somewhere below first row.
const tools::Rectangle aOrigRect(1000, 1000, 1200, 1200);
- SdrCircObj* pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrCircObj> pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
+ pPage->InsertObject(pObj.get());
// Anchor to cell
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0, false);
const tools::Rectangle& rNewRect = pObj->GetLogicRect();
@@ -191,6 +191,7 @@ void ScAnchorTest::testTdf76183()
// The resize of first row must have moved the object down after its anchor cell
CPPUNIT_ASSERT(aOrigRect.Top() < rNewRect.Top());
+ pObj.clear();
pDocSh->DoClose();
}
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 8417d0bf51b9..4eb7a9a5ef60 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -606,14 +606,15 @@ void ScShapeTest::testTdf139583_Rotate180deg()
const tools::Rectangle aRect(Point(3000, 4000), Size(5000, 2000));
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
CPPUNIT_ASSERT_MESSAGE("No ScDrawLayer", pDrawLayer);
- SdrRectObj* pObj = new SdrRectObj(*pDrawLayer, aRect);
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(*pDrawLayer, aRect);
CPPUNIT_ASSERT_MESSAGE("Could not create rectangle", pObj);
- pPage->InsertObject(pObj);
+ pPage->InsertObject(pObj.get());
// Anchor "to cell (resize with cell)" and then rotate it by 180deg around center
// The order is important here.
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
pObj->Rotate(aRect.Center(), Degree100(18000), 0.0, -1.0);
+ pObj.clear();
// Save and reload.
saveAndReload(xComponent, "calc8");
@@ -838,13 +839,13 @@ void ScShapeTest::testTdf137576_LogicRectInNewMeasureline()
Point aEndPoint(13000, 8000);
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
CPPUNIT_ASSERT_MESSAGE("No ScDrawLayer", pDrawLayer);
- SdrMeasureObj* pObj = new SdrMeasureObj(*pDrawLayer, aStartPoint, aEndPoint);
+ rtl::Reference<SdrMeasureObj> pObj = new SdrMeasureObj(*pDrawLayer, aStartPoint, aEndPoint);
CPPUNIT_ASSERT_MESSAGE("Could not create measure line", pObj);
- pPage->InsertObject(pObj);
+ pPage->InsertObject(pObj.get());
// Anchor "to cell (resize with cell)" and examine NonRotatedAnchor
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
- ScDrawObjData* pNData = ScDrawLayer::GetNonRotatedObjData(pObj);
+ ScDrawObjData* pNData = ScDrawLayer::GetNonRotatedObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to get NonRotatedAnchor", pNData);
// Without the fix all four values would be zero.
CPPUNIT_ASSERT_EQUAL(SCCOL(1), pNData->maStart.Col());
@@ -852,6 +853,7 @@ void ScShapeTest::testTdf137576_LogicRectInNewMeasureline()
CPPUNIT_ASSERT_EQUAL(SCCOL(7), pNData->maEnd.Col());
CPPUNIT_ASSERT_EQUAL(SCROW(2), pNData->maEnd.Row());
+ pObj.clear();
pDocSh->DoClose();
}
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 2a631c12d296..59ecb66e6bc2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3210,8 +3210,8 @@ void Test::testGraphicsInGroup()
{
//Add a square
tools::Rectangle aOrigRect(2,2,100,100);
- SdrRectObj *pObj = new SdrRectObj(*pDrawLayer, aOrigRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(*pDrawLayer, aOrigRect);
+ pPage->InsertObject(pObj.get());
const tools::Rectangle &rNewRect = pObj->GetLogicRect();
CPPUNIT_ASSERT_EQUAL_MESSAGE("must have equal position and size",
const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
@@ -3249,8 +3249,8 @@ void Test::testGraphicsInGroup()
{
// Add a circle.
tools::Rectangle aOrigRect(10,10,210,210); // 200 x 200
- SdrCircObj* pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrCircObj> pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
+ pPage->InsertObject(pObj.get());
const tools::Rectangle& rNewRect = pObj->GetLogicRect();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Position and size of the circle shouldn't change when inserted into the page.",
const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
@@ -3281,9 +3281,9 @@ void Test::testGraphicsInGroup()
tools::Rectangle aOrigRect(10,200,110,300); // 100 x 100
aTempPoly.append(basegfx::B2DPoint(aStartPos.X(), aStartPos.Y()));
aTempPoly.append(basegfx::B2DPoint(aEndPos.X(), aEndPos.Y()));
- SdrPathObj* pObj = new SdrPathObj(*pDrawLayer, SdrObjKind::Line, basegfx::B2DPolyPolygon(aTempPoly));
+ rtl::Reference<SdrPathObj> pObj = new SdrPathObj(*pDrawLayer, SdrObjKind::Line, basegfx::B2DPolyPolygon(aTempPoly));
pObj->NbcSetLogicRect(aOrigRect);
- pPage->InsertObject(pObj);
+ pPage->InsertObject(pObj.get());
const tools::Rectangle& rNewRect = pObj->GetLogicRect();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Size differ.",
const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
@@ -3324,13 +3324,13 @@ void Test::testGraphicsOnSheetMove()
// Insert an object.
tools::Rectangle aObjRect(2,2,100,100);
- SdrObject* pObj = new SdrRectObj(*pDrawLayer, aObjRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrObject> pObj = new SdrRectObj(*pDrawLayer, aObjRect);
+ pPage->InsertObject(pObj.get());
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0, false);
CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be one object on the 1st sheet.", static_cast<size_t>(1), pPage->GetObjCount());
- const ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
+ const ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Object meta-data doesn't exist.", pData);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet ID in cell anchor data!", SCTAB(0), pData->maStart.Tab());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet ID in cell anchor data!", SCTAB(0), pData->maEnd.Tab());
@@ -3386,7 +3386,7 @@ void Test::testGraphicsOnSheetMove()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Copied sheet should have one object.", size_t(1), pPage->GetObjCount());
pObj = pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("Failed to get drawing object.", pObj);
- pData = ScDrawLayer::GetObjData(pObj);
+ pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to get drawing object meta-data.", pData);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet ID in cell anchor data!", SCTAB(2), pData->maStart.Tab());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet ID in cell anchor data!", SCTAB(2), pData->maEnd.Tab());
@@ -5471,8 +5471,8 @@ void Test::testAnchoredRotatedShape()
tools::Rectangle aRect( 4000, 5000, 10000, 7000 );
tools::Rectangle aRotRect( 6000, 3000, 8000, 9000 );
- SdrRectObj *pObj = new SdrRectObj(*pDrawLayer, aRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(*pDrawLayer, aRect);
+ pPage->InsertObject(pObj.get());
Point aRef1(pObj->GetSnapRect().Center());
Degree100 nAngle = 9000_deg100; //90 deg.
double nSin = 1.0; // sin(90 deg)
@@ -5488,7 +5488,7 @@ void Test::testAnchoredRotatedShape()
CPPUNIT_ASSERT_EQUAL( true, testEqualsWithTolerance( aRotRect.Top(), aSnap.Top(), TOLERANCE ) );
ScDrawObjData aAnchor;
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj.get() );
CPPUNIT_ASSERT_MESSAGE("Failed to get drawing object meta-data.", pData);
aAnchor.maStart = pData->maStart;
@@ -6435,19 +6435,19 @@ void Test::testUndoDataAnchor()
// Insert an object.
tools::Rectangle aObjRect(2,1000,100,1100);
- SdrObject* pObj = new SdrRectObj(*pDrawLayer, aObjRect);
- pPage->InsertObject(pObj);
+ rtl::Reference<SdrObject> pObj = new SdrRectObj(*pDrawLayer, aObjRect);
+ pPage->InsertObject(pObj.get());
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0, false);
// Get anchor data
- ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
+ ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve user data for this object.", pData);
ScAddress aOldStart = pData->maStart;
ScAddress aOldEnd = pData->maEnd;
// Get non rotated anchor data
- ScDrawObjData* pNData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ ScDrawObjData* pNData = ScDrawLayer::GetNonRotatedObjData( pObj.get() );
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve non rotated user data for this object.", pNData);
ScAddress aNOldStart = pNData->maStart;
@@ -6462,14 +6462,14 @@ void Test::testUndoDataAnchor()
aMark.SelectOneTable(0);
rFunc.InsertCells(ScRange( 0, aOldStart.Row() - 1, 0, m_pDoc->MaxCol(), aOldStart.Row(), 0 ), &aMark, INS_INSROWS_BEFORE, true, true);
- pData = ScDrawLayer::GetObjData(pObj);
+ pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve user data for this object.", pData);
ScAddress aNewStart = pData->maStart;
ScAddress aNewEnd = pData->maEnd;
// Get non rotated anchor data
- pNData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ pNData = ScDrawLayer::GetNonRotatedObjData( pObj.get() );
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve non rotated user data for this object.", pNData);
ScAddress aNNewStart = pNData->maStart;
@@ -6490,11 +6490,11 @@ void Test::testUndoDataAnchor()
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Failed to check state SCA_CELL.", SCA_CELL, oldType);
// Get anchor data
- pData = ScDrawLayer::GetObjData(pObj);
+ pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve user data for this object.", pData);
// Get non rotated anchor data
- pNData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ pNData = ScDrawLayer::GetNonRotatedObjData( pObj.get() );
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve non rotated user data for this object.", pNData);
// Check if data has moved to new rows
@@ -6507,11 +6507,11 @@ void Test::testUndoDataAnchor()
pUndoMgr->Redo();
// Get anchor data
- pData = ScDrawLayer::GetObjData(pObj);
+ pData = ScDrawLayer::GetObjData(pObj.get());
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve user data for this object.", pData);
// Get non rotated anchor data
- pNData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ pNData = ScDrawLayer::GetNonRotatedObjData( pObj.get() );
CPPUNIT_ASSERT_MESSAGE("Failed to retrieve non rotated user data for this object.", pNData);
// Check if data has moved to new rows
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 2af82ec07429..0f0218753403 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -1986,15 +1986,15 @@ void TestSort::testSortImages()
// Insert graphic in cell B2.
const tools::Rectangle aOrigRect(1000, 1000, 1200, 1200);
- SdrCircObj* pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
+ rtl::Reference<SdrCircObj> pObj = new SdrCircObj(*pDrawLayer, SdrCircKind::Full, aOrigRect);
SdrPage* pPage = pDrawLayer->GetPage(0);
CPPUNIT_ASSERT(pPage);
- pPage->InsertObject(pObj);
+ pPage->InsertObject(pObj.get());
// Anchor to cell
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0, false);
// Move to cell B2
ScAddress aCellPos(1, 1, 0);
- pDrawLayer->MoveObject(pObj, aCellPos);
+ pDrawLayer->MoveObject(pObj.get(), aCellPos);
std::map<SCROW, std::vector<SdrObject*>> pRowObjects
= pDrawLayer->GetObjectsAnchoredToRange(aCellPos.Tab(), aCellPos.Col(), aCellPos.Row(), aCellPos.Row());
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 28f0e233386c..b471a9a0f0f6 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -77,9 +77,9 @@ void ScDocument::TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTA
while (pOldObject)
{
// Clone to target SdrModel
- SdrObject* pNewObject(pOldObject->CloneSdrObject(*mpDrawLayer));
+ rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*mpDrawLayer));
pNewObject->NbcMove(Size(0,0));
- pNewPage->InsertObject( pNewObject );
+ pNewPage->InsertObject( pNewObject.get() );
if (mpDrawLayer->IsRecording())
mpDrawLayer->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pNewObject ) );
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 1b8da616f014..78c32baabea1 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -107,7 +107,7 @@ ScUndoObjData::~ScUndoObjData()
void ScUndoObjData::Undo()
{
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( mxObj.get() );
OSL_ENSURE(pData,"ScUndoObjData: Data missing");
if (pData)
{
@@ -116,7 +116,7 @@ void ScUndoObjData::Undo()
}
// Undo also an untransformed anchor
- pData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ pData = ScDrawLayer::GetNonRotatedObjData( mxObj.get() );
if (pData)
{
pData->maStart = aOldStt;
@@ -126,7 +126,7 @@ void ScUndoObjData::Undo()
void ScUndoObjData::Redo()
{
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( mxObj.get() );
OSL_ENSURE(pData,"ScUndoObjData: Data missing");
if (pData)
{
@@ -135,7 +135,7 @@ void ScUndoObjData::Redo()
}
// Redo also an untransformed anchor
- pData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ pData = ScDrawLayer::GetNonRotatedObjData( mxObj.get() );
if (pData)
{
pData->maStart = aNewStt;
@@ -159,30 +159,30 @@ ScUndoAnchorData::~ScUndoAnchorData()
void ScUndoAnchorData::Undo()
{
// Trigger Object Change
- if (pObj->IsInserted() && pObj->getSdrPageFromSdrObject())
+ if (mxObj->IsInserted() && mxObj->getSdrPageFromSdrObject())
{
- SdrHint aHint(SdrHintKind::ObjectChange, *pObj);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ SdrHint aHint(SdrHintKind::ObjectChange, *mxObj);
+ mxObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
if (mbWasCellAnchored)
- ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *mpDoc, mnTab, mbWasResizeWithCell);
+ ScDrawLayer::SetCellAnchoredFromPosition(*mxObj, *mpDoc, mnTab, mbWasResizeWithCell);
else
- ScDrawLayer::SetPageAnchored( *pObj );
+ ScDrawLayer::SetPageAnchored( *mxObj );
}
void ScUndoAnchorData::Redo()
{
if (mbWasCellAnchored)
- ScDrawLayer::SetPageAnchored( *pObj );
+ ScDrawLayer::SetPageAnchored( *mxObj );
else
- ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *mpDoc, mnTab, mbWasResizeWithCell);
+ ScDrawLayer::SetCellAnchoredFromPosition(*mxObj, *mpDoc, mnTab, mbWasResizeWithCell);
// Trigger Object Change
- if (pObj->IsInserted() && pObj->getSdrPageFromSdrObject())
+ if (mxObj->IsInserted() && mxObj->getSdrPageFromSdrObject())
{
- SdrHint aHint(SdrHintKind::ObjectChange, *pObj);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ SdrHint aHint(SdrHintKind::ObjectChange, *mxObj);
+ mxObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
}
@@ -449,10 +449,10 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
}
// Clone to target SdrModel
- SdrObject* pNewObject(pOldObject->CloneSdrObject(*this));
+ rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*this));
pNewObject->NbcMove(Size(0,0));
- pNewPage->InsertObject( pNewObject );
- ScDrawObjData* pNewData = GetObjData(pNewObject);
+ pNewPage->InsertObject( pNewObject.get() );
+ ScDrawObjData* pNewData = GetObjData(pNewObject.get());
if (pNewData)
{
pNewData->maStart.SetTab(nNewTab);
@@ -1735,12 +1735,12 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec
if (pDestPage)
{
// Clone to target SdrModel
- SdrObject* pNewObject(pOldObject->CloneSdrObject(*pDestModel));
+ rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*pDestModel));
uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) );
if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise
pNewObject->NbcMove(Size(0,0));
- pDestPage->InsertObject( pNewObject );
+ pDestPage->InsertObject( pNewObject.get() );
// no undo needed in clipboard document
// charts are not updated
@@ -1905,16 +1905,16 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
&& !IsNoteCaption(pOldObject))
{
// Clone to target SdrModel
- SdrObject* pNewObject(pOldObject->CloneSdrObject(*this));
+ rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*this));
if ( bMirrorObj )
- MirrorRTL( pNewObject ); // first mirror, then move
+ MirrorRTL( pNewObject.get() ); // first mirror, then move
pNewObject->NbcMove( aMove );
if ( bResize )
pNewObject->NbcResize( aRefPos, aHorFract, aVerFract );
- pDestPage->InsertObject( pNewObject );
+ pDestPage->InsertObject( pNewObject.get() );
if (bRecording)
AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pNewObject ) );
@@ -1922,7 +1922,7 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if ( pNewObject->GetObjIdentifier() == SdrObjKind::OLE2 )
{
- uno::Reference< embed::XEmbeddedObject > xIPObj = static_cast<SdrOle2Obj*>(pNewObject)->GetObjRef();
+ uno::Reference< embed::XEmbeddedObject > xIPObj = static_cast<SdrOle2Obj*>(pNewObject.get())->GetObjRef();
uno::Reference< embed::XClassifiedObject > xClassified = xIPObj;
SvGlobalName aObjectClassName;
if ( xClassified.is() )
@@ -1937,10 +1937,10 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if ( xIPObj.is() && SotExchange::IsChart( aObjectClassName ) )
{
- uno::Reference< chart2::XChartDocument > xNewChart( ScChartHelper::GetChartFromSdrObject( pNewObject ) );
+ uno::Reference< chart2::XChartDocument > xNewChart( ScChartHelper::GetChartFromSdrObject( pNewObject.get() ) );
if( xNewChart.is() && !xNewChart->hasInternalDataProvider() )
{
- OUString aChartName = static_cast<SdrOle2Obj*>(pNewObject)->GetPersistName();
+ OUString aChartName = static_cast<SdrOle2Obj*>(pNewObject.get())->GetPersistName();
::std::vector< ScRangeList > aRangesVector;
pDoc->GetChartRanges( aChartName, aRangesVector, *pDoc );
if( !aRangesVector.empty() )
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 9f0f7ab2af4b..f33ed9dd6b68 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -167,12 +167,12 @@ public:
/** Create a new caption. The caption will not be inserted into the document. */
explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, bool bTailFront );
/** Manipulate an existing caption. */
- explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScCaptionPtr xCaption );
+ explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, const rtl::Reference<SdrCaptionObj>& xCaption );
/** Returns the drawing layer page of the sheet contained in maPos. */
SdrPage* GetDrawPage();
/** Returns the caption drawing object. */
- ScCaptionPtr & GetCaption() { return mxCaption; }
+ rtl::Reference<SdrCaptionObj> & GetCaption() { return mxCaption; }
/** Moves the caption inside the passed rectangle. Uses page area if 0 is passed. */
void FitCaptionToRect( const tools::Rectangle* pVisRect = nullptr );
@@ -199,7 +199,7 @@ private:
private:
ScDocument& mrDoc;
ScAddress maPos;
- ScCaptionPtr mxCaption;
+ rtl::Reference<SdrCaptionObj> mxCaption;
tools::Rectangle maPageRect;
tools::Rectangle maCellRect;
bool mbNegPage;
@@ -213,10 +213,10 @@ ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, boo
CreateCaption( true/*bShown*/, bTailFront );
}
-ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScCaptionPtr xCaption ) :
+ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, const rtl::Reference<SdrCaptionObj>& xCaption ) :
mrDoc( rDoc ),
maPos( rPos ),
- mxCaption(std::move( xCaption ))
+ mxCaption( xCaption )
{
Initialize();
}
@@ -380,11 +380,11 @@ void ScCaptionCreator::CreateCaption( bool bShown, bool bTailFront )
// create the caption drawing object
tools::Rectangle aTextRect( Point( 0 , 0 ), Size( SC_NOTECAPTION_WIDTH, SC_NOTECAPTION_HEIGHT ) );
Point aTailPos = CalcTailPos( bTailFront );
- mxCaption.reset(
+ mxCaption =
new SdrCaptionObj(
*mrDoc.GetDrawLayer(), // TTTT should ret a ref?
aTextRect,
- aTailPos));
+ aTailPos);
// basic caption settings
ScCaptionUtil::SetBasicCaptionSettings( *mxCaption, bShown );
}
@@ -410,7 +410,7 @@ public:
/** Create a new caption object and inserts it into the document. */
explicit ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScNoteData& rNoteData );
/** Manipulate an existing caption. */
- explicit ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScCaptionPtr& xCaption, bool bShown );
+ explicit ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, rtl::Reference<SdrCaptionObj>& xCaption, bool bShown );
};
ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScNoteData& rNoteData ) :
@@ -434,7 +434,7 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& r
}
}
-ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScCaptionPtr& xCaption, bool bShown ) :
+ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, rtl::Reference<SdrCaptionObj>& xCaption, bool bShown ) :
ScCaptionCreator( rDoc, rPos, xCaption )
{
SdrPage* pDrawPage = GetDrawPage();
@@ -453,372 +453,6 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& r
} // namespace
-ScCaptionPtr::ScCaptionPtr() :
- mpHead(nullptr), mpNext(nullptr), mpCaption(nullptr), mbNotOwner(false)
-{
-}
-
-ScCaptionPtr::ScCaptionPtr( SdrCaptionObj* p ) :
- mpHead(nullptr), mpNext(nullptr), mpCaption(p), mbNotOwner(false)
-{
- if (p)
- {
- newHead();
- }
-}
-
-ScCaptionPtr::ScCaptionPtr( const ScCaptionPtr& r ) :
- mpHead(r.mpHead), mpCaption(r.mpCaption), mbNotOwner(false)
-{
- if (r.mpCaption)
- {
- assert(r.mpHead);
- r.incRef();
- // Insert into list.
- mpNext = r.mpNext;
- r.mpNext = this;
- }
- else
- {
- assert(!r.mpHead);
- mpNext = nullptr;
- }
-}
-
-ScCaptionPtr::ScCaptionPtr(ScCaptionPtr&& r) noexcept
- : mpHead(r.mpHead), mpNext(r.mpNext), mpCaption(r.mpCaption), mbNotOwner(false)
-{
- r.replaceInList( this );
- r.mpCaption = nullptr;
- r.mbNotOwner = false;
-}
-
-ScCaptionPtr& ScCaptionPtr::operator=(ScCaptionPtr&& r) noexcept
-{
- assert(this != &r);
-
- mpHead = r.mpHead;
- mpNext = r.mpNext;
- mpCaption = r.mpCaption;
- mbNotOwner = r.mbNotOwner;
-
- r.replaceInList( this );
- r.mpCaption = nullptr;
- r.mbNotOwner = false;
-
- return *this;
-}
-
-ScCaptionPtr& ScCaptionPtr::operator=( const ScCaptionPtr& r )
-{
- if (this == &r)
- return *this;
-
- if (mpCaption == r.mpCaption)
- {
- // Two lists for the same caption is bad.
- assert(!mpCaption || mpHead == r.mpHead);
- assert(!mpCaption); // assigning same caption pointer within same list is weird
- // Nullptr captions are not inserted to the list, so nothing to do here
- // if both are.
- return *this;
- }
-
- // Let's find some weird usage.
- // Assigning without head doesn't make sense unless it is a nullptr caption.
- assert(r.mpHead || !r.mpCaption);
- // A nullptr caption must not be in a list and thus not have a head.
- assert(!r.mpHead || r.mpCaption);
- // Same captions were caught above, so here different heads must be present.
- assert(r.mpHead != mpHead);
-
- r.incRef();
- decRefAndDestroy();
- removeFromList();
-
- mpCaption = r.mpCaption;
- mbNotOwner = r.mbNotOwner;
- // That head is this' master.
- mpHead = r.mpHead;
- // Insert into list.
- mpNext = r.mpNext;
- r.mpNext = this;
-
- return *this;
-}
-
-void ScCaptionPtr::setNotOwner()
-{
- mbNotOwner = true;
-}
-
-ScCaptionPtr::Head::Head( ScCaptionPtr* p ) :
- mpFirst(p), mnRefs(1)
-{
-}
-
-void ScCaptionPtr::newHead()
-{
- assert(!mpHead);
- mpHead = new Head(this);
-}
-
-void ScCaptionPtr::replaceInList(ScCaptionPtr* pNew) noexcept
-{
- if (!mpHead && !mpNext)
- return;
-
- assert(mpHead);
- assert(mpCaption == pNew->mpCaption);
-
- ScCaptionPtr* pThat = mpHead->mpFirst;
- while (pThat && pThat != this && pThat->mpNext != this)
- {
- pThat = pThat->mpNext;
- }
- if (pThat && pThat != this)
- {
- assert(pThat->mpNext == this);
- pThat->mpNext = pNew;
- }
- pNew->mpNext = mpNext;
- if (mpHead->mpFirst == this)
- mpHead->mpFirst = pNew;
-
- mpHead = nullptr;
- mpNext = nullptr;
-}
-
-void ScCaptionPtr::removeFromList()
-{
- if (!mpHead && !mpNext && !mpCaption)
- return;
-
-#if OSL_DEBUG_LEVEL > 0
- oslInterlockedCount nCount = 0;
-#endif
- ScCaptionPtr* pThat = (mpHead ? mpHead->mpFirst : nullptr);
- while (pThat && pThat != this && pThat->mpNext != this)
- {
- // Use the walk to check consistency on the fly.
- assert(pThat->mpHead == mpHead); // all belong to the same
- assert(pThat->mpHead || !pThat->mpNext); // next without head is bad
- assert(pThat->mpCaption == mpCaption);
- pThat = pThat->mpNext;
-#if OSL_DEBUG_LEVEL > 0
- ++nCount;
-#endif
- }
- assert(pThat || !mpHead); // not found only if this was standalone
- if (pThat)
- {
- if (pThat != this)
- {
-#if OSL_DEBUG_LEVEL > 0
- // The while loop above was not executed, and for this
- // (pThat->mpNext) the loop below won't either.
- ++nCount;
-#endif
- pThat->mpNext = mpNext;
- }
-#if OSL_DEBUG_LEVEL > 0
- do
- {
- assert(pThat->mpHead == mpHead); // all belong to the same
- assert(pThat->mpHead || !pThat->mpNext); // next without head is bad
- assert(pThat->mpCaption == mpCaption);
- ++nCount;
- }
- while ((pThat = pThat->mpNext) != nullptr);
-#endif
- }
-#if OSL_DEBUG_LEVEL > 0
- // If part of a list then refs were already decremented.
- assert(nCount == (mpHead ? mpHead->mnRefs + 1 : 0));
-#endif
- if (mpHead && mpHead->mpFirst == this)
- {
- if (mpNext)
- mpHead->mpFirst = mpNext;
- else
- {
- // The only one destroys also head.
- assert(mpHead->mnRefs == 0); // cough
- delete mpHead; // DEAD now
- }
- }
- mpHead = nullptr;
- mpNext = nullptr;
-}
-
-void ScCaptionPtr::reset( SdrCaptionObj* p )
-{
- assert(!p || p != mpCaption);
-#if OSL_DEBUG_LEVEL > 0
- if (p)
- {
- // Check if we end up with a duplicated management in this list.
- ScCaptionPtr* pThat = (mpHead ? mpHead->mpFirst : nullptr);
- while (pThat)
- {
- assert(pThat->mpCaption != p);
- pThat = pThat->mpNext;
- }
- }
-#endif
- decRefAndDestroy();
- removeFromList();
- mpCaption = p;
- mbNotOwner = false;
- if (p)
- {
- newHead();
- }
-}
-
-ScCaptionPtr::~ScCaptionPtr()
-{
- decRefAndDestroy();
- removeFromList();
-}
-
-oslInterlockedCount ScCaptionPtr::getRefs() const
-{
- return mpHead ? mpHead->mnRefs : 0;
-}
-
-void ScCaptionPtr::incRef() const
-{
- if (mpHead)
- osl_atomic_increment(&mpHead->mnRefs);
-}
-
-bool ScCaptionPtr::decRef() const
-{
- return mpHead && mpHead->mnRefs > 0 && !osl_atomic_decrement(&mpHead->mnRefs);
-}
-
-void ScCaptionPtr::decRefAndDestroy()
-{
- if (!decRef())
- return;
-
- assert(mpHead->mpFirst == this); // this must be one and only one
- assert(!mpNext); // this must be one and only one
- assert(mpCaption);
-
-#if 0
- // Quick workaround for when there are still cases where the caption
- // pointer is dangling
- mpCaption = nullptr;
- mbNotOwner = false;
-#else
- // Destroying Draw Undo and some other delete the SdrObject, don't
- // attempt that twice.
- if (mbNotOwner)
- {
- mpCaption = nullptr;
- mbNotOwner = false;
- }
- else
- {
- removeFromDrawPageAndFree( true ); // ignoring Undo
- if (mpCaption)
- {
- // There's no draw page associated so removeFromDrawPageAndFree()
- // didn't do anything, but still we want to delete the caption
- // object. release()/dissolve() also resets mpCaption.
- SdrObject* pObj = release();
- SdrObject::Free( pObj );
- }
- }
-#endif
- delete mpHead;
- mpHead = nullptr;
-}
-
-void ScCaptionPtr::insertToDrawPage( SdrPage& rDrawPage )
-{
- assert(mpHead && mpCaption);
-
- rDrawPage.InsertObject( mpCaption );
-}
-
-void ScCaptionPtr::removeFromDrawPage( SdrPage& rDrawPage )
-{
- assert(mpHead && mpCaption);
- SdrObject* pObj = rDrawPage.RemoveObject( mpCaption->GetOrdNum() );
- assert(pObj == mpCaption); (void)pObj;
-}
-
-void ScCaptionPtr::removeFromDrawPageAndFree( bool bIgnoreUndo )
-{
- assert(mpHead && mpCaption);
- SdrPage* pDrawPage(mpCaption->getSdrPageFromSdrObject());
- SAL_WARN_IF( !pDrawPage, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing page");
- if (!pDrawPage)
- return;
-
- pDrawPage->RecalcObjOrdNums();
- bool bRecording = false;
- if(!bIgnoreUndo)
- {
- ScDrawLayer* pDrawLayer(dynamic_cast< ScDrawLayer* >(&mpCaption->getSdrModelFromSdrObject()));
- SAL_WARN_IF( !pDrawLayer, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing layer");
- // create drawing undo action (before removing the object to have valid draw page in undo action)
- bRecording = (pDrawLayer && pDrawLayer->IsRecording());
- if (bRecording)
- pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoDelObj>( *mpCaption ));
- }
- // remove the object from the drawing page, delete if undo is disabled
- removeFromDrawPage( *pDrawPage );
- // If called from outside mnRefs must be 1 to delete. If called from
- // decRefAndDestroy() mnRefs is already 0.
- if (!bRecording && getRefs() <= 1)
- {
- SdrObject* pObj = release();
- SdrObject::Free( pObj );
- }
-}
-
-SdrCaptionObj* ScCaptionPtr::release()
-{
- SdrCaptionObj* pTmp = mpCaption;
- dissolve();
- return pTmp;
-}
-
-void ScCaptionPtr::forget()
-{
- decRef();
- removeFromList();
- mpCaption = nullptr;
- mbNotOwner = false;
-}
-
-void ScCaptionPtr::dissolve()
-{
- ScCaptionPtr::Head* pHead = mpHead;
- ScCaptionPtr* pThat = (mpHead ? mpHead->mpFirst : this);
- while (pThat)
- {
- assert(!pThat->mpNext || pThat->mpHead); // next without head is bad
- assert(pThat->mpHead == pHead); // same head required within one list
- ScCaptionPtr* p = pThat->mpNext;
- pThat->clear();
- pThat = p;
- }
- assert(!mpHead && !mpNext && !mpCaption); // should had been cleared during list walk
- delete pHead;
-}
-
-void ScCaptionPtr::clear()
-{
- mpHead = nullptr;
- mpNext = nullptr;
- mpCaption = nullptr;
- mbNotOwner = false;
-}
struct ScCaptionInitData
{
@@ -858,7 +492,7 @@ ScPostIt::ScPostIt( ScDocument& rDoc, const ScAddress& rPos, const ScPostIt& rNo
maNoteData( rNote.maNoteData )
{
mnPostItId = nPostItId == 0 ? mnLastPostItId++ : nPostItId;
- maNoteData.mxCaption.reset(nullptr);
+ maNoteData.mxCaption.clear();
CreateCaption( rPos, rNote.maNoteData.mxCaption.get() );
}
@@ -974,13 +608,13 @@ void ScPostIt::ForgetCaption( bool bPreserveData )
pInitData->maSimpleText = GetText();
maNoteData.mxInitData.reset(pInitData);
- maNoteData.mxCaption.forget();
+ maNoteData.mxCaption.clear();
}
else
{
/* This function is used in undo actions to give up the responsibility for
the caption object which is handled by separate drawing undo actions. */
- maNoteData.mxCaption.forget();
+ maNoteData.mxCaption.clear();
maNoteData.mxInitData.reset();
}
}
@@ -1091,7 +725,7 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const
void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCaption )
{
OSL_ENSURE( !maNoteData.mxCaption, "ScPostIt::CreateCaption - unexpected caption object found" );
- maNoteData.mxCaption.reset(nullptr);
+ maNoteData.mxCaption.clear();
/* #i104915# Never try to create notes in Undo document, leads to
crash due to missing document members (e.g. row height array). */
@@ -1147,9 +781,23 @@ void ScPostIt::RemoveCaption()
// TTTT maybe no longer needed - can that still happen?
ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer();
if (pDrawLayer == &maNoteData.mxCaption->getSdrModelFromSdrObject())
- maNoteData.mxCaption.removeFromDrawPageAndFree();
+ {
+ SdrPage* pDrawPage(maNoteData.mxCaption->getSdrPageFromSdrObject());
+ SAL_WARN_IF( !pDrawPage, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing page");
+ if (pDrawPage)
+ {
+ pDrawPage->RecalcObjOrdNums();
+ // create drawing undo action (before removing the object to have valid draw page in undo action)
+ bool bRecording = (pDrawLayer && pDrawLayer->IsRecording());
+ if (bRecording)
+ pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoDelObj>( *maNoteData.mxCaption ));
+ // remove the object from the drawing page
+ rtl::Reference<SdrObject> pRemovedObj = pDrawPage->RemoveObject( maNoteData.mxCaption->GetOrdNum() );
+ assert(pRemovedObj.get() == maNoteData.mxCaption.get()); (void)pRemovedObj;
+ }
+ }
- SAL_INFO("sc.core","ScPostIt::RemoveCaption - refs: " << maNoteData.mxCaption.getRefs() <<
+ SAL_INFO("sc.core","ScPostIt::RemoveCaption -"
" IsUndo: " << mrDoc.IsUndo() << " IsClip: " << mrDoc.IsClipboard() <<
" Dtor: " << mrDoc.IsInDtorClear());
@@ -1157,11 +805,11 @@ void ScPostIt::RemoveCaption()
if (maNoteData.mxCaption)
{
SAL_INFO("sc.core","ScPostIt::RemoveCaption - forgetting one ref");
- maNoteData.mxCaption.forget();
+ maNoteData.mxCaption.clear();
}
}
-ScCaptionPtr ScNoteUtil::CreateTempCaption(
+rtl::Reference<SdrCaptionObj> ScNoteUtil::CreateTempCaption(
ScDocument& rDoc, const ScAddress& rPos, SdrPage& rDrawPage,
std::u16string_view rUserText, const tools::Rectangle& rVisRect, bool bTailFront )
{
@@ -1178,7 +826,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
// create a caption if any text exists
if( !pNoteCaption && aBuffer.isEmpty() )
- return ScCaptionPtr();
+ return rtl::Reference<SdrCaptionObj>();
// prepare visible rectangle (add default distance to all borders)
tools::Rectangle aVisRect(
@@ -1191,9 +839,9 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
ScCaptionCreator aCreator( rDoc, rPos, bTailFront );
// insert caption into page (needed to set caption text)
- aCreator.GetCaption().insertToDrawPage( rDrawPage );
+ rtl::Reference<SdrCaptionObj> pCaption = aCreator.GetCaption(); // just for ease of use
+ rDrawPage.InsertObject( pCaption.get() );
- SdrCaptionObj* pCaption = aCreator.GetCaption().get(); // just for ease of use
// clone the edit text object, unless user text is present, then set this text
if( pNoteCaption && rUserText.empty() )
@@ -1230,7 +878,7 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption(
ScDocument& rDoc, const ScAddress& rPos, SdrCaptionObj* pCaption )
{
ScNoteData aNoteData( true/*bShown*/ );
- aNoteData.mxCaption.reset( pCaption );
+ aNoteData.mxCaption = pCaption;
ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false );
pNote->AutoStamp();
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index bd5202ecfbb7..ee8ba8b2226d 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -452,17 +452,17 @@ void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
// insert the rectangle before the arrow - this is relied on in FindFrameForObject
tools::Rectangle aRect = GetDrawRect( nRefStartCol, nRefStartRow, nRefEndCol, nRefEndRow );
- SdrRectObj* pBox = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pBox = new SdrRectObj(
*pModel,
aRect);
pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
pBox->SetLayer( SC_LAYER_INTERN );
- pPage->InsertObject( pBox );
+ pPage->InsertObject( pBox.get() );
pModel->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pBox ) );
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, true );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox.get(), true );
pData->maStart.Set( nRefStartCol, nRefStartRow, nTab);
pData->maEnd.Set( nRefEndCol, nRefEndRow, nTab);
}
@@ -495,7 +495,7 @@ void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
basegfx::B2DPolygon aTempPoly;
aTempPoly.append(basegfx::B2DPoint(aStartPos.X(), aStartPos.Y()));
aTempPoly.append(basegfx::B2DPoint(aEndPos.X(), aEndPos.Y()));
- SdrPathObj* pArrow = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pArrow = new SdrPathObj(
*pModel,
SdrObjKind::Line,
basegfx::B2DPolyPolygon(aTempPoly));
@@ -503,10 +503,10 @@ void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
pArrow->SetLayer( SC_LAYER_INTERN );
- pPage->InsertObject( pArrow );
+ pPage->InsertObject( pArrow.get() );
pModel->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pArrow ) );
- ScDrawObjData* pData = ScDrawLayer::GetObjData(pArrow, true);
+ ScDrawObjData* pData = ScDrawLayer::GetObjData(pArrow.get(), true);
if (bFromOtherTab)
pData->maStart.SetInvalid();
else
@@ -529,17 +529,17 @@ void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
if (bArea)
{
tools::Rectangle aRect = GetDrawRect( nStartCol, nStartRow, nEndCol, nEndRow );
- SdrRectObj* pBox = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pBox = new SdrRectObj(
*pModel,
aRect);
pBox->SetMergedItemSetAndBroadcast(rData.GetBoxSet());
pBox->SetLayer( SC_LAYER_INTERN );
- pPage->InsertObject( pBox );
+ pPage->InsertObject( pBox.get() );
pModel->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pBox ) );
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, true );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox.get(), true );
pData->maStart.Set( nStartCol, nStartRow, nTab);
pData->maEnd.Set( nEndCol, nEndRow, nTab);
}
@@ -564,7 +564,7 @@ void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
basegfx::B2DPolygon aTempPoly;
aTempPoly.append(basegfx::B2DPoint(aStartPos.X(), aStartPos.Y()));
aTempPoly.append(basegfx::B2DPoint(aEndPos.X(), aEndPos.Y()));
- SdrPathObj* pArrow = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pArrow = new SdrPathObj(
*pModel,
SdrObjKind::Line,
basegfx::B2DPolyPolygon(aTempPoly));
@@ -573,10 +573,10 @@ void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
pArrow->SetMergedItemSetAndBroadcast(rAttrSet);
pArrow->SetLayer( SC_LAYER_INTERN );
- pPage->InsertObject( pArrow );
+ pPage->InsertObject( pArrow.get() );
pModel->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pArrow ) );
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pArrow, true );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pArrow.get(), true );
pData->maStart.Set( nStartCol, nStartRow, nTab);
pData->maEnd.SetInvalid();
@@ -634,7 +634,7 @@ void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData
aRect.AdjustTop( -70 );
aRect.AdjustBottom(70 );
- SdrCircObj* pCircle = new SdrCircObj(
+ rtl::Reference<SdrCircObj> pCircle = new SdrCircObj(
*pModel,
SdrCircKind::Full,
aRect);
@@ -643,10 +643,10 @@ void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData
pCircle->SetMergedItemSetAndBroadcast(rAttrSet);
pCircle->SetLayer( SC_LAYER_INTERN );
- pPage->InsertObject( pCircle );
+ pPage->InsertObject( pCircle.get() );
pModel->AddCalcUndo( std::make_unique<SdrUndoInsertObj>( *pCircle ) );
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pCircle, true );
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pCircle.get(), true );
pData->maStart.Set( nCol, nRow, nTab);
pData->maEnd.SetInvalid();
pData->meType = ScDrawObjData::ValidationCircle;
@@ -696,9 +696,7 @@ void ScDetectiveFunc::DeleteArrowsAt( SCCOL nCol, SCROW nRow, bool bDestPnt )
for (size_t i=1; i<=nDelCount; ++i)
{
// remove the object from the drawing page, delete if undo is disabled
- SdrObject* pObj = pPage->RemoveObject(ppObj[nDelCount-i]->GetOrdNum());
- if( !bRecording )
- SdrObject::Free( pObj );
+ pPage->RemoveObject(ppObj[nDelCount-i]->GetOrdNum());
}
ppObj.reset();
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 1337e909d1ff..4d60bd5b3f5d 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -432,9 +432,9 @@ std::size_t XclImpDrawObjBase::GetProgressSize() const
return DoGetProgressSize();
}
-SdrObjectUniquePtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const
+rtl::Reference<SdrObject> XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const
{
- SdrObjectUniquePtr xSdrObj;
+ rtl::Reference<SdrObject> xSdrObj;
if( bIsDff && !mbCustomDff )
{
rDffConv.Progress( GetProgressSize() );
@@ -825,7 +825,7 @@ std::size_t XclImpDrawObjBase::DoGetProgressSize() const
return 1;
}
-SdrObjectUniquePtr XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& ) const
+rtl::Reference<SdrObject> XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& ) const
{
rDffConv.Progress( GetProgressSize() );
return nullptr;
@@ -1046,9 +1046,9 @@ std::size_t XclImpGroupObj::DoGetProgressSize() const
return XclImpDrawObjBase::DoGetProgressSize() + maChildren.GetProgressSize();
}
-SdrObjectUniquePtr XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& /*rAnchorRect*/ ) const
+rtl::Reference<SdrObject> XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& /*rAnchorRect*/ ) const
{
- std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> xSdrObj(
+ rtl::Reference<SdrObjGroup> xSdrObj(
new SdrObjGroup(
*GetDoc().GetDrawLayer()));
// child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle
@@ -1095,7 +1095,7 @@ void XclImpLineObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
ReadMacro5( rStrm, nMacroSize );
}
-SdrObjectUniquePtr XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
::basegfx::B2DPolygon aB2DPolygon;
switch( mnStartPoint )
@@ -1118,7 +1118,7 @@ SdrObjectUniquePtr XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv,
aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Right(), rAnchorRect.Top() ) );
break;
}
- SdrObjectUniquePtr xSdrObj(
+ rtl::Reference<SdrObject> xSdrObj(
new SdrPathObj(
*GetDoc().GetDrawLayer(),
SdrObjKind::Line,
@@ -1235,9 +1235,9 @@ void XclImpRectObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
ReadMacro5( rStrm, nMacroSize );
}
-SdrObjectUniquePtr XclImpRectObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpRectObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- SdrObjectUniquePtr xSdrObj(
+ rtl::Reference<SdrObject> xSdrObj(
new SdrRectObj(
*GetDoc().GetDrawLayer(),
rAnchorRect));
@@ -1251,9 +1251,9 @@ XclImpOvalObj::XclImpOvalObj( const XclImpRoot& rRoot ) :
{
}
-SdrObjectUniquePtr XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- SdrObjectUniquePtr xSdrObj(
+ rtl::Reference<SdrObject> xSdrObj(
new SdrCircObj(
*GetDoc().GetDrawLayer(),
SdrCircKind::Full,
@@ -1295,7 +1295,7 @@ void XclImpArcObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uIn
ReadMacro5( rStrm, nMacroSize );
}
-SdrObjectUniquePtr XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
tools::Rectangle aNewRect = rAnchorRect;
Degree100 nStartAngle;
@@ -1329,7 +1329,7 @@ SdrObjectUniquePtr XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, c
break;
}
SdrCircKind eObjKind = maFillData.IsFilled() ? SdrCircKind::Section : SdrCircKind::Arc;
- SdrObjectUniquePtr xSdrObj(
+ rtl::Reference<SdrObject> xSdrObj(
new SdrCircObj(
*GetDoc().GetDrawLayer(),
eObjKind,
@@ -1400,9 +1400,9 @@ namespace {
} // namespace
-SdrObjectUniquePtr XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- SdrObjectUniquePtr xSdrObj;
+ rtl::Reference<SdrObject> xSdrObj;
if( maCoords.size() >= 2 )
{
// create the polygon
@@ -1414,11 +1414,11 @@ SdrObjectUniquePtr XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffCon
aB2DPolygon.append( lclGetPolyPoint( rAnchorRect, maCoords.front() ) );
// create the SdrObject
SdrObjKind eObjKind = maFillData.IsFilled() ? SdrObjKind::PathPoly : SdrObjKind::PathPolyLine;
- xSdrObj.reset(
+ xSdrObj =
new SdrPathObj(
*GetDoc().GetDrawLayer(),
eObjKind,
- ::basegfx::B2DPolyPolygon(aB2DPolygon)));
+ ::basegfx::B2DPolyPolygon(aB2DPolygon));
ConvertRectStyle( *xSdrObj );
}
rDffConv.Progress();
@@ -1478,9 +1478,9 @@ void XclImpTextObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
maTextData.ReadFormats( rStrm );
}
-SdrObjectUniquePtr XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- std::unique_ptr<SdrObjCustomShape, SdrObjectFreeOp> xSdrObj(
+ rtl::Reference<SdrObjCustomShape> xSdrObj(
new SdrObjCustomShape(
*GetDoc().GetDrawLayer()));
xSdrObj->NbcSetSnapRect( rAnchorRect );
@@ -1751,9 +1751,9 @@ std::size_t XclImpChartObj::DoGetProgressSize() const
return mxChart ? mxChart->GetProgressSize() : 1;
}
-SdrObjectUniquePtr XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- SdrObjectUniquePtr xSdrObj;
+ rtl::Reference<SdrObject> xSdrObj;
SfxObjectShell* pDocShell = GetDocShell();
if( rDffConv.SupportsOleObjects() && SvtModuleOptions().IsChart() && pDocShell && mxChart && !mxChart->IsPivotChart() )
{
@@ -1777,12 +1777,12 @@ SdrObjectUniquePtr XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv,
// ChartHelper::AdaptDefaultsForChart( xEmbObj );
// create the container OLE object
- xSdrObj.reset(
+ xSdrObj =
new SdrOle2Obj(
*GetDoc().GetDrawLayer(),
svt::EmbeddedObjectRef(xEmbObj, nAspect),
aEmbObjName,
- rAnchorRect));
+ rAnchorRect);
}
return xSdrObj;
@@ -1883,11 +1883,11 @@ XclImpControlHelper::~XclImpControlHelper()
{
}
-SdrObjectUniquePtr XclImpControlHelper::CreateSdrObjectFromShape(
+rtl::Reference<SdrObject> XclImpControlHelper::CreateSdrObjectFromShape(
const Reference< XShape >& rxShape, const tools::Rectangle& rAnchorRect ) const
{
mxShape = rxShape;
- SdrObjectUniquePtr xSdrObj( SdrObject::getSdrObjectFromXShape( rxShape ) );
+ rtl::Reference<SdrObject> xSdrObj( SdrObject::getSdrObjectFromXShape( rxShape ) );
if( xSdrObj )
{
xSdrObj->NbcSetSnapRect( rAnchorRect );
@@ -2130,9 +2130,9 @@ void XclImpTbxObjBase::ConvertLabel( ScfPropertySet& rPropSet ) const
ConvertFont( rPropSet );
}
-SdrObjectUniquePtr XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
- SdrObjectUniquePtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
+ rtl::Reference<SdrObject> xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
rDffConv.Progress();
return xSdrObj;
}
@@ -3011,10 +3011,10 @@ void XclImpPictureObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRec
}
}
-SdrObjectUniquePtr XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
+rtl::Reference<SdrObject> XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const
{
// try to create an OLE object or form control
- SdrObjectUniquePtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
+ rtl::Reference<SdrObject> xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
// insert a graphic replacement for unsupported ole object ( if none already
// exists ) Hmm ok, it's possibly that there has been some imported
@@ -3032,11 +3032,11 @@ SdrObjectUniquePtr XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffCon
// no OLE - create a plain picture from IMGDATA record data
if( !xSdrObj && (maGraphic.GetType() != GraphicType::NONE) )
{
- xSdrObj.reset(
+ xSdrObj =
new SdrGrafObj(
*GetDoc().GetDrawLayer(),
maGraphic,
- rAnchorRect));
+ rAnchorRect);
ConvertRectStyle( *xSdrObj );
}
@@ -3392,11 +3392,11 @@ void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, XclImpDrawObjBase&
if( rDrawObj.IsValidSize( aAnchorRect ) )
{
// CreateSdrObject() recursively creates embedded child objects
- SdrObjectUniquePtr xSdrObj( rDrawObj.CreateSdrObject( *this, aAnchorRect, false ) );
+ rtl::Reference<SdrObject> xSdrObj( rDrawObj.CreateSdrObject( *this, aAnchorRect, false ) );
if( xSdrObj )
rDrawObj.PreProcessSdrObject( *this, *xSdrObj );
// call InsertSdrObject() also, if SdrObject is missing
- InsertSdrObject( rObjList, rDrawObj, xSdrObj.release() );
+ InsertSdrObject( rObjList, rDrawObj, xSdrObj.get() );
}
}
@@ -3437,9 +3437,9 @@ void XclImpDffConverter::NotifyMacroEventRead()
mbNotifyMacroEventRead = true;
}
-SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect )
+rtl::Reference<SdrObject> XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect )
{
- SdrObjectUniquePtr xSdrObj;
+ rtl::Reference<SdrObject> xSdrObj;
OUString aServiceName = rTbxObj.GetServiceName();
if( SupportsOleObjects() && !aServiceName.isEmpty() ) try
@@ -3472,9 +3472,9 @@ SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase&
return xSdrObj;
}
-SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, const tools::Rectangle& rAnchorRect )
+rtl::Reference<SdrObject> XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, const tools::Rectangle& rAnchorRect )
{
- SdrObjectUniquePtr xSdrObj;
+ rtl::Reference<SdrObject> xSdrObj;
if( SupportsOleObjects() )
{
@@ -3527,7 +3527,7 @@ SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpPictureObj&
ErrCode nError = ERRCODE_NONE;
namespace cssea = ::com::sun::star::embed::Aspects;
sal_Int64 nAspects = rPicObj.IsSymbol() ? cssea::MSOLE_ICON : cssea::MSOLE_CONTENT;
- xSdrObj.reset(
+ xSdrObj =
CreateSdrOLEFromStorage(
GetConvData().mrSdrModel,
aStrgName,
@@ -3540,7 +3540,7 @@ SdrObjectUniquePtr XclImpDffConverter::CreateSdrObject( const XclImpPictureObj&
nError,
mnOleImpFlags,
nAspects,
- GetRoot().GetMedium().GetBaseURL()));
+ GetRoot().GetMedium().GetBaseURL());
}
}
}
@@ -3602,7 +3602,7 @@ struct XclImpDrawObjClientData : public SvxMSDffClientData
}
-SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffObjData,
+rtl::Reference<SdrObject> XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffObjData,
SvxMSDffClientData& rClientData, tools::Rectangle& /*rTextRect*/, SdrObject* pOldSdrObj )
{
XclImpDffConvData& rConvData = GetConvData();
@@ -3610,7 +3610,7 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO
/* pOldSdrObj passes a generated SdrObject. This function owns this object
and can modify it. The function has either to return it back to caller
or to delete it by itself. */
- SdrObjectUniquePtr xSdrObj( pOldSdrObj );
+ rtl::Reference<SdrObject> xSdrObj( pOldSdrObj );
// find the OBJ record data related to the processed shape
XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd );
@@ -3659,7 +3659,7 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO
pTbxObj->SetDffProperties( *this );
// try to create a custom SdrObject that overwrites the passed object
- SdrObjectUniquePtr xNewSdrObj( xDrawObj->CreateSdrObject( *this, rAnchorRect, true ) );
+ rtl::Reference<SdrObject> xNewSdrObj( xDrawObj->CreateSdrObject( *this, rAnchorRect, true ) );
if( xNewSdrObj )
xSdrObj = std::move( xNewSdrObj );
@@ -3678,7 +3678,7 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO
has inserted the note into the document, and the SdrObject is not
needed anymore. */
if( !xDrawObj->IsInsertSdrObj() )
- xSdrObj.reset();
+ xSdrObj.clear();
}
if( xSdrObj )
@@ -3699,7 +3699,7 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO
xDrawObj->PostProcessSdrObject( *this, *xSdrObj );
}
- return xSdrObj.release();
+ return xSdrObj;
}
SdrObject* XclImpDffConverter::FinalizeObj(DffObjData& rDffObjData, SdrObject* pOldSdrObj )
@@ -3709,7 +3709,7 @@ SdrObject* XclImpDffConverter::FinalizeObj(DffObjData& rDffObjData, SdrObject* p
/* pOldSdrObj passes a generated SdrObject. This function owns this object
and can modify it. The function has either to return it back to caller
or to delete it by itself. */
- SdrObjectUniquePtr xSdrObj( pOldSdrObj );
+ rtl::Reference<SdrObject> xSdrObj( pOldSdrObj );
// find the OBJ record data related to the processed shape
XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd );
@@ -3721,7 +3721,7 @@ SdrObject* XclImpDffConverter::FinalizeObj(DffObjData& rDffObjData, SdrObject* p
ScDrawLayer::SetCellAnchoredFromPosition( *xSdrObj, GetDoc(), xDrawObj->GetTab(), false );
}
- return xSdrObj.release();
+ return xSdrObj.get();
}
bool XclImpDffConverter::InsertControl( const Reference< XFormComponent >& rxFormComp,
@@ -3876,9 +3876,9 @@ bool XclImpDffConverter::ProcessShContainer( SvStream& rDffStrm, const DffRecord
and the returned group object contains them all. ImportObj() calls the
virtual functions ProcessClientAnchor2() and ProcessObj() and writes
the pointer to the related draw object data (OBJ record) into aDrawObjClientData. */
- SdrObjectUniquePtr xSdrObj( ImportObj( rDffStrm, aDrawObjClientData, aDummy, aDummy, /*nCalledByGroup*/0, /*pShapeId*/nullptr ) );
+ rtl::Reference<SdrObject> xSdrObj( ImportObj( rDffStrm, aDrawObjClientData, aDummy, aDummy, /*nCalledByGroup*/0, /*pShapeId*/nullptr ) );
if (aDrawObjClientData.m_pTopLevelObj && xSdrObj )
- InsertSdrObject( GetConvData().mrSdrPage, *aDrawObjClientData.m_pTopLevelObj, xSdrObj.release() );
+ InsertSdrObject( GetConvData().mrSdrPage, *aDrawObjClientData.m_pTopLevelObj, xSdrObj.get() );
return rShHeader.SeekToEndOfRecord( rDffStrm );
}
@@ -3887,10 +3887,10 @@ void XclImpDffConverter::InsertSdrObject( SdrObjList& rObjList, const XclImpDraw
XclImpDffConvData& rConvData = GetConvData();
/* Take ownership of the passed object. If insertion fails (e.g. rDrawObj
states to skip insertion), the object is automatically deleted. */
- SdrObjectUniquePtr xSdrObj( pSdrObj );
+ rtl::Reference<SdrObject> xSdrObj( pSdrObj );
if( xSdrObj && rDrawObj.IsInsertSdrObj() )
{
- rObjList.NbcInsertObject( xSdrObj.release() );
+ rObjList.NbcInsertObject( xSdrObj.get() );
// callback to drawing manager for e.g. tracking of used sheet area
rConvData.mrDrawing.OnObjectInserted( rDrawObj );
// callback to drawing object for post processing (use pSdrObj, xSdrObj already released)
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 8a66101954bd..78d173568e97 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -168,7 +168,7 @@ class XclObjComment : public XclObj
{
ScAddress maScPos;
- // no need to use std::unique_ptr< SdrCaptionObj, SdrObjectFreeOp >
+ // no need to use std::unique_ptr< SdrCaptionObj >
SdrCaptionObj* mpCaption;
bool mbVisible;
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index cc7360576b81..2079d68f11c1 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -121,7 +121,7 @@ public:
/** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
std::size_t GetProgressSize() const;
/** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
- SdrObjectUniquePtr CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const;
+ rtl::Reference<SdrObject> CreateSdrObject( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect, bool bIsDff ) const;
/** Additional processing for the passed SdrObject before insertion into
the drawing page (calls virtual DoPreProcessSdrObj() function). */
void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj );
@@ -166,7 +166,7 @@ protected:
/** Derived classes may return a progress bar size different from 1. */
virtual std::size_t DoGetProgressSize() const;
/** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const;
/** Derived classes may perform additional processing for the passed SdrObject before insertion. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes may perform additional processing for the passed SdrObject after insertion. */
@@ -252,7 +252,7 @@ private:
/** Returns a progress bar size that takes all group children into account. */
virtual std::size_t DoGetProgressSize() const override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
XclImpDrawObjVector maChildren; /// Grouped objects.
sal_uInt16 mnFirstUngrouped; /// Object identifier of first object not grouped into this group.
@@ -272,7 +272,7 @@ private:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
XclObjLineData maLineData; /// BIFF5 line formatting.
sal_uInt16 mnArrows; /// Line arrows.
@@ -299,7 +299,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
protected:
XclObjFillData maFillData; /// BIFF5 fill formatting.
@@ -315,7 +315,7 @@ public:
protected:
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
};
/** An arc object. */
@@ -332,7 +332,7 @@ private:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
XclObjFillData maFillData; /// BIFF5 fill formatting.
XclObjLineData maLineData; /// BIFF5 line formatting.
@@ -354,7 +354,7 @@ private:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
typedef std::vector< Point > PointVector;
PointVector maCoords; /// Coordinates relative to bounding rectangle.
@@ -390,7 +390,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
/** Inserts the contained text data at the passed object. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const override;
@@ -420,7 +420,7 @@ protected:
/** Returns the needed size on the progress bar. */
virtual std::size_t DoGetProgressSize() const override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
/** Converts the chart document. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const override;
@@ -464,7 +464,7 @@ public:
bool HasCellLink() const { return mxCellLink != nullptr; }
/** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
- SdrObjectUniquePtr CreateSdrObjectFromShape(
+ rtl::Reference<SdrObject> CreateSdrObjectFromShape(
const css::uno::Reference< css::drawing::XShape >& rxShape,
const tools::Rectangle& rAnchorRect ) const;
@@ -518,7 +518,7 @@ protected:
void ConvertLabel( ScfPropertySet& rPropSet ) const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
/** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const override;
@@ -833,7 +833,7 @@ protected:
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) override;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObjectUniquePtr DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
+ virtual rtl::Reference<SdrObject> DoCreateSdrObj( XclImpDffConverter& rDffConv, const tools::Rectangle& rAnchorRect ) const override;
/** Override to do additional processing on the SdrObject. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const override;
@@ -940,9 +940,9 @@ public:
void FinalizeDrawing();
/** Creates the SdrObject for the passed Excel TBX form control object. */
- SdrObjectUniquePtr CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect );
+ rtl::Reference<SdrObject> CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const tools::Rectangle& rAnchorRect );
/** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
- SdrObjectUniquePtr CreateSdrObject( const XclImpPictureObj& rPicObj, const tools::Rectangle& rAnchorRect );
+ rtl::Reference<SdrObject> CreateSdrObject( const XclImpPictureObj& rPicObj, const tools::Rectangle& rAnchorRect );
/** Returns true, if the conversion of OLE objects is supported. */
bool SupportsOleObjects() const;
@@ -958,7 +958,7 @@ private:
DffRecordHeader& rHeader,
DffObjData& rObjData ) override;
/** Processes a DFF object, reads properties from DFF stream. */
- virtual SdrObject* ProcessObj(
+ virtual rtl::Reference<SdrObject> ProcessObj(
SvStream& rDffStrm,
DffObjData& rDffObjData,
SvxMSDffClientData& rClientData,
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index e3cdd25adee9..a36af94c2699 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -593,7 +593,7 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab,
if ( pI->pGraphic )
{
tools::Rectangle aRect ( aInsertPos, aLogicSize );
- SdrGrafObj* pObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pObj = new SdrGrafObj(
*pModel,
*pI->pGraphic,
aRect);
@@ -601,7 +601,7 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab,
// calling SetGraphicLink here doesn't work
pObj->SetName( pI->aURL );
- pPage->InsertObject( pObj );
+ pPage->InsertObject( pObj.get() );
// SetGraphicLink has to be used after inserting the object,
// otherwise an empty graphic is swapped in and the contact stuff crashes.
diff --git a/sc/source/ui/drawfunc/fuconarc.cxx b/sc/source/ui/drawfunc/fuconarc.cxx
index ef9b2c0fdd8e..77deb115fac8 100644
--- a/sc/source/ui/drawfunc/fuconarc.cxx
+++ b/sc/source/ui/drawfunc/fuconarc.cxx
@@ -111,13 +111,13 @@ void FuConstArc::Deactivate()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{
// case SID_DRAW_ARC:
// case SID_DRAW_PIE:
// case SID_DRAW_CIRCLECUT:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/fuconcustomshape.cxx b/sc/source/ui/drawfunc/fuconcustomshape.cxx
index ec2e7f0836b7..2994187b368e 100644
--- a/sc/source/ui/drawfunc/fuconcustomshape.cxx
+++ b/sc/source/ui/drawfunc/fuconcustomshape.cxx
@@ -112,9 +112,9 @@ void FuConstCustomShape::Deactivate()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
{
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/fuconpol.cxx b/sc/source/ui/drawfunc/fuconpol.cxx
index 6ce044ad9d5a..7290b5186ad7 100644
--- a/sc/source/ui/drawfunc/fuconpol.cxx
+++ b/sc/source/ui/drawfunc/fuconpol.cxx
@@ -174,7 +174,7 @@ void FuConstPolygon::Deactivate()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{
// case SID_DRAW_XPOLYGON:
// case SID_DRAW_XPOLYGON_NOFILL:
@@ -185,7 +185,7 @@ SdrObjectUniquePtr FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, con
// case SID_DRAW_FREELINE:
// case SID_DRAW_FREELINE_NOFILL:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx
index 8e31015e8ae3..6c2d548094bb 100644
--- a/sc/source/ui/drawfunc/fuconrec.cxx
+++ b/sc/source/ui/drawfunc/fuconrec.cxx
@@ -344,9 +344,9 @@ void FuConstRectangle::Deactivate()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/fuconuno.cxx b/sc/source/ui/drawfunc/fuconuno.cxx
index e4e3c3e3764b..f113b1825051 100644
--- a/sc/source/ui/drawfunc/fuconuno.cxx
+++ b/sc/source/ui/drawfunc/fuconuno.cxx
@@ -100,11 +100,11 @@ void FuConstUnoControl::Deactivate()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
{
// case SID_FM_CREATE_CONTROL:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 1e2791b12e16..9816bdb1e363 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -179,7 +179,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
tools::Rectangle aRect ( aInsertPos, aLogicSize );
- SdrGrafObj* pObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pObj = new SdrGrafObj(
pView->getSdrModelFromSdrView(), // TTTT pView should be reference
rGraphic1,
aRect);
@@ -198,7 +198,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
// don't select if from (dispatch) API, to allow subsequent cell operations
SdrInsertFlags nInsOptions = (bApi && !comphelper::LibreOfficeKit::isActive()) ? SdrInsertFlags::DONTMARK : SdrInsertFlags::NONE;
- bool bSuccess = pView->InsertObjectAtView( pObj, *pPV, nInsOptions );
+ bool bSuccess = pView->InsertObjectAtView( pObj.get(), *pPV, nInsOptions );
// SetGraphicLink has to be used after inserting the object,
// otherwise an empty graphic is swapped in and the contact stuff crashes.
@@ -247,12 +247,12 @@ static void lcl_InsertMedia( const OUString& rMediaURL, bool bApi,
if (!bRet) { return; }
}
- SdrMediaObj* pObj = new SdrMediaObj(
+ rtl::Reference<SdrMediaObj> pObj = new SdrMediaObj(
*rData.GetDocument().GetDrawLayer(),
tools::Rectangle(aInsertPos, aSize));
pObj->setURL( realURL, ""/*TODO?*/ );
- pView->InsertObjectAtView( pObj, *pPV, bApi ? SdrInsertFlags::DONTMARK : SdrInsertFlags::NONE );
+ pView->InsertObjectAtView( pObj.get(), *pPV, bApi ? SdrInsertFlags::DONTMARK : SdrInsertFlags::NONE );
}
#endif
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 945de4ac9268..ba7c2cba3573 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -342,13 +342,13 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView*
if ( rData.GetDocument().IsNegativePage( rData.GetTabNo() ) )
aPnt.AdjustX( -(aSize.Width()) ); // move position to left edge
tools::Rectangle aRect (aPnt, aSize);
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
*pDoc, // TTTT should be reference
aObjRef,
aName,
aRect);
SdrPageView* pPV = pView->GetSdrPageView();
- bool bSuccess = pView->InsertObjectAtView(pObj, *pPV);
+ bool bSuccess = pView->InsertObjectAtView(pObj.get(), *pPV);
if (bSuccess && nAspect != embed::Aspects::MSOLE_ICON)
{
@@ -383,7 +383,7 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView*
}
else if (bSuccess)
{
- rViewShell.ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
+ rViewShell.ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
}
}
@@ -583,7 +583,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
Point aStart = rViewSh.GetChartInsertPos( aSize, aPositionRange );
tools::Rectangle aRect (aStart, aSize);
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
*pDoc, // TTTT should be reference
svt::EmbeddedObjectRef(xObj, nAspect),
aName,
@@ -598,9 +598,9 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
// use the page instead of the view to insert, so no undo action is created yet
SdrPage* pPage = pPV->GetPage();
- pPage->InsertObject( pObj );
+ pPage->InsertObject( pObj.get() );
pView->UnmarkAllObj();
- pView->MarkObj( pObj, pPV );
+ pView->MarkObj( pObj.get(), pPV );
if (rReq.IsAPI())
{
@@ -613,7 +613,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
// only activate object if not called via API (e.g. macro)
if (!comphelper::LibreOfficeKit::isActive())
- rViewShell.ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
+ rViewShell.ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
//open wizard
//@todo get context from calc if that has one
diff --git a/sc/source/ui/drawfunc/fupoor.cxx b/sc/source/ui/drawfunc/fupoor.cxx
index decfacebe85c..a10aa185b54f 100644
--- a/sc/source/ui/drawfunc/fupoor.cxx
+++ b/sc/source/ui/drawfunc/fupoor.cxx
@@ -216,7 +216,7 @@ void FuPoor::StopDragTimer()
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& /* rRectangle */)
+rtl::Reference<SdrObject> FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& /* rRectangle */)
{
// empty base implementation
return nullptr;
diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx
index d907a0a72bf8..7f0ec1281484 100644
--- a/sc/source/ui/drawfunc/futext.cxx
+++ b/sc/source/ui/drawfunc/futext.cxx
@@ -620,14 +620,14 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
}
// Create default drawing objects via keyboard
-SdrObjectUniquePtr FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{
// case SID_DRAW_TEXT:
// case SID_DRAW_TEXT_VERTICAL:
// case SID_DRAW_TEXT_MARQUEE:
// case SID_DRAW_NOTEEDIT:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
*pDrDoc,
pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()));
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index c4487d45d724..9252dffa7695 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -120,11 +120,11 @@ void ScGraphicShell::ExecuteFilter( const SfxRequest& rReq )
if( pPageView )
{
- SdrGrafObj* pFilteredObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
+ rtl::Reference<SdrGrafObj> pFilteredObj = SdrObject::Clone(*pGraphicObj, pGraphicObj->getSdrModelFromSdrObject());
OUString aStr = pView->GetDescriptionOfMarkedObjects() + " " + ScResId(SCSTR_UNDO_GRAFFILTER);
pView->BegUndo( aStr );
pFilteredObj->SetGraphicObject( aFilterObj );
- pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj.get() );
pView->EndUndo();
}
}
@@ -169,7 +169,7 @@ void ScGraphicShell::ExecuteExternalEdit( SAL_UNUSED_PARAMETER SfxRequest& )
{
GraphicObject aGraphicObject( pGraphicObj->GetGraphicObject() );
m_ExternalEdits.push_back( std::make_unique<SdrExternalToolEdit>(
- pView, pObj));
+ pView, pGraphicObj));
m_ExternalEdits.back()->Edit( &aGraphicObject );
}
}
@@ -210,11 +210,11 @@ void ScGraphicShell::ExecuteCompressGraphic( SAL_UNUSED_PARAMETER SfxRequest& )
CompressGraphicsDialog dialog(GetViewData().GetDialogParent(), pGraphicObj, GetViewData().GetBindings());
if (dialog.run() == RET_OK)
{
- SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj();
+ rtl::Reference<SdrGrafObj> pNewObject = dialog.GetCompressedSdrGrafObj();
SdrPageView* pPageView = pView->GetSdrPageView();
OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Compress";
pView->BegUndo( aUndoString );
- pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject.get() );
pView->EndUndo();
}
}
@@ -343,12 +343,12 @@ void ScGraphicShell::ExecuteChangePicture( SAL_UNUSED_PARAMETER SfxRequest& /*rR
ErrCode nError = aDlg.GetGraphic(aGraphic);
if( nError == ERRCODE_NONE )
{
- SdrGrafObj* pNewObject(pGraphicObj->CloneSdrObject(pGraphicObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrGrafObj> pNewObject(SdrObject::Clone(*pGraphicObj, pGraphicObj->getSdrModelFromSdrObject()));
pNewObject->SetGraphic( aGraphic );
SdrPageView* pPageView = pView->GetSdrPageView();
OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Change";
pView->BegUndo( aUndoString );
- pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject.get() );
pView->EndUndo();
}
}
diff --git a/sc/source/ui/inc/fuconarc.hxx b/sc/source/ui/inc/fuconarc.hxx
index d1fb31aada2e..a330840ed078 100644
--- a/sc/source/ui/inc/fuconarc.hxx
+++ b/sc/source/ui/inc/fuconarc.hxx
@@ -37,7 +37,7 @@ public:
virtual void Deactivate() override;
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconcustomshape.hxx b/sc/source/ui/inc/fuconcustomshape.hxx
index 89f22d17a5bb..b491b48fe5e6 100644
--- a/sc/source/ui/inc/fuconcustomshape.hxx
+++ b/sc/source/ui/inc/fuconcustomshape.hxx
@@ -40,7 +40,7 @@ public:
virtual void Deactivate() override;
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject( const sal_uInt16 nID, const tools::Rectangle& rRectangle ) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject( const sal_uInt16 nID, const tools::Rectangle& rRectangle ) override;
// #i33136#
virtual bool doConstructOrthogonal() const override;
diff --git a/sc/source/ui/inc/fuconpol.hxx b/sc/source/ui/inc/fuconpol.hxx
index e09225136649..8cebc3b03a76 100644
--- a/sc/source/ui/inc/fuconpol.hxx
+++ b/sc/source/ui/inc/fuconpol.hxx
@@ -38,7 +38,7 @@ public:
virtual void Deactivate() override;
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconrec.hxx b/sc/source/ui/inc/fuconrec.hxx
index 1f3fbb8ee770..865ad5b2b425 100644
--- a/sc/source/ui/inc/fuconrec.hxx
+++ b/sc/source/ui/inc/fuconrec.hxx
@@ -38,7 +38,7 @@ public:
static void SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_uInt16 nSlotId);
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconuno.hxx b/sc/source/ui/inc/fuconuno.hxx
index 1c58d5db3f12..a1034c3ed4b6 100644
--- a/sc/source/ui/inc/fuconuno.hxx
+++ b/sc/source/ui/inc/fuconuno.hxx
@@ -44,7 +44,7 @@ public:
SC_DLLPUBLIC virtual void Deactivate() override;
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fupoor.hxx b/sc/source/ui/inc/fupoor.hxx
index 978a2ca095ed..6f226776b03f 100644
--- a/sc/source/ui/inc/fupoor.hxx
+++ b/sc/source/ui/inc/fupoor.hxx
@@ -94,7 +94,7 @@ public:
void StopDragTimer();
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle);
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle);
protected:
static void ImpForceQuadratic(tools::Rectangle& rRect);
diff --git a/sc/source/ui/inc/futext.hxx b/sc/source/ui/inc/futext.hxx
index c53a5b38892d..fc8e75dc15c0 100644
--- a/sc/source/ui/inc/futext.hxx
+++ b/sc/source/ui/inc/futext.hxx
@@ -47,7 +47,7 @@ public:
void StopEditMode();
// Create default drawing objects via keyboard
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
private:
std::unique_ptr<SdrOutliner> MakeOutliner();
diff --git a/sc/source/ui/inc/notemark.hxx b/sc/source/ui/inc/notemark.hxx
index 5fb1d6e94704..31965be07802 100644
--- a/sc/source/ui/inc/notemark.hxx
+++ b/sc/source/ui/inc/notemark.hxx
@@ -49,7 +49,7 @@ private:
tools::Rectangle m_aRect;
std::unique_ptr<SdrModel> m_pModel;
- ScCaptionPtr m_xObject;
+ rtl::Reference<SdrCaptionObj> m_xObject;
bool m_bVisible;
DECL_LINK( TimeHdl, Timer*, void );
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index b306dcd83a07..5d15ac26a677 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -22,6 +22,7 @@
#include <scitems.hxx>
#include <editeng/editobj.hxx>
#include <sfx2/app.hxx>
+#include <svx/svdocapt.hxx>
#include <comphelper/lok.hxx>
#include <osl/diagnose.h>
@@ -731,12 +732,10 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
if (bInsert)
{
maNewData = rNoteData;
- maNewData.mxCaption.setNotOwner();
}
else
{
maOldData = rNoteData;
- maOldData.mxCaption.setNotOwner();
}
}
@@ -750,8 +749,6 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
{
OSL_ENSURE( maOldData.mxCaption || maNewData.mxCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
OSL_ENSURE( !maOldData.mxInitData && !maNewData.mxInitData, "ScUndoReplaceNote::ScUndoReplaceNote - unexpected uninitialized note" );
- maOldData.mxCaption.setNotOwner();
- maNewData.mxCaption.setNotOwner();
}
ScUndoReplaceNote::~ScUndoReplaceNote()
diff --git a/sc/source/ui/unoobj/TablePivotCharts.cxx b/sc/source/ui/unoobj/TablePivotCharts.cxx
index b3a32cd457a0..da5fc9f2f19d 100644
--- a/sc/source/ui/unoobj/TablePivotCharts.cxx
+++ b/sc/source/ui/unoobj/TablePivotCharts.cxx
@@ -150,7 +150,7 @@ void SAL_CALL TablePivotCharts::addNewByName(OUString const & rName,
xReceiver->setArguments(aArgs);
}
- SdrOle2Obj* pObject = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObject = new SdrOle2Obj(
*pModel,
svt::EmbeddedObjectRef(xObject, embed::Aspects::MSOLE_CONTENT),
aName,
@@ -159,7 +159,7 @@ void SAL_CALL TablePivotCharts::addNewByName(OUString const & rName,
if (xObject.is())
xObject->setVisualAreaSize(nAspect, aAwtSize);
- pPage->InsertObject(pObject);
+ pPage->InsertObject(pObject.get());
pModel->AddUndo(std::make_unique<SdrUndoInsertObj>(*pObject));
}
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index 4b74bdf9c6d0..4d4ea02c3e24 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -248,7 +248,7 @@ void SAL_CALL ScChartsObj::addNewByName( const OUString& rName,
rDoc.GetChartListenerCollection()->insert( pChartListener );
pChartListener->StartListeningTo();
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
*pModel,
::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
aName,
@@ -262,7 +262,7 @@ void SAL_CALL ScChartsObj::addNewByName( const OUString& rName,
// Add here again if this is wanted (see task description for details)
// ChartHelper::AdaptDefaultsForChart( xObj );
- pPage->InsertObject( pObj );
+ pPage->InsertObject( pObj.get() );
pModel->AddUndo( std::make_unique<SdrUndoInsertObj>( *pObj ) );
}
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 2774e962aa67..24aec4aa5da2 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -1129,19 +1129,19 @@ SdrObject* ScDrawView::ApplyGraphicToObject(
const OUString& rBeginUndoText,
const OUString& rFile)
{
- if(dynamic_cast< SdrGrafObj* >(&rHitObject))
+ if(auto pGrafHitObj = dynamic_cast< SdrGrafObj* >(&rHitObject))
{
- SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(rHitObject.CloneSdrObject(rHitObject.getSdrModelFromSdrObject())));
+ rtl::Reference<SdrGrafObj> pNewGrafObj = SdrObject::Clone(*pGrafHitObj, rHitObject.getSdrModelFromSdrObject());
pNewGrafObj->SetGraphic(rGraphic);
BegUndo(rBeginUndoText);
- ReplaceObjectAtView(&rHitObject, *GetSdrPageView(), pNewGrafObj);
+ ReplaceObjectAtView(&rHitObject, *GetSdrPageView(), pNewGrafObj.get());
// set in all cases - the Clone() will have copied an existing link (!)
pNewGrafObj->SetGraphicLink( rFile );
EndUndo();
- return pNewGrafObj;
+ return pNewGrafObj.get();
}
else if(rHitObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rHitObject))
{
diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx
index 0c5774957080..2824a453e7e9 100644
--- a/sc/source/ui/view/notemark.cxx
+++ b/sc/source/ui/view/notemark.cxx
@@ -65,8 +65,7 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window*
ScNoteMarker::~ScNoteMarker()
{
- if (m_pModel)
- m_xObject.release(); // deleting pModel also deletes the SdrCaptionObj
+ m_xObject.clear();
InvalidateWin();
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index a1cf1879c12e..c25d3412d3fa 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -361,13 +361,13 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
return;
// create the default object
- SdrObjectUniquePtr pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
+ rtl::Reference<SdrObject> pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
if(!pObj)
return;
// insert into page
- pView->InsertObjectAtView(pObj.release(), *pPageView);
+ pView->InsertObjectAtView(pObj.get(), *pPageView);
switch ( nNewId )
{
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 75a359e6c9ef..d718a2e2cd00 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -507,7 +507,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
if(pPageView)
{
svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
- SdrObjectUniquePtr pNewDBField = pDrView->CreateFieldControl(aDescriptor);
+ rtl::Reference<SdrObject> pNewDBField = pDrView->CreateFieldControl(aDescriptor);
if(pNewDBField)
{
@@ -539,7 +539,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
}
}
- pView->InsertObjectAtView(pNewDBField.release(), *pPageView);
+ pView->InsertObjectAtView(pNewDBField.get(), *pPageView);
}
}
}
diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx
index 365d51117292..f4fc1f02bae0 100644
--- a/sc/source/ui/view/tabvwshg.cxx
+++ b/sc/source/ui/view/tabvwshg.cxx
@@ -60,12 +60,12 @@ void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rUR
ScDrawView* pDrView = pView->GetScDrawView();
SdrModel* pModel = pDrView->GetModel();
- SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj = SdrObjFactory::MakeNewObject(
*pModel,
SdrInventor::FmForm,
SdrObjKind::FormButton);
- SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
+ SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj.get() );
OSL_ENSURE( pUnoCtrl, "no SdrUnoObj");
if( !pUnoCtrl )
return;
@@ -114,7 +114,7 @@ void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rUR
// that seems not to be needed with UnoControls
// do not mark when Ole
- pDrView->InsertObjectSafe( pObj, *pDrView->GetSdrPageView() );
+ pDrView->InsertObjectSafe( pObj.get(), *pDrView->GetSdrPageView() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 714a759ed7c4..d1a6e5965fca 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -497,7 +497,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
{
MakeDrawLayer();
ScDrawView* pScDrawView = GetScDrawView();
- SdrObjectUniquePtr pObj = pScDrawView->CreateFieldControl( svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
+ rtl::Reference<SdrObject> pObj = pScDrawView->CreateFieldControl( svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
if (pObj)
{
Point aInsPos = aPos;
@@ -527,7 +527,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
}
}
- pScDrawView->InsertObjectSafe(pObj.release(), *pScDrawView->GetSdrPageView());
+ pScDrawView->InsertObjectSafe(pObj.get(), *pScDrawView->GetSdrPageView());
GetViewData().GetViewShell()->SetDrawShell( true );
bRet = true;
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index d83d6867fd87..d42860dad5fc 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -153,18 +153,18 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
const SdrObject* pObj=pM->GetMarkedSdrObj();
// Directly Clone to target SdrModel
- SdrObject* pNewObj(pObj->CloneSdrObject(*pDrawModel));
+ rtl::Reference<SdrObject> pNewObj(pObj->CloneSdrObject(*pDrawModel));
if (pNewObj!=nullptr)
{
// copy graphics within the same model - always needs new name
- if ( dynamic_cast<const SdrGrafObj*>( pNewObj) != nullptr && !bPasteIsMove )
+ if ( dynamic_cast<const SdrGrafObj*>( pNewObj.get()) != nullptr && !bPasteIsMove )
pNewObj->SetName(static_cast<ScDrawLayer*>(pDrawModel)->GetNewGraphicName());
if (nDiffX!=0 || nDiffY!=0)
pNewObj->NbcMove(Size(nDiffX,nDiffY));
if (pDestPage)
- pDestPage->InsertObject( pNewObj );
+ pDestPage->InsertObject( pNewObj.get() );
pScDrawView->AddUndo(std::make_unique<SdrUndoInsertObj>( *pNewObj ));
if (ScDrawLayer::IsCellAnchored(*pNewObj))
@@ -348,14 +348,14 @@ bool ScViewFunc::PasteObject( const Point& rPos, const uno::Reference < embed::X
tools::Rectangle aRect( aInsPos, aSize );
ScDrawView* pDrView = GetScDrawView();
- SdrOle2Obj* pSdrObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pSdrObj = new SdrOle2Obj(
pDrView->getSdrModelFromSdrView(),
aObjRef,
aName,
aRect);
SdrPageView* pPV = pDrView->GetSdrPageView();
- pDrView->InsertObjectSafe( pSdrObj, *pPV ); // don't mark if OLE
+ pDrView->InsertObjectSafe( pSdrObj.get(), *pPV ); // don't mark if OLE
GetViewData().GetViewShell()->SetDrawShell( true );
return true;
}
@@ -430,7 +430,7 @@ bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic,
GetViewData().GetViewShell()->SetDrawShell( true );
tools::Rectangle aRect(aPos, aSize);
- SdrGrafObj* pGrafObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(
pScDrawView->getSdrModelFromSdrView(),
rGraphic,
aRect);
@@ -442,7 +442,7 @@ bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic,
pGrafObj->SetName(aName);
// don't mark if OLE
- bool bSuccess = pScDrawView->InsertObjectSafe(pGrafObj, *pScDrawView->GetSdrPageView());
+ bool bSuccess = pScDrawView->InsertObjectSafe(pGrafObj.get(), *pScDrawView->GetSdrPageView());
// SetGraphicLink has to be used after inserting the object,
// otherwise an empty graphic is swapped in and the contact stuff crashes.
diff --git a/sd/inc/CustomAnimationEffect.hxx b/sd/inc/CustomAnimationEffect.hxx
index b30af36054d8..e6d1530fb48f 100644
--- a/sd/inc/CustomAnimationEffect.hxx
+++ b/sd/inc/CustomAnimationEffect.hxx
@@ -24,6 +24,7 @@
#include <com/sun/star/animations/XAudio.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/util/XChangesListener.hpp>
+#include <rtl/ref.hxx>
#include <vcl/timer.hxx>
#include <tools/long.hxx>
#include "sddllapi.h"
@@ -165,7 +166,7 @@ public:
SAL_DLLPRIVATE static sal_Int32 get_node_type( const css::uno::Reference< css::animations::XAnimationNode >& xNode );
SAL_DLLPRIVATE static sal_Int32 getNumberOfSubitems( const css::uno::Any& aTarget, sal_Int16 nIterateType );
- SAL_DLLPRIVATE SdrPathObj* createSdrPathObjFromPath(SdrModel& rTargetModel);
+ SAL_DLLPRIVATE rtl::Reference<SdrPathObj> createSdrPathObjFromPath(SdrModel& rTargetModel);
SAL_DLLPRIVATE void updateSdrPathObjFromPath( SdrPathObj& rPathObj );
SAL_DLLPRIVATE void updatePathFromSdrPathObj( const SdrPathObj& rPathObj );
diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index f8c2b4dc12b5..8d00cfbbba9c 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -272,7 +272,7 @@ private:
selection. This copy is necessary because during the search
process the mark list is modified.
*/
- ::std::vector<tools::WeakReference<SdrObject>> maMarkListCopy;
+ ::std::vector<unotools::WeakReference<SdrObject>> maMarkListCopy;
/** Current object that may be a text object. The object pointer to
corresponds to <member>mnObjIndex</member>. While iterating over the
diff --git a/sd/inc/OutlinerIterator.hxx b/sd/inc/OutlinerIterator.hxx
index d160609d885b..93ab32aba214 100644
--- a/sd/inc/OutlinerIterator.hxx
+++ b/sd/inc/OutlinerIterator.hxx
@@ -223,7 +223,7 @@ private:
This specifies at which object the iterator points initially.
*/
static Iterator CreateSelectionIterator (
- const ::std::vector<::tools::WeakReference<SdrObject>>& rObjectList,
+ const ::std::vector<::unotools::WeakReference<SdrObject>>& rObjectList,
SdDrawDocument* pDocument,
const std::shared_ptr<ViewShell>& rpViewShell,
bool bDirectionIsForward,
@@ -296,7 +296,7 @@ public:
bool operator== (const IteratorPosition& aPosition) const;
/// Pointer to the actual <type>SdrObject</type> object.
- ::tools::WeakReference<SdrObject> mxObject;
+ ::unotools::WeakReference<SdrObject> mxObject;
/// Number of the actual SdrText from the current <type>SdrObject</type>
sal_Int32 mnText;
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 16315c219603..9ba839724bc0 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -166,8 +166,8 @@ public:
sd::ShapeList& GetPresentationShapeList() { return maPresentationShapeList; }
void EnsureMasterPageDefaultBackground();
- SdrObject* CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect);
- SdrObject* CreateDefaultPresObj(PresObjKind eObjKind);
+ SdrObject* CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect);
+ rtl::Reference<SdrObject> CreateDefaultPresObj(PresObjKind eObjKind);
void DestroyDefaultPresObj(PresObjKind eObjKind);
SdrObject* GetPresObj(PresObjKind eObjKind, int nIndex = 1, bool bFuzzySearch = false );
PresObjKind GetPresObjKind(SdrObject* pObj) const;
@@ -192,12 +192,12 @@ public:
SdrObject* InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit);
virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
- virtual SdrObject* NbcRemoveObject(size_t nObjNum) override;
- virtual SdrObject* RemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> NbcRemoveObject(size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum) override;
/** Also override ReplaceObject methods to realize when
objects are removed with this mechanism instead of RemoveObject*/
- virtual SdrObject* ReplaceObject(SdrObject* pNewObj, size_t nObjNum) override;
+ virtual rtl::Reference<SdrObject> ReplaceObject(SdrObject* pNewObj, size_t nObjNum) override;
void SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, std::u16string_view rStr );
diff --git a/sd/inc/undo/undoobjects.hxx b/sd/inc/undo/undoobjects.hxx
index 4602187ec28e..830ced1464aa 100644
--- a/sd/inc/undo/undoobjects.hxx
+++ b/sd/inc/undo/undoobjects.hxx
@@ -54,7 +54,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
class UndoDeleteObject final : public SdrUndoDelObj, public UndoRemovePresObjectImpl
@@ -66,7 +66,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
class UndoReplaceObject final : public SdrUndoReplaceObj, public UndoRemovePresObjectImpl
@@ -78,7 +78,7 @@ public:
virtual void Redo() override;
private:
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
class UndoObjectSetText final : public SdrUndoObjSetText
@@ -93,7 +93,7 @@ public:
private:
std::unique_ptr<SfxUndoAction> mpUndoAnimation;
bool mbNewEmptyPresObj;
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
// Undo for SdrObject::SetUserCall()
@@ -109,7 +109,7 @@ public:
private:
SdrObjUserCall* mpOldUserCall;
SdrObjUserCall* mpNewUserCall;
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
// Undo for SdPage::InsertPresObj() and SdPage::RemovePresObj()
@@ -126,7 +126,7 @@ private:
PresObjKind meOldKind;
PresObjKind meNewKind;
::unotools::WeakReference<SdPage> mxPage;
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
// Restores correct position and size for presentation shapes with user call
@@ -154,7 +154,7 @@ public:
private:
::unotools::WeakReference<SdPage> mxPage;
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
class UndoAttrObject final : public SdrUndoAttrObj
@@ -167,7 +167,7 @@ public:
private:
::unotools::WeakReference<SdPage> mxPage;
- ::tools::WeakReference<SdrObject> mxSdrObject;
+ ::unotools::WeakReference<SdrObject> mxSdrObject;
};
} // namespace sd
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index fdd01128b7bf..db770887c999 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2567,8 +2567,7 @@ void SdTiledRenderingTest::testRegenerateDiagram()
// as the group shape is a diagram. Do the same as before done by triggering UI
// events directly in the model
// Remove and free top-left entry (Box showing "A")
- SdrObject* pTopLeftRemoved = pActualPage->GetObj(0)->GetSubList()->RemoveObject(1);
- SdrObject::Free(pTopLeftRemoved);
+ pActualPage->GetObj(0)->GetSubList()->RemoveObject(1);
// select diagram
pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx
index 8276184b45c9..52220afe7525 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -1566,9 +1566,9 @@ bool CustomAnimationEffect::getStopAudio() const
return mnCommand == EffectCommands::STOPAUDIO;
}
-SdrPathObj* CustomAnimationEffect::createSdrPathObjFromPath(SdrModel& rTargetModel)
+rtl::Reference<SdrPathObj> CustomAnimationEffect::createSdrPathObjFromPath(SdrModel& rTargetModel)
{
- SdrPathObj * pPathObj = new SdrPathObj(rTargetModel, SdrObjKind::PathLine);
+ rtl::Reference<SdrPathObj> pPathObj = new SdrPathObj(rTargetModel, SdrObjKind::PathLine);
updateSdrPathObjFromPath( *pPathObj );
return pPathObj;
}
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index afe778e8afc4..6c99ed6ba6e6 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -288,7 +288,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
- SdrObject* pSdrObj = nullptr;
+ rtl::Reference<SdrObject> pSdrObj;
bool bForceText = false; // forces the shape text to be set even if it's empty
bool bEmptyPresObj = true;
@@ -359,27 +359,27 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
Graphic aGraphic( aBmpEx );
- static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
}
break;
case PresObjKind::Chart:
{
pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
- static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" );
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarChart" );
BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
Graphic aGraphic( aBmpEx );
- static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
}
break;
case PresObjKind::OrgChart:
{
pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
- static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" );
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarOrg" );
BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
Graphic aGraphic( aBmpEx );
- static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
}
break;
@@ -387,10 +387,10 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
case PresObjKind::Calc:
{
pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
- static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" );
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarCalc" );
BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
Graphic aGraphic( aBmpEx );
- static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
+ static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
}
break;
@@ -446,9 +446,9 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
pSdrObj->SetEmptyPresObj(bEmptyPresObj);
pSdrObj->SetLogicRect(rRect);
- InsertObject(pSdrObj);
+ InsertObject(pSdrObj.get());
- if ( auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) )
+ if ( auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj.get() ) )
{
// Tell the object EARLY that it is vertical to have the
// defaults for AutoGrowWidth/Height reversed
@@ -496,7 +496,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
OUString aString = GetPresObjText(eObjKind);
if(!aString.isEmpty() || bForceText)
- if (auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) )
+ if (auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj.get() ) )
{
SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
@@ -589,13 +589,13 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>(*pSdrObj) );
}
- InsertPresObj(pSdrObj, eObjKind);
+ InsertPresObj(pSdrObj.get(), eObjKind);
pSdrObj->SetUserCall(this);
pSdrObj->RecalcBoundRect();
}
- return pSdrObj;
+ return pSdrObj.get();
}
/*************************************************************************
@@ -825,8 +825,8 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
// handout template
// delete all available handout presentation objects
- SdrObject *pObj=nullptr;
- while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) != nullptr )
+ rtl::Reference<SdrObject> pObj;
+ while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) )
{
pMasterPage->RemoveObject(pObj->GetOrdNum());
@@ -834,10 +834,7 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
{
pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
}
- else
- {
- SdrObject::Free( pObj );
- }
+ pObj.clear();
}
std::vector< ::tools::Rectangle > aAreas;
@@ -972,7 +969,7 @@ void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPag
}
-SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
+rtl::Reference<SdrObject> SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
{
if( eObjKind == PresObjKind::Title )
{
@@ -1069,9 +1066,6 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
SdrObjList* pOL = pObject->getParentSdrObjListFromSdrObject();
pOL->RemoveObject(pObject->GetOrdNumDirect());
-
- if( !bUndo )
- SdrObject::Free(pObject);
}
}
@@ -1659,12 +1653,12 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
if( !bInit )
return;
- SdrObject* pObj = nullptr;
maPresentationShapeList.seekShape(0);
+ rtl::Reference<SdrObject> pObj;
while( (pObj = maPresentationShapeList.getNextShape()) )
{
- if( aUsedPresentationObjects.count(pObj) == 0 )
+ if( aUsedPresentationObjects.count(pObj.get()) == 0 )
{
if( pObj->IsEmptyPresObj() )
@@ -1673,9 +1667,7 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
RemoveObject( pObj->GetOrdNum() );
-
- if( !bUndo )
- SdrObject::Free( pObj );
+ pObj.clear();
}
/* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
}
@@ -1713,7 +1705,7 @@ void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
|*
\************************************************************************/
-SdrObject* SdPage::RemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> SdPage::RemoveObject(size_t nObjNum)
{
onRemoveObject(GetObj( nObjNum ));
return FmFormPage::RemoveObject(nObjNum);
@@ -1725,7 +1717,7 @@ SdrObject* SdPage::RemoveObject(size_t nObjNum)
|*
\************************************************************************/
-SdrObject* SdPage::NbcRemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> SdPage::NbcRemoveObject(size_t nObjNum)
{
onRemoveObject(GetObj( nObjNum ));
return FmFormPage::NbcRemoveObject(nObjNum);
@@ -1733,7 +1725,7 @@ SdrObject* SdPage::NbcRemoveObject(size_t nObjNum)
// Also override ReplaceObject methods to realize when
// objects are removed with this mechanism instead of RemoveObject
-SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
+rtl::Reference<SdrObject> SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
{
onRemoveObject(GetObj( nObjNum ));
return FmFormPage::ReplaceObject(pNewObj, nObjNum);
@@ -2070,7 +2062,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN
}
}
-static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
+static rtl::Reference<SdrObject> convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
{
SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
if( !pSourceObj )
@@ -2079,7 +2071,7 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc
SfxUndoManager* pUndoManager = rModel.GetUndoManager();
const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
- SdrObject* pNewObj = pSourceObj;
+ rtl::Reference<SdrObject> pNewObj = pSourceObj;
if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() == SdrObjKind::Text) )
{
pNewObj = rPage.CreatePresObj(PresObjKind::Outline, bVertical, rRect);
@@ -2127,9 +2119,6 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc
// Remove outline shape from page
rPage.RemoveObject( pSourceObj->GetOrdNum() );
-
- if( !bUndo )
- SdrObject::Free( pSourceObj );
}
}
else if((eObjKind == PresObjKind::Text) && (pSourceObj->GetObjIdentifier() == SdrObjKind::OutlineText) )
@@ -2171,9 +2160,6 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc
pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
rPage.RemoveObject( pSourceObj->GetOrdNum() );
-
- if( !bUndo )
- SdrObject::Free( pSourceObj );
}
}
else if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() != SdrObjKind::OutlineText) )
@@ -2207,8 +2193,9 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc
@returns
A presentation shape that was either found or created with the given parameters
*/
-SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
+SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj1, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
@@ -2220,7 +2207,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
{
// convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
if( bInit )
- pObj = convertPresentationObjectImpl(*this, pObj, eObjKind, bVertical, rRect);
+ pObj = convertPresentationObjectImpl(*this, pObj.get(), eObjKind, bVertical, rRect);
if( bUndo )
{
@@ -2233,7 +2220,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
pObj->SetUserCall(this);
- SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj.get());
if( pTextObject )
{
if( pTextObject->IsVerticalWriting() != bVertical )
@@ -2286,12 +2273,12 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
if(pObj && bInit )
{
- if( !IsPresObj( pObj ) )
+ if( !IsPresObj( pObj.get() ) )
{
if( bUndo )
pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pObj ) );
- InsertPresObj( pObj, eObjKind );
+ InsertPresObj( pObj.get(), eObjKind );
}
// make adjustments for vertical title and outline shapes
@@ -2309,10 +2296,10 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
}
}
- if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj ) == nullptr ) )
+ if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj.get() ) == nullptr ) )
pObj->AdjustToMaxRect(rRect);
- return pObj;
+ return pObj.get();
}
/*************************************************************************
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index a5c8d1d5ff6d..6b2b73cda11c 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -491,7 +491,6 @@ void SdPage::RemoveEmptyPresentationObjects()
if (pShape->IsEmptyPresObj())
{
RemoveObject( pShape->GetOrdNum() );
- SdrObject::Free( pShape );
}
}
}
diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx
index f586dac21f64..62cc3accae7a 100644
--- a/sd/source/core/undo/undoobjects.cxx
+++ b/sd/source/core/undo/undoobjects.cxx
@@ -100,8 +100,8 @@ UndoRemoveObject::UndoRemoveObject( SdrObject& rObject )
void UndoRemoveObject::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoRemoveObject::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoRemoveObject::Undo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
SdrUndoRemoveObj::Undo();
UndoRemovePresObjectImpl::Undo();
@@ -110,8 +110,8 @@ void UndoRemoveObject::Undo()
void UndoRemoveObject::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoRemoveObject::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoRemoveObject::Redo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
UndoRemovePresObjectImpl::Redo();
SdrUndoRemoveObj::Redo();
@@ -127,8 +127,8 @@ UndoDeleteObject::UndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect )
void UndoDeleteObject::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoDeleteObject::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoDeleteObject::Undo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
SdrUndoDelObj::Undo();
UndoRemovePresObjectImpl::Undo();
@@ -137,8 +137,8 @@ void UndoDeleteObject::Undo()
void UndoDeleteObject::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoDeleteObject::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoDeleteObject::Redo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
UndoRemovePresObjectImpl::Redo();
SdrUndoDelObj::Redo();
@@ -154,8 +154,8 @@ UndoReplaceObject::UndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObje
void UndoReplaceObject::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoReplaceObject::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoReplaceObject::Undo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
SdrUndoReplaceObj::Undo();
UndoRemovePresObjectImpl::Undo();
@@ -164,8 +164,8 @@ void UndoReplaceObject::Undo()
void UndoReplaceObject::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoReplaceObject::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoReplaceObject::Redo(), object already dead!" );
+ if( mxSdrObject.get().is() )
{
UndoRemovePresObjectImpl::Redo();
SdrUndoReplaceObj::Redo();
@@ -197,10 +197,10 @@ UndoObjectSetText::~UndoObjectSetText()
void UndoObjectSetText::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoObjectSetText::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoObjectSetText::Undo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
- mbNewEmptyPresObj = mxSdrObject->IsEmptyPresObj();
+ mbNewEmptyPresObj = pSdrObject->IsEmptyPresObj();
SdrUndoObjSetText::Undo();
if( mpUndoAnimation )
mpUndoAnimation->Undo();
@@ -209,13 +209,13 @@ void UndoObjectSetText::Undo()
void UndoObjectSetText::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoObjectSetText::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoObjectSetText::Redo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
if( mpUndoAnimation )
mpUndoAnimation->Redo();
SdrUndoObjSetText::Redo();
- mxSdrObject->SetEmptyPresObj(mbNewEmptyPresObj);
+ pSdrObject->SetEmptyPresObj(mbNewEmptyPresObj);
}
}
@@ -231,20 +231,20 @@ UndoObjectUserCall::UndoObjectUserCall(SdrObject& rObject)
void UndoObjectUserCall::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoObjectUserCall::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoObjectUserCall::Undo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
- mpNewUserCall = mxSdrObject->GetUserCall();
- mxSdrObject->SetUserCall(mpOldUserCall);
+ mpNewUserCall = pSdrObject->GetUserCall();
+ pSdrObject->SetUserCall(mpOldUserCall);
}
}
void UndoObjectUserCall::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoObjectUserCall::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoObjectUserCall::Redo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
- mxSdrObject->SetUserCall(mpNewUserCall);
+ pSdrObject->SetUserCall(mpNewUserCall);
}
}
@@ -265,28 +265,30 @@ UndoObjectPresentationKind::UndoObjectPresentationKind(SdrObject& rObject)
void UndoObjectPresentationKind::Undo()
{
- if( !mxSdrObject.is() )
- return;
- if( rtl::Reference<SdPage> pPage = mxPage.get() )
+ if( auto pSdrObject = mxSdrObject.get() )
{
- meNewKind = pPage->GetPresObjKind( mxSdrObject.get() );
- if( meNewKind != PresObjKind::NONE )
- pPage->RemovePresObj( mxSdrObject.get() );
- if( meOldKind != PresObjKind::NONE )
- pPage->InsertPresObj( mxSdrObject.get(), meOldKind );
+ if( rtl::Reference<SdPage> pPage = mxPage.get() )
+ {
+ meNewKind = pPage->GetPresObjKind( pSdrObject.get() );
+ if( meNewKind != PresObjKind::NONE )
+ pPage->RemovePresObj( pSdrObject.get() );
+ if( meOldKind != PresObjKind::NONE )
+ pPage->InsertPresObj( pSdrObject.get(), meOldKind );
+ }
}
}
void UndoObjectPresentationKind::Redo()
{
- if( !mxSdrObject.is() )
- return;
- if( rtl::Reference<SdPage> pPage = mxPage.get() )
+ if( auto pSdrObject = mxSdrObject.get() )
{
- if( meOldKind != PresObjKind::NONE )
- pPage->RemovePresObj( mxSdrObject.get() );
- if( meNewKind != PresObjKind::NONE )
- pPage->InsertPresObj( mxSdrObject.get(), meNewKind );
+ if( rtl::Reference<SdPage> pPage = mxPage.get() )
+ {
+ if( meOldKind != PresObjKind::NONE )
+ pPage->RemovePresObj( pSdrObject.get() );
+ if( meNewKind != PresObjKind::NONE )
+ pPage->InsertPresObj( pSdrObject.get(), meNewKind );
+ }
}
}
@@ -316,8 +318,8 @@ UndoGeoObject::UndoGeoObject( SdrObject& rNewObj )
void UndoGeoObject::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoGeoObject::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoGeoObject::Undo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
if( auto pPage = mxPage.get() )
{
@@ -333,8 +335,8 @@ void UndoGeoObject::Undo()
void UndoGeoObject::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoGeoObject::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoGeoObject::Redo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
if( auto pPage = mxPage.get() )
{
@@ -357,8 +359,8 @@ UndoAttrObject::UndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSav
void UndoAttrObject::Undo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoAttrObject::Undo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoAttrObject::Undo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
if( auto pPage = mxPage.get() )
{
@@ -374,8 +376,8 @@ void UndoAttrObject::Undo()
void UndoAttrObject::Redo()
{
- DBG_ASSERT( mxSdrObject.is(), "sd::UndoAttrObject::Redo(), object already dead!" );
- if( mxSdrObject.is() )
+ DBG_ASSERT( mxSdrObject.get().is(), "sd::UndoAttrObject::Redo(), object already dead!" );
+ if( auto pSdrObject = mxSdrObject.get() )
{
if( auto pPage = mxPage.get() )
{
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 002c1c5db4e6..39c6ada55f4e 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -83,13 +83,13 @@ bool SdPdfFilter::Import()
// Make the page size match the rendered image.
pPage->SetSize(aSizeHMM);
- SdrGrafObj* pSdrGrafObj = new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
- tools::Rectangle(Point(), aSizeHMM));
+ rtl::Reference<SdrGrafObj> pSdrGrafObj = new SdrGrafObj(
+ pPage->getSdrModelFromSdrPage(), rGraphic, tools::Rectangle(Point(), aSizeHMM));
pSdrGrafObj->SetResizeProtect(true);
pSdrGrafObj->SetMoveProtect(true);
- pPage->InsertObject(pSdrGrafObj);
+ pPage->InsertObject(pSdrGrafObj.get());
for (auto const& rPDFAnnotation : rPDFGraphicResult.GetAnnotations())
{
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 305e1813ae77..7fd3a903dcd4 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -782,9 +782,9 @@ bool ImplSdPPTImport::Import()
break;
}
}
- SdrObject* pObj = ImportPageBackgroundObject( *pMPage, pE->nBackgroundOffset ); // import background
+ rtl::Reference<SdrObject> pObj = ImportPageBackgroundObject( *pMPage, pE->nBackgroundOffset ); // import background
if ( pObj )
- pMPage->NbcInsertObject( pObj );
+ pMPage->NbcInsertObject( pObj.get() );
bool bNewAnimationsUsed = false;
ProcessData aProcessData( (*pList)[ m_nCurrentPageNum ], SdPageCapsule(pMPage) );
@@ -827,11 +827,11 @@ bool ImplSdPPTImport::Import()
::tools::Rectangle aEmpty;
if (!aHd2.SeekToBegOfRecord(rStCtrl))
break;
- SdrObject* pImpObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/ nullptr );
+ rtl::Reference<SdrObject> pImpObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/ nullptr );
if ( pImpObj )
{
pImpObj->SetLayer( mnBackgroundObjectsLayerID );
- pMPage->NbcInsertObject( pImpObj );
+ pMPage->NbcInsertObject( pImpObj.get() );
}
}
}
@@ -910,7 +910,7 @@ bool ImplSdPPTImport::Import()
}
pMPage->RemoveObject(pObj->GetOrdNum());
- SdrObject::Free(pObj);
+ pObj.clear();
}
}
}
@@ -1463,9 +1463,9 @@ void ImplSdPPTImport::SetHeaderFooterPageSettings( SdPage* pPage, const PptSlide
bVisible = false;
rStCtrl.Seek( nPosition );
ProcessData aProcessData( rSlidePersist, SdPageCapsule(pPage) );
- SdrObject* pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
+ rtl::Reference<SdrObject> pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
if ( pObj )
- pPage->NbcInsertObject( pObj, 0 );
+ pPage->NbcInsertObject( pObj.get(), 0 );
}
}
OUString aPlaceHolderString = pHFE->pPlaceholder[ i ];
@@ -2590,28 +2590,23 @@ SdrObject* ImplSdPPTImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pObj
}
}
}
- if ( pRet != pText )
- {
- SdrObject* pFree( pText );
- SdrObject::Free( pFree );
- }
return pRet;
}
-SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, ::tools::Rectangle& rTextRect, SdrObject* pRet )
+rtl::Reference<SdrObject> ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, ::tools::Rectangle& rTextRect, SdrObject* pRet )
{
- SdrObject* pObj = SdrPowerPointImport::ProcessObj( rSt, rData, rClientData, rTextRect, pRet );
+ rtl::Reference<SdrObject> pObj = SdrPowerPointImport::ProcessObj( rSt, rData, rClientData, rTextRect, pRet );
// read animation effect of object
if ( pObj )
{
// further setup placeholder objects
- if (dynamic_cast<const SdrPageObj*>(pObj))
+ if (dynamic_cast<const SdrPageObj*>(pObj.get()))
{
const ProcessData& rProcessData=static_cast<const ProcessData&>(rClientData);
if(rProcessData.pPage.page)
static_cast<SdPage *>(rProcessData.pPage.page)->InsertPresObj(
- pObj, PresObjKind::Page );
+ pObj.get(), PresObjKind::Page );
}
DffRecordHeader aMasterShapeHd;
@@ -2650,10 +2645,10 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSD
bool bDontAnimateInvisibleShape = false;
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj.get());
if( pTextObj && pTextObj->HasText() &&
- dynamic_cast< SdrObjGroup *>( pObj ) == nullptr &&
+ dynamic_cast< SdrObjGroup *>( pObj.get() ) == nullptr &&
pAnimation->HasAnimateAssociatedShape() )
{
const SfxItemSet& rObjItemSet = pObj->GetMergedItemSet();
@@ -2671,7 +2666,7 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSD
//maybe some actions necessary to ensure that animations on master pages are played before animations on normal pages
//maybe todo in future: bool bIsEffectOnMasterPage = !bInhabitanceChecked;?
- maAnimations[pObj] = pAnimation;
+ maAnimations[pObj.get()] = pAnimation;
bAnimationInfoFound = true;
}
@@ -2710,7 +2705,7 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSD
aMediaURL = ReadSound( nRef );
if ( !aMediaURL.isEmpty() )
{
- SdrMediaObj* pMediaObj = new SdrMediaObj(
+ rtl::Reference<SdrMediaObj> pMediaObj = new SdrMediaObj(
pObj->getSdrModelFromSdrObject(),
pObj->GetSnapRect());
pMediaObj->SetMergedItemSet( pObj->GetMergedItemSet() );
@@ -2718,16 +2713,15 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSD
//--remove object from maAnimations list and add the new object instead
Ppt97AnimationPtr pAnimation;
{
- tAnimationMap::iterator aFound = maAnimations.find( pObj );
+ tAnimationMap::iterator aFound = maAnimations.find( pObj.get() );
if( aFound != maAnimations.end() )
{
pAnimation = (*aFound).second;
maAnimations.erase(aFound);
}
- maAnimations[pMediaObj] = pAnimation;
+ maAnimations[pMediaObj.get()] = pAnimation;
}
- SdrObject::Free( pObj );
pObj = pMediaObj; // SJ: hoping that pObj is not inserted in any list
pMediaObj->setURL( aMediaURL, ""/*TODO?*/ );
}
diff --git a/sd/source/filter/ppt/pptin.hxx b/sd/source/filter/ppt/pptin.hxx
index 39eff289045f..6dc02652cc76 100644
--- a/sd/source/filter/ppt/pptin.hxx
+++ b/sd/source/filter/ppt/pptin.hxx
@@ -60,7 +60,7 @@ class ImplSdPPTImport : public SdrPowerPointImport
void FillSdAnimationInfo( SdAnimationInfo* pInfo, PptInteractiveInfoAtom const * pIAtom, const OUString& aMacroName );
- virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, ::tools::Rectangle& rTextRect, SdrObject* pObj ) override;
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rData, SvxMSDffClientData& rClientData, ::tools::Rectangle& rTextRect, SdrObject* pObj ) override;
virtual SdrObject* ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pText, SdPageCapsule pPage,
SfxStyleSheet*, SfxStyleSheet** ) const override;
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index b963d8b66a5b..5ddcc9ac7921 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -353,7 +353,7 @@ MotionPathTag::MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, con
mpPathObj->SetMergedItem(XLineTransparenceItem(50));
- mpMark.reset(new SdrMark( mpPathObj, mrView.GetSdrPageView() ));
+ mpMark.reset(new SdrMark( mpPathObj.get(), mrView.GetSdrPageView() ));
mpPathObj->AddListener( *this );
@@ -887,10 +887,10 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
}
SmartTagReference xThis( this );
- std::unique_ptr<SdPathHdl> pHdl(new SdPathHdl( xThis, mpPathObj ));
+ std::unique_ptr<SdPathHdl> pHdl(new SdPathHdl( xThis, mpPathObj.get() ));
pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
pHdl->SetPageView( mrView.GetSdrPageView() );
- pHdl->SetObj(mpPathObj);
+ pHdl->SetObj(mpPathObj.get());
rHandlerList.AddHdl( std::move(pHdl) );
if( !isSelected() )
@@ -908,7 +908,7 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
{
SdrHdl* pTempHdl = aTemp.GetHdl( nHandle );
- SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj, pTempHdl->GetPos(), pTempHdl->GetKind() );
+ SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj.get(), pTempHdl->GetPos(), pTempHdl->GetKind() );
pSmartHdl->SetObjHdlNum( static_cast<sal_uInt32>(nHandle) );
pSmartHdl->SetPolyNum( pTempHdl->GetPolyNum() );
pSmartHdl->SetPointNum( pTempHdl->GetPointNum() );
@@ -929,7 +929,7 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusHdlCnt; nPlusNum++)
{
SdrHdl* pPlusHdl = plusList.GetHdl(nPlusNum);
- pPlusHdl->SetObj(mpPathObj);
+ pPlusHdl->SetObj(mpPathObj.get());
pPlusHdl->SetPageView(mrView.GetSdrPageView());
pPlusHdl->SetPlusHdl(true);
}
@@ -949,23 +949,23 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
bool bHgt0=aRect.Top()==aRect.Bottom();
if (bWdt0 && bHgt0)
{
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft(),SdrHdlKind::UpperLeft));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.TopLeft(),SdrHdlKind::UpperLeft));
}
else if (bWdt0 || bHgt0)
{
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft() ,SdrHdlKind::UpperLeft));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomRight(),SdrHdlKind::LowerRight));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.TopLeft() ,SdrHdlKind::UpperLeft));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.BottomRight(),SdrHdlKind::LowerRight));
}
else // !bWdt0 && !bHgt0
{
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft() ,SdrHdlKind::UpperLeft));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopCenter() ,SdrHdlKind::Upper));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopRight() ,SdrHdlKind::UpperRight));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.LeftCenter() ,SdrHdlKind::Left ));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.RightCenter() ,SdrHdlKind::Right));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomLeft() ,SdrHdlKind::LowerLeft));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomCenter(),SdrHdlKind::Lower));
- rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomRight() ,SdrHdlKind::LowerRight));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.TopLeft() ,SdrHdlKind::UpperLeft));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.TopCenter() ,SdrHdlKind::Upper));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.TopRight() ,SdrHdlKind::UpperRight));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.LeftCenter() ,SdrHdlKind::Left ));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.RightCenter() ,SdrHdlKind::Right));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.BottomLeft() ,SdrHdlKind::LowerLeft));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.BottomCenter(),SdrHdlKind::Lower));
+ rHandlerList.AddHdl(std::make_unique<SmartHdl>( xThis, mpPathObj.get(), aRect.BottomRight() ,SdrHdlKind::LowerRight));
}
while( nCount < rHandlerList.GetHdlCount() )
@@ -986,12 +986,8 @@ void MotionPathTag::disposing()
if( mpPathObj )
{
- SdrObject* pTemp(mpPathObj);
mpPathObj = nullptr;
mrView.updateHandles();
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject::Free(pTemp);
}
mpMark.reset();
diff --git a/sd/source/ui/animations/motionpathtag.hxx b/sd/source/ui/animations/motionpathtag.hxx
index 715ce4268426..7e7973385c14 100644
--- a/sd/source/ui/animations/motionpathtag.hxx
+++ b/sd/source/ui/animations/motionpathtag.hxx
@@ -39,7 +39,7 @@ public:
MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, const CustomAnimationEffectPtr& pEffect );
virtual ~MotionPathTag() override;
- SdrPathObj* getPathObj() const { return mpPathObj; }
+ SdrPathObj* getPathObj() const { return mpPathObj.get(); }
/// @return true if the SmartTag handled the event.
virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& ) override;
@@ -102,7 +102,7 @@ private:
CustomAnimationEffectPtr mpEffect;
::basegfx::B2DPolyPolygon mxPolyPoly;
css::uno::Reference< css::drawing::XShape > mxOrigin;
- SdrPathObj* mpPathObj;
+ rtl::Reference<SdrPathObj> mpPathObj;
css::awt::Point maOriginPos;
std::unique_ptr<SdrMark> mpMark;
OUString msLastPath;
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 8b140a3b472d..f9bb96dff6af 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -403,7 +403,7 @@ IMPL_LINK( AnimationWindow, ClickGetObjectHdl, weld::Button&, rBtn, void )
IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, weld::Button&, rBtn, void )
{
SdPage* pPage = pMyDoc->GetSdPage(0, PageKind::Standard);
- SdrObject* pObject;
+ rtl::Reference<SdrObject> pObject;
// tdf#95298 check m_nCurrentFrame for EMPTY_FRAMELIST to avoid out-of-bound array access
if (&rBtn == m_xBtnRemoveBitmap.get() && EMPTY_FRAMELIST != m_nCurrentFrame)
@@ -417,7 +417,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, weld::Button&, rBtn, void )
{
pObject = pPage->RemoveObject(m_nCurrentFrame);
DBG_ASSERT(pObject, "Clone not found during deletion");
- SdrObject::Free( pObject );
+ pObject.clear();
pPage->RecalcObjOrdNums();
}
@@ -445,7 +445,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, weld::Button&, rBtn, void )
{
pObject = pPage->RemoveObject( i );
DBG_ASSERT(pObject, "Clone not found during deletion");
- SdrObject::Free( pObject );
+ pObject.clear();
//pPage->RecalcObjOrdNums();
}
}
@@ -773,7 +773,7 @@ void AnimationWindow::AddObj (::sd::View& rView )
// Clone
pPage->InsertObject(
- pSnapShot->CloneSdrObject(pPage->getSdrModelFromSdrPage()),
+ pSnapShot->CloneSdrObject(pPage->getSdrModelFromSdrPage()).get(),
m_nCurrentFrame);
}
bAnimObj = true;
@@ -797,9 +797,9 @@ void AnimationWindow::AddObj (::sd::View& rView )
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObject = pMark->GetMarkedSdrObj();
- SdrObject* pClone(pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
+ rtl::Reference<SdrObject> pClone(pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
size_t nIndex = m_nCurrentFrame + 1;
- pPage->InsertObject(pClone, nIndex);
+ pPage->InsertObject(pClone.get(), nIndex);
}
// several objects: group the clones
else if (nMarkCount > 1)
@@ -821,25 +821,25 @@ void AnimationWindow::AddObj (::sd::View& rView )
++m_nCurrentFrame;
pPage->InsertObject(
- pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()),
+ pObject->CloneSdrObject(pPage->getSdrModelFromSdrPage()).get(),
m_nCurrentFrame);
}
bAnimObj = true; // that we don't change again
}
else
{
- SdrObjGroup* pCloneGroup = new SdrObjGroup(rView.getSdrModelFromSdrView());
+ rtl::Reference<SdrObjGroup> pCloneGroup = new SdrObjGroup(rView.getSdrModelFromSdrView());
SdrObjList* pObjList = pCloneGroup->GetSubList();
for (size_t nObject= 0; nObject < nMarkCount; ++nObject)
{
pObjList->InsertObject(
rMarkList.GetMark(nObject)->GetMarkedSdrObj()->CloneSdrObject(
- pPage->getSdrModelFromSdrPage()));
+ pPage->getSdrModelFromSdrPage()).get());
}
size_t nIndex = m_nCurrentFrame + 1;
- pPage->InsertObject(pCloneGroup, nIndex);
+ pPage->InsertObject(pCloneGroup.get(), nIndex);
}
}
@@ -979,13 +979,13 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
aAnimation.SetLoopCount( nLoopCount );
}
- SdrGrafObj* pGrafObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(
rView.getSdrModelFromSdrView(),
Graphic(aAnimation));
const Point aOrg( aWindowCenter.X() - ( aMaxSizeLog.Width() >> 1 ), aWindowCenter.Y() - ( aMaxSizeLog.Height() >> 1 ) );
pGrafObj->SetLogicRect( ::tools::Rectangle( aOrg, aMaxSizeLog ) );
- rView.InsertObjectAtView( pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER);
+ rView.InsertObjectAtView( pGrafObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
}
else
{
@@ -1054,7 +1054,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
if(pTargetSdPage)
{
// create animation group
- SdrObjGroup* pGroup = new SdrObjGroup(rView.getSdrModelFromSdrView());
+ rtl::Reference<SdrObjGroup> pGroup = new SdrObjGroup(rView.getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
for (size_t i = 0; i < nCount; ++i)
@@ -1062,9 +1062,9 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
// the clone remains in the animation; we insert a clone of the
// clone into the group
pClone = pPage->GetObj(i);
- SdrObject* pCloneOfClone(pClone->CloneSdrObject(pTargetSdPage->getSdrModelFromSdrPage()));
+ rtl::Reference<SdrObject> pCloneOfClone(pClone->CloneSdrObject(pTargetSdPage->getSdrModelFromSdrPage()));
//SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
- pObjList->InsertObject(pCloneOfClone);
+ pObjList->InsertObject(pCloneOfClone.get());
}
// until now the top left corner of the group is in the window center;
@@ -1077,14 +1077,6 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
// #i42894# create needed SMIL stuff and move child objects to page directly (see
// comments at EffectMigration::CreateAnimatedGroup why this has to be done).
EffectMigration::CreateAnimatedGroup(*pGroup, *pTargetSdPage);
-
- // #i42894# if that worked, delete the group again
- if(!pGroup->GetSubList()->GetObjCount())
- {
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pGroup);
- SdrObject::Free(pTemp);
- }
}
}
diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx
index fb844548fafc..a2f76b8d8df9 100644
--- a/sd/source/ui/func/fucon3d.cxx
+++ b/sd/source/ui/func/fucon3d.cxx
@@ -77,9 +77,9 @@ void FuConstruct3dObject::DoExecute( SfxRequest& rReq )
ToolBarManager::msDrawingObjectToolBar);
}
-E3dCompoundObject* FuConstruct3dObject::ImpCreateBasic3DShape()
+rtl::Reference<E3dCompoundObject> FuConstruct3dObject::ImpCreateBasic3DShape()
{
- E3dCompoundObject* p3DObj = nullptr;
+ rtl::Reference<E3dCompoundObject> p3DObj;
switch (nSlotId)
{
@@ -328,11 +328,11 @@ bool FuConstruct3dObject::MouseButtonDown(const MouseEvent& rMEvt)
weld::WaitObject aWait(mpViewShell->GetFrameWeld());
- E3dCompoundObject* p3DObj = ImpCreateBasic3DShape();
- E3dScene* pScene = mpView->SetCurrent3DObj(p3DObj);
+ rtl::Reference<E3dCompoundObject> p3DObj = ImpCreateBasic3DShape();
+ rtl::Reference<E3dScene> pScene = mpView->SetCurrent3DObj(p3DObj.get());
- ImpPrepareBasic3DShape(p3DObj, pScene);
- bReturn = mpView->BegCreatePreparedObject(aPnt, nDrgLog, pScene);
+ ImpPrepareBasic3DShape(p3DObj.get(), pScene.get());
+ bReturn = mpView->BegCreatePreparedObject(aPnt, nDrgLog, pScene.get());
SdrObject* pObj = mpView->GetCreateObj();
@@ -376,9 +376,9 @@ bool FuConstruct3dObject::MouseButtonUp(const MouseEvent& rMEvt)
aClickPos = mpView->GetSnapPos(aClickPos, pPV);
::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize));
- SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
+ rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
- bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV);
+ bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV);
}
}
bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn;
@@ -396,10 +396,10 @@ void FuConstruct3dObject::Activate()
FuConstruct::Activate();
}
-SdrObjectUniquePtr FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
- E3dCompoundObject* p3DObj = ImpCreateBasic3DShape();
+ rtl::Reference<E3dCompoundObject> p3DObj = ImpCreateBasic3DShape();
// E3dView::SetCurrent3DObj part
// get transformed BoundVolume of the object
@@ -409,7 +409,7 @@ SdrObjectUniquePtr FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID
double fW(aVolume.getWidth());
double fH(aVolume.getHeight());
::tools::Rectangle a3DRect(0, 0, static_cast<::tools::Long>(fW), static_cast<::tools::Long>(fH));
- std::unique_ptr< E3dScene, SdrObjectFreeOp > pScene(new E3dScene(*mpDoc));
+ rtl::Reference< E3dScene > pScene(new E3dScene(*mpDoc));
// copied code from E3dView::InitScene
double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0));
@@ -422,11 +422,11 @@ SdrObjectUniquePtr FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID
aCam.SetPosAndLookAt(aCamPos, aLookAt);
aCam.SetFocalLength(mpView->GetDefaultCamFocal());
pScene->SetCamera(aCam);
- pScene->InsertObject(p3DObj);
+ pScene->InsertObject(p3DObj.get());
pScene->NbcSetSnapRect(a3DRect);
- ImpPrepareBasic3DShape(p3DObj, pScene.get());
+ ImpPrepareBasic3DShape(p3DObj.get(), pScene.get());
SfxItemSet aAttr(mpDoc->GetPool());
- SetStyleSheet(aAttr, p3DObj);
+ SetStyleSheet(aAttr, p3DObj.get());
aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE));
p3DObj->SetMergedItemSet(aAttr);
@@ -466,7 +466,7 @@ SdrObjectUniquePtr FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID
// use changed rectangle, not original one
pScene->SetLogicRect(aRect);
- return SdrObjectUniquePtr(pScene.release());
+ return pScene;
}
} // end of namespace sd
diff --git a/sd/source/ui/func/fuconarc.cxx b/sd/source/ui/func/fuconarc.cxx
index b5be93f9b7fb..35b2c33b4ad7 100644
--- a/sd/source/ui/func/fuconarc.cxx
+++ b/sd/source/ui/func/fuconarc.cxx
@@ -90,7 +90,7 @@ void FuConstructArc::DoExecute( SfxRequest& rReq )
pCenterY->GetValue () + pAxisY->GetValue () / 2);
Activate(); // sets aObjKind
- SdrCircObj* pNewCircle =
+ rtl::Reference<SdrCircObj> pNewCircle =
new SdrCircObj(
mpView->getSdrModelFromSdrView(),
ToSdrCircKind(mpView->GetCurrentObjIdentifier()),
@@ -99,7 +99,7 @@ void FuConstructArc::DoExecute( SfxRequest& rReq )
Degree100(pPhiEnd->GetValue() * 10));
SdrPageView *pPV = mpView->GetSdrPageView();
- mpView->InsertObjectAtView(pNewCircle, *pPV, SdrInsertFlags::SETDEFLAYER);
+ mpView->InsertObjectAtView(pNewCircle.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
}
bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt )
@@ -199,10 +199,10 @@ void FuConstructArc::Activate()
FuConstruct::Activate();
}
-SdrObjectUniquePtr FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx
index b123e9c2ddff..319c8b1b9adb 100644
--- a/sd/source/ui/func/fuconbez.cxx
+++ b/sd/source/ui/func/fuconbez.cxx
@@ -401,7 +401,7 @@ void FuConstructBezierPolygon::SetEditMode(sal_uInt16 nMode)
rBindings.Invalidate(SID_BEZIER_INSERT);
}
-SdrObjectUniquePtr FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
// case SID_DRAW_POLYGON:
// case SID_DRAW_POLYGON_NOFILL:
@@ -412,7 +412,7 @@ SdrObjectUniquePtr FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt1
// case SID_DRAW_BEZIER_FILL: // BASIC
// case SID_DRAW_BEZIER_NOFILL: // BASIC
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx
index 806960dd254a..7fbecef5d00d 100644
--- a/sd/source/ui/func/fuconcs.cxx
+++ b/sd/source/ui/func/fuconcs.cxx
@@ -138,9 +138,9 @@ bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
aClickPos = mpView->GetSnapPos(aClickPos, pPV);
::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize));
- SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
+ rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
- bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV);
+ bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV);
}
}
bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
@@ -229,9 +229,9 @@ const OUString& FuConstructCustomShape::GetShapeType() const
return aCustomShape;
}
-SdrObjectUniquePtr FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
{
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index d93ef2849468..a1f4e5f3c6cf 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -144,13 +144,13 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
pCenterY->GetValue () - pAxisY->GetValue () / 2,
pCenterX->GetValue () + pAxisX->GetValue () / 2,
pCenterY->GetValue () + pAxisY->GetValue () / 2);
- SdrCircObj *pNewCircle = new SdrCircObj(
+ rtl::Reference<SdrCircObj> pNewCircle = new SdrCircObj(
mpView->getSdrModelFromSdrView(),
SdrCircKind::Full,
aNewRectangle);
SdrPageView *pPV = mpView->GetSdrPageView();
- mpView->InsertObjectAtView(pNewCircle, *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
+ mpView->InsertObjectAtView(pNewCircle.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
}
break;
@@ -189,12 +189,12 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
pMouseStartY->GetValue (),
pMouseEndX->GetValue (),
pMouseEndY->GetValue ());
- SdrRectObj *pNewRect = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pNewRect = new SdrRectObj(
mpView->getSdrModelFromSdrView(),
aNewRectangle);
SdrPageView *pPV = mpView->GetSdrPageView();
- mpView->InsertObjectAtView(pNewRect, *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
+ mpView->InsertObjectAtView(pNewRect.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
}
break;
}
@@ -328,9 +328,9 @@ bool FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt)
aClickPos = mpView->GetSnapPos(aClickPos, pPV);
::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize));
- SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
+ rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
- bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV);
+ bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV);
}
}
@@ -876,7 +876,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj
}
}
-SdrObjectUniquePtr FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
DBG_ASSERT( (nID != SID_DRAW_FONTWORK) && (nID != SID_DRAW_FONTWORK_VERTICAL ), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" );
@@ -933,7 +933,7 @@ SdrObjectUniquePtr FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nI
// case SID_CONNECTOR_LINES_CIRCLE_END:
// case SID_CONNECTOR_LINES_CIRCLES:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
diff --git a/sd/source/ui/func/fuconuno.cxx b/sd/source/ui/func/fuconuno.cxx
index afa4523c6ef9..9ff3c242d845 100644
--- a/sd/source/ui/func/fuconuno.cxx
+++ b/sd/source/ui/func/fuconuno.cxx
@@ -128,11 +128,11 @@ void FuConstructUnoControl::Deactivate()
mpWindow->SetPointer( aOldPointer );
}
-SdrObjectUniquePtr FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
{
// case SID_FM_CREATE_CONTROL:
- SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 919814d56093..a00cb453d6b0 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -355,7 +355,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
aRect = ::tools::Rectangle(aPos, aSize);
}
- SdrOle2Obj* pOleObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pOleObj = new SdrOle2Obj(
mpView->getSdrModelFromSdrView(),
svt::EmbeddedObjectRef( xObj, nAspect ),
aObjName,
@@ -368,7 +368,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
SdPage* pPage = static_cast< SdPage* >(pPickObj->getSdrPageFromSdrObject());
if(pPage && pPage->IsPresObj(pPickObj))
{
- pPage->InsertPresObj( pOleObj, ePresObjKind );
+ pPage->InsertPresObj( pOleObj.get(), ePresObjKind );
pOleObj->SetUserCall(pPickObj->GetUserCall());
}
@@ -383,9 +383,9 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
bool bRet = true;
if( pPickObj )
- mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj );
+ mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj.get() );
else
- bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SdrInsertFlags::SETDEFLAYER);
+ bRet = mpView->InsertObjectAtView(pOleObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
if (bRet && !comphelper::LibreOfficeKit::isActive())
{
@@ -410,7 +410,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
aVisualSize.Width = aTmp.Width();
aVisualSize.Height = aTmp.Height();
xObj->setVisualAreaSize( nAspect, aVisualSize );
- mpViewShell->ActivateObject(pOleObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
+ mpViewShell->ActivateObject(pOleObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
if (nSlotId == SID_INSERT_DIAGRAM)
{
@@ -585,13 +585,13 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
Point aPnt ((aPageSize.Width() - aSize.Width()) / 2,
(aPageSize.Height() - aSize.Height()) / 2);
::tools::Rectangle aRect (aPnt, aSize);
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
mpView->getSdrModelFromSdrView(),
aObjRef,
aName,
aRect);
- if( mpView->InsertObjectAtView(pObj, *pPV, SdrInsertFlags::SETDEFLAYER) )
+ if( mpView->InsertObjectAtView(pObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER) )
{
// Math objects change their object size during InsertObject.
// New size must be set in SdrObject, or a wrong scale will be set at
@@ -626,7 +626,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
xObj->setVisualAreaSize( nAspect, aSz );
}
- mpViewShell->ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
+ mpViewShell->ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
}
Size aVisSizePixel = mpWindow->GetOutputSizePixel();
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index 6569514cfb73..729652e03c34 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -488,7 +488,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
}
else
{
- SdrRectObj* pTO = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pTO = new SdrRectObj(
mpView->getSdrModelFromSdrView(),
SdrObjKind::Text);
pTO->SetOutlinerParaObject(std::move(pOPO));
@@ -496,7 +496,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
const bool bUndo = mpView->IsUndoEnabled();
if( bUndo )
mpView->BegUndo(SdResId(STR_UNDO_INSERT_TEXTFRAME));
- pPage->InsertObject(pTO);
+ pPage->InsertObject(pTO.get());
/* can be bigger as the maximal allowed size:
limit object size if necessary */
diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx
index 34fe631616cb..26ae109e0215 100644
--- a/sd/source/ui/func/fulinend.cxx
+++ b/sd/source/ui/func/fulinend.cxx
@@ -58,7 +58,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
const SdrObject* pNewObj;
- SdrObjectUniquePtr pConvPolyObj;
+ rtl::Reference<SdrObject> pConvPolyObj;
if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr )
{
@@ -88,7 +88,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
const ::basegfx::B2DPolyPolygon aPolyPolygon = static_cast<const SdrPathObj*>(pNewObj)->GetPathPoly();
// Delete the created poly-object
- pConvPolyObj.reset();
+ pConvPolyObj.clear();
XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index c2f94b440c3c..5f1021dcf327 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -81,16 +81,16 @@ void FuMorph::DoExecute( SfxRequest& )
// create clones
SdrObject* pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
SdrObject* pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
- SdrObject* pCloneObj1(pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()));
- SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pCloneObj1(pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()));
// delete text at clone, otherwise we do not get a correct PathObj
pCloneObj1->SetOutlinerParaObject(std::nullopt);
pCloneObj2->SetOutlinerParaObject(std::nullopt);
// create path objects
- SdrObjectUniquePtr pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
- SdrObjectUniquePtr pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
ScopedVclPtr<AbstractMorphDlg> pDlg( pFact->CreateMorphDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, pObj1, pObj2) );
if(pPolyObj1 && pPolyObj2 && (pDlg->Execute() == RET_OK))
@@ -170,8 +170,6 @@ void FuMorph::DoExecute( SfxRequest& )
mpView->EndUndo();
}
}
- SdrObject::Free( pCloneObj1 );
- SdrObject::Free( pCloneObj2 );
}
static ::basegfx::B2DPolygon ImpGetExpandedPolygon(
@@ -376,7 +374,7 @@ void FuMorph::ImpInsertPolygons(
return;
SfxItemSet aSet( aSet1 );
- std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> xObjGroup(new SdrObjGroup(mpView->getSdrModelFromSdrView()));
+ rtl::Reference<SdrObjGroup> xObjGroup(new SdrObjGroup(mpView->getSdrModelFromSdrView()));
SdrObjList* pObjList = xObjGroup->GetSubList();
const size_t nCount = rPolyPolyList3D.size();
const double fStep = 1. / ( nCount + 1 );
@@ -389,7 +387,7 @@ void FuMorph::ImpInsertPolygons(
for ( size_t i = 0; i < nCount; i++, fFactor += fStep )
{
const ::basegfx::B2DPolyPolygon& rPolyPoly3D = rPolyPolyList3D[ i ];
- SdrPathObj* pNewObj = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pNewObj = new SdrPathObj(
mpView->getSdrModelFromSdrView(),
SdrObjKind::Polygon,
rPolyPoly3D);
@@ -418,19 +416,19 @@ void FuMorph::ImpInsertPolygons(
pNewObj->SetMergedItemSetAndBroadcast(aSet);
- pObjList->InsertObject( pNewObj );
+ pObjList->InsertObject( pNewObj.get() );
}
if ( nCount )
{
pObjList->InsertObject(
- pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()),
+ pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()).get(),
0 );
pObjList->InsertObject(
- pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()) );
+ pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()).get() );
mpView->DeleteMarked();
- mpView->InsertObjectAtView(xObjGroup.release(), *pPageView, SdrInsertFlags:: SETDEFLAYER);
+ mpView->InsertObjectAtView(xObjGroup.get(), *pPageView, SdrInsertFlags:: SETDEFLAYER);
}
}
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index e901d07a6318..b9aab12a4b27 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -1009,7 +1009,7 @@ void FuPoor::ReceiveRequest(SfxRequest& /*rReq*/)
{
}
-SdrObjectUniquePtr FuPoor::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& )
+rtl::Reference<SdrObject> FuPoor::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& )
{
// empty base implementation
return nullptr;
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index 656dc4670c75..68839bded557 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -153,7 +153,7 @@ void FuText::disposing()
if(mpView)
{
if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
// reset the RequestHandler of the used Outliner to the handler of the document
::Outliner* pOutliner = mpView->GetTextEditOutliner();
@@ -196,7 +196,7 @@ void FuText::DoExecute( SfxRequest& )
mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
mpView->MarkObj(aVEvt.mpRootObj, pPV);
- mxTextObj.reset( dynamic_cast< SdrTextObj* >( aVEvt.mpObj ) );
+ mxTextObj = dynamic_cast< SdrTextObj* >( aVEvt.mpObj );
}
else if (mpView->AreObjectsMarked())
{
@@ -205,7 +205,7 @@ void FuText::DoExecute( SfxRequest& )
if (rMarkList.GetMarkCount() == 1)
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- mxTextObj.reset( dynamic_cast< SdrTextObj* >( pObj ) );
+ mxTextObj = dynamic_cast< SdrTextObj* >( pObj );
}
}
@@ -258,7 +258,7 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
{
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
- if (mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
+ if (mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
{
const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
if (pFieldItem)
@@ -297,7 +297,7 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
list. The call MarkObj further below accesses then the dead
object. As a simple fix, we determine eHit after
SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
}
@@ -356,7 +356,7 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
if (auto pSdrTextObj = dynamic_cast<SdrTextObj*>(aVEvt.mpObj))
{
- mxTextObj.reset( pSdrTextObj );
+ mxTextObj = pSdrTextObj;
}
SetInEditMode(rMEvt, true);
@@ -633,7 +633,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
bool bEmptyTextObj = false;
- if (mxTextObj.is())
+ if (mxTextObj.get().is())
{
bool bReset = true;
@@ -642,9 +642,9 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
if (rMarkList.GetMarkCount() == 1
- && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get()) )
+ && ( rMarkList.GetMark(0)->GetMarkedSdrObj() == mxTextObj.get().get()) )
{
- if( mxTextObj.is() && !GetTextObj()->GetOutlinerParaObject() )
+ if( mxTextObj.get().is() && !GetTextObj()->GetOutlinerParaObject() )
bEmptyTextObj = true;
else
bFirstObjCreated = true;
@@ -654,7 +654,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
if (bReset)
{
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
}
}
@@ -702,15 +702,16 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
{
// object was created
- mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
+ rtl::Reference<SdrTextObj> pTextObj = dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() );
+ mxTextObj = pTextObj.get();
- if( mxTextObj.is() )
+ if( pTextObj )
{
//AW outliner needs to be set to vertical when there is no
// outliner object up to now; also it needs to be set back to not
// vertical when there was a vertical one used last time.
OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
- SdrOutliner& rOutl(mxTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
+ SdrOutliner& rOutl(pTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj()));
bool bVertical((pOPO && pOPO->IsEffectivelyVertical())
|| nSlotId == SID_ATTR_CHAR_VERTICAL
|| nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
@@ -740,7 +741,8 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
if (!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
{
// it was not possible to create text object
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
+ pTextObj = nullptr;
}
else if (nSlotId == SID_TEXT_FITTOSIZE)
{
@@ -784,7 +786,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
mpView->MarkObj(aVEvt.mpRootObj, pPV2);
}
- if ( !mxTextObj.is() && mpView )
+ if ( !mxTextObj.get().is() && mpView )
{
if ( ( (!bEmptyTextObj && bPermanent) ||
(!bFirstObjCreated && !bPermanent) ) &&
@@ -806,22 +808,22 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
aPnt.AdjustY(nDrgLog + nDrgLog );
mpView->MovAction(aPnt);
- mxTextObj.reset( dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() ) );
+ mxTextObj = dynamic_cast< SdrTextObj* >( mpView->GetCreateObj() );
- if(mxTextObj.is())
+ if(mxTextObj.get().is())
{
GetTextObj()->SetDisableAutoWidthOnDragging(true);
}
if(!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
{
- mxTextObj.reset(nullptr);
+ mxTextObj.clear();
}
if(bSnapEnabled)
mpView->SetSnapEnabled(bSnapEnabled);
- if(mxTextObj.is())
+ if(mxTextObj.get().is())
{
SfxItemSet aSet(mpViewShell->GetPool());
aSet.Put(makeSdrTextMinFrameHeightItem(0));
@@ -906,7 +908,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
// switch to selection
if (mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
{
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
}
mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
@@ -934,7 +936,7 @@ bool FuText::KeyInput(const KeyEvent& rKEvt)
vcl::KeyCode nCode = rKEvt.GetKeyCode();
bool bShift = nCode.IsShift();
- if(mxTextObj.is())
+ if(mxTextObj.get().is())
{
// maybe object is deleted, test if it's equal to the selected object
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
@@ -946,17 +948,18 @@ bool FuText::KeyInput(const KeyEvent& rKEvt)
pSelectedObj = pMark->GetMarkedSdrObj();
}
- if(mxTextObj.get() != pSelectedObj)
+ if(mxTextObj.get().get() != pSelectedObj)
{
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
}
}
- if ( mxTextObj.is() && mxTextObj->GetObjInventor() == SdrInventor::Default && mxTextObj->GetObjIdentifier() == SdrObjKind::TitleText && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
- {
- // title text object: always soft breaks
- bShift = true;
- }
+ if (auto pTextObj = mxTextObj.get())
+ if ( pTextObj->GetObjInventor() == SdrInventor::Default && pTextObj->GetObjIdentifier() == SdrObjKind::TitleText && rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
+ {
+ // title text object: always soft breaks
+ bShift = true;
+ }
sal_uInt16 nKey = nCode.GetCode();
vcl::KeyCode aKeyCode (nKey, bShift, nCode.IsMod1(), nCode.IsMod2(), nCode.IsMod3() );
@@ -1036,7 +1039,7 @@ void FuText::Deactivate()
void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
{
SdrPageView* pPV = mpView->GetSdrPageView();
- if( mxTextObj.is() && (mxTextObj->getSdrPageFromSdrObject() == pPV->GetPage()) )
+ if( mxTextObj.get().is() && (mxTextObj.get()->getSdrPageFromSdrObject() == pPV->GetPage()) )
{
mpView->SetCurrentObj(SdrObjKind::Text);
@@ -1065,13 +1068,14 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
if (GetTextObj() != mpView->GetTextEditObject() || bEmptyOutliner)
{
- SdrInventor nInv = mxTextObj->GetObjInventor();
- SdrObjKind nSdrObjKind = mxTextObj->GetObjIdentifier();
+ rtl::Reference<SdrTextObj> pTextObj = mxTextObj.get();
+ SdrInventor nInv = pTextObj->GetObjInventor();
+ SdrObjKind nSdrObjKind = pTextObj->GetObjIdentifier();
if (nInv == SdrInventor::Default && GetTextObj()->HasTextEdit() &&
(nSdrObjKind == SdrObjKind::Text ||
nSdrObjKind == SdrObjKind::TitleText ||
- nSdrObjKind == SdrObjKind::OutlineText || !mxTextObj->IsEmptyPresObj() ) )
+ nSdrObjKind == SdrObjKind::OutlineText || !pTextObj->IsEmptyPresObj() ) )
{
// create new outliner (owned by SdrObjEditView)
std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
@@ -1079,7 +1083,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
if (bEmptyOutliner)
mpView->SdrEndTextEdit(true);
- SdrTextObj* pTextObj = GetTextObj();
+ pTextObj = GetTextObj();
if( pTextObj )
{
OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
@@ -1098,7 +1102,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) );
}
- if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, true, pOutl.release()) && mxTextObj->GetObjInventor() == SdrInventor::Default)
+ if (mpView->SdrBeginTextEdit(pTextObj.get(), pPV, mpWindow, true, pOutl.release()) && mxTextObj.get()->GetObjInventor() == SdrInventor::Default)
{
//tdf#102293 flush overlay before going on to pass clicks down to
//the outline view which will want to paint selections
@@ -1118,7 +1122,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
- nSdrObjKind = mxTextObj->GetObjIdentifier();
+ nSdrObjKind = mxTextObj.get()->GetObjIdentifier();
SdrViewEvent aVEvt;
SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
@@ -1153,7 +1157,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
}
else
{
- mpView->RestoreDefaultText( mxTextObj.get() );
+ mpView->RestoreDefaultText( mxTextObj.get().get() );
}
}
}
@@ -1161,7 +1165,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
}
else
{
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
}
}
@@ -1170,15 +1174,15 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag)
*/
void FuText::DeleteDefaultText()
{
- if ( !(mxTextObj.is() && mxTextObj->IsEmptyPresObj()) )
+ if ( !(mxTextObj.get().is() && mxTextObj.get()->IsEmptyPresObj()) )
return;
- SdPage* pPage = static_cast<SdPage*>( mxTextObj->getSdrPageFromSdrObject() );
+ SdPage* pPage = static_cast<SdPage*>( mxTextObj.get()->getSdrPageFromSdrObject() );
if (!pPage)
return;
- PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get());
+ PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get().get());
if ( !(ePresObjKind == PresObjKind::Title ||
ePresObjKind == PresObjKind::Outline ||
@@ -1202,7 +1206,7 @@ void FuText::DeleteDefaultText()
(ePresObjKind == PresObjKind::Notes || ePresObjKind == PresObjKind::Text))
pOutliner->SetStyleSheet(0, pSheet);
- mxTextObj->SetEmptyPresObj(true);
+ mxTextObj.get()->SetEmptyPresObj(true);
}
bool FuText::RequestHelp(const HelpEvent& rHEvt)
@@ -1212,7 +1216,7 @@ bool FuText::RequestHelp(const HelpEvent& rHEvt)
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if ((Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled()) &&
- mxTextObj.is() && pOLV && pOLV->GetFieldUnderMousePointer())
+ mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
{
OUString aHelpText;
const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
@@ -1225,7 +1229,7 @@ bool FuText::RequestHelp(const HelpEvent& rHEvt)
}
if (!aHelpText.isEmpty())
{
- ::tools::Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj->GetLogicRect());
+ ::tools::Rectangle aLogicPix = mpWindow->LogicToPixel(mxTextObj.get()->GetLogicRect());
::tools::Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
@@ -1262,14 +1266,14 @@ void FuText::ReceiveRequest(SfxRequest& rReq)
MouseEvent aMEvt(mpWindow->GetPointerPosPixel());
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
if (nSlotId == SID_TEXTEDIT)
{
// are we currently editing?
- mxTextObj.reset( mpView->GetTextEditObject() );
+ mxTextObj = mpView->GetTextEditObject();
- if (!mxTextObj.is())
+ if (!mxTextObj.get().is())
{
// Try to select an object
SdrPageView* pPV = mpView->GetSdrPageView();
@@ -1279,7 +1283,7 @@ void FuText::ReceiveRequest(SfxRequest& rReq)
if (auto pSdrTextObj = dynamic_cast<SdrTextObj*>(aVEvt.mpObj))
{
- mxTextObj.reset( pSdrTextObj );
+ mxTextObj = pSdrTextObj;
}
}
}
@@ -1293,7 +1297,7 @@ void FuText::ReceiveRequest(SfxRequest& rReq)
if( auto pTextObj = dynamic_cast<SdrTextObj *>( pObj ))
{
- mxTextObj.reset( pTextObj );
+ mxTextObj = pTextObj;
}
}
}
@@ -1325,9 +1329,9 @@ void FuText::DoubleClick(const MouseEvent& )
/** Removed the insertion of default text and putting a new text
object directly into edit mode.
*/
-SdrObjectUniquePtr FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
+rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
- SdrObjectUniquePtr pObj( SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj( SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier(),
@@ -1381,7 +1385,7 @@ bool FuText::cancel()
if ( mpView->IsTextEdit() )
{
if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
- mxTextObj.reset(nullptr);
+ mxTextObj = nullptr;
mpView->SetCurrentObj(SdrObjKind::Text);
mpView->SetEditMode(SdrViewEditMode::Edit);
diff --git a/sd/source/ui/func/fuvect.cxx b/sd/source/ui/func/fuvect.cxx
index 64840810ca21..d657c0d18ba0 100644
--- a/sd/source/ui/func/fuvect.cxx
+++ b/sd/source/ui/func/fuvect.cxx
@@ -72,12 +72,12 @@ void FuVectorize::DoExecute( SfxRequest& )
if( pPageView && rMtf.GetActionSize() )
{
- SdrGrafObj* pVectObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) );
+ rtl::Reference<SdrGrafObj> pVectObj = SdrObject::Clone(static_cast<SdrGrafObj&>(*pObj), pObj->getSdrModelFromSdrObject());
OUString aStr = mpView->GetDescriptionOfMarkedObjects() +
" " + SdResId( STR_UNDO_VECTORIZE );
mpView->BegUndo( aStr );
pVectObj->SetGraphic( rMtf );
- mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj );
+ mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj.get() );
mpView->EndUndo();
}
}
diff --git a/sd/source/ui/inc/OutlinerIteratorImpl.hxx b/sd/source/ui/inc/OutlinerIteratorImpl.hxx
index 788e6ae61072..25a98078d8ed 100644
--- a/sd/source/ui/inc/OutlinerIteratorImpl.hxx
+++ b/sd/source/ui/inc/OutlinerIteratorImpl.hxx
@@ -126,7 +126,7 @@ class SelectionIteratorImpl
{
public:
SelectionIteratorImpl (
- const ::std::vector< ::tools::WeakReference<SdrObject> >& rObjectList,
+ const ::std::vector< ::unotools::WeakReference<SdrObject> >& rObjectList,
sal_Int32 nObjectIndex,
SdDrawDocument* pDocument,
const std::weak_ptr<ViewShell>& rpViewShellWeak,
@@ -140,7 +140,7 @@ public:
virtual bool operator== (const IteratorImplBase& rIterator) const override;
private:
- const ::std::vector<::tools::WeakReference<SdrObject>>& mrObjectList;
+ const ::std::vector<::unotools::WeakReference<SdrObject>>& mrObjectList;
sal_Int32 mnObjectIndex;
/** Compare the given iterator with this object. This method handles
diff --git a/sd/source/ui/inc/fucon3d.hxx b/sd/source/ui/inc/fucon3d.hxx
index 545b193272df..84871359d56a 100644
--- a/sd/source/ui/inc/fucon3d.hxx
+++ b/sd/source/ui/inc/fucon3d.hxx
@@ -42,7 +42,7 @@ public:
virtual void Activate() override;
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
FuConstruct3dObject (
@@ -53,7 +53,7 @@ private:
SfxRequest& rReq);
void ImpPrepareBasic3DShape(E3dCompoundObject const * p3DObj, E3dScene *pScene);
- E3dCompoundObject* ImpCreateBasic3DShape();
+ rtl::Reference<E3dCompoundObject> ImpCreateBasic3DShape();
};
} // end of namespace sd
diff --git a/sd/source/ui/inc/fuconarc.hxx b/sd/source/ui/inc/fuconarc.hxx
index 9a1beae89456..263c56220cce 100644
--- a/sd/source/ui/inc/fuconarc.hxx
+++ b/sd/source/ui/inc/fuconarc.hxx
@@ -37,7 +37,7 @@ public:
virtual void Activate() override;
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
FuConstructArc (
diff --git a/sd/source/ui/inc/fuconbez.hxx b/sd/source/ui/inc/fuconbez.hxx
index fe9aceae2cc8..7827470b82a2 100644
--- a/sd/source/ui/inc/fuconbez.hxx
+++ b/sd/source/ui/inc/fuconbez.hxx
@@ -51,7 +51,7 @@ public:
*/
void SetAttributes(SfxItemSet& rAttr, SdrObject* pObj);
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
FuConstructBezierPolygon (
diff --git a/sd/source/ui/inc/fuconcs.hxx b/sd/source/ui/inc/fuconcs.hxx
index f4f4ef30ecfd..cf63c214ed87 100644
--- a/sd/source/ui/inc/fuconcs.hxx
+++ b/sd/source/ui/inc/fuconcs.hxx
@@ -43,7 +43,7 @@ public:
void SetAttributes( SdrObject* pObj );
const OUString& GetShapeType() const;
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
// #i33136#
virtual bool doConstructOrthogonal() const override;
diff --git a/sd/source/ui/inc/fuconrec.hxx b/sd/source/ui/inc/fuconrec.hxx
index caf8ac7eb1fd..a5230c593732 100644
--- a/sd/source/ui/inc/fuconrec.hxx
+++ b/sd/source/ui/inc/fuconrec.hxx
@@ -54,7 +54,7 @@ public:
void SetAttributes(SfxItemSet& rAttr, SdrObject* pObj);
void SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj);
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
FuConstructRectangle (
diff --git a/sd/source/ui/inc/fuconuno.hxx b/sd/source/ui/inc/fuconuno.hxx
index df8e4d415844..e31ff0a6b4ff 100644
--- a/sd/source/ui/inc/fuconuno.hxx
+++ b/sd/source/ui/inc/fuconuno.hxx
@@ -44,7 +44,7 @@ public:
virtual void Activate() override;
virtual void Deactivate() override;
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
FuConstructUnoControl(
diff --git a/sd/source/ui/inc/fupoor.hxx b/sd/source/ui/inc/fupoor.hxx
index 553f6688de61..6a2611cb5054 100644
--- a/sd/source/ui/inc/fupoor.hxx
+++ b/sd/source/ui/inc/fupoor.hxx
@@ -88,7 +88,7 @@ public:
void StartDelayToScrollTimer ();
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle);
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle);
/** is called when the current function should be aborted. <p>
This is used when a function gets a KEY_ESCAPE but can also
diff --git a/sd/source/ui/inc/futext.hxx b/sd/source/ui/inc/futext.hxx
index f101e07a0a0f..310df1455af1 100644
--- a/sd/source/ui/inc/futext.hxx
+++ b/sd/source/ui/inc/futext.hxx
@@ -20,7 +20,7 @@
#pragma once
#include "fuconstr.hxx"
-#include <tools/weakbase.h>
+#include <unotools/weakref.hxx>
class SdrTextObj;
class FontList;
@@ -52,9 +52,9 @@ public:
void SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag);
void DeleteDefaultText();
- SdrTextObj* GetTextObj() { return mxTextObj.get(); }
+ SdrTextObj* GetTextObj() { return mxTextObj.get().get(); }
- virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
+ virtual rtl::Reference<SdrObject> CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
/** is called when the current function should be aborted. <p>
This is used when a function gets a KEY_ESCAPE but can also
@@ -79,7 +79,7 @@ protected:
private:
virtual void disposing() override;
- ::tools::WeakReference<SdrTextObj>
+ ::unotools::WeakReference<SdrTextObj>
mxTextObj;
bool bFirstObjCreated;
bool bJustEndedEdit;
diff --git a/sd/source/ui/inc/unopage.hxx b/sd/source/ui/inc/unopage.hxx
index af09e5982c65..775e68ba7e57 100644
--- a/sd/source/ui/inc/unopage.hxx
+++ b/sd/source/ui/inc/unopage.hxx
@@ -104,7 +104,7 @@ public:
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
// this is called whenever a SdrObject must be created for an empty api shape wrapper
- virtual SdrObject *CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
+ virtual rtl::Reference<SdrObject> CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
// SvxFmDrawPage
virtual css::uno::Reference<css::drawing::XShape> CreateShape(SdrObject *pObj) const override;
diff --git a/sd/source/ui/table/tablefunction.cxx b/sd/source/ui/table/tablefunction.cxx
index 861e4e6d186f..f2843311c2b9 100644
--- a/sd/source/ui/table/tablefunction.cxx
+++ b/sd/source/ui/table/tablefunction.cxx
@@ -141,13 +141,13 @@ static void InsertTableImpl(const DrawViewShell* pShell,
aRect = ::tools::Rectangle(aPos, aSize);
}
- sdr::table::SdrTableObj* pObj = new sdr::table::SdrTableObj(
+ rtl::Reference<sdr::table::SdrTableObj> pObj = new sdr::table::SdrTableObj(
*pShell->GetDoc(), // TTTT should be reference
aRect,
nColumns,
nRows);
pObj->NbcSetStyleSheet( pShell->GetDoc()->GetDefaultStyleSheet(), true );
- apply_table_style( pObj, pShell->GetDoc(), sTableStyle );
+ apply_table_style( pObj.get(), pShell->GetDoc(), sTableStyle );
SdrPageView* pPV = pView->GetSdrPageView();
// #i123359# if an object is to be replaced/manipulated it may be that it is in text edit mode,
@@ -166,15 +166,15 @@ static void InsertTableImpl(const DrawViewShell* pShell,
if(pPage && pPage->IsPresObj(pPickObj))
{
pObj->SetUserCall( pPickObj->GetUserCall() );
- pPage->InsertPresObj( pObj, PresObjKind::Table );
+ pPage->InsertPresObj( pObj.get(), PresObjKind::Table );
}
}
pShell->GetParentWindow()->GrabFocus();
if( pPickObj )
- pView->ReplaceObjectAtView(pPickObj, *pPV, pObj );
+ pView->ReplaceObjectAtView(pPickObj, *pPV, pObj.get() );
else
- pView->InsertObjectAtView(pObj, *pPV, SdrInsertFlags::SETDEFLAYER);
+ pView->InsertObjectAtView(pObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
}
void DrawViewShell::FuTable(SfxRequest& rReq)
@@ -274,15 +274,15 @@ void CreateTableFromRTF( SvStream& rStream, SdDrawDocument* pModel )
Size aSize( 200, 200 );
::tools::Rectangle aRect (Point(), aSize);
- sdr::table::SdrTableObj* pObj = new sdr::table::SdrTableObj(
+ rtl::Reference<sdr::table::SdrTableObj> pObj = new sdr::table::SdrTableObj(
*pModel,
aRect,
1,
1);
pObj->NbcSetStyleSheet( pModel->GetDefaultStyleSheet(), true );
- apply_table_style( pObj, pModel, OUString() );
+ apply_table_style( pObj.get(), pModel, OUString() );
- pPage->NbcInsertObject( pObj );
+ pPage->NbcInsertObject( pObj.get() );
sdr::table::ImportAsRTF( rStream, *pObj );
}
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index 85a3045d5000..b90636070135 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -479,10 +479,6 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c
if(!pGroup->GetSubList()->GetObjCount())
{
pPage->NbcRemoveObject(pGroup->GetOrdNum());
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pGroup);
- SdrObject::Free(pTemp);
}
}
}
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index c0536daab015..4831b29bb53d 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -388,7 +388,7 @@ void SdGenericDrawPage::UpdateModel()
}
// this is called whenever a SdrObject must be created for an empty api shape wrapper
-SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape )
+rtl::Reference<SdrObject> SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape )
{
if( nullptr == SvxFmDrawPage::mpPage || !xShape.is() )
return nullptr;
@@ -397,8 +397,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap
static const OUStringLiteral aPrefix( u"com.sun.star.presentation." );
if( !aType.startsWith( aPrefix ) )
{
- SdrObject* pObj = SvxFmDrawPage::CreateSdrObject_( xShape );
- return pObj;
+ return SvxFmDrawPage::CreateSdrObject_( xShape );
}
aType = aType.copy( aPrefix.getLength() );
@@ -485,7 +484,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap
const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
xShape->setSize( aSize );
- SdrObject *pPresObj = nullptr;
+ rtl::Reference<SdrObject> pPresObj;
if( (eObjKind == PresObjKind::Table) || (eObjKind == PresObjKind::Media) )
{
pPresObj = SvxFmDrawPage::CreateSdrObject_( xShape );
@@ -493,7 +492,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap
{
SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
pPresObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true);
- GetPage()->InsertPresObj( pPresObj, eObjKind );
+ GetPage()->InsertPresObj( pPresObj.get(), eObjKind );
}
}
else
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index 7c21f23c9fae..307c0d324bb9 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -1508,11 +1508,7 @@ private:
// delete all previous shapes from handout page
while( pHandout->GetObjCount() )
- {
- SdrObject* pObj = pHandout->NbcRemoveObject(0);
- if( pObj )
- SdrObject::Free( pObj );
- }
+ pHandout->NbcRemoveObject(0);
const bool bDrawLines (eLayout == AUTOLAYOUT_HANDOUT3);
@@ -1545,14 +1541,14 @@ private:
aPathPoly.append( aPoly );
}
- SdrPathObj* pPathObj = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPathObj = new SdrPathObj(
rModel,
SdrObjKind::PathLine,
std::move(aPathPoly));
pPathObj->SetMergedItem(XLineStyleItem(drawing::LineStyle_SOLID));
pPathObj->SetMergedItem(XLineColorItem(OUString(), COL_BLACK));
- pHandout->NbcInsertObject( pPathObj );
+ pHandout->NbcInsertObject( pPathObj.get() );
}
}
}
diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx
index 60cab73f7b06..b1e94f7219ec 100644
--- a/sd/source/ui/view/GraphicObjectBar.cxx
+++ b/sd/source/ui/view/GraphicObjectBar.cxx
@@ -119,13 +119,13 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest const & rReq )
if( pPageView )
{
- SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) );
+ rtl::Reference<SdrGrafObj> pFilteredObj = SdrObject::Clone(static_cast<SdrGrafObj&>(*pObj), pObj->getSdrModelFromSdrObject());
OUString aStr = mpView->GetDescriptionOfMarkedObjects() +
" " + SdResId(STR_UNDO_GRAFFILTER);
mpView->BegUndo( aStr );
pFilteredObj->SetGraphicObject( aFilterObj );
::sd::View* const pView = mpView;
- pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj.get() );
pView->EndUndo();
return;
}
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 527bead48b85..7c6684339c3f 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1160,13 +1160,13 @@ namespace
bool lclIsValidTextObject(const sd::outliner::IteratorPosition& rPosition)
{
- auto* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get() );
+ auto* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get().get() );
return (pObject != nullptr) && pObject->HasText() && ! pObject->IsEmptyPresObj();
}
bool isValidVectorGraphicObject(const sd::outliner::IteratorPosition& rPosition)
{
- auto* pGraphicObject = dynamic_cast<SdrGrafObj*>(rPosition.mxObject.get());
+ auto* pGraphicObject = dynamic_cast<SdrGrafObj*>(rPosition.mxObject.get().get());
if (pGraphicObject)
{
auto const& pVectorGraphicData = pGraphicObject->GetGraphic().getVectorGraphicData();
@@ -1240,12 +1240,12 @@ void SdOutliner::ProvideNextTextObject()
if (meMode != SEARCH)
mpObj = SetObject(maCurrentPosition);
else
- mpObj = maCurrentPosition.mxObject.get();
+ mpObj = maCurrentPosition.mxObject.get().get();
}
// Or if the object is a valid graphic object which contains vector graphic
else if (meMode == SEARCH && isValidVectorGraphicObject(maCurrentPosition))
{
- mpObj = maCurrentPosition.mxObject.get();
+ mpObj = maCurrentPosition.mxObject.get().get();
rVectorGraphicSearchContext.mbCurrentIsVectorGraphic = true;
}
}
@@ -1735,7 +1735,7 @@ SdrObject* SdOutliner::SetObject (
SetViewMode (rPosition.mePageKind);
SetPage (rPosition.meEditMode, static_cast<sal_uInt16>(rPosition.mnPageIndex));
mnText = rPosition.mnText;
- return rPosition.mxObject.get();
+ return rPosition.mxObject.get().get();
}
void SdOutliner::SetViewShell (const std::shared_ptr<sd::ViewShell>& rpViewShell)
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index 70b1a34222f8..2d668468263d 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -169,7 +169,7 @@ Iterator OutlinerContainer::CreateIterator (IteratorLocation aLocation)
}
Iterator OutlinerContainer::CreateSelectionIterator (
- const ::std::vector<::tools::WeakReference<SdrObject>>& rObjectList,
+ const ::std::vector<::unotools::WeakReference<SdrObject>>& rObjectList,
SdDrawDocument* pDocument,
const std::shared_ptr<ViewShell>& rpViewShell,
bool bDirectionIsForward,
@@ -411,7 +411,7 @@ void IteratorImplBase::Reverse()
//===== SelectionIteratorImpl ===========================================
SelectionIteratorImpl::SelectionIteratorImpl (
- const ::std::vector<::tools::WeakReference<SdrObject>>& rObjectList,
+ const ::std::vector<::unotools::WeakReference<SdrObject>>& rObjectList,
sal_Int32 nObjectIndex,
SdDrawDocument* pDocument,
const std::weak_ptr<ViewShell>& rpViewShellWeak,
@@ -436,7 +436,7 @@ IteratorImplBase* SelectionIteratorImpl::Clone (IteratorImplBase* pObject) const
void SelectionIteratorImpl::GotoNextText()
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get().get() );
if (mbDirectionIsForward)
{
if( pTextObj )
@@ -472,7 +472,7 @@ void SelectionIteratorImpl::GotoNextText()
if( (maPosition.mnText == -1) && (mnObjectIndex >= 0) )
{
- pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() );
+ pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get().get() );
if( pTextObj )
maPosition.mnText = pTextObj->getTextCount() - 1;
}
@@ -549,9 +549,9 @@ IteratorImplBase* ViewIteratorImpl::Clone (IteratorImplBase* pObject) const
pIterator->mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward) );
// No direct way to set the object iterator to the current object.
- pIterator->maPosition.mxObject.reset(nullptr);
- while (pIterator->mpObjectIterator->IsMore() && pIterator->maPosition.mxObject!=maPosition.mxObject)
- pIterator->maPosition.mxObject.reset(pIterator->mpObjectIterator->Next());
+ pIterator->maPosition.mxObject = nullptr;
+ while (pIterator->mpObjectIterator->IsMore() && pIterator->maPosition.mxObject.get()!=maPosition.mxObject.get())
+ pIterator->maPosition.mxObject = pIterator->mpObjectIterator->Next();
}
else
pIterator->mpObjectIterator.reset();
@@ -561,7 +561,7 @@ IteratorImplBase* ViewIteratorImpl::Clone (IteratorImplBase* pObject) const
void ViewIteratorImpl::GotoNextText()
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get().get() );
if( pTextObj )
{
if (mbDirectionIsForward)
@@ -579,11 +579,11 @@ void ViewIteratorImpl::GotoNextText()
}
if (mpObjectIterator != nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject.reset(mpObjectIterator->Next());
+ maPosition.mxObject = mpObjectIterator->Next();
else
- maPosition.mxObject.reset(nullptr);
+ maPosition.mxObject = nullptr;
- if (!maPosition.mxObject.is() )
+ if (!maPosition.mxObject.get().is() )
{
if (mbDirectionIsForward)
SetPage (maPosition.mnPageIndex+1);
@@ -593,15 +593,15 @@ void ViewIteratorImpl::GotoNextText()
if (mpPage != nullptr)
mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward) );
if (mpObjectIterator!=nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject.reset(mpObjectIterator->Next());
+ maPosition.mxObject = mpObjectIterator->Next();
else
- maPosition.mxObject.reset(nullptr);
+ maPosition.mxObject = nullptr;
}
maPosition.mnText = 0;
- if( !mbDirectionIsForward && maPosition.mxObject.is() )
+ if( !mbDirectionIsForward && maPosition.mxObject.get().is() )
{
- pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get().get() );
if( pTextObj )
maPosition.mnText = pTextObj->getTextCount() - 1;
}
@@ -649,14 +649,14 @@ void ViewIteratorImpl::SetPage (sal_Int32 nPageIndex)
// Get object pointer.
if (mpObjectIterator!=nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject.reset( mpObjectIterator->Next() );
+ maPosition.mxObject = mpObjectIterator->Next();
else
- maPosition.mxObject.reset(nullptr);
+ maPosition.mxObject = nullptr;
maPosition.mnText = 0;
- if( !mbDirectionIsForward && maPosition.mxObject.is() )
+ if( !mbDirectionIsForward && maPosition.mxObject.get().is() )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get().get() );
if( pTextObj )
maPosition.mnText = pTextObj->getTextCount() - 1;
}
@@ -674,14 +674,13 @@ void ViewIteratorImpl::Reverse()
mpObjectIterator.reset();
// Move iterator to the current object.
- ::tools::WeakReference<SdrObject> xObject = std::move(maPosition.mxObject);
- maPosition.mxObject.reset(nullptr);
+ ::unotools::WeakReference<SdrObject> xObject = std::move(maPosition.mxObject);
if (!mpObjectIterator)
return;
- while (mpObjectIterator->IsMore() && maPosition.mxObject != xObject)
- maPosition.mxObject.reset(mpObjectIterator->Next());
+ while (mpObjectIterator->IsMore() && maPosition.mxObject.get() != xObject.get())
+ maPosition.mxObject = mpObjectIterator->Next();
}
//===== DocumentIteratorImpl ============================================
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 955a9104ea71..a44277634698 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -524,12 +524,12 @@ public:
if (!pMasterPage)
continue;
- SdrRectObj* pObject = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObject = new SdrRectObj(
*m_rDrawViewShell.GetDoc(), // TTTT should be reference
SdrObjKind::Text);
pObject->SetMergedItem(makeSdrTextAutoGrowWidthItem(true));
pObject->SetOutlinerParaObject(pOutliner->CreateParaObject());
- pMasterPage->InsertObject(pObject);
+ pMasterPage->InsertObject(pObject.get());
// Calculate position
::tools::Rectangle aRectangle(Point(), pMasterPage->GetSize());
@@ -1202,7 +1202,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
}
// create new object
- SdrGrafObj* pGraphicObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(
*GetDoc(),
aGraphic);
@@ -1237,7 +1237,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
pGraphicObj->SetLayer(pReplacementCandidate->GetLayer());
// now replace lowest object with new one
- mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
+ mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj.get());
// switch off undo
mpDrawView->EndUndo();
@@ -1456,7 +1456,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
GraphicObject aGraphicObject( pGraphicObj->GetGraphicObject() );
m_ExternalEdits.push_back(
std::make_unique<SdrExternalToolEdit>(
- mpDrawView.get(), pObj));
+ mpDrawView.get(), pGraphicObj));
m_ExternalEdits.back()->Edit( &aGraphicObject );
}
}
@@ -1478,11 +1478,11 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() );
if (dialog.run() == RET_OK)
{
- SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj();
+ rtl::Reference<SdrGrafObj> pNewObject = dialog.GetCompressedSdrGrafObj();
SdrPageView* pPageView = mpDrawView->GetSdrPageView();
OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress";
mpDrawView->BegUndo( aUndoString );
- mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
+ mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject.get() );
mpDrawView->EndUndo();
}
}
@@ -2533,7 +2533,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
pOutl->QuickInsertField( *pFieldItem, ESelection() );
std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
- SdrRectObj* pRectObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pRectObj = new SdrRectObj(
*GetDoc(),
SdrObjKind::Text);
pRectObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(true));
@@ -2554,7 +2554,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
::tools::Rectangle aLogicRect(aPos, aSize);
pRectObj->SetLogicRect(aLogicRect);
pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) );
- mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
+ mpDrawView->InsertObjectAtView(pRectObj.get(), *mpDrawView->GetSdrPageView());
pOutl->Init( nOutlMode );
}
diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
index 7d85151f78e1..45b6edd5c0d6 100644
--- a/sd/source/ui/view/drviews6.cxx
+++ b/sd/source/ui/view/drviews6.cxx
@@ -268,8 +268,7 @@ void DrawViewShell::ExecBmpMask( SfxRequest const & rReq )
if ( pObj && !mpDrawView->IsTextEdit() )
{
- typedef std::unique_ptr< SdrGrafObj, SdrObjectFreeOp > SdrGrafObjPtr;
- SdrGrafObjPtr xNewObj(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrGrafObj> xNewObj(SdrObject::Clone(*pObj, pObj->getSdrModelFromSdrObject()));
bool bCont = true;
if (xNewObj->IsLinkedGraphic())
@@ -303,7 +302,7 @@ void DrawViewShell::ExecBmpMask( SfxRequest const & rReq )
" " + SdResId(STR_EYEDROPPER);
mpDrawView->BegUndo( aStr );
- mpDrawView->ReplaceObjectAtView(pObj, *pPV, xNewObj.release());
+ mpDrawView->ReplaceObjectAtView(pObj, *pPV, xNewObj.get());
mpDrawView->EndUndo();
}
}
diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx
index e5ae5cd975fa..0f2907d424ba 100644
--- a/sd/source/ui/view/drviews8.cxx
+++ b/sd/source/ui/view/drviews8.cxx
@@ -113,12 +113,12 @@ void DrawViewShell::ScannerEvent()
if( bInsertNewObject )
{
- auto pGrafObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(
GetView()->getSdrModelFromSdrView(),
Graphic(aScanBmp),
aRect);
SdrPageView* pPV = GetView()->GetSdrPageView();
- GetView()->InsertObjectAtView( pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER );
+ GetView()->InsertObjectAtView( pGrafObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER );
}
}
}
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index f80419587729..543d874e7271 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -124,7 +124,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
aPnt += Point(pPage->GetLeftBorder(), pPage->GetUpperBorder());
::tools::Rectangle aRect (aPnt, aSize);
- SdrGrafObj* pGrafObj = nullptr;
+ rtl::Reference<SdrGrafObj> pGrafObj;
bool bInsertNewObject = true;
@@ -147,7 +147,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
// the empty graphic object gets a new graphic
bInsertNewObject = false;
- SdrGrafObj* pNewGrafObj(pGrafObj->CloneSdrObject(pGrafObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrGrafObj> pNewGrafObj(SdrObject::Clone(*pGrafObj, pGrafObj->getSdrModelFromSdrObject()));
pNewGrafObj->SetEmptyPresObj(false);
pNewGrafObj->SetOutlinerParaObject(std::nullopt);
pNewGrafObj->SetGraphic(aGraphic);
@@ -156,7 +156,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
" " + SdResId(STR_UNDO_REPLACE);
mpDrawView->BegUndo(aStr);
SdrPageView* pPV = mpDrawView->GetSdrPageView();
- mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj);
+ mpDrawView->ReplaceObjectAtView(pGrafObj.get(), *pPV, pNewGrafObj.get());
mpDrawView->EndUndo();
}
}
@@ -170,7 +170,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
aGraphic,
aRect);
SdrPageView* pPV = mpDrawView->GetSdrPageView();
- mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER);
+ mpDrawView->InsertObjectAtView(pGrafObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
}
}
// insert sound
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index c264c25e9d5f..a345af61331b 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -23,6 +23,7 @@
#include <comphelper/processfactory.hxx>
#include <editeng/sizeitem.hxx>
#include <svx/svdlayer.hxx>
+#include <svx/svdograf.hxx>
#include <sfx2/zoomitem.hxx>
#include <svx/svdpagv.hxx>
#include <svl/ptitem.hxx>
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 309eb2b85a63..59142ad4bb76 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -276,7 +276,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
if(pPageView)
{
svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
- SdrObjectUniquePtr pNewDBField = pFormView->CreateFieldControl(aDescriptor);
+ rtl::Reference<SdrObject> pNewDBField = pFormView->CreateFieldControl(aDescriptor);
if(pNewDBField)
{
@@ -289,7 +289,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
pNewDBField->SetLogicRect(aNewObjectRectangle);
- GetView()->InsertObjectAtView(pNewDBField.release(), *pPageView);
+ GetView()->InsertObjectAtView(pNewDBField.get(), *pPageView);
}
}
}
@@ -640,14 +640,14 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
return;
// create the default object
- SdrObjectUniquePtr pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
+ rtl::Reference<SdrObject> pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
if(!pObj)
return;
auto pObjTmp = pObj.get();
// insert into page
- GetView()->InsertObjectAtView(pObj.release(), *pPageView);
+ GetView()->InsertObjectAtView(pObj.get(), *pPageView);
// Now that pFuActual has done what it was created for we
// can switch on the edit mode for callout objects.
@@ -1499,7 +1499,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText,
pOutl->QuickInsertField( aURLItem, ESelection() );
std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
- SdrRectObj* pRectObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pRectObj = new SdrRectObj(
GetView()->getSdrModelFromSdrView(),
SdrObjKind::Text);
@@ -1521,7 +1521,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText,
::tools::Rectangle aLogicRect(aPos, aSize);
pRectObj->SetLogicRect(aLogicRect);
pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) );
- mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
+ mpDrawView->InsertObjectAtView(pRectObj.get(), *mpDrawView->GetSdrPageView());
pOutl->Init( nOutlMode );
}
}
@@ -1583,11 +1583,11 @@ void DrawViewShell::InsertURLButton(const OUString& rURL, const OUString& rText,
try
{
- SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >(
+ rtl::Reference<SdrUnoObj> pUnoCtrl = static_cast< SdrUnoObj* >(
SdrObjFactory::MakeNewObject(
GetView()->getSdrModelFromSdrView(),
SdrInventor::FmForm,
- SdrObjKind::FormButton)); //,
+ SdrObjKind::FormButton).get()); //,
//mpDrawView->GetSdrPageView()->GetPage()));
Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_SET_THROW );
@@ -1631,7 +1631,7 @@ void DrawViewShell::InsertURLButton(const OUString& rURL, const OUString& rText,
nOptions |= SdrInsertFlags::DONTMARK;
}
- mpDrawView->InsertObjectAtView(pUnoCtrl, *mpDrawView->GetSdrPageView(), nOptions);
+ mpDrawView->InsertObjectAtView(pUnoCtrl.get(), *mpDrawView->GetSdrPageView(), nOptions);
}
catch( Exception& )
{
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 7099977b31cf..a2483fadce67 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -757,15 +757,15 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
{
maMasterViewFilter.End();
- ::tools::WeakReference<SdrTextObj> xObj( GetTextEditObject() );
+ SdrTextObj* xObj = GetTextEditObject();
- bool bDefaultTextRestored = RestoreDefaultText( xObj.get() );
+ bool bDefaultTextRestored = RestoreDefaultText( xObj );
SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
if( bDefaultTextRestored )
{
- if( xObj.is() && !xObj->IsEmptyPresObj() )
+ if( xObj && !xObj->IsEmptyPresObj() )
{
xObj->SetEmptyPresObj( true );
}
@@ -774,22 +774,21 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
eKind = SdrEndTextEditKind::Unchanged;
}
}
- else if( xObj.is() && xObj->IsEmptyPresObj() )
+ else if( xObj && xObj->IsEmptyPresObj() )
{
- SdrTextObj* pObj = xObj.get();
- if( pObj && pObj->HasText() )
+ if( xObj && xObj->HasText() )
{
- SdrPage* pPage = pObj->getSdrPageFromSdrObject();
+ SdrPage* pPage = xObj->getSdrPageFromSdrObject();
if( !pPage || !pPage->IsMasterPage() )
- pObj->SetEmptyPresObj( false );
+ xObj->SetEmptyPresObj( false );
}
}
GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
EventMultiplexerEventId::EndTextEdit,
- static_cast<void*>(xObj.get()) );
+ static_cast<void*>(xObj) );
- if( xObj.is() )
+ if( xObj )
{
if ( mpViewSh )
{
@@ -802,7 +801,7 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
SdPage* pPage = dynamic_cast< SdPage* >( xObj->getSdrPageFromSdrObject() );
if( pPage )
- pPage->onEndTextEdit( xObj.get() );
+ pPage->onEndTextEdit( xObj );
}
return eKind;
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 17449a6b8a86..af76e39afd4b 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -408,8 +408,8 @@ void View::DragFinished( sal_Int8 nDropAction )
if( pObj && pObj->getSdrPageFromSdrObject() )
{
const size_t nOrdNum = pObj->GetOrdNumDirect();
- SdrObject* pChkObj = pObj->getSdrPageFromSdrObject()->RemoveObject(nOrdNum);
- DBG_ASSERT(pChkObj==pObj,"pChkObj!=pObj in RemoveObject()");
+ rtl::Reference<SdrObject> pChkObj = pObj->getSdrPageFromSdrObject()->RemoveObject(nOrdNum);
+ DBG_ASSERT(pChkObj.get()==pObj,"pChkObj!=pObj in RemoveObject()");
}
}
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index b72e837c4ea6..0050fb85db6a 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -487,7 +487,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
for(size_t a = 0; a < pMarkList->GetMarkCount(); ++a)
{
SdrMark* pM = pMarkList->GetMark(a);
- SdrObject* pObj(pM->GetMarkedSdrObj()->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
+ rtl::Reference<SdrObject> pObj(pM->GetMarkedSdrObj()->CloneSdrObject(pPage->getSdrModelFromSdrPage()));
if(pObj)
{
@@ -499,9 +499,9 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
SdrObject* pMarkParent = pM->GetMarkedSdrObj()->getParentSdrObjectFromSdrObject();
if (bCopy || (pMarkParent && pMarkParent->IsGroupObject()))
- pPage->InsertObjectThenMakeNameUnique(pObj, aNameSet);
+ pPage->InsertObjectThenMakeNameUnique(pObj.get(), aNameSet);
else
- pPage->InsertObject(pObj);
+ pPage->InsertObject(pObj.get());
if( IsUndoEnabled() )
{
@@ -512,10 +512,10 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
ImpRememberOrigAndClone aRem;
aRem.pOrig = pM->GetMarkedSdrObj();
- aRem.pClone = pObj;
+ aRem.pClone = pObj.get();
aConnectorContainer.push_back(aRem);
- if(dynamic_cast< SdrEdgeObj *>( pObj ) != nullptr)
+ if(dynamic_cast< SdrEdgeObj *>( pObj.get() ) != nullptr)
nConnectorCount++;
}
}
@@ -744,7 +744,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
{
// replace object
SdrPage* pWorkPage = GetSdrPageView()->GetPage();
- SdrObject* pNewObj(pObj->CloneSdrObject(pWorkPage->getSdrModelFromSdrPage()));
+ rtl::Reference<SdrObject> pNewObj(pObj->CloneSdrObject(pWorkPage->getSdrModelFromSdrPage()));
::tools::Rectangle aPickObjRect( pPickObj2->GetCurrentBoundRect() );
Size aPickObjSize( aPickObjRect.GetSize() );
Point aVec( aPickObjRect.TopLeft() );
@@ -763,7 +763,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if( bUndo )
BegUndo(SdResId(STR_UNDO_DRAGDROP));
pNewObj->NbcSetLayer( pPickObj->GetLayer() );
- pWorkPage->InsertObject( pNewObj );
+ pWorkPage->InsertObject( pNewObj.get() );
if( bUndo )
{
AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
@@ -775,10 +775,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
{
EndUndo();
}
- else
- {
- SdrObject::Free(pPickObj2 );
- }
+
bChanged = true;
mnAction = DND_ACTION_COPY;
}
@@ -870,7 +867,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if( aDataHelper.GetString( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE, aOUString ) )
{
- SdrObjectUniquePtr pObj = CreateFieldControl( aOUString );
+ rtl::Reference<SdrObject> pObj = CreateFieldControl( aOUString );
if( pObj )
{
@@ -882,7 +879,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
aRect.SetPos( maDropPos );
pObj->SetLogicRect( aRect );
- InsertObjectAtView( pObj.release(), *GetSdrPageView(), SdrInsertFlags::SETDEFLAYER );
+ InsertObjectAtView( pObj.get(), *GetSdrPageView(), SdrInsertFlags::SETDEFLAYER );
bReturn = true;
}
}
@@ -1016,7 +1013,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
maDropPos.AdjustY( -(std::min( aSize.Height(), aMaxSize.Height() ) >> 1) );
::tools::Rectangle aRect( maDropPos, aSize );
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
getSdrModelFromSdrView(),
aObjRef,
aName,
@@ -1034,7 +1031,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
}
// bInserted of false means that pObj has been deleted
- bool bInserted = InsertObjectAtView( pObj, *pPV, nOptions );
+ bool bInserted = InsertObjectAtView( pObj.get(), *pPV, nOptions );
if (bInserted && pImageMap)
pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( *pImageMap )) );
@@ -1191,7 +1188,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
maDropPos.AdjustY( -(std::min( aSize.Height(), aMaxSize.Height() ) >> 1) );
::tools::Rectangle aRect( maDropPos, aSize );
- SdrOle2Obj* pObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pObj = new SdrOle2Obj(
getSdrModelFromSdrView(),
aObjRef,
aName,
@@ -1208,7 +1205,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
nOptions |= SdrInsertFlags::DONTMARK;
}
- bReturn = InsertObjectAtView( pObj, *pPV, nOptions );
+ bReturn = InsertObjectAtView( pObj.get(), *pPV, nOptions );
if (bReturn)
{
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 7a3c7c2267a5..548e85c5798b 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -82,7 +82,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
mnAction = rAction;
// Is there an object at the position rPos?
- SdrGrafObj* pNewGrafObj = nullptr;
+ rtl::Reference<SdrGrafObj> pNewGrafObj;
SdrPageView* pPV = GetSdrPageView();
SdrObject* pPickObj = pObj;
const bool bOnMaster = pPV && pPV->GetPage() && pPV->GetPage()->IsMasterPage();
@@ -115,7 +115,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
if( bIsGraphic )
{
// We fill the object with the Bitmap
- pNewGrafObj = static_cast<SdrGrafObj*>( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
+ pNewGrafObj = SdrObject::Clone(static_cast<SdrGrafObj&>(*pPickObj), pPickObj->getSdrModelFromSdrObject());
pNewGrafObj->SetGraphic(rGraphic);
}
else
@@ -138,14 +138,14 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
if (pPage && pPage->IsPresObj(pPickObj))
{
// Insert new PresObj into the list
- pPage->InsertPresObj( pNewGrafObj, PresObjKind::Graphic );
+ pPage->InsertPresObj( pNewGrafObj.get(), PresObjKind::Graphic );
pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
}
if (pImageMap)
pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
- ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
+ ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj.get()); // maybe ReplaceObjectAtView
if( IsUndoEnabled() )
EndUndo();
@@ -269,7 +269,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
BegUndo(SdResId(STR_UNDO_DRAGDROP));
pNewGrafObj->NbcSetLayer(pPickObj->GetLayer());
SdrPage* pP = pPV->GetPage();
- pP->InsertObject(pNewGrafObj);
+ pP->InsertObject(pNewGrafObj.get());
if( bUndo )
{
AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
@@ -281,15 +281,11 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
{
EndUndo();
}
- else
- {
- SdrObject::Free(pPickObj);
- }
mnAction = DND_ACTION_COPY;
}
else
{
- bool bSuccess = InsertObjectAtView(pNewGrafObj, *pPV, nOptions);
+ bool bSuccess = InsertObjectAtView(pNewGrafObj.get(), *pPV, nOptions);
if (!bSuccess)
pNewGrafObj = nullptr;
else if (pImageMap)
@@ -299,7 +295,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
rAction = mnAction;
- return pNewGrafObj;
+ return pNewGrafObj.get();
}
void View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
@@ -332,7 +328,7 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
SdrEndTextEdit();
mnAction = rAction;
- SdrMediaObj* pNewMediaObj = nullptr;
+ rtl::Reference<SdrMediaObj> pNewMediaObj;
SdrPageView* pPV = GetSdrPageView();
SdrObject* pPickObj = GetEmptyPresentationObject( PresObjKind::Media );
@@ -344,11 +340,11 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
if( mnAction == DND_ACTION_LINK && pPV && dynamic_cast< SdrMediaObj *>( pPickObj ) )
{
- pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
+ pNewMediaObj = SdrObject::Clone(static_cast<SdrMediaObj&>(*pPickObj), pPickObj->getSdrModelFromSdrObject());
pNewMediaObj->setURL( rMediaURL, ""/*TODO?*/, rMimeType );
BegUndo(SdResId(STR_UNDO_DRAGDROP));
- ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+ ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj.get());
EndUndo();
}
else if( pPV )
@@ -372,15 +368,15 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
bIsPres = pPage && pPage->IsPresObj(pPickObj);
if( bIsPres )
{
- pPage->InsertPresObj( pNewMediaObj, PresObjKind::Media );
+ pPage->InsertPresObj( pNewMediaObj.get(), PresObjKind::Media );
}
}
if( pPickObj )
- ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+ ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj.get());
else
{
- if (!InsertObjectAtView(pNewMediaObj, *pPV, SdrInsertFlags::SETDEFLAYER))
+ if (!InsertObjectAtView(pNewMediaObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER))
pNewMediaObj = nullptr;
}
@@ -405,7 +401,7 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
rAction = mnAction;
- return pNewMediaObj;
+ return pNewMediaObj.get();
}
/**
@@ -581,7 +577,7 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl, Timer *, void)
aRect = ::tools::Rectangle( maDropPos, aSize );
- SdrOle2Obj* pOleObj = new SdrOle2Obj(
+ rtl::Reference<SdrOle2Obj> pOleObj = new SdrOle2Obj(
getSdrModelFromSdrView(),
svt::EmbeddedObjectRef(xObj, nAspect),
aName,
@@ -597,7 +593,7 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl, Timer *, void)
nOptions |= SdrInsertFlags::DONTMARK;
}
- if (InsertObjectAtView( pOleObj, *GetSdrPageView(), nOptions ))
+ if (InsertObjectAtView( pOleObj.get(), *GetSdrPageView(), nOptions ))
pOleObj->SetLogicRect( aRect );
aSz.Width = aRect.GetWidth();
aSz.Height = aRect.GetHeight();
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx
index 3cdfb9787337..42399fc21a33 100644
--- a/sd/source/ui/view/viewoverlaymanager.cxx
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -134,7 +134,7 @@ protected:
virtual void addCustomHandles( SdrHdlList& rHandlerList ) override;
private:
- ::tools::WeakReference<SdrObject> mxPlaceholderObj;
+ ::unotools::WeakReference<SdrObject> mxPlaceholderObj;
};
class ImageButtonHdl : public SmartHdl
@@ -316,14 +316,14 @@ bool ChangePlaceholderTag::MouseButtonDown( const MouseEvent& /*rMEvt*/, SmartHd
{
sal_uInt16 nSID = gButtonSlots[nHighlightId];
- if( mxPlaceholderObj )
+ if( auto pPlaceholder = mxPlaceholderObj.get() )
{
// mark placeholder if it is not currently marked (or if also others are marked)
- if( !mrView.IsObjMarked( mxPlaceholderObj.get() ) || (mrView.GetMarkedObjectList().GetMarkCount() != 1) )
+ if( !mrView.IsObjMarked( pPlaceholder.get() ) || (mrView.GetMarkedObjectList().GetMarkCount() != 1) )
{
SdrPageView* pPV = mrView.GetSdrPageView();
mrView.UnmarkAllObj(pPV );
- mrView.MarkObj(mxPlaceholderObj.get(), pPV);
+ mrView.MarkObj(pPlaceholder.get(), pPV);
}
}
@@ -354,9 +354,8 @@ bool ChangePlaceholderTag::KeyInput( const KeyEvent& rKEvt )
BitmapEx ChangePlaceholderTag::createOverlayImage( int nHighlight )
{
BitmapEx aRet;
- if( mxPlaceholderObj.is() )
+ if( auto pPlaceholder = mxPlaceholderObj.get() )
{
- SdrObject* pPlaceholder = mxPlaceholderObj.get();
SmartTagReference xThis( this );
const ::tools::Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
@@ -388,10 +387,10 @@ BitmapEx ChangePlaceholderTag::createOverlayImage( int nHighlight )
void ChangePlaceholderTag::addCustomHandles( SdrHdlList& rHandlerList )
{
- if( !mxPlaceholderObj.is() )
+ rtl::Reference<SdrObject> pPlaceholder = mxPlaceholderObj.get();
+ if( !pPlaceholder )
return;
- SdrObject* pPlaceholder = mxPlaceholderObj.get();
SmartTagReference xThis( this );
const ::tools::Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
const Point aPoint;
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index b442a4cee603..f185a1ebb719 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -214,6 +214,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
bool m_bSuicide ;
bool m_bExternalTitle ;
bool m_bModifiedSinceLastSave ;
+ bool m_bDisposing ;
Reference< view::XPrintable> m_xPrintable ;
Reference< ui::XUIConfigurationManager2 > m_xUIConfigurationManager;
::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListen ;
@@ -235,6 +236,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
, m_bSuicide ( false )
, m_bExternalTitle ( false )
, m_bModifiedSinceLastSave( false )
+ , m_bDisposing ( false )
{
// increase global instance counter.
++g_nInstanceCounter;
@@ -726,6 +728,10 @@ void SAL_CALL SfxBaseModel::dispose()
return;
}
+ if ( m_pData->m_bDisposing )
+ return;
+ m_pData->m_bDisposing = true;
+
if ( m_pData->m_pStorageModifyListen.is() )
{
m_pData->m_pStorageModifyListen->dispose();
diff --git a/svx/inc/extrud3d.hxx b/svx/inc/extrud3d.hxx
index 9e797e57924d..2b8f39d282bd 100644
--- a/svx/inc/extrud3d.hxx
+++ b/svx/inc/extrud3d.hxx
@@ -95,7 +95,7 @@ public:
virtual SdrObjKind GetObjIdentifier() const override;
- virtual E3dExtrudeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
// TakeObjName...() is for the display in the UI (for example "3 frames selected")
virtual OUString TakeObjNameSingul() const override;
@@ -106,7 +106,7 @@ public:
const basegfx::B2DPolyPolygon &GetExtrudePolygon() const { return maExtrudePolygon; }
virtual bool IsBreakObjPossible() override;
- virtual std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> GetBreakObj() override;
+ virtual rtl::Reference<SdrAttrObj> GetBreakObj() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/inc/polygn3d.hxx b/svx/inc/polygn3d.hxx
index 5a4a234eb191..2f5b9f7fcdd2 100644
--- a/svx/inc/polygn3d.hxx
+++ b/svx/inc/polygn3d.hxx
@@ -53,9 +53,10 @@ public:
const basegfx::B2DPolyPolygon& GetPolyTexture2D() const { return aPolyTexture2D; }
virtual SdrObjKind GetObjIdentifier() const override;
- virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+ virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier,
+ bool bAddText) const override;
- virtual E3dPolygonObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
// LineOnly?
bool GetLineOnly() const { return bLineOnly; }
diff --git a/svx/inc/sdr/primitive2d/sdrolecontentprimitive2d.hxx b/svx/inc/sdr/primitive2d/sdrolecontentprimitive2d.hxx
index 20a0b9dd971f..20d694399705 100644
--- a/svx/inc/sdr/primitive2d/sdrolecontentprimitive2d.hxx
+++ b/svx/inc/sdr/primitive2d/sdrolecontentprimitive2d.hxx
@@ -22,7 +22,7 @@
#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <tools/weakbase.h>
+#include <unotools/weakref.hxx>
// predefinitions
@@ -35,7 +35,7 @@ namespace drawinglayer::primitive2d
class SdrOleContentPrimitive2D final : public BufferedDecompositionPrimitive2D
{
private:
- tools::WeakReference<SdrOle2Obj> mpSdrOle2Obj;
+ unotools::WeakReference<SdrOle2Obj> mpSdrOle2Obj;
basegfx::B2DHomMatrix maObjectTransform;
// #i104867# The GraphicVersion number to identify in operator== if
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 0b1970378e2a..39478fd92772 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -745,8 +745,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf121845_two_commands_U)
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- SdrPathObjUniquePtr pPathObj(
- static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().release()));
+ rtl::Reference<SdrPathObj> pPathObj(
+ static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().get()));
CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast<sal_uInt32>(2),
@@ -1129,8 +1129,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandT_CaseZeroHeight)
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- SdrPathObjUniquePtr pPathObj(
- static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().release()));
+ rtl::Reference<SdrPathObj> pPathObj(
+ static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().get()));
CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast<sal_uInt32>(1),
@@ -1159,8 +1159,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandG_CaseZeroHeight)
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- SdrPathObjUniquePtr pPathObj(
- static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().release()));
+ rtl::Reference<SdrPathObj> pPathObj(
+ static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().get()));
CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast<sal_uInt32>(1),
@@ -1189,8 +1189,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf122323_largeSwingAngle)
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- SdrPathObjUniquePtr pPathObj(
- static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().release()));
+ rtl::Reference<SdrPathObj> pPathObj(
+ static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().get()));
CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0));
@@ -1393,8 +1393,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148707_two_commands_B_V)
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- SdrPathObjUniquePtr pPathObj(
- static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().release()));
+ rtl::Reference<SdrPathObj> pPathObj(
+ static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry().get()));
CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", sal_uInt32(2), aPolyPolygon.count());
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index dacf558c5f7f..f6ca7fd4b09e 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -278,8 +278,8 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObject)
pModel->InsertPage(pPage.get(), 0);
tools::Rectangle aSize(Point(), Size(100, 100));
- auto* pRectangle = new SdrRectObj(*pModel, aSize);
- pPage->NbcInsertObject(pRectangle);
+ rtl::Reference<SdrRectObj> pRectangle = new SdrRectObj(*pModel, aSize);
+ pPage->NbcInsertObject(pRectangle.get());
pRectangle->SetMergedItem(XLineStyleItem(drawing::LineStyle_SOLID));
pRectangle->SetMergedItem(XLineStartWidthItem(200));
@@ -343,9 +343,6 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObject)
assertXPath(pXmlDoc, aBasePath + "/stroke", 0);
pPage->RemoveObject(0);
-
- SdrObject* pObject(pRectangle);
- SdrObject::Free(pObject);
}
CPPUNIT_TEST_FIXTURE(SvdrawTest, testAutoHeightMultiColShape)
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index 508fb245fbc7..8126e491006d 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -156,7 +156,7 @@ void ExternalToolEdit::Edit(GraphicObject const*const pGraphicObject)
SdrExternalToolEdit::SdrExternalToolEdit(
FmFormView* pView,
- SdrObject* pObj)
+ SdrGrafObj* pObj)
: m_pView(pView)
,m_pObj(pObj)
{
@@ -171,7 +171,7 @@ void SdrExternalToolEdit::Notify(SfxBroadcaster & rBC, SfxHint const& rHint)
return;
SdrHint const*const pSdrHint(static_cast<SdrHint const*>(&rHint));
if (SdrHintKind::ModelCleared == pSdrHint->GetKind()
- || (pSdrHint->GetObject() == m_pObj
+ || (pSdrHint->GetObject() == m_pObj.get()
&& SdrHintKind::ObjectRemoved == pSdrHint->GetKind()))
{
m_pView = nullptr;
@@ -188,7 +188,7 @@ void SdrExternalToolEdit::Update(Graphic & rGraphic)
if (!pPageView)
return;
- SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->CloneSdrObject(m_pObj->getSdrModelFromSdrObject())));
+ rtl::Reference<SdrGrafObj> pNewObj = SdrObject::Clone(*m_pObj, m_pObj->getSdrModelFromSdrObject());
assert(pNewObj);
OUString const description =
m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
@@ -196,9 +196,9 @@ void SdrExternalToolEdit::Update(Graphic & rGraphic)
pNewObj->SetGraphicObject(rGraphic);
// set to new object before ReplaceObjectAtView() so that Notify() will
// not delete the running timer and crash
- SdrObject *const pOldObj = m_pObj;
+ rtl::Reference<SdrObject> pOldObj = m_pObj;
m_pObj = pNewObj;
- m_pView->ReplaceObjectAtView(pOldObj, *pPageView, pNewObj);
+ m_pView->ReplaceObjectAtView(pOldObj.get(), *pPageView, pNewObj.get());
m_pView->EndUndo();
}
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 6e9ee5ecce12..d93dbee142a3 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -2049,7 +2049,7 @@ static double lcl_getNormalizedAngleRad(const double fCircleAngleDeg)
void EnhancedCustomShape2d::CreateSubPath(
sal_Int32& rSrcPt,
sal_Int32& rSegmentInd,
- std::vector< std::pair< SdrPathObjUniquePtr, double> >& rObjectList,
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double> >& rObjectList,
const bool bLineGeometryNeededOnly,
const bool bSortFilledObjectsToBack,
sal_Int32 nIndex)
@@ -2608,7 +2608,7 @@ void EnhancedCustomShape2d::CreateSubPath(
{
basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
aClosedPolyPolygon.setClosed(true);
- SdrPathObjUniquePtr pFill(new SdrPathObj(
+ rtl::Reference<SdrPathObj> pFill(new SdrPathObj(
mrSdrObjCustomShape.getSdrModelFromSdrObject(),
SdrObjKind::Polygon,
std::move(aClosedPolyPolygon)));
@@ -2616,7 +2616,7 @@ void EnhancedCustomShape2d::CreateSubPath(
aTempSet.Put(makeSdrShadowItem(false));
aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
pFill->SetMergedItemSet(aTempSet);
- rObjectList.push_back(std::pair< SdrPathObjUniquePtr, double >(std::move(pFill), dBrightness));
+ rObjectList.push_back(std::pair< rtl::Reference<SdrPathObj>, double >(std::move(pFill), dBrightness));
}
if(!bNoStroke)
@@ -2625,7 +2625,7 @@ void EnhancedCustomShape2d::CreateSubPath(
// the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs
// to correct the polygon (here: open it) using the type, the last edge may get lost.
// Thus, use a type that fits the polygon
- SdrPathObjUniquePtr pStroke(new SdrPathObj(
+ rtl::Reference<SdrPathObj> pStroke(new SdrPathObj(
mrSdrObjCustomShape.getSdrModelFromSdrObject(),
aNewB2DPolyPolygon.isClosed() ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
aNewB2DPolyPolygon));
@@ -2633,31 +2633,31 @@ void EnhancedCustomShape2d::CreateSubPath(
aTempSet.Put(makeSdrShadowItem(false));
aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
pStroke->SetMergedItemSet(aTempSet);
- rObjectList.push_back(std::pair< SdrPathObjUniquePtr, double >(std::move(pStroke), dBrightness));
+ rObjectList.push_back(std::pair< rtl::Reference<SdrPathObj>, double >(std::move(pStroke), dBrightness));
}
}
else
{
- SdrPathObjUniquePtr pObj;
+ rtl::Reference<SdrPathObj> pObj;
SfxItemSet aTempSet(*this);
aTempSet.Put(makeSdrShadowItem(false));
if(bNoFill)
{
// see comment above about OBJ_PLIN
- pObj.reset(new SdrPathObj(
+ pObj = new SdrPathObj(
mrSdrObjCustomShape.getSdrModelFromSdrObject(),
aNewB2DPolyPolygon.isClosed() ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
- aNewB2DPolyPolygon));
+ aNewB2DPolyPolygon);
aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
}
else
{
aNewB2DPolyPolygon.setClosed(true);
- pObj.reset(new SdrPathObj(
+ pObj = new SdrPathObj(
mrSdrObjCustomShape.getSdrModelFromSdrObject(),
SdrObjKind::Polygon,
- aNewB2DPolyPolygon));
+ aNewB2DPolyPolygon);
}
if(bNoStroke)
@@ -2666,14 +2666,14 @@ void EnhancedCustomShape2d::CreateSubPath(
}
pObj->SetMergedItemSet(aTempSet);
- rObjectList.push_back(std::pair< SdrPathObjUniquePtr, double >(std::move(pObj), dBrightness));
+ rObjectList.push_back(std::pair< rtl::Reference<SdrPathObj>, double >(std::move(pObj), dBrightness));
}
}
static void CorrectCalloutArrows(
MSO_SPT eSpType,
sal_uInt32 nLineObjectCount,
- std::vector< std::pair< SdrPathObjUniquePtr, double> >& vObjectList )
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double> >& vObjectList )
{
bool bAccent = false;
switch( eSpType )
@@ -2692,7 +2692,7 @@ static void CorrectCalloutArrows(
{
sal_uInt32 nLine = 0;
- for ( const std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( const std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
@@ -2719,7 +2719,7 @@ static void CorrectCalloutArrows(
{
sal_uInt32 nLine = 0;
- for ( const std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( const std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
@@ -2747,7 +2747,7 @@ static void CorrectCalloutArrows(
{
sal_uInt32 nLine = 0;
- for ( const std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( const std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
@@ -2856,19 +2856,19 @@ void EnhancedCustomShape2d::AdaptObjColor(
nColorIndex++;
}
-SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
+rtl::Reference<SdrObject> EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
{
if ( !seqCoordinates.hasElements() )
{
return nullptr;
}
- std::vector< std::pair< SdrPathObjUniquePtr, double > > vObjectList;
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double > > vObjectList;
const bool bSortFilledObjectsToBack(SortFilledObjectsToBackByDefault(eSpType));
sal_Int32 nSubPathIndex(0);
sal_Int32 nSrcPt(0);
sal_Int32 nSegmentInd(0);
- SdrObjectUniquePtr pRet;
+ rtl::Reference<SdrObject> pRet;
while( nSegmentInd <= seqSegments.getLength() )
{
@@ -2889,9 +2889,9 @@ SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeede
sal_uInt32 nColorIndex(0);
// #i37011# remove invisible objects
- std::vector< std::pair< SdrPathObjUniquePtr, double> > vNewList;
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double> > vNewList;
- for ( std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
const drawing::LineStyle eLineStyle(pObj->GetMergedItem(XATTR_LINESTYLE).GetValue());
@@ -2920,7 +2920,7 @@ SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeede
sal_Int32 nLineObjectCount(0);
// correct some values and collect content data
- for ( const std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( const std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
@@ -2959,17 +2959,17 @@ SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeede
// for some strange objects
if(bSortFilledObjectsToBack)
{
- std::vector< std::pair< SdrPathObjUniquePtr, double> > vTempList;
+ std::vector< std::pair< rtl::Reference<SdrPathObj>, double> > vTempList;
vTempList.reserve(vObjectList.size());
- for ( std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
SdrPathObj* pObj(rCandidate.first.get());
if ( !pObj->IsLine() )
vTempList.push_back(std::move(rCandidate));
}
- for ( std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
if ( rCandidate.first )
vTempList.push_back(std::move(rCandidate));
@@ -2986,16 +2986,16 @@ SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeede
// copy remaining objects to pRet
if(vObjectList.size() > 1)
{
- pRet.reset(new SdrObjGroup(mrSdrObjCustomShape.getSdrModelFromSdrObject()));
+ pRet = new SdrObjGroup(mrSdrObjCustomShape.getSdrModelFromSdrObject());
- for ( std::pair< SdrPathObjUniquePtr, double >& rCandidate : vObjectList )
+ for ( std::pair< rtl::Reference<SdrPathObj>, double >& rCandidate : vObjectList )
{
- pRet->GetSubList()->NbcInsertObject(rCandidate.first.release());
+ pRet->GetSubList()->NbcInsertObject(rCandidate.first.get());
}
}
else if(1 == vObjectList.size())
{
- pRet.reset(vObjectList.begin()->first.release());
+ pRet = vObjectList.begin()->first;
}
if(pRet)
@@ -3010,13 +3010,13 @@ SdrObjectUniquePtr EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeede
return pRet;
}
-SdrObjectUniquePtr EnhancedCustomShape2d::CreateObject( bool bLineGeometryNeededOnly )
+rtl::Reference<SdrObject> EnhancedCustomShape2d::CreateObject( bool bLineGeometryNeededOnly )
{
- SdrObjectUniquePtr pRet;
+ rtl::Reference<SdrObject> pRet;
if ( eSpType == mso_sptRectangle )
{
- pRet.reset(new SdrRectObj(mrSdrObjCustomShape.getSdrModelFromSdrObject(), aLogicRect));
+ pRet = new SdrRectObj(mrSdrObjCustomShape.getSdrModelFromSdrObject(), aLogicRect);
pRet->SetMergedItemSet( *this );
}
if ( !pRet )
@@ -3044,7 +3044,7 @@ void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
}
}
-SdrObjectUniquePtr EnhancedCustomShape2d::CreateLineGeometry()
+rtl::Reference<SdrObject> EnhancedCustomShape2d::CreateLineGeometry()
{
return CreateObject( true );
}
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 748492aec630..3e8a495a7a3f 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -230,11 +230,11 @@ void lcl_SoftLightsDirection(const basegfx::B3DVector& rLight, basegfx::B3DVecto
}
}
-SdrObject* EnhancedCustomShape3d::Create3DObject(
+rtl::Reference<SdrObject> EnhancedCustomShape3d::Create3DObject(
const SdrObject* pShape2d,
const SdrObjCustomShape& rSdrObjCustomShape)
{
- SdrObject* pRet(nullptr);
+ rtl::Reference<SdrObject> pRet;
const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY));
double fMap(1.0), *pMap = nullptr;
Fraction aFraction( rSdrObjCustomShape.getSdrModelFromSdrObject().GetScaleFraction() );
@@ -302,7 +302,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
a3DDefaultAttr.SetDefaultLatheCharacterMode( true );
a3DDefaultAttr.SetDefaultExtrudeCharacterMode( true );
- E3dScene* pScene = new E3dScene(rSdrObjCustomShape.getSdrModelFromSdrObject());
+ rtl::Reference<E3dScene> pScene = new E3dScene(rSdrObjCustomShape.getSdrModelFromSdrObject());
bool bSceneHasObjects ( false );
bool bUseTwoFillStyles( false );
@@ -398,8 +398,8 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
if (bNeedToConvertToContour && !bFuzzing)
{
- SdrObject* pNewObj = pNext->ConvertToContourObj(const_cast< SdrObject* >(pNext));
- SdrPathObj* pNewPathObj = dynamic_cast< SdrPathObj* >(pNewObj);
+ rtl::Reference<SdrObject> pNewObj = pNext->ConvertToContourObj(const_cast< SdrObject* >(pNext));
+ SdrPathObj* pNewPathObj = dynamic_cast< SdrPathObj* >(pNewObj.get());
if(pNewPathObj)
{
@@ -433,8 +433,6 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
aLocalSet.Put(XLineStyleItem(drawing::LineStyle_SOLID));
}
}
-
- SdrObject::Free(pNewObj);
}
else
{
@@ -443,7 +441,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
}
else
{
- SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false );
+ rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( false, false );
SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
if ( pPath )
aPolyPoly = pPath->GetPathPoly();
@@ -462,7 +460,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
aBoundRect2d.Union( aBoundRect );
// #i122777# depth 0 is okay for planes when using double-sided
- E3dCompoundObject* p3DObj = new E3dExtrudeObj(
+ rtl::Reference<E3dCompoundObject> p3DObj = new E3dExtrudeObj(
rSdrObjCustomShape.getSdrModelFromSdrObject(),
a3DDefaultAttr,
aPolyPoly,
@@ -472,7 +470,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
p3DObj->SetMergedItemSet( aLocalSet );
if ( bIsPlaceholderObject )
- aPlaceholderObjectList.push_back( p3DObj );
+ aPlaceholderObjectList.push_back( p3DObj.get() );
else if ( bUseTwoFillStyles )
{
BitmapEx aFillBmp;
@@ -516,7 +514,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
p3DObj->SetMergedItem(XFillBitmapItem(OUString(), Graphic(aFillBmp)));
}
}
- pScene->InsertObject( p3DObj );
+ pScene->InsertObject( p3DObj.get() );
p3DObj = new E3dExtrudeObj(
rSdrObjCustomShape.getSdrModelFromSdrObject(),
a3DDefaultAttr,
@@ -529,7 +527,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
p3DObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
p3DObj->SetMergedItem( Svx3DCloseFrontItem( false ) );
p3DObj->SetMergedItem( Svx3DCloseBackItem( false ) );
- pScene->InsertObject( p3DObj );
+ pScene->InsertObject( p3DObj.get() );
// #i122777# depth 0 is okay for planes when using double-sided
p3DObj = new E3dExtrudeObj(
@@ -558,7 +556,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
p3DObj->SetMergedItem( Svx3DCloseFrontItem( false ) );
p3DObj->SetMergedItem( Svx3DCloseBackItem( false ) );
}
- pScene->InsertObject( p3DObj );
+ pScene->InsertObject( p3DObj.get() );
bSceneHasObjects = true;
}
}
@@ -1021,17 +1019,8 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
for (E3dCompoundObject* pTemp : aPlaceholderObjectList)
{
pScene->RemoveObject( pTemp->GetOrdNum() );
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp2(pTemp);
- SdrObject::Free(pTemp2);
}
}
- else
- {
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pScene);
- SdrObject::Free(pTemp);
- }
}
return pRet;
}
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.hxx b/svx/source/customshapes/EnhancedCustomShape3d.hxx
index 77e7d350f470..db744f24c216 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.hxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_SVX_SOURCE_CUSTOMSHAPES_ENHANCEDCUSTOMSHAPE3D_HXX
#define INCLUDED_SVX_SOURCE_CUSTOMSHAPES_ENHANCEDCUSTOMSHAPE3D_HXX
+#include <rtl/ref.hxx>
+
class SdrObject;
class SdrObjCustomShape;
@@ -27,7 +29,7 @@ class EnhancedCustomShape3d final
{
public:
- static SdrObject* Create3DObject(
+ static rtl::Reference<SdrObject> Create3DObject(
const SdrObject* pShape2d,
const SdrObjCustomShape& rSdrObjCustomShape);
};
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index ae919904a818..c2efafc93665 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -64,9 +64,9 @@ class EnhancedCustomShapeEngine : public cppu::WeakImplHelper
css::uno::Reference< css::drawing::XShape > mxShape;
bool mbForceGroupWithText;
- std::unique_ptr<SdrObject, SdrObjectFreeOp> ImplForceGroupWithText(
+ rtl::Reference<SdrObject> ImplForceGroupWithText(
const SdrObjCustomShape& rSdrObjCustomShape,
- std::unique_ptr<SdrObject, SdrObjectFreeOp> pRenderedShape);
+ SdrObject* pRenderedShape);
public:
EnhancedCustomShapeEngine();
@@ -138,10 +138,11 @@ Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceName
}
// XCustomShapeEngine
-std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForceGroupWithText(
+rtl::Reference<SdrObject> EnhancedCustomShapeEngine::ImplForceGroupWithText(
const SdrObjCustomShape& rSdrObjCustomShape,
- std::unique_ptr<SdrObject, SdrObjectFreeOp> pRenderedShape)
+ SdrObject* pRenderedShape1)
{
+ rtl::Reference<SdrObject> pRenderedShape = pRenderedShape1;
const bool bHasText(rSdrObjCustomShape.HasText());
if ( pRenderedShape || bHasText )
@@ -156,17 +157,17 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr )
{
auto pTmp = std::move(pRenderedShape);
- pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()));
- static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() );
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
+ static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.get() );
}
static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject(
- pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()),
+ pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()).get(),
0);
}
else
{
- pRenderedShape.reset( pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject()) );
+ pRenderedShape = pShadowGeometry->CloneSdrObject(pShadowGeometry->getSdrModelFromSdrObject());
}
}
@@ -174,7 +175,7 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
if ( bHasText )
{
// #i37011# also create a text object and add at rPos + 1
- std::unique_ptr<SdrObject, SdrObjectFreeOp> pTextObj( SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pTextObj( SdrObjFactory::MakeNewObject(
rSdrObjCustomShape.getSdrModelFromSdrObject(),
rSdrObjCustomShape.GetObjInventor(),
SdrObjKind::Text) );
@@ -223,10 +224,10 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr )
{
auto pTmp = std::move(pRenderedShape);
- pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()));
- static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() );
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
+ static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.get() );
}
- static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTextObj.release() );
+ static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTextObj.get() );
}
else
pRenderedShape = std::move(pTextObj);
@@ -238,8 +239,8 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape.get() ) == nullptr )
{
auto pTmp = std::move(pRenderedShape);
- pRenderedShape.reset(new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject()));
- static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.release() );
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
+ static_cast<SdrObjGroup*>(pRenderedShape.get())->GetSubList()->NbcInsertObject( pTmp.get() );
}
}
}
@@ -247,16 +248,6 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
return pRenderedShape;
}
-void SetTemporary( uno::Reference< drawing::XShape > const & xShape )
-{
- if ( xShape.is() )
- {
- SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
- if ( pShape )
- pShape->TakeSdrObjectOwnership();
- }
-}
-
Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
{
SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape));
@@ -280,12 +271,12 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
bool bFlipH = aCustomShape2d.IsFlipHorz();
bool bLineGeometryNeededOnly = bTextPathOn;
- std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedShape(aCustomShape2d.CreateObject(bLineGeometryNeededOnly));
+ rtl::Reference<SdrObject> xRenderedShape(aCustomShape2d.CreateObject(bLineGeometryNeededOnly));
if (xRenderedShape)
{
if ( bTextPathOn )
{
- std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedFontWork(
+ rtl::Reference<SdrObject> xRenderedFontWork(
EnhancedCustomShapeFontWork::CreateFontWork(
xRenderedShape.get(),
*pSdrObjCustomShape));
@@ -295,7 +286,7 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
xRenderedShape = std::move(xRenderedFontWork);
}
}
- std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedShape3d(EnhancedCustomShape3d::Create3DObject(xRenderedShape.get(), *pSdrObjCustomShape));
+ rtl::Reference<SdrObject> xRenderedShape3d(EnhancedCustomShape3d::Create3DObject(xRenderedShape.get(), *pSdrObjCustomShape));
if (xRenderedShape3d)
{
bFlipV = bFlipH = false;
@@ -341,7 +332,7 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
{
xRenderedShape = ImplForceGroupWithText(
*pSdrObjCustomShape,
- std::move(xRenderedShape));
+ xRenderedShape.get());
}
Reference< drawing::XShape > xShape;
@@ -349,13 +340,10 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
if (xRenderedShape)
{
aCustomShape2d.ApplyGluePoints(xRenderedShape.get());
- SdrObject* pRenderedShape = xRenderedShape.release();
- xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
- pRenderedShape->GetObjInventor(), pRenderedShape );
+ xShape = SvxDrawPage::CreateShapeByTypeAndInventor( xRenderedShape->GetObjIdentifier(),
+ xRenderedShape->GetObjInventor(), xRenderedShape.get() );
}
- SetTemporary( xShape );
-
return xShape;
}
@@ -388,7 +376,7 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
if(pSdrObjCustomShape)
{
EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
- SdrObjectUniquePtr pObj = aCustomShape2d.CreateLineGeometry();
+ rtl::Reference<SdrObject> pObj = aCustomShape2d.CreateLineGeometry();
if ( pObj )
{
@@ -438,7 +426,7 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
}
else
{
- SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false );
+ rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( false, false );
SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
if ( pPath )
aPP = pPath->GetPathPoly();
@@ -447,7 +435,7 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
if ( aPP.count() )
aPolyPolygon.append(aPP);
}
- pObj.reset();
+ pObj.clear();
basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon,
aPolyPolygonBezierCoords );
}
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 9311763920bb..e13e680d7407 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -896,11 +896,11 @@ static void FitTextOutlinesToShapeOutlines( const tools::PolyPolygon& aOutlines2
}
}
-static SdrObject* CreateSdrObjectFromParagraphOutlines(
+static rtl::Reference<SdrObject> CreateSdrObjectFromParagraphOutlines(
const FWData& rFWData,
const SdrObjCustomShape& rSdrObjCustomShape)
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
basegfx::B2DPolyPolygon aPolyPoly;
if ( !rFWData.vTextAreas.empty() )
{
@@ -944,11 +944,11 @@ Reference < i18n::XBreakIterator > const & EnhancedCustomShapeFontWork::GetBreak
return mxBreakIterator;
}
-SdrObject* EnhancedCustomShapeFontWork::CreateFontWork(
+rtl::Reference<SdrObject> EnhancedCustomShapeFontWork::CreateFontWork(
const SdrObject* pShape2d,
const SdrObjCustomShape& rSdrObjCustomShape)
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
tools::PolyPolygon aOutlines2d( GetOutlinesFromShape2d( pShape2d ) );
sal_uInt16 nOutlinesCount2d = aOutlines2d.Count();
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
index 335701be4125..571aeb4014c0 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SVX_SOURCE_CUSTOMSHAPES_ENHANCEDCUSTOMSHAPEFONTWORK_HXX
#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <rtl/ref.hxx>
class SdrObject;
class SdrObjCustomShape;
@@ -32,7 +33,7 @@ class EnhancedCustomShapeFontWork
public:
static css::uno::Reference < css::i18n::XBreakIterator > const & GetBreakIterator();
- static SdrObject* CreateFontWork(
+ static rtl::Reference<SdrObject> CreateFontWork(
const SdrObject* pShape2d,
const SdrObjCustomShape& rSdrObjCustomShape);
};
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index a8b5916d8dde..91399497c48e 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -425,11 +425,11 @@ Graphic CompressGraphicsDialog::GetCompressedGraphic()
return Graphic();
}
-SdrGrafObj* CompressGraphicsDialog::GetCompressedSdrGrafObj()
+rtl::Reference<SdrGrafObj> CompressGraphicsDialog::GetCompressedSdrGrafObj()
{
if ( m_dResolution > 0.0 )
{
- SdrGrafObj* pNewObject(m_xGraphicObj->CloneSdrObject(m_xGraphicObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrGrafObj> pNewObject = SdrObject::Clone(*m_xGraphicObj, m_xGraphicObj->getSdrModelFromSdrObject());
if ( m_xReduceResolutionCB->get_active() )
{
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index 0249b5dd965a..ebf0c44c27f9 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -34,8 +34,7 @@
#include <memory>
SvxXConnectionPreview::SvxXConnectionPreview()
- : pEdgeObj(nullptr)
- , pView(nullptr)
+ : pView(nullptr)
{
SetMapMode(MapMode(MapUnit::Map100thMM));
}
@@ -154,7 +153,7 @@ void SvxXConnectionPreview::Construct()
}
const SdrEdgeObj* pTmpEdgeObj = static_cast<const SdrEdgeObj*>(pObj);
- pEdgeObj = pTmpEdgeObj->CloneSdrObject(mxSdrPage->getSdrModelFromSdrPage());
+ pEdgeObj = SdrObject::Clone(*pTmpEdgeObj, mxSdrPage->getSdrModelFromSdrPage());
SdrObjConnection& rConn1 = pEdgeObj->GetConnection( true );
SdrObjConnection& rConn2 = pEdgeObj->GetConnection( false );
@@ -167,19 +166,19 @@ void SvxXConnectionPreview::Construct()
if( pTmpObj1 )
{
- SdrObject* pObj1 = pTmpObj1->CloneSdrObject(mxSdrPage->getSdrModelFromSdrPage());
- mxSdrPage->InsertObject( pObj1 );
- pEdgeObj->ConnectToNode( true, pObj1 );
+ rtl::Reference<SdrObject> pObj1 = pTmpObj1->CloneSdrObject(mxSdrPage->getSdrModelFromSdrPage());
+ mxSdrPage->InsertObject( pObj1.get() );
+ pEdgeObj->ConnectToNode( true, pObj1.get() );
}
if( pTmpObj2 )
{
- SdrObject* pObj2 = pTmpObj2->CloneSdrObject(mxSdrPage->getSdrModelFromSdrPage());
- mxSdrPage->InsertObject( pObj2 );
- pEdgeObj->ConnectToNode( false, pObj2 );
+ rtl::Reference<SdrObject> pObj2 = pTmpObj2->CloneSdrObject(mxSdrPage->getSdrModelFromSdrPage());
+ mxSdrPage->InsertObject( pObj2.get() );
+ pEdgeObj->ConnectToNode( false, pObj2.get() );
}
- mxSdrPage->InsertObject( pEdgeObj );
+ mxSdrPage->InsertObject( pEdgeObj.get() );
}
}
}
diff --git a/svx/source/dialog/contwnd.cxx b/svx/source/dialog/contwnd.cxx
index 1c68b5324732..95a5cb650e35 100644
--- a/svx/source/dialog/contwnd.cxx
+++ b/svx/source/dialog/contwnd.cxx
@@ -59,7 +59,7 @@ void ContourWindow::SetPolyPolygon(const tools::PolyPolygon& rPolyPoly)
{
basegfx::B2DPolyPolygon aPolyPolygon;
aPolyPolygon.append(aPolyPoly[ i ].getB2DPolygon());
- SdrPathObj* pPathObj = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPathObj = new SdrPathObj(
*pModel,
SdrObjKind::PathFill,
std::move(aPolyPolygon));
@@ -72,7 +72,7 @@ void ContourWindow::SetPolyPolygon(const tools::PolyPolygon& rPolyPoly)
pPathObj->SetMergedItemSetAndBroadcast(aSet);
- pPage->InsertObject( pPathObj );
+ pPage->InsertObject( pPathObj.get() );
}
if (nPolyCount)
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 792485a06048..ffad222628eb 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -44,9 +44,7 @@
using namespace com::sun::star;
Svx3DPreviewControl::Svx3DPreviewControl()
- : mpScene(nullptr)
- , mp3DObj(nullptr)
- , mnObjectType(SvxPreviewObjectType::SPHERE)
+ : mnObjectType(SvxPreviewObjectType::SPHERE)
{
}
@@ -111,7 +109,7 @@ void Svx3DPreviewControl::Construct()
rCamera.SetFocalLength(fDefaultCamFocal);
mpScene->SetCamera( rCamera );
- mxFmPage->InsertObject( mpScene );
+ mxFmPage->InsertObject( mpScene.get() );
basegfx::B3DHomMatrix aRotation;
aRotation.rotate(basegfx::deg2rad( 25 ), 0.0, 0.0);
@@ -134,7 +132,7 @@ void Svx3DPreviewControl::Construct()
mp3DView->hideMarkHandles();
// mark scene
- mp3DView->MarkObj( mpScene, pPageView );
+ mp3DView->MarkObj( mpScene.get(), pPageView );
}
void Svx3DPreviewControl::Resize()
@@ -185,9 +183,7 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
{
aSet.Put(mp3DObj->GetMergedItemSet());
mpScene->RemoveObject( mp3DObj->GetOrdNum() );
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(mp3DObj);
- SdrObject::Free(pTemp);
+ mp3DObj.clear();
}
switch( nType )
@@ -215,7 +211,7 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
if (mp3DObj)
{
- mpScene->InsertObject( mp3DObj );
+ mpScene->InsertObject( mp3DObj.get() );
mp3DObj->SetMergedItemSet(aSet);
}
@@ -244,9 +240,6 @@ const sal_Int32 g_nInteractionStartDistance = 5 * 5 * 2;
Svx3DLightControl::Svx3DLightControl()
: maSelectedLight(NO_LIGHT_SELECTED),
- mpExpansionObject(nullptr),
- mpLampBottomObject(nullptr),
- mpLampShaftObject(nullptr),
maLightObjects(MAX_NUMBER_LIGHTS, nullptr),
mfRotateX(-20.0),
mfRotateY(45.0),
@@ -284,7 +277,7 @@ void Svx3DLightControl::Construct2()
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint(-fMaxExpansion, -fMaxExpansion, -fMaxExpansion),
basegfx::B3DVector(2.0 * fMaxExpansion, 2.0 * fMaxExpansion, 2.0 * fMaxExpansion));
- mpScene->InsertObject( mpExpansionObject );
+ mpScene->InsertObject( mpExpansionObject.get() );
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) );
aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
@@ -306,7 +299,7 @@ void Svx3DLightControl::Construct2()
mpLampBottomObject = new E3dPolygonObj(
*mpModel,
basegfx::B3DPolyPolygon(a3DCircle));
- mpScene->InsertObject( mpLampBottomObject );
+ mpScene->InsertObject( mpLampBottomObject.get() );
// half circle with stand
basegfx::B2DPolygon a2DHalfCircle;
@@ -320,7 +313,7 @@ void Svx3DLightControl::Construct2()
mpLampShaftObject = new E3dPolygonObj(
*mpModel,
basegfx::B3DPolyPolygon(a3DHalfCircle));
- mpScene->InsertObject( mpLampShaftObject );
+ mpScene->InsertObject( mpLampShaftObject.get() );
// initially invisible
SfxItemSet aSet(mpModel->GetItemPool());
@@ -366,9 +359,6 @@ void Svx3DLightControl::ConstructLightObjects()
if(maLightObjects[a])
{
mpScene->RemoveObject(maLightObjects[a]->GetOrdNum());
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(maLightObjects[a]);
- SdrObject::Free(pTemp);
maLightObjects[a] = nullptr;
}
@@ -380,12 +370,12 @@ void Svx3DLightControl::ConstructLightObjects()
aDirection *= RADIUS_LAMP_PREVIEW_SIZE;
const double fLampSize(bIsSelectedLight ? RADIUS_LAMP_BIG : RADIUS_LAMP_SMALL);
- E3dObject* pNewLight = new E3dSphereObj(
+ rtl::Reference<E3dObject> pNewLight = new E3dSphereObj(
*mpModel,
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( 0, 0, 0 ),
basegfx::B3DVector( fLampSize, fLampSize, fLampSize));
- mpScene->InsertObject(pNewLight);
+ mpScene->InsertObject(pNewLight.get());
basegfx::B3DHomMatrix aTransform;
aTransform.translate(aDirection.getX(), aDirection.getY(), aDirection.getZ());
@@ -397,7 +387,7 @@ void Svx3DLightControl::ConstructLightObjects()
aSet.Put( XFillColorItem(OUString(), GetLightColor(a)));
pNewLight->SetMergedItemSet(aSet);
- maLightObjects[a] = pNewLight;
+ maLightObjects[a] = pNewLight.get();
}
}
}
@@ -473,14 +463,14 @@ void Svx3DLightControl::TrySelection(Point aPosPixel)
for(auto const & b: aResult)
{
- if(b && b != mpExpansionObject)
+ if(b && b != mpExpansionObject.get())
{
pResult = b;
break;
}
}
- if(pResult == mp3DObj)
+ if(pResult == mp3DObj.get())
{
if(!mbGeometrySelected)
{
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 35737285a231..df3d7b1c8b71 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1119,10 +1119,7 @@ void SvxXLinePreview::Resize()
}
SvxXLinePreview::SvxXLinePreview()
- : mpLineObjA(nullptr)
- , mpLineObjB(nullptr)
- , mpLineObjC(nullptr)
- , mpGraphic(nullptr)
+ : mpGraphic(nullptr)
, mbWithSymbol(false)
{
}
@@ -1141,12 +1138,6 @@ void SvxXLinePreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
SvxXLinePreview::~SvxXLinePreview()
{
- SdrObject *pFoo = mpLineObjA;
- SdrObject::Free( pFoo );
- pFoo = mpLineObjB;
- SdrObject::Free( pFoo );
- pFoo = mpLineObjC;
- SdrObject::Free( pFoo );
}
void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
@@ -1184,9 +1175,9 @@ void SvxXLinePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rec
// paint objects to buffer device
sdr::contact::SdrObjectVector aObjectVector;
- aObjectVector.push_back(mpLineObjA);
- aObjectVector.push_back(mpLineObjB);
- aObjectVector.push_back(mpLineObjC);
+ aObjectVector.push_back(mpLineObjA.get());
+ aObjectVector.push_back(mpLineObjB.get());
+ aObjectVector.push_back(mpLineObjC.get());
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), std::move(aObjectVector), nullptr);
sdr::contact::DisplayInfo aDisplayInfo;
@@ -1207,8 +1198,6 @@ void SvxXLinePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rec
}
SvxXShadowPreview::SvxXShadowPreview()
- : mpRectangleObject(nullptr)
- , mpRectangleShadow(nullptr)
{
}
@@ -1237,8 +1226,6 @@ void SvxXShadowPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
SvxXShadowPreview::~SvxXShadowPreview()
{
- SdrObject::Free(mpRectangleObject);
- SdrObject::Free(mpRectangleShadow);
}
void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
@@ -1277,8 +1264,8 @@ void SvxXShadowPreview::Paint(vcl::RenderContext& rRenderContext, const tools::R
sdr::contact::SdrObjectVector aObjectVector;
- aObjectVector.push_back(mpRectangleShadow);
- aObjectVector.push_back(mpRectangleObject);
+ aObjectVector.push_back(mpRectangleShadow.get());
+ aObjectVector.push_back(mpRectangleObject.get());
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), std::move(aObjectVector), nullptr);
sdr::contact::DisplayInfo aDisplayInfo;
@@ -1381,7 +1368,6 @@ void SvxPreviewBase::StyleUpdated()
}
SvxXRectPreview::SvxXRectPreview()
- : mpRectangleObject(nullptr)
{
}
@@ -1402,19 +1388,18 @@ void SvxXRectPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
void SvxXRectPreview::Resize()
{
- SdrObject *pOrigObject = mpRectangleObject;
+ rtl::Reference<SdrObject> pOrigObject = mpRectangleObject;
if (pOrigObject)
{
mpRectangleObject = new SdrRectObj(getModel(), GetPreviewSize());
SetAttributes(pOrigObject->GetMergedItemSet());
- SdrObject::Free(pOrigObject);
+ pOrigObject.clear();
}
SvxPreviewBase::Resize();
}
SvxXRectPreview::~SvxXRectPreview()
{
- SdrObject::Free(mpRectangleObject);
}
void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
@@ -1431,7 +1416,7 @@ void SvxXRectPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rec
sdr::contact::SdrObjectVector aObjectVector;
- aObjectVector.push_back(mpRectangleObject);
+ aObjectVector.push_back(mpRectangleObject.get());
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), std::move(aObjectVector), nullptr);
sdr::contact::DisplayInfo aDisplayInfo;
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 0e7b85131593..97fd5d3be3a8 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -109,11 +109,11 @@ void IMapWindow::ReplaceImageMap( const ImageMap& rImageMap )
for ( sal_uInt16 i(nCount); i > 0; i-- )
{
- SdrObject* pNewObj = CreateObj( rImageMap.GetIMapObject( i - 1 ) );
+ rtl::Reference<SdrObject> pNewObj = CreateObj( rImageMap.GetIMapObject( i - 1 ) );
if (pNewObj && pPage)
{
- pPage->InsertObject( pNewObj );
+ pPage->InsertObject( pNewObj.get() );
}
}
}
@@ -170,10 +170,10 @@ void IMapWindow::SetTargetList( const TargetList& rTargetList )
pModel->SetChanged( false );
}
-SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
+rtl::Reference<SdrObject> IMapWindow::CreateObj( const IMapObject* pIMapObj )
{
tools::Rectangle aClipRect( Point(), GetGraphicSize() );
- SdrObject* pSdrObj = nullptr;
+ rtl::Reference<SdrObject> pSdrObj;
IMapObjectPtr pCloneIMapObj;
switch( pIMapObj->GetType() )
@@ -310,12 +310,10 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj )
case SdrObjKind::CircleOrEllipse:
{
SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) );
- SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ).release() );
+ rtl::Reference<SdrPathObj> pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ).get() );
tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pPathObj);
- SdrObject::Free(pTemp);
+ pPathObj.clear();
auto pObj = std::make_shared<IMapPolygonObject>( aPoly, "", "", "", "", "", true, false );
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
@@ -380,16 +378,13 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj )
case SdrObjKind::CircleOrEllipse:
{
const SdrCircObj& rCircObj = static_cast<const SdrCircObj&>(rObj);
- SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ).release() );
+ rtl::Reference<SdrPathObj> pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ).get() );
tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
auto pObj = std::make_shared<IMapPolygonObject>( aPoly, aURL, aAltText, aDesc, aTarget, "", bActive, false );
pObj->SetExtraEllipse( aPoly.GetBoundRect() );
- // was only created by us temporarily
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pPathObj);
- SdrObject::Free(pTemp);
+ pPathObj.clear();
pUserData->ReplaceObject( pObj );
}
diff --git a/svx/source/dialog/imapwnd.hxx b/svx/source/dialog/imapwnd.hxx
index d92c5f6754e3..7c41f290039c 100644
--- a/svx/source/dialog/imapwnd.hxx
+++ b/svx/source/dialog/imapwnd.hxx
@@ -105,7 +105,7 @@ class IMapWindow final : public GraphCtrl
void ReplaceImageMap( const ImageMap& rNewImageMap );
- SdrObject* CreateObj( const IMapObject* pIMapObj );
+ rtl::Reference<SdrObject> CreateObj( const IMapObject* pIMapObj );
static IMapObject* GetIMapObj( const SdrObject* pSdrObj );
SdrObject* GetHitSdrObj( const Point& rPosPixel ) const;
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index ac1303db20ee..9539d2f68c46 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -42,7 +42,7 @@ void SvxXMeasurePreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
pModel.reset(new SdrModel(nullptr, nullptr, true));
- pMeasureObj.reset(new SdrMeasureObj(*pModel, Point(), Point()));
+ pMeasureObj = new SdrMeasureObj(*pModel, Point(), Point());
ResizeImpl(aSize);
Invalidate();
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
index 020d4c85eefc..94e482659b97 100644
--- a/svx/source/engine3d/cube3d.cxx
+++ b/svx/source/engine3d/cube3d.cxx
@@ -90,12 +90,12 @@ SdrObjKind E3dCubeObj::GetObjIdentifier() const
// Convert the object into a group object consisting of 6 polygons
-SdrObjectUniquePtr E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+rtl::Reference<SdrObject> E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
{
return nullptr;
}
-E3dCubeObj* E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dCubeObj(rTargetModel, *this);
}
diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx
index fadb645d3292..c268bec20baa 100644
--- a/svx/source/engine3d/extrud3d.cxx
+++ b/svx/source/engine3d/extrud3d.cxx
@@ -112,7 +112,7 @@ SdrObjKind E3dExtrudeObj::GetObjIdentifier() const
return SdrObjKind::E3D_Extrusion;
}
-E3dExtrudeObj* E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dExtrudeObj(rTargetModel, *this);
}
@@ -154,7 +154,7 @@ bool E3dExtrudeObj::IsBreakObjPossible()
return true;
}
-std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dExtrudeObj::GetBreakObj()
+rtl::Reference<SdrAttrObj> E3dExtrudeObj::GetBreakObj()
{
basegfx::B3DPolyPolygon aFrontSide;
basegfx::B3DPolyPolygon aBackSide;
@@ -205,13 +205,13 @@ std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dExtrudeObj::GetBreakObj()
{
// create PathObj
basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
- std::unique_ptr<SdrPathObj,SdrObjectFreeOp> pPathObj(new SdrPathObj(getSdrModelFromSdrObject(), SdrObjKind::PolyLine, std::move(aPoly)));
+ rtl::Reference<SdrPathObj> pPathObj(new SdrPathObj(getSdrModelFromSdrObject(), SdrObjKind::PolyLine, std::move(aPoly)));
SfxItemSet aSet(GetObjectItemSet());
aSet.Put(XLineStyleItem(css::drawing::LineStyle_SOLID));
pPathObj->SetMergedItemSet(aSet);
- return std::unique_ptr<SdrAttrObj,SdrObjectFreeOp>(pPathObj.release());
+ return pPathObj;
}
return nullptr;
diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx
index 0c0b8eeb8d85..65d6e4d13a8d 100644
--- a/svx/source/engine3d/float3d.cxx
+++ b/svx/source/engine3d/float3d.cxx
@@ -33,6 +33,7 @@
#include <svx/xlineit0.hxx>
#include <svx/fmmodel.hxx>
#include <svx/dlgutil.hxx>
+#include <svx/obj3d.hxx>
#include <svx/sdshitm.hxx>
#include <svx/svx3ditems.hxx>
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
index 9e01fa4235a5..e8664cb949ad 100644
--- a/svx/source/engine3d/lathe3d.cxx
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -117,14 +117,14 @@ SdrObjKind E3dLatheObj::GetObjIdentifier() const
return SdrObjKind::E3D_Lathe;
}
-E3dLatheObj* E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dLatheObj(rTargetModel, *this);
}
// Convert the object to group object consisting of n polygons
-SdrObjectUniquePtr E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+rtl::Reference<SdrObject> E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
{
return nullptr;
}
@@ -181,12 +181,12 @@ bool E3dLatheObj::IsBreakObjPossible()
return true;
}
-std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dLatheObj::GetBreakObj()
+rtl::Reference<SdrAttrObj> E3dLatheObj::GetBreakObj()
{
// create PathObj
basegfx::B3DPolyPolygon aLathePoly3D(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D));
basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
- std::unique_ptr<SdrPathObj,SdrObjectFreeOp> pPathObj(new SdrPathObj(getSdrModelFromSdrObject(), SdrObjKind::PolyLine, std::move(aTransPoly)));
+ rtl::Reference<SdrPathObj> pPathObj(new SdrPathObj(getSdrModelFromSdrObject(), SdrObjKind::PolyLine, std::move(aTransPoly)));
// Set Attribute
SfxItemSet aSet(GetObjectItemSet());
@@ -196,7 +196,7 @@ std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dLatheObj::GetBreakObj()
pPathObj->SetMergedItemSet(aSet);
- return std::unique_ptr<SdrAttrObj,SdrObjectFreeOp>(pPathObj.release());
+ return pPathObj;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
index 613e3e93fa83..64e0d8444f9d 100644
--- a/svx/source/engine3d/obj3d.cxx
+++ b/svx/source/engine3d/obj3d.cxx
@@ -95,7 +95,7 @@ bool E3dObject::IsBreakObjPossible()
return false;
}
-std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dObject::GetBreakObj()
+rtl::Reference<SdrAttrObj> E3dObject::GetBreakObj()
{
return nullptr;
}
@@ -397,7 +397,7 @@ OUString E3dObject::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralObj3d);
}
-E3dObject* E3dObject::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dObject::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dObject(rTargetModel, *this);
}
@@ -593,7 +593,7 @@ void E3dCompoundObject::RecalcSnapRect()
sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY())));
}
-E3dCompoundObject* E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dCompoundObject(rTargetModel, *this);
}
diff --git a/svx/source/engine3d/objfac3d.cxx b/svx/source/engine3d/objfac3d.cxx
index 4153ffab55fd..aa5a25496864 100644
--- a/svx/source/engine3d/objfac3d.cxx
+++ b/svx/source/engine3d/objfac3d.cxx
@@ -40,7 +40,7 @@ E3dObjFactory::E3dObjFactory()
// Generate chart internal objects
-IMPL_STATIC_LINK( E3dObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
+IMPL_STATIC_LINK( E3dObjFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> )
{
if ( aParams.nInventor == SdrInventor::E3d )
{
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
index e7a5623bf01d..3303cfe77d60 100644
--- a/svx/source/engine3d/polygn3d.cxx
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -217,12 +217,13 @@ void E3dPolygonObj::SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyText
// Convert the object into a group object consisting of 6 polygons
-SdrObjectUniquePtr E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+rtl::Reference<SdrObject> E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/,
+ bool /*bAddText*/) const
{
return nullptr;
}
-E3dPolygonObj* E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dPolygonObj(rTargetModel, *this);
}
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index dcad0e7603e6..cea87b316552 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -434,13 +434,12 @@ void E3dScene::removeAllNonSelectedObjects()
{
NbcRemoveObject(pObj->GetOrdNum());
a--;
- SdrObject::Free(pObj);
}
}
}
}
-E3dScene* E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dScene::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dScene(rTargetModel, *this);
}
@@ -777,10 +776,10 @@ void E3dScene::InsertObject(SdrObject* pObj, size_t nPos)
}
}
-SdrObject* E3dScene::NbcRemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> E3dScene::NbcRemoveObject(size_t nObjNum)
{
// call parent
- SdrObject* pRetval = SdrObjList::NbcRemoveObject(nObjNum);
+ rtl::Reference<SdrObject> pRetval = SdrObjList::NbcRemoveObject(nObjNum);
InvalidateBoundVolume();
StructureChanged();
@@ -788,10 +787,10 @@ SdrObject* E3dScene::NbcRemoveObject(size_t nObjNum)
return pRetval;
}
-SdrObject* E3dScene::RemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> E3dScene::RemoveObject(size_t nObjNum)
{
// call parent
- SdrObject* pRetval(SdrObjList::RemoveObject(nObjNum));
+ rtl::Reference<SdrObject> pRetval(SdrObjList::RemoveObject(nObjNum));
InvalidateBoundVolume();
StructureChanged();
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
index cac250907902..4b1121453921 100644
--- a/svx/source/engine3d/sphere3d.cxx
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -94,12 +94,12 @@ SdrObjKind E3dSphereObj::GetObjIdentifier() const
// Convert the object into a group object consisting of n polygons
-SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+rtl::Reference<SdrObject> E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
{
return nullptr;
}
-E3dSphereObj* E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new E3dSphereObj(rTargetModel, *this);
}
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index deebb7c27d46..7b9e81bf06e5 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -492,7 +492,7 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce
if(pCompoundObj)
{
- E3dCompoundObject* pNewCompoundObj(pCompoundObj->CloneSdrObject(pDstScene->getSdrModelFromSdrObject()));
+ rtl::Reference<E3dCompoundObject> pNewCompoundObj = SdrObject::Clone(*pCompoundObj, pDstScene->getSdrModelFromSdrObject());
if(pNewCompoundObj)
{
@@ -568,7 +568,7 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce
// fill and insert new object
pNewCompoundObj->NbcSetLayer(pCompoundObj->GetLayer());
pNewCompoundObj->NbcSetStyleSheet(pCompoundObj->GetStyleSheet(), true);
- pDstScene->InsertObject(pNewCompoundObj);
+ pDstScene->InsertObject(pNewCompoundObj.get());
bRetval = true;
// Create undo
@@ -728,7 +728,7 @@ void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, boo
}
// Create a new extrude object
- E3dObject* p3DObj = nullptr;
+ rtl::Reference<E3dObject> p3DObj;
if(bExtrude)
{
p3DObj = new E3dExtrudeObj(pObj->getSdrModelFromSdrObject(), aDefault, pPath->GetPathPoly(), fDepth);
@@ -753,7 +753,7 @@ void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, boo
p3DObj->NbcSetStyleSheet(pObj->GetStyleSheet(), true);
// Insert a new extrude object
- pScene->InsertObject(p3DObj);
+ pScene->InsertObject(p3DObj.get());
}
void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude, double fDepth, basegfx::B2DHomMatrix const & rLatheMat)
@@ -775,7 +775,7 @@ void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude
ImpChangeSomeAttributesFor3DConversion(pObj);
// convert completely to path objects
- SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false).release();
+ rtl::Reference<SdrObject> pNewObj1 = pObj->ConvertToPolyObj(false, false);
if(!pNewObj1)
return;
@@ -791,10 +791,10 @@ void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude
}
}
else
- ImpChangeSomeAttributesFor3DConversion2(pNewObj1);
+ ImpChangeSomeAttributesFor3DConversion2(pNewObj1.get());
// convert completely to path objects
- SdrObject* pNewObj2 = pObj->ConvertToContourObj(pNewObj1, true);
+ rtl::Reference<SdrObject> pNewObj2 = pObj->ConvertToContourObj(pNewObj1.get(), true);
if(pNewObj2)
{
@@ -809,16 +809,8 @@ void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude
}
}
else
- ImpCreateSingle3DObjectFlat(pScene, pNewObj2, bExtrude, fDepth, rLatheMat);
-
- // delete object in between
- if (pNewObj2 != pObj && pNewObj2 != pNewObj1)
- SdrObject::Free( pNewObj2 );
+ ImpCreateSingle3DObjectFlat(pScene, pNewObj2.get(), bExtrude, fDepth, rLatheMat);
}
-
- // delete object in between
- if (pNewObj1 != pObj)
- SdrObject::Free( pNewObj1 );
}
void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1, const basegfx::B2DPoint& rPnt2)
@@ -835,7 +827,7 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
SdrModel& rSdrModel(GetSdrMarkByIndex(0)->GetMarkedSdrObj()->getSdrModelFromSdrObject());
// Create a new scene for the created 3D object
- E3dScene* pScene = new E3dScene(rSdrModel);
+ rtl::Reference<E3dScene> pScene = new E3dScene(rSdrModel);
// Determine rectangle and possibly correct it
tools::Rectangle aRect = GetAllMarkedRect();
@@ -935,14 +927,14 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
SdrMark* pMark = GetSdrMarkByIndex(a);
SdrObject* pObj = pMark->GetMarkedSdrObj();
- ImpCreate3DObject(pScene, pObj, bExtrude, fDepth, aLatheMat);
+ ImpCreate3DObject(pScene.get(), pObj, bExtrude, fDepth, aLatheMat);
}
if(pScene->GetSubList() && pScene->GetSubList()->GetObjCount() != 0)
{
// Arrange all created objects by depth
if(bExtrude)
- DoDepthArrange(pScene, fDepth);
+ DoDepthArrange(pScene.get(), fDepth);
// Center 3D objects in the middle of the overall rectangle
basegfx::B3DPoint aCenter(pScene->GetBoundVolume().getCenter());
@@ -954,16 +946,16 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
// Initialize scene
pScene->NbcSetSnapRect(aRect);
basegfx::B3DRange aBoundVol = pScene->GetBoundVolume();
- InitScene(pScene, static_cast<double>(aRect.GetWidth()), static_cast<double>(aRect.GetHeight()), aBoundVol.getDepth());
+ InitScene(pScene.get(), static_cast<double>(aRect.GetWidth()), static_cast<double>(aRect.GetHeight()), aBoundVol.getDepth());
// Insert scene instead of the first selected object and throw away
// all the old objects
SdrObject* pRepObj = GetMarkedObjectByIndex(0);
SdrPageView* pPV = GetSdrPageViewOfMarkedByIndex(0);
MarkObj(pRepObj, pPV, true);
- ReplaceObjectAtView(pRepObj, *pPV, pScene, false);
+ ReplaceObjectAtView(pRepObj, *pPV, pScene.get(), false);
DeleteMarked();
- MarkObj(pScene, pPV);
+ MarkObj(pScene.get(), pPV);
// Rotate Rotation body around the axis of rotation
if(!bExtrude && fRot3D != 0.0)
@@ -984,12 +976,7 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
}
}
else
- {
- // No 3D object was created, throw away everything
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pScene);
- SdrObject::Free(pTemp);
- }
+ pScene.clear();
EndUndo();
}
@@ -1262,7 +1249,7 @@ bool E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut,
}
// Set current 3D drawing object, create the scene for this
-E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj)
+rtl::Reference<E3dScene> E3dView::SetCurrent3DObj(E3dObject* p3DObj)
{
DBG_ASSERT(p3DObj != nullptr, "Who puts in a NULL-pointer here");
@@ -1274,9 +1261,9 @@ E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj)
tools::Rectangle aRect(0,0, static_cast<tools::Long>(fW), static_cast<tools::Long>(fH));
- E3dScene* pScene = new E3dScene(p3DObj->getSdrModelFromSdrObject());
+ rtl::Reference<E3dScene> pScene = new E3dScene(p3DObj->getSdrModelFromSdrObject());
- InitScene(pScene, fW, fH, aVolume.getMaxZ() + ((fW + fH) / 4.0));
+ InitScene(pScene.get(), fW, fH, aVolume.getMaxZ() + ((fW + fH) / 4.0));
pScene->InsertObject(p3DObj);
pScene->NbcSetSnapRect(aRect);
@@ -1546,10 +1533,10 @@ void E3dView::BreakSingle3DObj(E3dObject* pObj)
}
else
{
- SdrAttrObj* pNewObj = pObj->GetBreakObj().release();
+ rtl::Reference<SdrAttrObj> pNewObj = pObj->GetBreakObj();
if (pNewObj)
{
- if (InsertObjectAtView(pNewObj, *GetSdrPageView(), SdrInsertFlags::DONTMARK))
+ if (InsertObjectAtView(pNewObj.get(), *GetSdrPageView(), SdrInsertFlags::DONTMARK))
{
pNewObj->SetChanged();
pNewObj->BroadcastObjectChange();
diff --git a/svx/source/engine3d/view3d1.cxx b/svx/source/engine3d/view3d1.cxx
index 22ec229bfd09..46830afda95a 100644
--- a/svx/source/engine3d/view3d1.cxx
+++ b/svx/source/engine3d/view3d1.cxx
@@ -34,7 +34,7 @@
void E3dView::ConvertMarkedToPolyObj()
{
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
if (GetMarkedObjectCount() == 1)
{
@@ -45,11 +45,11 @@ void E3dView::ConvertMarkedToPolyObj()
auto pScene = dynamic_cast< const E3dScene* >(pObj);
if (pScene)
{
- pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release();
+ pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/);
if (pNewObj)
{
BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
- ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
+ ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj.get());
EndUndo();
}
}
diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx
index e475cf8f8462..415e016eeedf 100644
--- a/svx/source/form/fmdmod.cxx
+++ b/svx/source/form/fmdmod.cxx
@@ -43,8 +43,8 @@ using namespace ::svxform;
else if ( rServiceSpecifier == "com.sun.star.drawing.ControlShape" )
{
SdrModel& rTargetModel(getSdrModelFromUnoModel());
- SdrObject* pObj = new FmFormObj(rTargetModel);
- xRet = static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper*>(new SvxShapeControl(pObj)));
+ rtl::Reference<SdrObject> pObj = new FmFormObj(rTargetModel);
+ xRet = static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper*>(new SvxShapeControl(pObj.get())));
}
if (!xRet.is())
diff --git a/svx/source/form/fmdpage.cxx b/svx/source/form/fmdpage.cxx
index 2351564e06bc..3846d65cda8f 100644
--- a/svx/source/form/fmdpage.cxx
+++ b/svx/source/form/fmdpage.cxx
@@ -59,7 +59,7 @@ css::uno::Sequence< css::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( )
css::uno::Sequence { cppu::UnoType<css::form::XFormsSupplier>::get() });
}
-SdrObject *SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xDescr )
+rtl::Reference<SdrObject> SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xDescr )
{
OUString aShapeType( xDescr->getShapeType() );
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 8328191816b9..59d8dae0eb92 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -361,7 +361,7 @@ SdrObjKind FmFormObj::GetObjIdentifier() const
return SdrObjKind::UNO;
}
-FmFormObj* FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new FmFormObj(rTargetModel, *this);
}
diff --git a/svx/source/form/fmobjfac.cxx b/svx/source/form/fmobjfac.cxx
index bbb1a5cc63d0..459350663aee 100644
--- a/svx/source/form/fmobjfac.cxx
+++ b/svx/source/form/fmobjfac.cxx
@@ -100,9 +100,9 @@ namespace
}
}
-IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject*)
+IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject>)
{
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
if (aParams.nInventor == SdrInventor::FmForm)
{
@@ -218,7 +218,7 @@ IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, Sdr
for (const auto& rInitProp : aInitialProperties)
{
lcl_initProperty(
- static_cast< FmFormObj* >( pNewObj ),
+ static_cast< FmFormObj* >( pNewObj.get() ),
rInitProp.first,
rInitProp.second
);
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index c4f0bcad55f5..b9d18e0a0c9c 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -161,11 +161,11 @@ bool FmFormPage::RequestHelp( vcl::Window* pWindow, SdrView const * pView,
}
-SdrObject* FmFormPage::RemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> FmFormPage::RemoveObject(size_t nObjNum)
{
- SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
+ rtl::Reference<SdrObject> pObj = SdrPage::RemoveObject(nObjNum);
if (pObj)
- static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Removed(pObj);
+ static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Removed(pObj.get());
return pObj;
}
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index 141bdc097c3b..40c86b72369b 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -371,19 +371,19 @@ void FmFormView::DeactivateControls(SdrPageView const * pPageView)
}
-SdrObjectUniquePtr FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
+rtl::Reference<SdrObject> FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
{
return pImpl->implCreateFieldControl( _rColumnDescriptor );
}
-SdrObjectUniquePtr FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
+rtl::Reference<SdrObject> FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
{
return pImpl->implCreateXFormsControl(_rDesc);
}
-SdrObjectUniquePtr FmFormView::CreateFieldControl(std::u16string_view rFieldDesc) const
+rtl::Reference<SdrObject> FmFormView::CreateFieldControl(std::u16string_view rFieldDesc) const
{
sal_Int32 nIdx{ 0 };
OUString sDataSource( o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx));
@@ -579,8 +579,8 @@ void FmFormView::createControlLabelPair( OutputDevice const * _pOutDev, sal_Int3
const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
SdrObjKind _nControlObjectID, SdrInventor _nInventor, SdrObjKind _nLabelObjectID,
SdrModel& _rModel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl )
+ rtl::Reference<SdrUnoObj>& _rpLabel,
+ rtl::Reference<SdrUnoObj>& _rpControl )
{
FmXFormView::createControlLabelPair(
*_pOutDev, _nXOffsetMM, _nYOffsetMM,
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index a35883d429d6..242f51dcca34 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1112,7 +1112,7 @@ namespace
}
-SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor )
+rtl::Reference<SdrObject> FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor )
{
// not if we're in design mode
if ( !m_pView->IsDesignMode() )
@@ -1299,8 +1299,8 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe
if (nOBJID == SdrObjKind::NONE)
return nullptr;
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
+ rtl::Reference<SdrUnoObj> pLabel;
+ rtl::Reference<SdrUnoObj> pControl;
if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
)
@@ -1313,12 +1313,12 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe
bool bCheckbox = ( SdrObjKind::FormCheckbox == nOBJID );
OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
if ( bCheckbox )
- return SdrObjectUniquePtr(pControl.release());
+ return pControl;
- SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
+ rtl::Reference<SdrObjGroup> pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
- pObjList->InsertObject( pLabel.release() );
- pObjList->InsertObject( pControl.release() );
+ pObjList->InsertObject( pLabel.get() );
+ pObjList->InsertObject( pControl.get() );
if ( bDateNTimeField )
{ // so far we created a date field only, but we also need a time field
@@ -1327,12 +1327,12 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe
xDataSource, sDataSource, sCommand, nCommandType )
)
{
- pObjList->InsertObject( pLabel.release() );
- pObjList->InsertObject( pControl.release() );
+ pObjList->InsertObject( pLabel.get() );
+ pObjList->InsertObject( pControl.get() );
}
}
- return SdrObjectUniquePtr(pGroup); // and done
+ return pGroup; // and done
}
catch (const Exception&)
{
@@ -1344,7 +1344,7 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe
}
-SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc )
+rtl::Reference<SdrObject> FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc )
{
// not if we're in design mode
if ( !m_pView->IsDesignMode() )
@@ -1400,8 +1400,8 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr
// xform control or submission button?
if ( !xSubmission.is() )
{
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
+ rtl::Reference<SdrUnoObj> pLabel;
+ rtl::Reference<SdrUnoObj> pControl;
if ( !createControlLabelPair( *pOutDev, 0, 0, nullptr, xNumberFormats, nOBJID, sLabelPostfix,
pLabel, pControl, nullptr, "", "", -1 )
)
@@ -1421,16 +1421,16 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr
bool bCheckbox = ( SdrObjKind::FormCheckbox == nOBJID );
OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
if ( bCheckbox )
- return SdrObjectUniquePtr(pControl.release());
+ return pControl;
// group objects
- SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
+ rtl::Reference<SdrObjGroup> pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
- pObjList->InsertObject(pLabel.release());
- pObjList->InsertObject(pControl.release());
+ pObjList->InsertObject(pLabel.get());
+ pObjList->InsertObject(pControl.get());
- return SdrObjectUniquePtr(pGroup);
+ return pGroup;
}
else {
@@ -1439,11 +1439,11 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr
const MapMode eSourceMode(MapUnit::Map100thMM);
const SdrObjKind nObjID = SdrObjKind::FormButton;
::Size controlSize(4000, 500);
- FmFormObj *pControl = static_cast<FmFormObj*>(
+ rtl::Reference<FmFormObj> pControl = static_cast<FmFormObj*>(
SdrObjFactory::MakeNewObject(
getView()->getSdrModelFromSdrView(),
SdrInventor::FmForm,
- nObjID));
+ nObjID).get());
controlSize.setWidth( tools::Long(controlSize.Width() * eTargetMode.GetScaleX()) );
controlSize.setHeight( tools::Long(controlSize.Height() * eTargetMode.GetScaleY()) );
::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
@@ -1460,7 +1460,7 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr
Reference< css::form::submission::XSubmissionSupplier > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
xSubmissionSupplier->setSubmission(xSubmission);
- return SdrObjectUniquePtr(pControl);
+ return rtl::Reference<SdrObject>(pControl);
}
}
catch (const Exception&)
@@ -1475,8 +1475,8 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr
bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
SdrObjKind _nControlObjectID, std::u16string_view _rFieldPostfix,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
+ rtl::Reference<SdrUnoObj>& _rpLabel,
+ rtl::Reference<SdrUnoObj>& _rpControl,
const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
const OUString& _rCommand, const sal_Int32 _nCommandType )
{
@@ -1522,7 +1522,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
const Reference< XNumberFormats >& _rxNumberFormats, SdrObjKind _nControlObjectID,
std::u16string_view _rFieldPostfix, SdrInventor _nInventor, SdrObjKind _nLabelObjectID,
SdrModel& _rModel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl)
+ rtl::Reference<SdrUnoObj>& _rpLabel, rtl::Reference<SdrUnoObj>& _rpControl)
{
sal_Int32 nDataType = 0;
OUString sFieldName;
@@ -1558,16 +1558,16 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
bool bNeedLabel = ( _nControlObjectID != SdrObjKind::FormCheckbox );
// the label
- ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pLabel;
+ rtl::Reference< SdrUnoObj > pLabel;
Reference< XPropertySet > xLabelModel;
if ( bNeedLabel )
{
- pLabel.reset( dynamic_cast< SdrUnoObj* >(
+ pLabel = dynamic_cast< SdrUnoObj* >(
SdrObjFactory::MakeNewObject(
_rModel,
_nInventor,
- _nLabelObjectID)));
+ _nLabelObjectID).get() );
OSL_ENSURE(pLabel, "FmXFormView::createControlLabelPair: could not create the label!");
@@ -1595,11 +1595,11 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
}
// the control
- ::std::unique_ptr< SdrUnoObj, SdrObjectFreeOp > pControl( dynamic_cast< SdrUnoObj* >(
+ rtl::Reference< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
SdrObjFactory::MakeNewObject(
_rModel,
_nInventor,
- _nControlObjectID)));
+ _nControlObjectID).get() ));
OSL_ENSURE(pControl, "FmXFormView::createControlLabelPair: could not create the control!");
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 4a9d10e609ff..be3430acbf15 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -611,10 +611,10 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans
if( aModel.GetModel() )
{
SdrPage* pPage = aModel.GetModel()->GetPage(0);
- SdrGrafObj* pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic );
+ rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic );
pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) );
- pPage->InsertObject( pGrafObj );
+ pPage->InsertObject( pGrafObj.get() );
bRet = InsertModel( *aModel.GetModel(), nInsertPos );
}
}
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
index d604cfd207ac..d19399a737ee 100644
--- a/svx/source/inc/fmobj.hxx
+++ b/svx/source/inc/fmobj.hxx
@@ -79,7 +79,7 @@ public:
SAL_DLLPRIVATE virtual SdrObjKind GetObjIdentifier() const override;
SAL_DLLPRIVATE virtual void NbcReformatText() override;
- SAL_DLLPRIVATE virtual FmFormObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
SAL_DLLPRIVATE static css::uno::Reference< css::uno::XInterface> ensureModelEnv(
const css::uno::Reference< css::uno::XInterface>& _rSourceContainer,
diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx
index 35255769fbc8..16c156d9a672 100644
--- a/svx/source/inc/fmvwimp.hxx
+++ b/svx/source/inc/fmvwimp.hxx
@@ -239,8 +239,8 @@ private:
void Activate(bool bSync = false);
void Deactivate(bool bDeactivateController = true);
- SdrObjectUniquePtr implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
- SdrObjectUniquePtr implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
+ rtl::Reference<SdrObject> implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
+ rtl::Reference<SdrObject> implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
static bool createControlLabelPair(
OutputDevice const & _rOutDev,
@@ -257,8 +257,8 @@ private:
// demand clear, hand over a SdrMldel&
SdrModel& _rModel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl
+ rtl::Reference<SdrUnoObj>& _rpLabel,
+ rtl::Reference<SdrUnoObj>& _rpControl
);
bool createControlLabelPair(
@@ -269,8 +269,8 @@ private:
const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
SdrObjKind _nControlObjectID,
std::u16string_view _rFieldPostfix,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
- std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
+ rtl::Reference<SdrUnoObj>& _rpLabel,
+ rtl::Reference<SdrUnoObj>& _rpControl,
const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource,
const OUString& _rDataSourceName,
const OUString& _rCommand,
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index f8736a7bc891..a644bee45d10 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -46,7 +46,7 @@ class SvdProgressInfo;
// Helper Class to import PDF
class ImpSdrPdfImport final
{
- std::vector<SdrObject*> maTmpList;
+ std::vector<rtl::Reference<SdrObject>> maTmpList;
ScopedVclPtr<VirtualDevice> mpVD;
tools::Rectangle maScaleRect;
size_t mnMapScalingOfs; // from here on, not edited with MapScaling
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index f8cca833880a..5c458be3b2ec 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -241,7 +241,7 @@ namespace sdr::contact
// needed and can be deleted.
// create temp RectObj as TextObj and set needed attributes
- SdrRectObj* pRectObj(new SdrRectObj(GetGrafObject().getSdrModelFromSdrObject(), SdrObjKind::Text));
+ rtl::Reference<SdrRectObj> pRectObj(new SdrRectObj(GetGrafObject().getSdrModelFromSdrObject(), SdrObjKind::Text));
pRectObj->NbcSetText(aDraftText);
pRectObj->SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
@@ -272,10 +272,6 @@ namespace sdr::contact
const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
xBlockTextPrimitive->get2DDecomposition(xRetval, aViewInformation2D);
}
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pRectObj);
- SdrObject::Free(pTemp);
}
return xRetval;
diff --git a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
index fe7e53481039..d5ead8c71cd4 100644
--- a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
@@ -34,7 +34,7 @@ namespace drawinglayer::primitive2d
{
void SdrOleContentPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
{
- const SdrOle2Obj* pSource = mpSdrOle2Obj.get();
+ rtl::Reference<SdrOle2Obj> pSource = mpSdrOle2Obj.get();
bool bScaleContent(false);
Graphic aGraphic;
@@ -145,9 +145,11 @@ namespace drawinglayer::primitive2d
if( BufferedDecompositionPrimitive2D::operator==(rPrimitive) )
{
const SdrOleContentPrimitive2D& rCompare = static_cast<const SdrOleContentPrimitive2D&>(rPrimitive);
- const bool bBothNot(!mpSdrOle2Obj.is() && !rCompare.mpSdrOle2Obj.is());
- const bool bBothAndEqual(mpSdrOle2Obj.is() && rCompare.mpSdrOle2Obj.is()
- && mpSdrOle2Obj.get() == rCompare.mpSdrOle2Obj.get());
+ auto xSdrThis = mpSdrOle2Obj.get();
+ auto xSdrThat = rCompare.mpSdrOle2Obj.get();
+ const bool bBothNot(!xSdrThis && !xSdrThat);
+ const bool bBothAndEqual(xSdrThis && xSdrThat
+ && xSdrThis.get() == xSdrThat.get());
return ((bBothNot || bBothAndEqual)
&& getObjectTransform() == rCompare.getObjectTransform()
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx
index 5f6f51312f4e..43112953fad7 100644
--- a/svx/source/svdraw/selectioncontroller.cxx
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -19,6 +19,7 @@
#include <svx/selectioncontroller.hxx>
+#include <svx/svdobj.hxx>
namespace sdr
{
@@ -84,7 +85,7 @@ bool SelectionController::SetStyleSheet( SfxStyleSheet* /*pStyleSheet*/, bool /*
return false;
}
-SdrObject* SelectionController::GetMarkedSdrObjClone( SdrModel& /*rTargetModel*/ )
+rtl::Reference<SdrObject> SelectionController::GetMarkedSdrObjClone( SdrModel& /*rTargetModel*/ )
{
return nullptr;
}
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index e2a7f2e028e5..a73c5fe531af 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -180,7 +180,6 @@ void SdrCreateView::ImpClearConnectMarker()
SdrCreateView::SdrCreateView(SdrModel& rSdrModel, OutputDevice* pOut)
: SdrDragView(rSdrModel, pOut)
- , mpCurrentCreate(nullptr)
, mpCreatePV(nullptr)
, mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
, maCurrentCreatePointer(PointerStyle::Cross)
@@ -197,7 +196,6 @@ SdrCreateView::~SdrCreateView()
{
ImpClearConnectMarker();
mpCreateViewExtraData.reset();
- SdrObject::Free(mpCurrentCreate);
}
bool SdrCreateView::IsAction() const
@@ -339,14 +337,14 @@ void SdrCreateView::SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent)
{
mnCurrentInvent=nInvent;
mnCurrentIdent=nIdent;
- SdrObject * pObj = (nIdent == SdrObjKind::NONE) ? nullptr :
- SdrObjFactory::MakeNewObject(
- *GetModel(),
- nInvent,
- nIdent);
- if(pObj)
+ if(nIdent != SdrObjKind::NONE)
{
+ rtl::Reference<SdrObject> pObj =
+ SdrObjFactory::MakeNewObject(
+ *GetModel(),
+ nInvent,
+ nIdent);
// Using text tool, mouse cursor is usually I-Beam,
// crosshairs with tiny I-Beam appears only on MouseButtonDown.
if(IsTextTool())
@@ -357,8 +355,6 @@ void SdrCreateView::SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent)
}
else
maCurrentCreatePointer = pObj->GetCreatePointer();
-
- SdrObject::Free( pObj );
}
else
{
@@ -425,7 +421,7 @@ bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, SdrObjKind nIdent, cons
mpCurrentCreate->SetMergedItemSet(maDefaultAttr);
}
- if (mpModel && dynamic_cast<const SdrCaptionObj *>(mpCurrentCreate) != nullptr)
+ if (mpModel && dynamic_cast<const SdrCaptionObj *>(mpCurrentCreate.get()) != nullptr)
{
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
@@ -485,7 +481,6 @@ bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, SdrObjKind nIdent, cons
}
else
{
- SdrObject::Free(mpCurrentCreate);
mpCurrentCreate = nullptr;
mpCreatePV = nullptr;
}
@@ -592,7 +587,7 @@ void SdrCreateView::SetupObjLayer(const SdrPageView* pPageView, const OUString&
bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
{
bool bRet=false;
- SdrObject* pObjCreated=mpCurrentCreate;
+ SdrObject* pObjCreated=mpCurrentCreate.get();
if (mpCurrentCreate!=nullptr)
{
@@ -616,10 +611,9 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
if (!bPntsEq)
{
// otherwise Brk, because all points are equal
- SdrObject* pObj=mpCurrentCreate;
- mpCurrentCreate=nullptr;
+ rtl::Reference<SdrObject> pObj = std::move(mpCurrentCreate);
- SetupObjLayer(mpCreatePV, maActualLayer, pObj);
+ SetupObjLayer(mpCreatePV, maActualLayer, pObj.get());
// recognize creation of a new 3D object inside a 3D scene
bool bSceneIntoScene(false);
@@ -633,8 +627,6 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
if(bDidInsert)
{
- // delete object, its content is cloned and inserted
- SdrObject::Free( pObjCreated );
pObjCreated = nullptr;
bSceneIntoScene = true;
}
@@ -658,7 +650,7 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
// created objects, see InsertObjectAtView below that calls
// CreateUndoNewObject.
basegfx::B2DVector aGridOffset(0.0, 0.0);
- if(getPossibleGridOffsetForSdrObject(aGridOffset, pObj, mpCreatePV))
+ if(getPossibleGridOffsetForSdrObject(aGridOffset, pObj.get(), mpCreatePV))
{
const Size aOffset(
basegfx::fround(-aGridOffset.getX()),
@@ -668,7 +660,7 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
}
// do the same as before
- InsertObjectAtView(pObj, *mpCreatePV);
+ InsertObjectAtView(pObj.get(), *mpCreatePV);
}
mpCreatePV = nullptr;
@@ -729,7 +721,6 @@ void SdrCreateView::BrkCreateObj()
{
HideCreateObj();
mpCurrentCreate->BrkCreate(maDragStat);
- SdrObject::Free( mpCurrentCreate );
mpCurrentCreate = nullptr;
mpCreatePV = nullptr;
}
@@ -771,7 +762,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
// check for form controls
if(bUseSolidDragging)
{
- if (dynamic_cast<const SdrUnoObj*>(mpCurrentCreate) != nullptr)
+ if (dynamic_cast<const SdrUnoObj*>(mpCurrentCreate.get()) != nullptr)
{
bUseSolidDragging = false;
}
@@ -780,7 +771,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
// #i101781# force to non-solid dragging when not creating a full circle
if(bUseSolidDragging)
{
- SdrCircObj* pCircObj = dynamic_cast<SdrCircObj*>(mpCurrentCreate);
+ SdrCircObj* pCircObj = dynamic_cast<SdrCircObj*>(mpCurrentCreate.get());
if(pCircObj && SdrObjKind::CircleOrEllipse != pCircObj->GetObjIdentifier())
{
@@ -796,7 +787,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
{
basegfx::B2DPolyPolygon aDragPolyPolygon;
- if (dynamic_cast<const SdrRectObj*>(mpCurrentCreate) != nullptr)
+ if (dynamic_cast<const SdrRectObj*>(mpCurrentCreate.get()) != nullptr)
{
// ensure object has some size, necessary for SdrTextObj because
// there are still untested divisions by that sizes
@@ -809,7 +800,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
}
}
- if (auto pPathObj = dynamic_cast<SdrPathObj*>(mpCurrentCreate))
+ if (auto pPathObj = dynamic_cast<SdrPathObj*>(mpCurrentCreate.get()))
{
// The up-to-now created path needs to be set at the object to have something
// that can be visualized
@@ -824,7 +815,7 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
}
// use the SdrObject directly for overlay
- mpCreateViewExtraData->CreateAndShowOverlay(*this, mpCurrentCreate, aDragPolyPolygon);
+ mpCreateViewExtraData->CreateAndShowOverlay(*this, mpCurrentCreate.get(), aDragPolyPolygon);
}
else
{
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 2789f629398a..4a332e8271c7 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -152,7 +152,7 @@ void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod)
// out when clone and original have the same class, so that i can use operator=
// in those cases
- mxClone.reset();
+ mxClone.clear();
if(mbModify)
{
@@ -1312,7 +1312,7 @@ void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt)
clearSdrDragEntries();
// delete current clone (after the last reference to it is deleted above)
- mxClone.reset();
+ mxClone.clear();
// create a new clone and modify to current drag state
mxClone = pObj->getFullDragClone();
@@ -3586,7 +3586,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
// there are currently no easy mechanisms to plug an alternative interaction
// from there
SdrObject* pSdrObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
- SdrObjectUniquePtr pFullDragClone;
+ rtl::Reference<SdrObject> pFullDragClone;
bool bExternal(false);
SdrObject* pExternalSdrObject(nullptr);
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index fbde60ff197f..8dbdaa85b885 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -192,9 +192,6 @@ void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pOL->RemoveObject(nObjNum);
-
- if( !bUndo )
- SdrObject::Free( pObj );
}
else
{
@@ -208,8 +205,6 @@ void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pOL->RemoveObject(nObjNum);
- if( !bUndo )
- SdrObject::Free( pObj );
}
}
}
@@ -261,8 +256,6 @@ void SdrEditView::DeleteLayer(const OUString& rName)
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pPage->RemoveObject(nObjNum);
- if( !bUndo )
- SdrObject::Free(pObj);
}
else
{
@@ -276,8 +269,6 @@ void SdrEditView::DeleteLayer(const OUString& rName)
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pPage->RemoveObject(nObjNum);
- if( !bUndo )
- SdrObject::Free(pObj);
}
}
}
@@ -793,14 +784,11 @@ std::vector<SdrObject*> SdrEditView::DeleteMarkedList(SdrMarkList const& rMark)
return ret;
}
-static void lcl_LazyDelete(std::vector<SdrObject*> & rLazyDelete)
+static void lcl_LazyDelete(std::vector<rtl::Reference<SdrObject>> & rLazyDelete)
{
// now delete removed scene objects
while (!rLazyDelete.empty())
- {
- SdrObject::Free( rLazyDelete.back() );
rLazyDelete.pop_back();
- }
}
void SdrEditView::DeleteMarkedObj()
@@ -815,7 +803,7 @@ void SdrEditView::DeleteMarkedObj()
BrkAction();
BegUndo(SvxResId(STR_EditDelete),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::Delete);
- std::vector<SdrObject*> lazyDeleteObjects;
+ std::vector<rtl::Reference<SdrObject>> lazyDeleteObjects;
// remove as long as something is selected. This allows to schedule objects for
// removal for a next run as needed
while(GetMarkedObjectCount())
@@ -942,16 +930,16 @@ void SdrEditView::CopyMarkedObj()
for (size_t nm=0; nm<nMarkCount; ++nm) {
SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
SdrObject* pSource(pM->GetMarkedSdrObj());
- SdrObject* pO(pSource->CloneSdrObject(pSource->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pO(pSource->CloneSdrObject(pSource->getSdrModelFromSdrObject()));
if (pO!=nullptr) {
- pM->GetPageView()->GetObjList()->InsertObjectThenMakeNameUnique(pO, aNameSet);
+ pM->GetPageView()->GetObjList()->InsertObjectThenMakeNameUnique(pO.get(), aNameSet);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO));
SdrMark aME(*pM);
- aME.SetMarkedSdrObj(pO);
- aCloneList.AddPair(pM->GetMarkedSdrObj(), pO);
+ aME.SetMarkedSdrObj(pO.get());
+ aCloneList.AddPair(pM->GetMarkedSdrObj(), pO.get());
if (pM->GetUser()==0)
{
@@ -996,7 +984,6 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
SdrLayerID nLayer=rPV.GetPage()->GetLayerAdmin().GetLayerID(maActualLayer);
if (nLayer==SDRLAYER_NOTFOUND) nLayer=SdrLayerID(0);
if (rPV.GetLockedLayers().IsSet(nLayer) || !rPV.GetVisibleLayers().IsSet(nLayer)) {
- SdrObject::Free( pObj ); // Layer locked or invisible
return false;
}
pObj->NbcSetLayer(nLayer);
@@ -1065,9 +1052,6 @@ void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrO
pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum());
- if( !bUndo )
- SdrObject::Free( pOldObj );
-
if (bMark) MarkObj(pNewObj,&rPV);
}
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index dd00da880e48..0626b0fbd867 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -630,7 +630,7 @@ basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj)
}
else
{
- SdrObjectUniquePtr pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false);
+ rtl::Reference<SdrObject> pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false);
if(pConvObj)
{
@@ -1120,9 +1120,9 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// #i73441# check insert list before taking actions
if(pInsOL)
{
- SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), SdrObjKind::PathFill, std::move(aMergePolyPolygonA));
- ImpCopyAttributes(pAttrObj, pPath);
- pInsOL->InsertObject(pPath, nInsPos);
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), SdrObjKind::PathFill, std::move(aMergePolyPolygonA));
+ ImpCopyAttributes(pAttrObj, pPath.get());
+ pInsOL->InsertObject(pPath.get(), nInsPos);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
@@ -1131,7 +1131,7 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// TTTT:Not needed for aw080 (!)
UnmarkAllObj(pInsPV);
- MarkObj(pPath, pInsPV, false, true);
+ MarkObj(pPath.get(), pInsPV, false, true);
}
aRemove.ForceSort();
@@ -1268,12 +1268,12 @@ void SdrEditView::CombineMarkedTextObjects()
if ( GetMarkedObjectCount() > 1 )
{
- SdrRectObj* pReplacement = new SdrRectObj( getSdrModelFromSdrView(), SdrObjKind::Text );
+ rtl::Reference<SdrRectObj> pReplacement = new SdrRectObj( getSdrModelFromSdrView(), SdrObjKind::Text );
pReplacement->SetOutlinerParaObject( rDrawOutliner.CreateParaObject() );
pReplacement->SetSnapRect( GetMarkedObjRect() );
const SdrInsertFlags nFlags = SdrInsertFlags::DONTMARK | SdrInsertFlags::SETDEFLAYER;
- if ( InsertObjectAtView( pReplacement, *pPageView, nFlags ) )
+ if ( InsertObjectAtView( pReplacement.get(), *pPageView, nFlags ) )
DeleteMarkedObj();
}
@@ -1413,10 +1413,10 @@ void SdrEditView::CombineMarkedObjects(bool bNoPolyPoly)
}
}
- SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), eKind, std::move(aPolyPolygon));
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), eKind, std::move(aPolyPolygon));
// attributes of the lowest object
- ImpCopyAttributes(pAttrObj, pPath);
+ ImpCopyAttributes(pAttrObj, pPath.get());
// If LineStyle of pAttrObj is drawing::LineStyle_NONE force to drawing::LineStyle_SOLID to make visible.
const drawing::LineStyle eLineStyle = pAttrObj->GetMergedItem(XATTR_LINESTYLE).GetValue();
@@ -1433,7 +1433,7 @@ void SdrEditView::CombineMarkedObjects(bool bNoPolyPoly)
pPath->SetMergedItem(XLineStyleItem(drawing::LineStyle_SOLID));
}
- pInsOL->InsertObject(pPath,nInsPos);
+ pInsOL->InsertObject(pPath.get(),nInsPos);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
@@ -1442,7 +1442,7 @@ void SdrEditView::CombineMarkedObjects(bool bNoPolyPoly)
// in the UNDO there is no problem, but as soon as they get deleted, the
// MarkList will contain deleted objects -> GPF.
UnmarkAllObj(pInsPV);
- MarkObj(pPath, pInsPV, false, true);
+ MarkObj(pPath.get(), pInsPV, false, true);
}
// build an UndoComment from the objects actually used
@@ -1583,16 +1583,16 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(!bMakeLines || nPointCount < 2)
{
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
pSrcPath->getSdrModelFromSdrObject(),
pSrcPath->GetObjIdentifier(),
basegfx::B2DPolyPolygon(rCandidate));
- ImpCopyAttributes(pSrcPath, pPath);
- pLast = pPath;
- rOL.InsertObject(pPath, rPos);
+ ImpCopyAttributes(pSrcPath, pPath.get());
+ pLast = pPath.get();
+ rOL.InsertObject(pPath.get(), rPos);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, true));
- MarkObj(pPath, pPV, false, true);
+ MarkObj(pPath.get(), pPV, false, true);
rPos++;
}
else
@@ -1620,16 +1620,16 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
aNewPolygon.append(rCandidate.getB2DPoint(nNextIndex));
}
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
pSrcPath->getSdrModelFromSdrObject(),
eKind,
basegfx::B2DPolyPolygon(aNewPolygon));
- ImpCopyAttributes(pSrcPath, pPath);
- pLast = pPath;
- rOL.InsertObject(pPath, rPos);
+ ImpCopyAttributes(pSrcPath, pPath.get());
+ pLast = pPath.get();
+ rOL.InsertObject(pPath.get(), rPos);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, true));
- MarkObj(pPath, pPV, false, true);
+ MarkObj(pPath.get(), pPV, false, true);
rPos++;
}
}
@@ -1649,7 +1649,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(pReplacement)
{
- SdrObject* pCandidate(pReplacement->CloneSdrObject(pReplacement->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pCandidate(pReplacement->CloneSdrObject(pReplacement->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue())
@@ -1660,15 +1660,15 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
}
}
- rOL.InsertObject(pCandidate, rPos);
+ rOL.InsertObject(pCandidate.get(), rPos);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pCandidate, true));
- MarkObj(pCandidate, pPV, false, true);
+ MarkObj(pCandidate.get(), pPV, false, true);
if(pCustomShape->HasText() && !pCustomShape->IsTextPath())
{
// #i37011# also create a text object and add at rPos + 1
- SdrObject* pTextObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pTextObj = SdrObjFactory::MakeNewObject(
pCustomShape->getSdrModelFromSdrObject(),
pCustomShape->GetObjInventor(),
SdrObjKind::Text);
@@ -1707,10 +1707,10 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
pTextObj->SetMergedItemSet(aTargetItemSet);
// insert object
- rOL.InsertObject(pTextObj, rPos + 1);
+ rOL.InsertObject(pTextObj.get(), rPos + 1);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pTextObj, true));
- MarkObj(pTextObj, pPV, false, true);
+ MarkObj(pTextObj.get(), pPV, false, true);
}
}
}
@@ -1757,9 +1757,6 @@ void SdrEditView::DismantleMarkedObjects(bool bMakeLines)
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj,true));
pOL->RemoveObject(nPos0);
-
- if( !bUndo )
- SdrObject::Free(pObj);
}
}
@@ -1810,7 +1807,7 @@ void SdrEditView::GroupMarked()
// make sure OrdNums are correct
if (pSrcLst->IsObjOrdNumsDirty())
pSrcLst->RecalcObjOrdNums();
- SdrObject* pGrp=nullptr;
+ rtl::Reference<SdrObject> pGrp;
SdrObjList* pDstLst=nullptr;
// if all selected objects come from foreign object lists.
// the group object is the last one in the list.
@@ -1823,7 +1820,7 @@ void SdrEditView::GroupMarked()
if (pM->GetPageView()==pPV)
{
SdrObject* pObj=pM->GetMarkedSdrObj();
- if (nullptr==pGrp)
+ if (!pGrp)
{
pGrp = new SdrObjGroup(pObj->getSdrModelFromSdrObject());
pDstLst=pGrp->GetSubList();
@@ -1852,9 +1849,9 @@ void SdrEditView::GroupMarked()
}
if (pGrp!=nullptr)
{
- aNewMark.InsertEntry(SdrMark(pGrp,pPV));
+ aNewMark.InsertEntry(SdrMark(pGrp.get(),pPV));
const size_t nCount=pDstLst->GetObjCount();
- pCurrentLst->InsertObject(pGrp,nInsPos);
+ pCurrentLst->InsertObject(pGrp.get(),nInsPos);
if( bUndo )
{
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // no recalculation!
@@ -1944,10 +1941,7 @@ void SdrEditView::UnGroupMarked()
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
- pObj = pSrcLst->RemoveObject(0);
-
- if( !bUndo )
- SdrObject::Free(pObj);
+ pSrcLst->RemoveObject(0);
nObjCount = pSrcLst->GetObjCount();
}
@@ -1969,14 +1963,14 @@ void SdrEditView::UnGroupMarked()
for (size_t no=0; no<nObjCount; ++no)
{
- SdrObject* pObj=pSrcLst->RemoveObject(0);
- pDstLst->InsertObject(pObj,nDstCnt);
+ rtl::Reference<SdrObject> pObj=pSrcLst->RemoveObject(0);
+ pDstLst->InsertObject(pObj.get(),nDstCnt);
if( bUndo )
AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pObj,true));
nDstCnt++;
// No SortCheck when inserting into MarkList, because that would
// provoke a RecalcOrdNums() each time because of pObj->GetOrdNum():
- aNewMark.InsertEntry(SdrMark(pObj,pM->GetPageView()),false);
+ aNewMark.InsertEntry(SdrMark(pObj.get(),pM->GetPageView()),false);
}
if( bUndo )
@@ -1989,9 +1983,6 @@ void SdrEditView::UnGroupMarked()
}
pDstLst->RemoveObject(nDstCnt);
- if( !bUndo )
- SdrObject::Free(pGrp);
-
GetMarkedObjectListWriteAccess().DeleteMark(nm);
}
}
@@ -2016,9 +2007,9 @@ void SdrEditView::UnGroupMarked()
// ConvertToPoly
-SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea)
+rtl::Reference<SdrObject> SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea)
{
- SdrObjectUniquePtr pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
+ rtl::Reference<SdrObject> pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
if (pNewObj)
{
SdrObjList* pOL = pObj->getParentSdrObjListFromSdrObject();
@@ -2026,13 +2017,9 @@ SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLine
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj));
- // ownership passed into here (despite the UniquePtr indicating that we are returning it)
pOL->ReplaceObject(pNewObj.get(), pObj->GetOrdNum());
-
- if( !bUndo )
- SdrObject::Free(pObj);
}
- return pNewObj.release();
+ return pNewObj;
}
void SdrEditView::ImpConvertTo(bool bPath, bool bLineToArea)
@@ -2076,10 +2063,10 @@ void SdrEditView::ImpConvertTo(bool bPath, bool bLineToArea)
ImpConvertOneObj(pObj,bPath,bLineToArea);
}
} else {
- SdrObject* pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea);
- if (pNewObj!=nullptr) {
+ rtl::Reference<SdrObject> pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea);
+ if (pNewObj) {
bMrkChg=true;
- GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj,pPV),nm);
+ GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj.get(),pPV),nm);
}
}
}
@@ -2223,9 +2210,6 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
// remove object from selection and delete
GetMarkedObjectListWriteAccess().DeleteMark(TryToFindMarkedObject(pObj));
pOL->RemoveObject(nInsPos-1);
-
- if (!bUndo)
- SdrObject::Free(pObj);
}
}
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 011590218dc1..7915e4db5cb9 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -243,13 +243,13 @@ void SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
void SdrObjEditView::ModelHasChanged()
{
SdrGlueEditView::ModelHasChanged();
- if (mxWeakTextEditObj.is() && !mxWeakTextEditObj->IsInserted())
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
+ if (pTextObj && !pTextObj->IsInserted())
SdrEndTextEdit(); // object deleted
// TextEditObj changed?
if (!IsTextEdit())
return;
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
if (pTextObj != nullptr)
{
size_t nOutlViewCnt = mpTextEditOutliner->GetViewCount();
@@ -271,7 +271,7 @@ void SdrObjEditView::ModelHasChanged()
// add possible GridOffset to up-to-now view-independent EditAreas
basegfx::B2DVector aGridOffset(0.0, 0.0);
- if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj, GetSdrPageView()))
+ if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj.get(), GetSdrPageView()))
{
const Point aOffset(basegfx::fround(aGridOffset.getX()),
basegfx::fround(aGridOffset.getY()));
@@ -856,7 +856,7 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, OutlinerVie
{
// background
Color aBackground(GetTextEditBackgroundColor(*this));
- SdrTextObj* pText = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pText = mxWeakTextEditObj.get();
bool bTextFrame = pText != nullptr && pText->IsTextFrame();
bool bContourFrame = pText != nullptr && pText->IsContourTextFrame();
// create OutlinerView
@@ -914,7 +914,7 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerStatusEventHdl, EditStatus&, rEditStat, voi
{
if (mpTextEditOutliner)
{
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
if (pTextObj)
{
pTextObj->onEditOutlinerStatusEvent(&rEditStat);
@@ -927,7 +927,7 @@ void SdrObjEditView::ImpChainingEventHdl()
if (!mpTextEditOutliner)
return;
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
OutlinerView* pOLV = GetTextEditOutlinerView();
if (pTextObj && pOLV)
{
@@ -939,16 +939,16 @@ void SdrObjEditView::ImpChainingEventHdl()
return;
}
// This is true during an underflow-caused overflow (with pEdtOutl->SetText())
- if (pTextChain->GetNilChainingEvent(pTextObj))
+ if (pTextChain->GetNilChainingEvent(pTextObj.get()))
{
return;
}
// We prevent to trigger further handling of overflow/underflow for pTextObj
- pTextChain->SetNilChainingEvent(pTextObj, true); // XXX
+ pTextChain->SetNilChainingEvent(pTextObj.get(), true); // XXX
// Save previous selection pos // NOTE: It must be done to have the right CursorEvent in KeyInput
- pTextChain->SetPreChainingSel(pTextObj, pOLV->GetSelection());
+ pTextChain->SetPreChainingSel(pTextObj.get(), pOLV->GetSelection());
//maPreChainingSel = new ESelection(pOLV->GetSelection());
// Handling Undo
@@ -982,7 +982,7 @@ void SdrObjEditView::ImpChainingEventHdl()
//SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
// NOTE: Must be called. Don't let the function return if you set it to true and not reset it
- pTextChain->SetNilChainingEvent(pTextObj, false);
+ pTextChain->SetNilChainingEvent(pTextObj.get(), false);
}
else
{
@@ -1003,22 +1003,23 @@ IMPL_LINK_NOARG(SdrObjEditView, ImpAfterCutOrPasteChainingEventHdl, LinkParamNon
void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager* pCursorManager)
{
- if (!mxWeakTextEditObj.is() || !pCursorManager)
- return;
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
+ if (!pTextObj || !pCursorManager)
+ return;
// Check if it has links to move it to
if (!pTextObj || !pTextObj->IsChainable())
return;
TextChain* pTextChain = pTextObj->GetTextChain();
- ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj);
+ ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj.get());
- pCursorManager->HandleCursorEventAfterChaining(pTextChain->GetCursorEvent(pTextObj), aNewSel);
+ pCursorManager->HandleCursorEventAfterChaining(pTextChain->GetCursorEvent(pTextObj.get()),
+ aNewSel);
// Reset event
- pTextChain->SetCursorEvent(pTextObj, CursorChainingEvent::NULL_EVENT);
+ pTextChain->SetCursorEvent(pTextObj.get(), CursorChainingEvent::NULL_EVENT);
}
IMPL_LINK(SdrObjEditView, ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, pFI, void)
@@ -1026,7 +1027,7 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, pFI, voi
bool bOk = false;
OUString& rStr = pFI->GetRepresentation();
rStr.clear();
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
if (pTextObj != nullptr)
{
std::optional<Color> pTxtCol;
@@ -1049,7 +1050,7 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, pFI, voi
}
}
}
- Outliner& rDrawOutl = mpModel->GetDrawOutliner(pTextObj);
+ Outliner& rDrawOutl = mpModel->GetDrawOutliner(pTextObj.get());
Link<EditFieldInfo*, void> aDrawOutlLink = rDrawOutl.GetCalcFieldValueHdl();
if (!bOk && aDrawOutlLink.IsSet())
{
@@ -1146,15 +1147,15 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
{
mpTextEditWin = pWin;
mpTextEditPV = pPV;
- mxWeakTextEditObj.reset(pObj);
+ mxWeakTextEditObj = pObj;
if (pGivenOutliner)
{
mpTextEditOutliner.reset(pGivenOutliner);
pGivenOutliner = nullptr; // so we don't delete it on the error path
}
else
- mpTextEditOutliner = SdrMakeOutliner(OutlinerMode::TextObject,
- mxWeakTextEditObj->getSdrModelFromSdrObject());
+ mpTextEditOutliner
+ = SdrMakeOutliner(OutlinerMode::TextObject, pObj->getSdrModelFromSdrObject());
{
SvtAccessibilityOptions aOptions;
@@ -1171,15 +1172,11 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
// It is just necessary to make the visualized page known. Set it.
mpTextEditOutliner->setVisualizedPage(pPV->GetPage());
- mpTextEditOutliner->SetTextObjNoInit(mxWeakTextEditObj.get());
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
+ mpTextEditOutliner->SetTextObjNoInit(pTextObj.get());
- if (mxWeakTextEditObj->BegTextEdit(*mpTextEditOutliner))
+ if (pTextObj->BegTextEdit(*mpTextEditOutliner))
{
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
- DBG_ASSERT(pTextObj, "svx::SdrObjEditView::BegTextEdit(), no text object?");
- if (!pTextObj)
- return false;
-
// switch off any running TextAnimations
pTextObj->SetTextAnimationAllowed(false);
@@ -1210,7 +1207,7 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
// add possible GridOffset to up-to-now view-independent EditAreas
basegfx::B2DVector aGridOffset(0.0, 0.0);
- if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj, pPV))
+ if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj.get(), pPV))
{
const Point aOffset(basegfx::fround(aGridOffset.getX()),
basegfx::fround(aGridOffset.getY()));
@@ -1412,7 +1409,7 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
mpTextEditOutliner.reset();
mpTextEditOutlinerView = nullptr;
- mxWeakTextEditObj.reset(nullptr);
+ mxWeakTextEditObj.clear();
mpTextEditPV = nullptr;
mpTextEditWin = nullptr;
maHdlList.SetMoveOutside(false);
@@ -1423,7 +1420,7 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
{
SdrEndTextEditKind eRet = SdrEndTextEditKind::Unchanged;
- SdrTextObj* pTEObj = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pTEObj = mxWeakTextEditObj.get();
vcl::Window* pTEWin = mpTextEditWin;
OutlinerView* pTEOutlinerView = mpTextEditOutlinerView;
vcl::Cursor* pTECursorBuffer = pTextEditCursorBuffer;
@@ -1485,11 +1482,12 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
assert(nullptr == mpOldTextEditUndoManager); // cannot be restored!
}
- if (GetModel() && mxWeakTextEditObj.is())
- {
- SdrHint aHint(SdrHintKind::EndEdit, *mxWeakTextEditObj);
- GetModel()->Broadcast(aHint);
- }
+ if (GetModel())
+ if (auto pTextEditObj = mxWeakTextEditObj.get())
+ {
+ SdrHint aHint(SdrHintKind::EndEdit, *pTextEditObj);
+ GetModel()->Broadcast(aHint);
+ }
// if new mechanism was used, clean it up. At cleanup no need to check
// for LibreOfficeKit
@@ -1499,7 +1497,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
maTEOverlayGroup.clear();
}
- mxWeakTextEditObj.reset(nullptr);
+ mxWeakTextEditObj.clear();
mpTextEditPV = nullptr;
mpTextEditWin = nullptr;
SdrOutliner* pTEOutliner = mpTextEditOutliner.release();
@@ -1688,7 +1686,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
}
// info about TextEdit. Default is false.
-bool SdrObjEditView::IsTextEdit() const { return mxWeakTextEditObj.is(); }
+bool SdrObjEditView::IsTextEdit() const { return mxWeakTextEditObj.get().is(); }
// info about TextEditPageView. Default is 0L.
SdrPageView* SdrObjEditView::GetTextEditPageView() const { return mpTextEditPV; }
@@ -1712,7 +1710,7 @@ OutlinerView* SdrObjEditView::ImpFindOutlinerView(vcl::Window const* pWin) const
void SdrObjEditView::SetTextEditWin(vcl::Window* pWin)
{
- if (!(mxWeakTextEditObj.is() && pWin != nullptr && pWin != mpTextEditWin))
+ if (!(mxWeakTextEditObj.get() && pWin != nullptr && pWin != mpTextEditWin))
return;
OutlinerView* pNewView = ImpFindOutlinerView(pWin);
@@ -1733,7 +1731,7 @@ void SdrObjEditView::SetTextEditWin(vcl::Window* pWin)
bool SdrObjEditView::IsTextEditHit(const Point& rHit) const
{
bool bOk = false;
- if (mxWeakTextEditObj.is())
+ if (mxWeakTextEditObj.get())
{
tools::Rectangle aEditArea;
if (OutlinerView* pOLV = mpTextEditOutliner->GetView(0))
@@ -1756,9 +1754,8 @@ bool SdrObjEditView::IsTextEditHit(const Point& rHit) const
bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
{
bool bOk = false;
- if (mxWeakTextEditObj.is())
+ if (rtl::Reference<SdrTextObj> pText = mxWeakTextEditObj.get())
{
- SdrTextObj* pText = mxWeakTextEditObj.get();
OutlinerView* pOLV = mpTextEditOutliner->GetView(0);
if (pOLV)
{
@@ -1788,7 +1785,7 @@ SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool*
{
*bOutHandled = false;
- SdrTextObj* pTextObj = mxWeakTextEditObj.get();
+ rtl::Reference<SdrTextObj> pTextObj = mxWeakTextEditObj.get();
if (!pTextObj)
return nullptr;
@@ -1796,7 +1793,7 @@ SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, bool*
return nullptr;
std::unique_ptr<TextChainCursorManager> pCursorManager(
- new TextChainCursorManager(this, pTextObj));
+ new TextChainCursorManager(this, pTextObj.get()));
if (pCursorManager->HandleKeyEvent(rKEvt))
{
// Possibly do other stuff here if necessary...
@@ -2080,9 +2077,9 @@ SvtScriptType SdrObjEditView::GetScriptType() const
if (IsTextEdit())
{
- if (mxWeakTextEditObj->GetOutlinerParaObject())
- nScriptType
- = mxWeakTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
+ auto pText = mxWeakTextEditObj.get();
+ if (pText->GetOutlinerParaObject())
+ nScriptType = pText->GetOutlinerParaObject()->GetTextObject().GetScriptType();
if (mpTextEditOutlinerView)
nScriptType = mpTextEditOutlinerView->GetSelectedScriptType();
@@ -2121,12 +2118,13 @@ void SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) c
DBG_ASSERT(mpTextEditOutliner != nullptr,
"SdrObjEditView::GetAttributes(): mpTextEditOutliner=NULL");
+ auto pText = mxWeakTextEditObj.get();
// take care of bOnlyHardAttr(!)
- if (!bOnlyHardAttr && mxWeakTextEditObj->GetStyleSheet())
- rTargetSet.Put(mxWeakTextEditObj->GetStyleSheet()->GetItemSet());
+ if (!bOnlyHardAttr && pText->GetStyleSheet())
+ rTargetSet.Put(pText->GetStyleSheet()->GetItemSet());
// add object attributes
- rTargetSet.Put(mxWeakTextEditObj->GetMergedItemSet());
+ rTargetSet.Put(pText->GetMergedItemSet());
if (mpTextEditOutlinerView)
{
@@ -2134,7 +2132,7 @@ void SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) c
rTargetSet.Put(mpTextEditOutlinerView->GetAttribs(), false);
}
- if (GetMarkedObjectCount() == 1 && GetMarkedObjectByIndex(0) == mxWeakTextEditObj.get())
+ if (GetMarkedObjectCount() == 1 && GetMarkedObjectByIndex(0) == pText.get())
{
MergeNotPersistAttrFromMarked(rTargetSet);
}
@@ -2148,7 +2146,8 @@ void SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) c
bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
{
bool bRet = false;
- bool bTextEdit = mpTextEditOutlinerView != nullptr && mxWeakTextEditObj.is();
+ rtl::Reference<SdrTextObj> pTextEditObj = mxWeakTextEditObj.get();
+ bool bTextEdit = mpTextEditOutlinerView != nullptr && pTextEditObj != nullptr;
bool bAllTextSelected = ImpIsTextEditAllSelected();
const SfxItemSet* pSet = &rSet;
@@ -2209,22 +2208,21 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
if (bUndo)
{
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
- AddUndo(
- GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxWeakTextEditObj));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pTextEditObj));
// If this is a text object also rescue the OutlinerParaObject since
// applying attributes to the object may change text layout when
// multiple portions exist with multiple formats. If an OutlinerParaObject
// really exists and needs to be rescued is evaluated in the undo
// implementation itself.
- bool bRescueText = mxWeakTextEditObj;
+ bool bRescueText(pTextEditObj);
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(
- *mxWeakTextEditObj, false, !bNoEEItems || bRescueText));
+ *pTextEditObj, false, !bNoEEItems || bRescueText));
EndUndo();
}
- mxWeakTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll);
+ pTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll);
FlushComeBackTimer(); // to set ModeHasChanged immediately
}
@@ -2256,17 +2254,14 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
if (IsUndoEnabled())
{
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
- AddUndo(
- GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxWeakTextEditObj));
- AddUndo(
- GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxWeakTextEditObj));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pTextEditObj));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pTextEditObj));
EndUndo();
}
- mxWeakTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll);
+ pTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll);
- if (GetMarkedObjectCount() == 1
- && GetMarkedObjectByIndex(0) == mxWeakTextEditObj.get())
+ if (GetMarkedObjectCount() == 1 && GetMarkedObjectByIndex(0) == pTextEditObj.get())
{
SetNotPersistAttrToMarked(aSet);
}
@@ -2342,7 +2337,7 @@ void SdrObjEditView::AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pW
{
SdrGlueEditView::AddWindowToPaintView(pNewWin, pWindow);
- if (mxWeakTextEditObj.is() && !mbTextEditOnlyOneView
+ if (mxWeakTextEditObj.get() && !mbTextEditOnlyOneView
&& pNewWin->GetOutDevType() == OUTDEV_WINDOW)
{
OutlinerView* pOutlView = ImpMakeOutlinerView(pNewWin->GetOwnerWindow(), nullptr);
@@ -2354,7 +2349,7 @@ void SdrObjEditView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
{
SdrGlueEditView::DeleteWindowFromPaintView(pOldWin);
- if (mxWeakTextEditObj.is() && !mbTextEditOnlyOneView
+ if (mxWeakTextEditObj.get() && !mbTextEditOnlyOneView
&& pOldWin->GetOutDevType() == OUTDEV_WINDOW)
{
for (size_t i = mpTextEditOutliner->GetViewCount(); i > 0;)
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 154bd3c7b084..203b566002b8 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -351,7 +351,7 @@ std::unique_ptr<SdrOutliner> SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrMode
return pOutl;
}
-std::vector<Link<SdrObjCreatorParams, SdrObject*>>& ImpGetUserMakeObjHdl()
+std::vector<Link<SdrObjCreatorParams, rtl::Reference<SdrObject>>>& ImpGetUserMakeObjHdl()
{
SdrGlobalData& rGlobalData=GetSdrGlobalData();
return rGlobalData.aUserMakeObjHdl;
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 6756e9626d58..587ca14a4637 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -284,9 +284,9 @@ size_t ImpSdrGDIMetaFileImport::DoImport(
// insert all objects cached in aTmpList now into rOL from nInsPos
nInsPos = std::min(nInsPos, rOL.GetObjCount());
- for(SdrObject* pObj : maTmpList)
+ for(rtl::Reference<SdrObject>& pObj : maTmpList)
{
- rOL.NbcInsertObject(pObj, nInsPos);
+ rOL.NbcInsertObject(pObj.get(), nInsPos);
nInsPos++;
if(pProgrInfo)
@@ -442,8 +442,9 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr
}
}
-void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
+void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj1, bool bScale)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if(bScale && !maScaleRect.IsEmpty())
{
if(mbSize)
@@ -463,8 +464,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
const SdrLayerID aOldLayer(pObj->GetLayer());
const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
- const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
- const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj);
+ const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj.get());
+ const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
if(pSdrTextObj && pSdrTextObj->HasText())
{
@@ -479,7 +480,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
// no overlap -> completely outside
if(!aClipRange.overlaps(aTextRange))
{
- SdrObject::Free(pObj);
+ pObj.clear();
break;
}
@@ -492,8 +493,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
// here text needs to be clipped; to do so, convert to SdrObjects with polygons
// and add these recursively. Delete original object, do not add in this run
- SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true).release();
- SdrObject::Free(pObj);
+ rtl::Reference<SdrObject> pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
+ pObj.clear();
if(pConverted)
{
@@ -509,20 +510,17 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
{
SdrObject* pCandidate = aIter.Next();
OSL_ENSURE(pCandidate && dynamic_cast< SdrObjGroup* >(pCandidate) == nullptr, "SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
- SdrObject* pNewClone(pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pNewClone(pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
if(pNewClone)
{
- InsertObj(pNewClone, false);
+ InsertObj(pNewClone.get(), false);
}
else
{
OSL_ENSURE(false, "SdrObject::Clone() failed (!)");
}
}
-
- // cleanup temporary conversion objects
- SdrObject::Free(pConverted);
}
break;
@@ -537,7 +535,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
}
- SdrObject::Free(pObj);
+ pObj.clear();
if(!aOldRange.isEmpty())
{
@@ -613,7 +611,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
if(!bVisible)
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
if(pTextObj && pTextObj->HasText())
{
@@ -623,7 +621,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
if(!bVisible)
{
- SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
+ SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj.get());
if(pGrafObj)
{
@@ -634,15 +632,11 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
}
}
- if(!bVisible)
- {
- SdrObject::Free(pObj);
- }
- else
+ if(bVisible)
{
maTmpList.push_back(pObj);
- if(dynamic_cast< SdrPathObj* >(pObj))
+ if(dynamic_cast< SdrPathObj* >(pObj.get()))
{
const bool bClosed(pObj->IsClosedObj());
@@ -685,7 +679,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
if(!bCreateLineObject)
return;
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Line,
basegfx::B2DPolyPolygon(aLine));
@@ -696,45 +690,45 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
rLineInfo.GetDistance());
- SetAttributes(pPath);
+ SetAttributes(pPath.get());
mnLineWidth = 0;
maLineJoin = basegfx::B2DLineJoin::NONE;
maDash = XDash();
- InsertObj(pPath, false);
+ InsertObj(pPath.get(), false);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction const & rAct)
{
- SdrRectObj* pRect = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pRect = new SdrRectObj(
*mpModel,
rAct.GetRect());
- SetAttributes(pRect);
- InsertObj(pRect);
+ SetAttributes(pRect.get());
+ InsertObj(pRect.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction const & rAct)
{
- SdrRectObj* pRect = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pRect = new SdrRectObj(
*mpModel,
rAct.GetRect());
- SetAttributes(pRect);
+ SetAttributes(pRect.get());
tools::Long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
if (nRad!=0) {
SfxItemSetFixed<SDRATTR_CORNER_RADIUS, SDRATTR_CORNER_RADIUS> aSet(*mpLineAttr->GetPool());
aSet.Put(SdrMetricItem(SDRATTR_CORNER_RADIUS, nRad));
pRect->SetMergedItemSet(aSet);
}
- InsertObj(pRect);
+ InsertObj(pRect.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction const & rAct)
{
- SdrCircObj* pCirc=new SdrCircObj(
+ rtl::Reference<SdrCircObj> pCirc=new SdrCircObj(
*mpModel,
SdrCircKind::Full,
rAct.GetRect());
- SetAttributes(pCirc);
- InsertObj(pCirc);
+ SetAttributes(pCirc.get());
+ InsertObj(pCirc.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction const & rAct)
@@ -742,12 +736,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction const & rAct)
Point aCenter(rAct.GetRect().Center());
Degree100 nStart=GetAngle(rAct.GetStartPoint()-aCenter);
Degree100 nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
+ rtl::Reference<SdrCircObj> pCirc = new SdrCircObj(
*mpModel,
SdrCircKind::Arc,
rAct.GetRect(),nStart,nEnd);
- SetAttributes(pCirc);
- InsertObj(pCirc);
+ SetAttributes(pCirc.get());
+ InsertObj(pCirc.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction const & rAct)
@@ -755,14 +749,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction const & rAct)
Point aCenter(rAct.GetRect().Center());
Degree100 nStart=GetAngle(rAct.GetStartPoint()-aCenter);
Degree100 nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
+ rtl::Reference<SdrCircObj> pCirc = new SdrCircObj(
*mpModel,
SdrCircKind::Section,
rAct.GetRect(),
nStart,
nEnd);
- SetAttributes(pCirc);
- InsertObj(pCirc);
+ SetAttributes(pCirc.get());
+ InsertObj(pCirc.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction const & rAct)
@@ -770,14 +764,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction const & rAct)
Point aCenter(rAct.GetRect().Center());
Degree100 nStart=GetAngle(rAct.GetStartPoint()-aCenter);
Degree100 nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
+ rtl::Reference<SdrCircObj> pCirc = new SdrCircObj(
*mpModel,
SdrCircKind::Cut,
rAct.GetRect(),
nStart,
nEnd);
- SetAttributes(pCirc);
- InsertObj(pCirc);
+ SetAttributes(pCirc.get());
+ InsertObj(pCirc.get());
}
bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
@@ -791,7 +785,7 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
// #i73407# reformulation to use new B2DPolygon classes
if(mbLastObjWasLine && (maOldLineColor == mpVD->GetLineColor()) && rSrcPoly.count())
{
- SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1] : nullptr;
+ SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1].get() : nullptr;
SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
if(pLastPoly)
@@ -857,7 +851,7 @@ bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPo
// #i73407# reformulation to use new B2DPolygon classes
if(mbLastObjWasPolyWithoutLine)
{
- SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1] : nullptr;
+ SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1].get() : nullptr;
SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
if(pLastPoly)
@@ -931,7 +925,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction const & rAct )
if(!bCreateLineObject)
return;
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
aSource.isClosed() ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
basegfx::B2DPolyPolygon(aSource));
@@ -942,11 +936,11 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction const & rAct )
rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
rLineInfo.GetDistance());
- SetAttributes(pPath);
+ SetAttributes(pPath.get());
mnLineWidth = 0;
maLineJoin = basegfx::B2DLineJoin::NONE;
maDash = XDash();
- InsertObj(pPath, false);
+ InsertObj(pPath.get(), false);
}
void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct )
@@ -964,12 +958,12 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct )
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
basegfx::B2DPolyPolygon(aSource));
- SetAttributes(pPath);
- InsertObj(pPath, false);
+ SetAttributes(pPath.get());
+ InsertObj(pPath.get(), false);
}
}
@@ -988,12 +982,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction const & rAct)
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource));
- SetAttributes(pPath);
- InsertObj(pPath, false);
+ SetAttributes(pPath.get());
+ InsertObj(pPath.get(), false);
}
}
@@ -1017,7 +1011,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
aPos.AdjustY( -nTextHeight );
tools::Rectangle aTextRect( aPos, aSize );
- SdrRectObj* pText = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pText = new SdrRectObj(
*mpModel,
SdrObjKind::Text,
aTextRect);
@@ -1041,7 +1035,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
pText->SetLayer(mnLayer);
pText->NbcSetText( rStr );
- SetAttributes( pText, true );
+ SetAttributes( pText.get(), true );
pText->SetSnapRect( aTextRect );
if (!aFnt.IsTransparent())
@@ -1054,7 +1048,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
Degree100 nAngle = to<Degree100>(aFnt.GetOrientation());
if ( nAngle )
pText->SdrAttrObj::NbcRotate(aPos,nAngle);
- InsertObj( pText, false );
+ InsertObj( pText.get(), false );
}
void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction const & rAct)
@@ -1082,7 +1076,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
Graphic(BitmapEx(rAct.GetBitmap())),
aRect);
@@ -1090,14 +1084,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
Graphic(BitmapEx(rAct.GetBitmap())),
aRect);
@@ -1105,14 +1099,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
rAct.GetBitmapEx(),
aRect);
@@ -1120,14 +1114,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
rAct.GetBitmapEx(),
aRect);
@@ -1135,7 +1129,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
@@ -1154,7 +1148,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct )
return;
const Hatch& rHatch = rAct.GetHatch();
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource));
@@ -1183,12 +1177,12 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct )
}
}
- SetAttributes(pPath);
+ SetAttributes(pPath.get());
aHatchAttr.Put(XFillStyleItem(drawing::FillStyle_HATCH));
aHatchAttr.Put(XFillHatchItem(XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
pPath->SetMergedItemSet(aHatchAttr);
- InsertObj(pPath, false);
+ InsertObj(pPath.get(), false);
}
@@ -1216,7 +1210,7 @@ void ImpSdrGDIMetaFileImport::MapScaling()
{
for(size_t i = mnMapScalingOfs; i < nCount; i++)
{
- SdrObject* pObj = maTmpList[i];
+ SdrObject* pObj = maTmpList[i].get();
pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
}
@@ -1245,7 +1239,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Gradient& rGrad = pAct->GetGradient();
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource));
@@ -1278,7 +1272,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF
pPath->SetMergedItemSet(aGradAttr);
- InsertObj(pPath);
+ InsertObj(pPath.get());
}
}
@@ -1316,7 +1310,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1324,7 +1318,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction const & rAct)
@@ -1335,7 +1329,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1343,7 +1337,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction const & rAct)
@@ -1352,7 +1346,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1360,7 +1354,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction const & rAct)
@@ -1369,7 +1363,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1377,7 +1371,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction const & rAct)
@@ -1387,7 +1381,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction const & rAct)
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1395,7 +1389,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction const & rAct)
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
namespace
@@ -1436,7 +1430,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction const & rAct)
const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
aRange.transform(aTransform);
const Gradient& rGradient = rAct.GetGradient();
- SdrRectObj* pRect = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pRect = new SdrRectObj(
*mpModel,
tools::Rectangle(
floor(aRange.getMinX()),
@@ -1459,12 +1453,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction const & rAct)
rGradient.GetEndIntensity(),
rGradient.GetSteps()));
- SetAttributes(pRect);
+ SetAttributes(pRect.get());
aGradientAttr.Put(XFillStyleItem(drawing::FillStyle_GRADIENT)); // #i125211#
aGradientAttr.Put(aXFillGradientItem);
pRect->SetMergedItemSet(aGradientAttr);
- InsertObj(pRect, false);
+ InsertObj(pRect.get(), false);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction const & rAct)
@@ -1478,13 +1472,13 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction const & rAct)
aSource.transform(aTransform);
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource));
- SetAttributes(pPath);
+ SetAttributes(pPath.get());
pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
- InsertObj(pPath, false);
+ InsertObj(pPath.get(), false);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct)
@@ -1501,7 +1495,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct)
return;
const Gradient& rGradient = rAct.GetGradient();
- SdrPathObj* pPath = new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(
*mpModel,
SdrObjKind::Polygon,
std::move(aSource));
@@ -1521,12 +1515,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct)
rGradient.GetEndIntensity(),
rGradient.GetSteps()));
- SetAttributes(pPath);
+ SetAttributes(pPath.get());
aGradientAttr.Put(XFillStyleItem(drawing::FillStyle_GRADIENT)); // #i125211#
aGradientAttr.Put(aXFillGradientItem);
pPath->SetMergedItemSet(aGradientAttr);
- InsertObj(pPath, false);
+ InsertObj(pPath.get(), false);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct)
@@ -1625,7 +1619,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct)
}
// create and add object
- SdrGrafObj* pGraf = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(
*mpModel,
aBitmapEx,
aRect);
@@ -1635,7 +1629,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct)
// dependent of these setting at the device content
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
index 0e788bcd5ad0..31c325582799 100644
--- a/svx/source/svdraw/svdfmtf.hxx
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -45,7 +45,7 @@ class SvdProgressInfo;
// Helper Class ImpSdrGDIMetaFileImport
class ImpSdrGDIMetaFileImport final
{
- ::std::vector< SdrObject* > maTmpList;
+ ::std::vector< rtl::Reference<SdrObject> > maTmpList;
ScopedVclPtr<VirtualDevice> mpVD;
tools::Rectangle maScaleRect;
size_t mnMapScalingOfs; // from here on, not edited with MapScaling
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index b487ba5f490f..535850f582c1 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -195,18 +195,12 @@ SdrModel::~SdrModel()
// SdrObjectLifetimeWatchDog:
if(!maAllIncarnatedObjects.empty())
{
- SAL_WARN("svx","SdrModel::~SdrModel: Not all incarnations of SdrObjects deleted, possible memory leak (!)");
- const std::vector<const SdrObject*> maRemainingObjects(maAllIncarnatedObjects.begin(),
- maAllIncarnatedObjects.end());
- for (auto pSdrObject : maRemainingObjects)
- {
- SdrObject* pCandidate(const_cast<SdrObject*>(pSdrObject));
- // calling SdrObject::Free will change maAllIncarnatedObjects, and potentially remove
- // more than one, so check if the candidate is still in the updated list before Free
- if (maAllIncarnatedObjects.find(pSdrObject) != maAllIncarnatedObjects.end())
- SdrObject::Free(pCandidate);
- }
+ SAL_WARN("svx",
+ "SdrModel::~SdrModel: Not all incarnations of SdrObjects deleted, possible memory leak");
+ for (const auto & pObj : maAllIncarnatedObjects)
+ SAL_WARN("svx", "leaked instance of " << typeid(*pObj).name());
}
+ assert(maAllIncarnatedObjects.empty());
#endif
m_pLayerAdmin.reset();
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 886307f86b48..5993781186a7 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -203,9 +203,9 @@ static bool ImpVerticalSwitch( const SdrObjCustomShape& rCustoShape )
// #i37011# create a clone with all attributes changed to shadow attributes
// and translation executed, too.
-static SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemSet& rOriginalSet)
+static rtl::Reference<SdrObject> ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemSet& rOriginalSet)
{
- SdrObject* pRetval = nullptr;
+ rtl::Reference<SdrObject> pRetval;
const bool bShadow(rOriginalSet.Get(SDRATTR_SHADOW).GetValue());
if(bShadow)
@@ -436,7 +436,7 @@ const SdrObject* SdrObjCustomShape::GetSdrObjectShadowFromCustomShape() const
}
}
- return mpLastShadowGeometry;
+ return mpLastShadowGeometry.get();
}
bool SdrObjCustomShape::IsTextPath() const
@@ -789,7 +789,6 @@ SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel)
: SdrTextObj(rSdrModel)
, fObjectRotation(0.0)
, mbAdjustingTextFrameWidthAndHeight(false)
- , mpLastShadowGeometry(nullptr)
{
m_bClosedObj = true; // custom shapes may be filled
mbTextFrame = true;
@@ -799,7 +798,6 @@ SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel, SdrObjCustomShape cons
: SdrTextObj(rSdrModel, rSource)
, fObjectRotation(0.0)
, mbAdjustingTextFrameWidthAndHeight(false)
- , mpLastShadowGeometry(nullptr)
{
m_bClosedObj = true; // custom shapes may be filled
mbTextFrame = true;
@@ -2776,7 +2774,7 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(std::optional<OutlinerParaObjec
InvalidateRenderGeometry();
}
-SdrObjCustomShape* SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrObjCustomShape(rTargetModel, *this);
}
@@ -2808,10 +2806,10 @@ basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
return basegfx::B2DPolyPolygon();
}
-SdrObjectUniquePtr SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// #i37011#
- SdrObjectUniquePtr pRetval;
+ rtl::Reference<SdrObject> pRetval;
SdrObject* pRenderedCustomShape = nullptr;
if ( !mXRenderedCustomShape.is() )
@@ -2828,10 +2826,10 @@ SdrObjectUniquePtr SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAdd
if ( pRenderedCustomShape )
{
// Clone to same SdrModel
- SdrObject* pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject()));
DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
- SdrObject::Free( pCandidate );
+ pCandidate.clear();
if(pRetval)
{
@@ -3209,7 +3207,6 @@ bool SdrObjCustomShape::doConstructOrthogonal(std::u16string_view rName)
void SdrObjCustomShape::InvalidateRenderGeometry()
{
mXRenderedCustomShape = nullptr;
- SdrObject::Free( mpLastShadowGeometry );
mpLastShadowGeometry = nullptr;
}
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index c3c01eda713d..2742e657f194 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -288,8 +288,11 @@ SdrModel& SdrObject::getSdrModelFromSdrObject() const
void SdrObject::setParentOfSdrObject(SdrObjList* pNewObjList)
{
- if(getParentSdrObjListFromSdrObject() == pNewObjList)
+ assert(!pNewObjList || mpParentOfSdrObject != pNewObjList);
+ if(mpParentOfSdrObject == pNewObjList)
return;
+ // we need to be removed from the old parent before we are attached to the new parent
+ assert(bool(mpParentOfSdrObject) != bool(pNewObjList) && "may only transition empty->full or full->empty");
// remember current page
SdrPage* pOldPage(getSdrPageFromSdrObject());
@@ -325,15 +328,15 @@ void SdrObject::SetBoundRectDirty()
#ifdef DBG_UTIL
// SdrObjectLifetimeWatchDog:
-void impAddIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel)
+void impAddIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel)
{
rSdrModel.maAllIncarnatedObjects.insert(&rSdrObject);
}
-void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel)
+void impRemoveIncarnatedSdrObjectToSdrModel(SdrObject& rSdrObject, SdrModel& rSdrModel)
{
if(!rSdrModel.maAllIncarnatedObjects.erase(&rSdrObject))
{
- SAL_WARN("svx","SdrObject::~SdrObject: Destructed incarnation of SdrObject not member of this SdrModel (!)");
+ assert(false && "SdrObject::~SdrObject: Destructed incarnation of SdrObject not member of this SdrModel (!)");
}
}
#endif
@@ -408,10 +411,6 @@ SdrObject::SdrObject(SdrModel& rSdrModel, SdrObject const & rSource)
m_bIs3DObj=false;
m_bMarkProt=false;
m_bIsUnoObj=false;
-#ifdef DBG_UTIL
- // SdrObjectLifetimeWatchDog:
- impAddIncarnatedSdrObjectToSdrModel(*this, getSdrModelFromSdrObject());
-#endif
mpProperties.reset();
mpViewContact.reset();
@@ -444,10 +443,15 @@ SdrObject::SdrObject(SdrModel& rSdrModel, SdrObject const & rSource)
m_pGrabBagItem.reset();
if (rSource.m_pGrabBagItem!=nullptr)
m_pGrabBagItem.reset(rSource.m_pGrabBagItem->Clone());
+#ifdef DBG_UTIL
+ // SdrObjectLifetimeWatchDog:
+ impAddIncarnatedSdrObjectToSdrModel(*this, getSdrModelFromSdrObject());
+#endif
}
SdrObject::~SdrObject()
{
+ assert(m_refCount == -1);
// Tell all the registered ObjectUsers that the page is in destruction.
// And clear the vector. This means that user do not need to call RemoveObjectUser()
// when they get called from ObjectInDestruction().
@@ -466,50 +470,32 @@ SdrObject::~SdrObject()
m_pGrabBagItem.reset();
mpProperties.reset();
mpViewContact.reset();
-
#ifdef DBG_UTIL
// SdrObjectLifetimeWatchDog:
impRemoveIncarnatedSdrObjectToSdrModel(*this, getSdrModelFromSdrObject());
#endif
}
-void SdrObject::Free( SdrObject*& _rpObject )
+void SdrObject::acquire() noexcept
{
- SdrObject* pObject = _rpObject; _rpObject = nullptr;
-
- if(nullptr == pObject)
- {
- // nothing to do
- return;
- }
-
- SvxShape* pShape(pObject->getSvxShape());
+#ifdef DBG_UTIL
+ assert(m_refCount != -1);
+#endif
+ osl_atomic_increment( &m_refCount );
+}
- if(pShape)
+void SdrObject::release() noexcept
+{
+ oslInterlockedCount x = osl_atomic_decrement( &m_refCount );
+ if ( x == 0 )
{
- if(pShape->HasSdrObjectOwnership())
- {
- // only the SvxShape is allowed to delete me, and will reset
- // the ownership before doing so
- return;
- }
- else
- {
- // not only delete pObject, but also need to dispose uno shape
- try
- {
- pShape->InvalidateSdrObject();
- uno::Reference< lang::XComponent > xShapeComp( pObject->getWeakUnoShape().get(), uno::UNO_QUERY_THROW );
- xShapeComp->dispose();
- }
- catch( const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("svx");
- }
- }
+ disposeWeakConnectionPoint();
+#ifdef DBG_UTIL
+ // make sure it doesn't accidentally come back to life, see assert in acquire()
+ osl_atomic_decrement( &m_refCount );
+#endif
+ delete this;
}
-
- delete pObject;
}
void SdrObject::SetBoundAndSnapRectsDirty(bool bNotMyself, bool bRecursive)
@@ -545,10 +531,8 @@ void SdrObject::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
{
SvxShape* const pShape(getSvxShape());
- if (pShape && !pShape->HasSdrObjectOwnership())
- {
+ if (pShape)
setUnoShape(nullptr);
- }
}
}
@@ -1072,7 +1056,7 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
-SdrObject* SdrObject::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrObject::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrObject(rTargetModel, *this);
}
@@ -1136,7 +1120,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
// create cloned object without text, but with drawing::LineStyle_SOLID,
// COL_BLACK as line color and drawing::FillStyle_NONE
- SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pClone(CloneSdrObject(getSdrModelFromSdrObject()));
if(pClone)
{
@@ -1211,9 +1195,6 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
}
}
}
-
- // Always use SdrObject::Free to delete SdrObjects (!)
- SdrObject::Free(pClone);
}
return aRetval;
@@ -1334,10 +1315,10 @@ bool SdrObject::supportsFullDrag() const
return true;
}
-SdrObjectUniquePtr SdrObject::getFullDragClone() const
+rtl::Reference<SdrObject> SdrObject::getFullDragClone() const
{
// default uses simple clone
- return SdrObjectUniquePtr(CloneSdrObject(getSdrModelFromSdrObject()));
+ return CloneSdrObject(getSdrModelFromSdrObject());
}
bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
@@ -2439,9 +2420,9 @@ static void extractLineContourFromPrimitive2DSequence(
}
-SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
+rtl::Reference<SdrObject> SdrObject::ImpConvertToContourObj(bool bForceLineDash)
{
- SdrObject* pRetval(nullptr);
+ rtl::Reference<SdrObject> pRetval;
if(LineGeometryUsageIsNecessary())
{
@@ -2475,8 +2456,8 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
{
SfxItemSet aSet(GetMergedItemSet());
drawing::FillStyle eOldFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue();
- SdrPathObj* aLinePolygonPart = nullptr;
- SdrPathObj* aLineHairlinePart = nullptr;
+ rtl::Reference<SdrPathObj> aLinePolygonPart;
+ rtl::Reference<SdrPathObj> aLineHairlinePart;
bool bBuildGroup(false);
if(aMergedLineFillPolyPolygon.count())
@@ -2541,7 +2522,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
// do we need a group?
if(bBuildGroup || bAddOriginalGeometry)
{
- SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
if(bAddOriginalGeometry)
{
@@ -2551,20 +2532,20 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aSet.Put(XLineWidthItem(0));
- SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pClone(CloneSdrObject(getSdrModelFromSdrObject()));
pClone->SetMergedItemSet(aSet);
- pGroup->GetSubList()->NbcInsertObject(pClone);
+ pGroup->GetSubList()->NbcInsertObject(pClone.get());
}
if(aLinePolygonPart)
{
- pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
+ pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart.get());
}
if(aLineHairlinePart)
{
- pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
+ pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart.get());
}
pRetval = pGroup;
@@ -2583,11 +2564,10 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
}
}
- if(nullptr == pRetval)
+ if(!pRetval)
{
// due to current method usage, create and return a clone when nothing has changed
- SdrObject* pClone(CloneSdrObject(getSdrModelFromSdrObject()));
- pRetval = pClone;
+ pRetval = CloneSdrObject(getSdrModelFromSdrObject());
}
return pRetval;
@@ -2613,24 +2593,25 @@ void SdrObject::SetNotVisibleAsMaster(bool bFlg)
// convert this path object to contour object, even when it is a group
-SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash) const
+rtl::Reference<SdrObject> SdrObject::ConvertToContourObj(SdrObject* pRet1, bool bForceLineDash) const
{
- if(dynamic_cast<const SdrObjGroup*>( pRet) != nullptr)
+ rtl::Reference<SdrObject> pRet = pRet1;
+ if(dynamic_cast<const SdrObjGroup*>( pRet.get()) != nullptr)
{
SdrObjList* pObjList2 = pRet->GetSubList();
- SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
for(size_t a=0; a<pObjList2->GetObjCount(); ++a)
{
SdrObject* pIterObj = pObjList2->GetObj(a);
- pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
+ pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash).get());
}
pRet = pGroup;
}
else
{
- if (SdrPathObj *pPathObj = dynamic_cast<SdrPathObj*>(pRet))
+ if (SdrPathObj *pPathObj = dynamic_cast<SdrPathObj*>(pRet.get()))
{
// bezier geometry got created, even for straight edges since the given
// object is a result of DoConvertToPolyObj. For conversion to contour
@@ -2651,14 +2632,13 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
}
-SdrObjectUniquePtr SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
+rtl::Reference<SdrObject> SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
{
- SdrObjectUniquePtr pRet = DoConvertToPolyObj(bBezier, true);
+ rtl::Reference<SdrObject> pRet = DoConvertToPolyObj(bBezier, true);
if(pRet && bLineToArea)
{
- SdrObject* pNewRet = ConvertToContourObj(pRet.get());
- pRet.reset(pNewRet);
+ pRet = ConvertToContourObj(pRet.get());
}
// #i73441# preserve LayerID
@@ -2671,7 +2651,7 @@ SdrObjectUniquePtr SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) c
}
-SdrObjectUniquePtr SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+rtl::Reference<SdrObject> SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
{
return nullptr;
}
@@ -2872,10 +2852,8 @@ void SdrObject::setUnoShape( const uno::Reference< drawing::XShape >& _rxUnoShap
return;
}
- bool bTransferOwnership( false );
if ( xOldUnoShape.is() )
{
- bTransferOwnership = mpSvxShape->HasSdrObjectOwnership();
// Remove yourself from the current UNO shape. Its destructor
// will reset our UNO shape otherwise.
mpSvxShape->InvalidateSdrObject();
@@ -2883,14 +2861,6 @@ void SdrObject::setUnoShape( const uno::Reference< drawing::XShape >& _rxUnoShap
maWeakUnoShape = _rxUnoShape;
mpSvxShape = comphelper::getFromUnoTunnel<SvxShape>( _rxUnoShape );
-
- // I think this may never happen... But I am not sure enough .-)
- if ( bTransferOwnership )
- {
- if (mpSvxShape)
- mpSvxShape->TakeSdrObjectOwnership();
- SAL_WARN( "svx.uno", "a UNO shape took over an SdrObject previously owned by another UNO shape!");
- }
}
/** only for internal use! */
@@ -2901,12 +2871,8 @@ SvxShape* SdrObject::getSvxShape()
// guarded by the SolarMutex
uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
-#if OSL_DEBUG_LEVEL > 0
- OSL_ENSURE( !( !xShape.is() && mpSvxShape ),
- "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
-#endif
//#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape
- if ( mpSvxShape && !xShape.is() )
+ if ( mpSvxShape && !xShape )
mpSvxShape = nullptr;
return mpSvxShape;
@@ -2915,12 +2881,10 @@ SvxShape* SdrObject::getSvxShape()
css::uno::Reference< css::drawing::XShape > SdrObject::getUnoShape()
{
// try weak reference first
- uno::Reference< css::drawing::XShape > xShape( getWeakUnoShape() );
- if( xShape )
+ uno::Reference< css::drawing::XShape > xShape = maWeakUnoShape;
+ if (xShape)
return xShape;
- OSL_ENSURE( mpSvxShape == nullptr, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
-
// try to access SdrPage from this SdrObject. This will only exist if the SdrObject is
// inserted in a SdrObjList (page/group/3dScene)
SdrPage* pPageCandidate(getSdrPageFromSdrObject());
@@ -2985,6 +2949,7 @@ css::uno::Reference< css::drawing::XShape > SdrObject::getUnoShape()
{
// create one
xShape = pDrawPage->CreateShape( this );
+ assert(xShape);
setUnoShape( xShape );
}
}
@@ -3247,11 +3212,11 @@ void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
m_aOutRect.Move(nXDelta, nYDelta);
}
-SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier)
+rtl::Reference<SdrObject> SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier)
{
SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
for (const auto & i : ImpGetUserMakeObjHdl()) {
- SdrObject* pObj = i.Call(aParams);
+ rtl::Reference<SdrObject> pObj = i.Call(aParams);
if (pObj) {
return pObj;
}
@@ -3259,13 +3224,13 @@ SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInvent
return nullptr;
}
-SdrObject* SdrObjFactory::MakeNewObject(
+rtl::Reference<SdrObject> SdrObjFactory::MakeNewObject(
SdrModel& rSdrModel,
SdrInventor nInventor,
SdrObjKind nIdentifier,
const tools::Rectangle* pSnapRect)
{
- SdrObject* pObj(nullptr);
+ rtl::Reference<SdrObject> pObj;
bool bSetSnapRect(nullptr != pSnapRect);
if (nInventor == SdrInventor::Default)
@@ -3397,9 +3362,9 @@ SdrObject* SdrObjFactory::MakeNewObject(
return pObj;
}
-void SdrObjFactory::InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink)
+void SdrObjFactory::InsertMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink)
{
- std::vector<Link<SdrObjCreatorParams, SdrObject*>>& rLL=ImpGetUserMakeObjHdl();
+ std::vector<Link<SdrObjCreatorParams, rtl::Reference<SdrObject>>>& rLL=ImpGetUserMakeObjHdl();
auto it = std::find(rLL.begin(), rLL.end(), rLink);
if (it != rLL.end()) {
OSL_FAIL("SdrObjFactory::InsertMakeObjectHdl(): Link already in place.");
@@ -3408,9 +3373,9 @@ void SdrObjFactory::InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> co
}
}
-void SdrObjFactory::RemoveMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink)
+void SdrObjFactory::RemoveMakeObjectHdl(Link<SdrObjCreatorParams, rtl::Reference<SdrObject>> const & rLink)
{
- std::vector<Link<SdrObjCreatorParams, SdrObject*>>& rLL=ImpGetUserMakeObjHdl();
+ std::vector<Link<SdrObjCreatorParams, rtl::Reference<SdrObject>>>& rLL=ImpGetUserMakeObjHdl();
auto it = std::find(rLL.begin(), rLL.end(), rLink);
if (it != rLL.end())
rLL.erase(it);
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 4734ea22283d..6a886272bad1 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -237,7 +237,7 @@ SdrObjKind SdrCaptionObj::GetObjIdentifier() const
return SdrObjKind::Caption;
}
-SdrCaptionObj* SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrCaptionObj(rTargetModel, *this);
}
@@ -666,11 +666,11 @@ void SdrCaptionObj::RestoreGeoData(const SdrObjGeoData& rGeo)
aTailPoly=rCGeo.aTailPoly;
}
-SdrObjectUniquePtr SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
- SdrObjectUniquePtr pRect = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
- SdrObjectUniquePtr pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier);
- SdrObjectUniquePtr pRet;
+ rtl::Reference<SdrObject> pRect = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
+ rtl::Reference<SdrObject> pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier);
+ rtl::Reference<SdrObject> pRet;
if (pTail && !pRect)
pRet = std::move(pTail);
else if (pRect && !pTail)
@@ -679,20 +679,20 @@ SdrObjectUniquePtr SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText
{
if (pTail->GetSubList())
{
- pTail->GetSubList()->NbcInsertObject(pRect.release());
+ pTail->GetSubList()->NbcInsertObject(pRect.get());
pRet = std::move(pTail);
}
else if (pRect->GetSubList())
{
- pRect->GetSubList()->NbcInsertObject(pTail.release(),0);
+ pRect->GetSubList()->NbcInsertObject(pTail.get(),0);
pRet = std::move(pRect);
}
else
{
- SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
- pGrp->GetSubList()->NbcInsertObject(pRect.release());
- pGrp->GetSubList()->NbcInsertObject(pTail.release(),0);
- pRet.reset(pGrp);
+ rtl::Reference<SdrObjGroup> pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
+ pGrp->GetSubList()->NbcInsertObject(pRect.get());
+ pGrp->GetSubList()->NbcInsertObject(pTail.get(),0);
+ pRet = pGrp;
}
}
return pRet;
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 514f07aba8e9..1207548114bf 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -369,7 +369,7 @@ OUString SdrCircObj::TakeObjNamePlural() const
return SvxResId(pID);
}
-SdrCircObj* SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrCircObj(rTargetModel, *this);
}
@@ -1137,11 +1137,11 @@ void SdrCircObj::ImpSetCircInfoToAttr()
ImpSetAttrToCircInfo();
}
-SdrObjectUniquePtr SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
const bool bFill(meCircleKind != SdrCircKind::Arc);
const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle));
- SdrObjectUniquePtr pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier);
+ rtl::Reference<SdrObject> pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier);
if(bAddText)
{
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 92a5829af2c0..f84ee128a6e0 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1666,7 +1666,7 @@ void SdrEdgeObj::Reformat()
}
}
-SdrEdgeObj* SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrEdgeObj(rTargetModel, *this);
}
@@ -1850,16 +1850,16 @@ bool SdrEdgeObj::hasSpecialDrag() const
return true;
}
-SdrObjectUniquePtr SdrEdgeObj::getFullDragClone() const
+rtl::Reference<SdrObject> SdrEdgeObj::getFullDragClone() const
{
// use Clone operator
- SdrEdgeObj* pRetval(CloneSdrObject(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrEdgeObj> pRetval = SdrObject::Clone(*this, getSdrModelFromSdrObject());
// copy connections for clone, SdrEdgeObj::operator= does not do this
pRetval->ConnectToNode(true, GetConnectedNode(true));
pRetval->ConnectToNode(false, GetConnectedNode(false));
- return SdrObjectUniquePtr(pRetval);
+ return pRetval;
}
bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const
@@ -2410,11 +2410,11 @@ void SdrEdgeObj::NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool b
}
}
-SdrObjectUniquePtr SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
basegfx::B2DPolyPolygon aPolyPolygon;
aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
- SdrObjectUniquePtr pRet = ImpConvertMakeObj(aPolyPolygon, false, bBezier);
+ rtl::Reference<SdrObject> pRet = ImpConvertMakeObj(aPolyPolygon, false, bBezier);
if(bAddText)
{
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 7691b104ab8e..1c1be8a7a69a 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -752,10 +752,10 @@ OUString SdrGrafObj::TakeObjNamePlural() const
return sName.makeStringAndClear();
}
-SdrObjectUniquePtr SdrGrafObj::getFullDragClone() const
+rtl::Reference<SdrObject> SdrGrafObj::getFullDragClone() const
{
// call parent
- SdrObjectUniquePtr pRetval = SdrRectObj::getFullDragClone();
+ rtl::Reference<SdrObject> pRetval = SdrRectObj::getFullDragClone();
// #i103116# the full drag clone leads to problems
// with linked graphics, so reset the link in this
@@ -768,7 +768,7 @@ SdrObjectUniquePtr SdrGrafObj::getFullDragClone() const
return pRetval;
}
-SdrGrafObj* SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrGrafObj(rTargetModel, *this);
}
@@ -908,9 +908,9 @@ GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const
return GDIMetaFile();
}
-SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
+rtl::Reference<SdrObject> SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
{
- SdrObject* pRetval = nullptr;
+ rtl::Reference<SdrObject> pRetval;
GraphicType aGraphicType(GetGraphicType());
GDIMetaFile aMtf(GetMetaFile(aGraphicType));
switch(aGraphicType)
@@ -922,7 +922,7 @@ SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText )
getSdrModelFromSdrObject(),
GetLayer(),
maRect);
- SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
+ rtl::Reference<SdrObjGroup> pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0))
{
@@ -948,15 +948,13 @@ SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText )
if(bAddText)
{
- pRetval = ImpConvertAddText(SdrObjectUniquePtr(pRetval), bBezier).release();
+ pRetval = ImpConvertAddText(pRetval, bBezier);
}
// convert all children
if( pRetval )
{
- SdrObject* pHalfDone = pRetval;
- pRetval = pRetval->DoConvertToPolyObj(bBezier, bAddText).release();
- SdrObject::Free( pHalfDone ); // resulting object is newly created
+ pRetval = pRetval->DoConvertToPolyObj(bBezier, bAddText);
if( pRetval )
{
@@ -971,33 +969,29 @@ SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText )
}
}
else
- {
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pGrp);
- SdrObject::Free(pTemp);
- }
+ pGrp.clear();
// #i118485# convert line and fill
- SdrObjectUniquePtr pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
+ rtl::Reference<SdrObject> pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
if(pLineFill)
{
if(pRetval)
{
- pGrp = dynamic_cast< SdrObjGroup* >(pRetval);
+ pGrp = dynamic_cast< SdrObjGroup* >(pRetval.get());
if(!pGrp)
{
pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
pGrp->NbcSetLayer(GetLayer());
- pGrp->GetSubList()->NbcInsertObject(pRetval);
+ pGrp->GetSubList()->NbcInsertObject(pRetval.get());
}
- pGrp->GetSubList()->NbcInsertObject(pLineFill.release(), 0);
+ pGrp->GetSubList()->NbcInsertObject(pLineFill.get(), 0);
}
else
{
- pRetval = pLineFill.release();
+ pRetval = pLineFill;
}
}
@@ -1006,7 +1000,7 @@ SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText )
case GraphicType::Bitmap:
{
// create basic object and add fill
- pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release();
+ pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
// save bitmap as an attribute
if(pRetval)
@@ -1026,12 +1020,12 @@ SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText )
case GraphicType::NONE:
case GraphicType::Default:
{
- pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release();
+ pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
break;
}
}
- return SdrObjectUniquePtr(pRetval);
+ return pRetval;
}
void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index d71ff03e1051..20d605e99a2d 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -266,7 +266,7 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const
}
}
-SdrObjGroup* SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrObjGroup(rTargetModel, *this);
}
@@ -809,19 +809,19 @@ void SdrObjGroup::NbcReformatText()
NbcReformatAllTextObjects();
}
-SdrObjectUniquePtr SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
- SdrObjectUniquePtr pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) );
+ rtl::Reference<SdrObject> pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) );
const size_t nObjCount(GetObjCount());
for(size_t a=0; a < nObjCount; ++a)
{
SdrObject* pIterObj(GetObj(a));
- SdrObjectUniquePtr pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
+ rtl::Reference<SdrObject> pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
// pResult can be NULL e.g. for empty objects
if( pResult )
- pGroup->GetSubList()->NbcInsertObject(pResult.release());
+ pGroup->GetSubList()->NbcInsertObject(pResult.get());
}
return pGroup;
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index b67add22bf8a..5e402646ef66 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -706,7 +706,7 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
-SdrMeasureObj* SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrMeasureObj(rTargetModel, *this);
}
@@ -1124,7 +1124,7 @@ void SdrMeasureObj::RestoreGeoData(const SdrObjGeoData& rGeo)
SetTextDirty();
}
-SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// get XOR Poly as base
XPolyPolygon aTmpPolyPolygon(TakeXorPoly());
@@ -1134,11 +1134,11 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
SfxStyleSheet* pStyleSheet = GetStyleSheet();
// prepare group
- std::unique_ptr<SdrObjGroup,SdrObjectFreeOp> pGroup(new SdrObjGroup(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObjGroup> pGroup(new SdrObjGroup(getSdrModelFromSdrObject()));
// prepare parameters
basegfx::B2DPolyPolygon aPolyPoly;
- SdrPathObj* pPath;
+ rtl::Reference<SdrPathObj> pPath;
sal_uInt16 nCount(aTmpPolyPolygon.Count());
sal_uInt16 nLoopStart(0);
@@ -1155,7 +1155,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
aSet.Put(XLineStartWidthItem(0));
aSet.Put(XLineEndWidthItem(0));
nLoopStart = 1;
@@ -1177,7 +1177,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
aSet.Put(XLineEndWidthItem(nEndWidth));
aSet.Put(XLineStartWidthItem(0));
@@ -1192,7 +1192,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
aSet.Put(XLineEndWidthItem(0));
nLoopStart = 2;
@@ -1214,7 +1214,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
aSet.Put(XLineEndWidthItem(nEndWidth));
aSet.Put(XLineStartWidthItem(0));
@@ -1229,7 +1229,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
aSet.Put(XLineEndWidthItem(0));
nLoopStart = 2;
@@ -1247,7 +1247,7 @@ SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
- pGroup->GetSubList()->NbcInsertObject(pPath);
+ pGroup->GetSubList()->NbcInsertObject(pPath.get());
}
if(bAddText)
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 1dd55f057991..f5d12d76e79c 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -143,7 +143,7 @@ OUString SdrMediaObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralMEDIA);
}
-SdrMediaObj* SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrMediaObj(rTargetModel, *this);
}
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 5abb4c4c8d46..6419c1041061 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -760,6 +760,8 @@ SdrOle2Obj::SdrOle2Obj(
: SdrRectObj(rSdrModel, rNewRect),
mpImpl(new SdrOle2ObjImpl(false/*bFrame_*/, rNewObjRef))
{
+ osl_atomic_increment(&m_refCount);
+
mpImpl->aPersistName = rNewObjName;
if (mpImpl->mxObjRef.is() && (mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
@@ -769,6 +771,8 @@ SdrOle2Obj::SdrOle2Obj(
SetClosedObj(!ImplIsMathObj( mpImpl->mxObjRef.GetObject() ));
Init();
+
+ osl_atomic_decrement(&m_refCount);
}
OUString SdrOle2Obj::GetStyleString()
@@ -1200,14 +1204,14 @@ void SdrOle2Obj::Disconnect_Impl()
mpImpl->mbConnected = false;
}
-SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
+rtl::Reference<SdrObject> SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
{
const Graphic* pOLEGraphic = GetGraphic();
if(pOLEGraphic)
{
// #i118485# allow creating a SdrGrafObj representation
- SdrGrafObj* pClone = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pClone = new SdrGrafObj(
getSdrModelFromSdrObject(),
*pOLEGraphic);
@@ -1233,13 +1237,13 @@ SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
}
}
- return SdrObjectUniquePtr(pClone);
+ return rtl::Reference<SdrObject>(pClone);
}
else
{
// #i100710# pOLEGraphic may be zero (no visualisation available),
// so we need to use the OLE replacement graphic
- SdrRectObj* pClone = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pClone = new SdrRectObj(
getSdrModelFromSdrObject(),
GetSnapRect());
@@ -1255,14 +1259,14 @@ SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
pClone->SetMergedItem(XFillBmpTileItem(false));
pClone->SetMergedItem(XFillBmpStretchItem(false));
- return SdrObjectUniquePtr(pClone);
+ return rtl::Reference<SdrObject>(pClone);
}
}
-SdrObjectUniquePtr SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// #i118485# missing converter added
- SdrObjectUniquePtr pRetval = createSdrGrafObjReplacement(true);
+ rtl::Reference<SdrObject> pRetval = createSdrGrafObjReplacement(true);
if(pRetval)
{
@@ -1336,7 +1340,7 @@ void SdrOle2Obj::SetClosedObj( bool bIsClosed )
m_bClosedObj = bIsClosed;
}
-SdrObjectUniquePtr SdrOle2Obj::getFullDragClone() const
+rtl::Reference<SdrObject> SdrOle2Obj::getFullDragClone() const
{
// #i118485# use central replacement generator
return createSdrGrafObjReplacement(false);
@@ -1410,7 +1414,7 @@ OUString SdrOle2Obj::TakeObjNamePlural() const
return SvxResId(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
}
-SdrOle2Obj* SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrOle2Obj(rTargetModel, *this);
}
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index 800102aba2c9..8bd374fe6b45 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -151,7 +151,7 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
rInfo.bCanConvToPolyLineToArea=false;
}
-SdrPageObj* SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrPageObj(rTargetModel, *this);
}
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 9c8f3ce98d31..b304426bf647 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1825,7 +1825,7 @@ SdrObjKind SdrPathObj::GetObjIdentifier() const
return meKind;
}
-SdrPathObj* SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrPathObj(rTargetModel, *this);
}
@@ -2624,9 +2624,9 @@ sal_uInt32 SdrPathObj::NbcInsPoint(const Point& rPos, bool bNewObj)
return nNewHdl;
}
-SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
+rtl::Reference<SdrPathObj> SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
{
- SdrPathObj* pNewObj = nullptr;
+ rtl::Reference<SdrPathObj> pNewObj;
const basegfx::B2DPolyPolygon aLocalPolyPolygon(GetPathPoly());
sal_uInt32 nPoly, nPnt;
@@ -2658,7 +2658,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
basegfx::B2DPolygon aSplitPolyA(aCandidate, 0, nPnt + 1);
SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyA));
- pNewObj = CloneSdrObject(getSdrModelFromSdrObject());
+ pNewObj = SdrObject::Clone(*this, getSdrModelFromSdrObject());
basegfx::B2DPolygon aSplitPolyB(aCandidate, nPnt, nPointCount - nPnt);
pNewObj->SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyB));
}
@@ -2670,7 +2670,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
return pNewObj;
}
-SdrObjectUniquePtr SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// #i89784# check for FontWork with activated HideContour
const drawinglayer::attribute::SdrTextAttribute aText(
@@ -2678,11 +2678,11 @@ SdrObjectUniquePtr SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) c
const bool bHideContour(
!aText.isDefault() && !aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour());
- SdrObjectUniquePtr pRet;
+ rtl::Reference<SdrObject> pRet;
if(!bHideContour)
{
- SdrPathObjUniquePtr pPath = ImpConvertMakeObj(GetPathPoly(), IsClosed(), bBezier);
+ rtl::Reference<SdrPathObj> pPath = ImpConvertMakeObj(GetPathPoly(), IsClosed(), bBezier);
if(pPath->GetPathPoly().areControlPointsUsed())
{
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 7acf90b7bc94..989fe0685e6b 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -244,7 +244,7 @@ OUString SdrRectObj::TakeObjNamePlural() const
return SvxResId(pResId);
}
-SdrRectObj* SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrRectObj(rTargetModel, *this);
}
@@ -524,7 +524,7 @@ SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const
return aGP;
}
-SdrObjectUniquePtr SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
XPolygon aXP(ImpCalcXPoly(maRect,GetEckenradius()));
{ // TODO: this is only for the moment, until we have the new TakeContour()
@@ -534,7 +534,7 @@ SdrObjectUniquePtr SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) c
basegfx::B2DPolyPolygon aPolyPolygon(aXP.getB2DPolygon());
aPolyPolygon.removeDoublePoints();
- SdrObjectUniquePtr pRet;
+ rtl::Reference<SdrObject> pRet;
// small correction: Do not create something when no fill and no line. To
// be sure to not damage something with non-text frames, do this only
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index e80d29847a55..2b5fa5023345 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -206,9 +206,6 @@ SdrTextObj::SdrTextObj(
SdrTextObj::~SdrTextObj()
{
- SdrOutliner& rOutl(getSdrModelFromSdrObject().GetHitTestOutliner());
- if( rOutl.GetTextObj() == this )
- rOutl.SetTextObj( nullptr );
mpText.reset();
ImpDeregisterLink();
}
@@ -602,10 +599,9 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle
if(bShadowOn)
{
// force shadow off
- SdrObject* pCopy(CloneSdrObject(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrTextObj> pCopy = SdrObject::Clone(*this, getSdrModelFromSdrObject());
pCopy->SetMergedItem(makeSdrShadowItem(false));
*pContourPolyPolygon = pCopy->TakeContour();
- SdrObject::Free( pCopy );
}
else
{
@@ -1068,7 +1064,7 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrTextObj(rTargetModel, *this);
}
@@ -2047,9 +2043,9 @@ bool SdrTextObj::GetPreventChainable() const
return mbIsUnchainableClone || (GetNextLinkInChain() && GetNextLinkInChain()->IsInEditMode());
}
-SdrObjectUniquePtr SdrTextObj::getFullDragClone() const
+rtl::Reference<SdrObject> SdrTextObj::getFullDragClone() const
{
- SdrObjectUniquePtr pClone = SdrAttrObj::getFullDragClone();
+ rtl::Reference<SdrObject> pClone = SdrAttrObj::getFullDragClone();
SdrTextObj *pTextObjClone = dynamic_cast<SdrTextObj *>(pClone.get());
if (pTextObjClone != nullptr) {
// Avoid transferring of text for chainable object during dragging
diff --git a/svx/source/svdraw/svdotxln.cxx b/svx/source/svdraw/svdotxln.cxx
index 19953dcc6942..44a55fdb4ea2 100644
--- a/svx/source/svdraw/svdotxln.cxx
+++ b/svx/source/svdraw/svdotxln.cxx
@@ -266,8 +266,10 @@ void SdrTextObj::ImpRegisterLink()
void SdrTextObj::ImpDeregisterLink()
{
ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
+ if (!pData)
+ return;
sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
- if (pLinkManager!=nullptr && pData!=nullptr && pData->mpLink!=nullptr) { // don't register twice
+ if (pLinkManager!=nullptr && pData->mpLink!=nullptr) { // don't register twice
// when doing Remove, *pLink is deleted implicitly
pLinkManager->Remove( pData->mpLink.get() );
pData->mpLink=nullptr;
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 597bb8735a74..95947be80425 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -283,9 +283,9 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
}
-SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
+rtl::Reference<SdrObject> SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
{
- SdrObjectUniquePtr pRetval;
+ rtl::Reference<SdrObject> pRetval;
if(!ImpCanConvTextToCurve())
{
@@ -307,7 +307,7 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly
if(nResultCount)
{
// prepare own target
- SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ rtl::Reference<SdrObjGroup> pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
SdrObjList* pObjectList = pGroup->GetSubList();
// process results
@@ -336,7 +336,7 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly
// create ItemSet with object attributes
SfxItemSet aAttributeSet(GetObjectItemSet());
- SdrPathObj* pPathObj = nullptr;
+ rtl::Reference<SdrPathObj> pPathObj;
// always clear objectshadow; this is included in the extraction
aAttributeSet.Put(makeSdrShadowItem(false));
@@ -376,28 +376,23 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly
// apply prepared ItemSet and add to target
pPathObj->SetMergedItemSet(aAttributeSet);
- pObjectList->InsertObject(pPathObj);
+ pObjectList->InsertObject(pPathObj.get());
}
}
// postprocess; if no result and/or only one object, simplify
if(!pObjectList->GetObjCount())
{
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pGroup);
- SdrObject::Free(pTemp);
+ pGroup.clear();
}
else if(1 == pObjectList->GetObjCount())
{
- pRetval.reset(pObjectList->RemoveObject(0));
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pGroup);
- SdrObject::Free(pTemp);
+ pGroup.clear();
+ pRetval = pObjectList->RemoveObject(0);
}
else
{
- pRetval.reset(pGroup);
+ pRetval = pGroup;
}
}
@@ -405,7 +400,7 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly
}
-SdrObjectUniquePtr SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+rtl::Reference<SdrObject> SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
if(bAddText)
{
@@ -420,7 +415,7 @@ bool SdrTextObj::ImpCanConvTextToCurve() const
return !IsOutlText();
}
-SdrPathObjUniquePtr SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier) const
+rtl::Reference<SdrPathObj> SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier) const
{
SdrObjKind ePathKind = bClosed ? SdrObjKind::PathFill : SdrObjKind::PathLine;
basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon);
@@ -432,7 +427,7 @@ SdrPathObjUniquePtr SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon&
ePathKind = bClosed ? SdrObjKind::Polygon : SdrObjKind::PolyLine;
}
- SdrPathObjUniquePtr pPathObj(new SdrPathObj(
+ rtl::Reference<SdrPathObj> pPathObj(new SdrPathObj(
getSdrModelFromSdrObject(),
ePathKind,
std::move(aB2DPolyPolygon)));
@@ -454,14 +449,14 @@ SdrPathObjUniquePtr SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon&
return pPathObj;
}
-SdrObjectUniquePtr SdrTextObj::ImpConvertAddText(SdrObjectUniquePtr pObj, bool bBezier) const
+rtl::Reference<SdrObject> SdrTextObj::ImpConvertAddText(rtl::Reference<SdrObject> pObj, bool bBezier) const
{
if(!ImpCanConvTextToCurve())
{
return pObj;
}
- SdrObjectUniquePtr pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
+ rtl::Reference<SdrObject> pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
if(!pText)
{
@@ -477,17 +472,17 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertAddText(SdrObjectUniquePtr pObj, bool b
{
// is already group object, add partial shape in front
SdrObjList* pOL=pText->GetSubList();
- pOL->InsertObject(pObj.release(),0);
+ pOL->InsertObject(pObj.get(),0);
return pText;
}
else
{
// not yet a group, create one and add partial and new shapes
- std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> pGrp(new SdrObjGroup(getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObjGroup> pGrp(new SdrObjGroup(getSdrModelFromSdrObject()));
SdrObjList* pOL=pGrp->GetSubList();
- pOL->InsertObject(pObj.release());
- pOL->InsertObject(pText.release());
+ pOL->InsertObject(pObj.get());
+ pOL->InsertObject(pText.get());
return pGrp;
}
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
index b8e652a01d4b..09de889e33e2 100644
--- a/svx/source/svdraw/svdouno.cxx
+++ b/svx/source/svdraw/svdouno.cxx
@@ -280,7 +280,7 @@ OUString SdrUnoObj::TakeObjNamePlural() const
return SvxResId(STR_ObjNamePluralUno);
}
-SdrUnoObj* SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrUnoObj(rTargetModel, *this);
}
diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx
index 3737b1fdf268..1888fbbd3236 100644
--- a/svx/source/svdraw/svdoutl.cxx
+++ b/svx/source/svdraw/svdoutl.cxx
@@ -39,7 +39,7 @@ SdrOutliner::~SdrOutliner()
void SdrOutliner::SetTextObj( const SdrTextObj* pObj )
{
- if( pObj && pObj != mxWeakTextObj.get() )
+ if( pObj && pObj != mxWeakTextObj.get().get() )
{
SetUpdateLayout(false);
OutlinerMode nOutlinerMode2 = OutlinerMode::OutlineObject;
@@ -61,12 +61,12 @@ void SdrOutliner::SetTextObj( const SdrTextObj* pObj )
ClearPolygon();
}
- mxWeakTextObj.reset( const_cast< SdrTextObj* >(pObj) );
+ mxWeakTextObj = const_cast< SdrTextObj* >(pObj);
}
void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
{
- mxWeakTextObj.reset( const_cast< SdrTextObj* >(pObj) );
+ mxWeakTextObj = const_cast< SdrTextObj* >(pObj);
}
OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
@@ -75,8 +75,8 @@ OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara
bool bOk = false;
OUString aRet;
- if(mxWeakTextObj.is())
- bOk = mxWeakTextObj->CalcFieldValue(rField, nPara, nPos, false, rpTxtColor, rpFldColor, aRet);
+ if(auto pTextObj = mxWeakTextObj.get())
+ bOk = pTextObj->CalcFieldValue(rField, nPara, nPos, false, rpTxtColor, rpFldColor, aRet);
if (!bOk)
aRet = Outliner::CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor);
@@ -86,7 +86,7 @@ OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara
const SdrTextObj* SdrOutliner::GetTextObj() const
{
- return mxWeakTextObj.get();
+ return mxWeakTextObj.get().get();
}
bool SdrOutliner::hasEditViewCallbacks() const
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index f43e1d554be8..23193d6e4aa4 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -27,7 +27,7 @@
sdr::properties::BaseProperties& SdrVirtObj::GetProperties() const
{
- return rRefObj.GetProperties();
+ return mxRefObj->GetProperties();
}
@@ -41,22 +41,22 @@ SdrVirtObj::SdrVirtObj(
SdrModel& rSdrModel,
SdrObject& rNewObj)
: SdrObject(rSdrModel),
- rRefObj(rNewObj)
+ mxRefObj(&rNewObj)
{
m_bVirtObj=true; // this is only a virtual object
- rRefObj.AddReference(*this);
- m_bClosedObj=rRefObj.IsClosedObj();
+ mxRefObj->AddReference(*this);
+ m_bClosedObj = mxRefObj->IsClosedObj();
}
SdrVirtObj::SdrVirtObj(
SdrModel& rSdrModel, SdrVirtObj const & rSource)
: SdrObject(rSdrModel, rSource),
- rRefObj(rSource.rRefObj)
+ mxRefObj(rSource.mxRefObj)
{
m_bVirtObj=true; // this is only a virtual object
- m_bClosedObj=rRefObj.IsClosedObj();
+ m_bClosedObj = mxRefObj->IsClosedObj();
- rRefObj.AddReference(*this);
+ mxRefObj->AddReference(*this);
aSnapRect = rSource.aSnapRect;
m_aAnchor = rSource.m_aAnchor;
@@ -64,22 +64,22 @@ SdrVirtObj::SdrVirtObj(
SdrVirtObj::~SdrVirtObj()
{
- rRefObj.DelReference(*this);
+ mxRefObj->DelReference(*this);
}
const SdrObject& SdrVirtObj::GetReferencedObj() const
{
- return rRefObj;
+ return *mxRefObj;
}
SdrObject& SdrVirtObj::ReferencedObj()
{
- return rRefObj;
+ return *mxRefObj;
}
void SdrVirtObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
{
- m_bClosedObj=rRefObj.IsClosedObj();
+ m_bClosedObj = mxRefObj->IsClosedObj();
SetBoundAndSnapRectsDirty(); // TODO: Optimize this.
// Only a repaint here, rRefObj may have changed and broadcasts
@@ -93,27 +93,27 @@ void SdrVirtObj::NbcSetAnchorPos(const Point& rAnchorPos)
void SdrVirtObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
- rRefObj.TakeObjInfo(rInfo);
+ mxRefObj->TakeObjInfo(rInfo);
}
SdrInventor SdrVirtObj::GetObjInventor() const
{
- return rRefObj.GetObjInventor();
+ return mxRefObj->GetObjInventor();
}
SdrObjKind SdrVirtObj::GetObjIdentifier() const
{
- return rRefObj.GetObjIdentifier();
+ return mxRefObj->GetObjIdentifier();
}
SdrObjList* SdrVirtObj::GetSubList() const
{
- return rRefObj.GetSubList();
+ return mxRefObj->GetSubList();
}
const tools::Rectangle& SdrVirtObj::GetCurrentBoundRect() const
{
- auto aRectangle = rRefObj.GetCurrentBoundRect(); // TODO: Optimize this.
+ auto aRectangle = mxRefObj->GetCurrentBoundRect(); // TODO: Optimize this.
aRectangle += m_aAnchor;
setOutRectangleConst(aRectangle);
return m_aOutRect;
@@ -121,7 +121,7 @@ const tools::Rectangle& SdrVirtObj::GetCurrentBoundRect() const
const tools::Rectangle& SdrVirtObj::GetLastBoundRect() const
{
- auto aRectangle = rRefObj.GetLastBoundRect(); // TODO: Optimize this.
+ auto aRectangle = mxRefObj->GetLastBoundRect(); // TODO: Optimize this.
aRectangle += m_aAnchor;
setOutRectangleConst(aRectangle);
return m_aOutRect;
@@ -129,12 +129,12 @@ const tools::Rectangle& SdrVirtObj::GetLastBoundRect() const
void SdrVirtObj::RecalcBoundRect()
{
- tools::Rectangle aRectangle = rRefObj.GetCurrentBoundRect();
+ tools::Rectangle aRectangle = mxRefObj->GetCurrentBoundRect();
aRectangle += m_aAnchor;
setOutRectangle(aRectangle);
}
-SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrVirtObj(rTargetModel, *this);
// TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject
@@ -147,7 +147,7 @@ SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
OUString SdrVirtObj::TakeObjNameSingul() const
{
- OUString sName = "[" + rRefObj.TakeObjNameSingul() + "]";
+ OUString sName = "[" + mxRefObj->TakeObjNameSingul() + "]";
OUString aName(GetName());
if (!aName.isEmpty())
@@ -158,18 +158,18 @@ OUString SdrVirtObj::TakeObjNameSingul() const
OUString SdrVirtObj::TakeObjNamePlural() const
{
- return "[" + rRefObj.TakeObjNamePlural() + "]";
+ return "[" + mxRefObj->TakeObjNamePlural() + "]";
}
bool SdrVirtObj::HasLimitedRotation() const
{
// RotGrfFlyFrame: If true, this SdrObject supports only limited rotation
- return rRefObj.HasLimitedRotation();
+ return mxRefObj->HasLimitedRotation();
}
basegfx::B2DPolyPolygon SdrVirtObj::TakeXorPoly() const
{
- basegfx::B2DPolyPolygon aPolyPolygon(rRefObj.TakeXorPoly());
+ basegfx::B2DPolyPolygon aPolyPolygon(mxRefObj->TakeXorPoly());
if(m_aAnchor.X() || m_aAnchor.Y())
{
@@ -182,13 +182,13 @@ basegfx::B2DPolyPolygon SdrVirtObj::TakeXorPoly() const
sal_uInt32 SdrVirtObj::GetHdlCount() const
{
- return rRefObj.GetHdlCount();
+ return mxRefObj->GetHdlCount();
}
void SdrVirtObj::AddToHdlList(SdrHdlList& rHdlList) const
{
SdrHdlList tempList(nullptr);
- rRefObj.AddToHdlList(tempList);
+ mxRefObj->AddToHdlList(tempList);
for (size_t i=0; i<tempList.GetHdlCount(); ++i)
{
SdrHdl* pHdl = tempList.GetHdl(i);
@@ -201,7 +201,7 @@ void SdrVirtObj::AddToHdlList(SdrHdlList& rHdlList) const
void SdrVirtObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const
{
SdrHdlList tempList(nullptr);
- rRefObj.AddToPlusHdlList(tempList, rHdl);
+ mxRefObj->AddToPlusHdlList(tempList, rHdl);
for (size_t i=0; i<tempList.GetHdlCount(); ++i)
{
SdrHdl* pHdl = tempList.GetHdl(i);
@@ -213,7 +213,7 @@ void SdrVirtObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const
bool SdrVirtObj::hasSpecialDrag() const
{
- return rRefObj.hasSpecialDrag();
+ return mxRefObj->hasSpecialDrag();
}
bool SdrVirtObj::supportsFullDrag() const
@@ -221,10 +221,10 @@ bool SdrVirtObj::supportsFullDrag() const
return false;
}
-SdrObjectUniquePtr SdrVirtObj::getFullDragClone() const
+rtl::Reference<SdrObject> SdrVirtObj::getFullDragClone() const
{
SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
- return SdrObjectUniquePtr(new SdrGrafObj(
+ return rtl::Reference<SdrObject>(new SdrGrafObj(
getSdrModelFromSdrObject(),
SdrDragView::GetObjGraphic(rReferencedObject),
GetLogicRect()));
@@ -232,54 +232,54 @@ SdrObjectUniquePtr SdrVirtObj::getFullDragClone() const
bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const
{
- return rRefObj.beginSpecialDrag(rDrag);
+ return mxRefObj->beginSpecialDrag(rDrag);
}
bool SdrVirtObj::applySpecialDrag(SdrDragStat& rDrag)
{
- return rRefObj.applySpecialDrag(rDrag);
+ return mxRefObj->applySpecialDrag(rDrag);
}
basegfx::B2DPolyPolygon SdrVirtObj::getSpecialDragPoly(const SdrDragStat& rDrag) const
{
- return rRefObj.getSpecialDragPoly(rDrag);
+ return mxRefObj->getSpecialDragPoly(rDrag);
// TODO: we don't handle offsets yet!
}
OUString SdrVirtObj::getSpecialDragComment(const SdrDragStat& rDrag) const
{
- return rRefObj.getSpecialDragComment(rDrag);
+ return mxRefObj->getSpecialDragComment(rDrag);
}
bool SdrVirtObj::BegCreate(SdrDragStat& rStat)
{
- return rRefObj.BegCreate(rStat);
+ return mxRefObj->BegCreate(rStat);
}
bool SdrVirtObj::MovCreate(SdrDragStat& rStat)
{
- return rRefObj.MovCreate(rStat);
+ return mxRefObj->MovCreate(rStat);
}
bool SdrVirtObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
{
- return rRefObj.EndCreate(rStat,eCmd);
+ return mxRefObj->EndCreate(rStat,eCmd);
}
bool SdrVirtObj::BckCreate(SdrDragStat& rStat)
{
- return rRefObj.BckCreate(rStat);
+ return mxRefObj->BckCreate(rStat);
}
void SdrVirtObj::BrkCreate(SdrDragStat& rStat)
{
- rRefObj.BrkCreate(rStat);
+ mxRefObj->BrkCreate(rStat);
}
basegfx::B2DPolyPolygon SdrVirtObj::TakeCreatePoly(const SdrDragStat& rDrag) const
{
- return rRefObj.TakeCreatePoly(rDrag);
+ return mxRefObj->TakeCreatePoly(rDrag);
// TODO: we don't handle offsets yet!
}
@@ -292,25 +292,25 @@ void SdrVirtObj::NbcMove(const Size& rSiz)
void SdrVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
- rRefObj.NbcResize(rRef-m_aAnchor,xFact,yFact);
+ mxRefObj->NbcResize(rRef-m_aAnchor,xFact,yFact);
SetBoundAndSnapRectsDirty();
}
void SdrVirtObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
{
- rRefObj.NbcRotate(rRef-m_aAnchor,nAngle,sn,cs);
+ mxRefObj->NbcRotate(rRef-m_aAnchor,nAngle,sn,cs);
SetBoundAndSnapRectsDirty();
}
void SdrVirtObj::NbcMirror(const Point& rRef1, const Point& rRef2)
{
- rRefObj.NbcMirror(rRef1-m_aAnchor,rRef2-m_aAnchor);
+ mxRefObj->NbcMirror(rRef1-m_aAnchor,rRef2-m_aAnchor);
SetBoundAndSnapRectsDirty();
}
void SdrVirtObj::NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
{
- rRefObj.NbcShear(rRef-m_aAnchor,nAngle,tn,bVShear);
+ mxRefObj->NbcShear(rRef-m_aAnchor,nAngle,tn,bVShear);
SetBoundAndSnapRectsDirty();
}
@@ -330,7 +330,7 @@ void SdrVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction
{
if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- rRefObj.Resize(rRef-m_aAnchor,xFact,yFact, bUnsetRelative);
+ mxRefObj->Resize(rRef-m_aAnchor,xFact,yFact, bUnsetRelative);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -340,7 +340,7 @@ void SdrVirtObj::Rotate(const Point& rRef, Degree100 nAngle, double sn, double c
{
if (nAngle) {
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- rRefObj.Rotate(rRef-m_aAnchor,nAngle,sn,cs);
+ mxRefObj->Rotate(rRef-m_aAnchor,nAngle,sn,cs);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -349,7 +349,7 @@ void SdrVirtObj::Rotate(const Point& rRef, Degree100 nAngle, double sn, double c
void SdrVirtObj::Mirror(const Point& rRef1, const Point& rRef2)
{
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- rRefObj.Mirror(rRef1-m_aAnchor,rRef2-m_aAnchor);
+ mxRefObj->Mirror(rRef1-m_aAnchor,rRef2-m_aAnchor);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -358,7 +358,7 @@ void SdrVirtObj::Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVSh
{
if (nAngle) {
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- rRefObj.Shear(rRef-m_aAnchor,nAngle,tn,bVShear);
+ mxRefObj->Shear(rRef-m_aAnchor,nAngle,tn,bVShear);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -367,13 +367,13 @@ void SdrVirtObj::Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVSh
void SdrVirtObj::RecalcSnapRect()
{
- aSnapRect=rRefObj.GetSnapRect();
+ aSnapRect=mxRefObj->GetSnapRect();
aSnapRect+=m_aAnchor;
}
const tools::Rectangle& SdrVirtObj::GetSnapRect() const
{
- const_cast<SdrVirtObj*>(this)->aSnapRect=rRefObj.GetSnapRect();
+ const_cast<SdrVirtObj*>(this)->aSnapRect=mxRefObj->GetSnapRect();
const_cast<SdrVirtObj*>(this)->aSnapRect+=m_aAnchor;
return aSnapRect;
}
@@ -383,7 +383,7 @@ void SdrVirtObj::SetSnapRect(const tools::Rectangle& rRect)
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
tools::Rectangle aR(rRect);
aR-=m_aAnchor;
- rRefObj.SetSnapRect(aR);
+ mxRefObj->SetSnapRect(aR);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -393,13 +393,13 @@ void SdrVirtObj::NbcSetSnapRect(const tools::Rectangle& rRect)
tools::Rectangle aR(rRect);
aR-=m_aAnchor;
SetBoundAndSnapRectsDirty();
- rRefObj.NbcSetSnapRect(aR);
+ mxRefObj->NbcSetSnapRect(aR);
}
const tools::Rectangle& SdrVirtObj::GetLogicRect() const
{
- const_cast<SdrVirtObj*>(this)->aSnapRect=rRefObj.GetLogicRect(); // An abuse of aSnapRect!
+ const_cast<SdrVirtObj*>(this)->aSnapRect=mxRefObj->GetLogicRect(); // An abuse of aSnapRect!
const_cast<SdrVirtObj*>(this)->aSnapRect+=m_aAnchor; // If there's trouble, we need another Rectangle Member (or a Heap).
return aSnapRect;
}
@@ -409,7 +409,7 @@ void SdrVirtObj::SetLogicRect(const tools::Rectangle& rRect)
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
tools::Rectangle aR(rRect);
aR-=m_aAnchor;
- rRefObj.SetLogicRect(aR);
+ mxRefObj->SetLogicRect(aR);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -419,83 +419,83 @@ void SdrVirtObj::NbcSetLogicRect(const tools::Rectangle& rRect)
tools::Rectangle aR(rRect);
aR-=m_aAnchor;
SetBoundAndSnapRectsDirty();
- rRefObj.NbcSetLogicRect(aR);
+ mxRefObj->NbcSetLogicRect(aR);
}
Degree100 SdrVirtObj::GetRotateAngle() const
{
- return rRefObj.GetRotateAngle();
+ return mxRefObj->GetRotateAngle();
}
Degree100 SdrVirtObj::GetShearAngle(bool bVertical) const
{
- return rRefObj.GetShearAngle(bVertical);
+ return mxRefObj->GetShearAngle(bVertical);
}
sal_uInt32 SdrVirtObj::GetSnapPointCount() const
{
- return rRefObj.GetSnapPointCount();
+ return mxRefObj->GetSnapPointCount();
}
Point SdrVirtObj::GetSnapPoint(sal_uInt32 i) const
{
- Point aP(rRefObj.GetSnapPoint(i));
+ Point aP(mxRefObj->GetSnapPoint(i));
aP+=m_aAnchor;
return aP;
}
bool SdrVirtObj::IsPolyObj() const
{
- return rRefObj.IsPolyObj();
+ return mxRefObj->IsPolyObj();
}
sal_uInt32 SdrVirtObj::GetPointCount() const
{
- return rRefObj.GetPointCount();
+ return mxRefObj->GetPointCount();
}
Point SdrVirtObj::GetPoint(sal_uInt32 i) const
{
- return rRefObj.GetPoint(i) + m_aAnchor;
+ return mxRefObj->GetPoint(i) + m_aAnchor;
}
void SdrVirtObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
{
Point aP(rPnt);
aP-=m_aAnchor;
- rRefObj.SetPoint(aP,i);
+ mxRefObj->SetPoint(aP,i);
SetBoundAndSnapRectsDirty();
}
std::unique_ptr<SdrObjGeoData> SdrVirtObj::NewGeoData() const
{
- return rRefObj.NewGeoData();
+ return mxRefObj->NewGeoData();
}
void SdrVirtObj::SaveGeoData(SdrObjGeoData& rGeo) const
{
- rRefObj.SaveGeoData(rGeo);
+ mxRefObj->SaveGeoData(rGeo);
}
void SdrVirtObj::RestoreGeoData(const SdrObjGeoData& rGeo)
{
- rRefObj.RestoreGeoData(rGeo);
+ mxRefObj->RestoreGeoData(rGeo);
SetBoundAndSnapRectsDirty();
}
std::unique_ptr<SdrObjGeoData> SdrVirtObj::GetGeoData() const
{
- return rRefObj.GetGeoData();
+ return mxRefObj->GetGeoData();
}
void SdrVirtObj::SetGeoData(const SdrObjGeoData& rGeo)
{
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- rRefObj.SetGeoData(rGeo);
+ mxRefObj->SetGeoData(rGeo);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
@@ -503,32 +503,32 @@ void SdrVirtObj::SetGeoData(const SdrObjGeoData& rGeo)
void SdrVirtObj::NbcReformatText()
{
- rRefObj.NbcReformatText();
+ mxRefObj->NbcReformatText();
}
bool SdrVirtObj::HasMacro() const
{
- return rRefObj.HasMacro();
+ return mxRefObj->HasMacro();
}
SdrObject* SdrVirtObj::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
{
- return rRefObj.CheckMacroHit(rRec); // TODO: positioning offset
+ return mxRefObj->CheckMacroHit(rRec); // TODO: positioning offset
}
PointerStyle SdrVirtObj::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
{
- return rRefObj.GetMacroPointer(rRec); // TODO: positioning offset
+ return mxRefObj->GetMacroPointer(rRec); // TODO: positioning offset
}
void SdrVirtObj::PaintMacro(OutputDevice& rOut, const tools::Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
{
- rRefObj.PaintMacro(rOut,rDirtyRect,rRec); // TODO: positioning offset
+ mxRefObj->PaintMacro(rOut,rDirtyRect,rRec); // TODO: positioning offset
}
bool SdrVirtObj::DoMacro(const SdrObjMacroHitRec& rRec)
{
- return rRefObj.DoMacro(rRec); // TODO: positioning offset
+ return mxRefObj->DoMacro(rRec); // TODO: positioning offset
}
Point SdrVirtObj::GetOffset() const
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 3ab2373f6fab..f5919d8a834c 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -23,6 +23,7 @@
#include <unordered_set>
#include <svx/svdpage.hxx>
+#include <svx/unoshape.hxx>
#include <o3tl/safeint.hxx>
#include <string.h>
@@ -72,7 +73,7 @@ void SdrObjList::impClearSdrObjList(bool bBroadcast)
while(!maList.empty())
{
// remove last object from list
- SdrObject* pObj(maList.back());
+ rtl::Reference<SdrObject> pObj(maList.back());
RemoveObjectFromContainer(maList.size()-1);
// flushViewObjectContacts() is done since SdrObject::Free is not guaranteed
@@ -91,9 +92,7 @@ void SdrObjList::impClearSdrObjList(bool bBroadcast)
SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, getSdrPageFromSdrObjList());
pObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
-
- // delete the object itself
- SdrObject::Free( pObj );
+ pObj->setParentOfSdrObject(nullptr);
}
if(bBroadcast && nullptr != pSdrModelFromRemovedSdrObject)
@@ -111,7 +110,13 @@ void SdrObjList::ClearSdrObjList()
SdrObjList::~SdrObjList()
{
// clear SdrObjects without broadcasting
- impClearSdrObjList(false);
+ while(!maList.empty())
+ {
+ // remove last object from list
+ SdrObject& rObj = *maList.back();
+ rObj.setParentOfSdrObject(nullptr);
+ maList.pop_back();
+ }
}
SdrPage* SdrObjList::getSdrPageFromSdrObjList() const
@@ -149,11 +154,11 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
for (size_t no(0); no < nCount; ++no)
{
SdrObject* pSO(rSrcList.GetObj(no));
- SdrObject* pDO(pSO->CloneSdrObject(rTargetSdrModel));
+ rtl::Reference<SdrObject> pDO(pSO->CloneSdrObject(rTargetSdrModel));
- if(nullptr != pDO)
+ if(pDO)
{
- NbcInsertObject(pDO, SAL_MAX_SIZE);
+ NbcInsertObject(pDO.get(), SAL_MAX_SIZE);
}
else
{
@@ -230,7 +235,7 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
void SdrObjList::RecalcObjOrdNums()
{
size_t no=0;
- for (SdrObject* pObj : maList)
+ for (const rtl::Reference<SdrObject>& pObj : maList)
pObj->SetOrdNum(no++);
mbObjOrdNumsDirty=false;
}
@@ -364,7 +369,7 @@ void SdrObjList::InsertObject(SdrObject* pObj, size_t nPos)
pObj->getSdrModelFromSdrObject().SetChanged();
}
-SdrObject* SdrObjList::NbcRemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> SdrObjList::NbcRemoveObject(size_t nObjNum)
{
if (nObjNum >= maList.size())
{
@@ -373,7 +378,7 @@ SdrObject* SdrObjList::NbcRemoveObject(size_t nObjNum)
}
const size_t nCount = GetObjCount();
- SdrObject* pObj=maList[nObjNum];
+ rtl::Reference<SdrObject> pObj=maList[nObjNum];
RemoveObjectFromContainer(nObjNum);
DBG_ASSERT(pObj!=nullptr,"Could not find object to remove.");
@@ -403,7 +408,7 @@ SdrObject* SdrObjList::NbcRemoveObject(size_t nObjNum)
return pObj;
}
-SdrObject* SdrObjList::RemoveObject(size_t nObjNum)
+rtl::Reference<SdrObject> SdrObjList::RemoveObject(size_t nObjNum)
{
if (nObjNum >= maList.size())
{
@@ -412,7 +417,7 @@ SdrObject* SdrObjList::RemoveObject(size_t nObjNum)
}
const size_t nCount = GetObjCount();
- SdrObject* pObj=maList[nObjNum];
+ rtl::Reference<SdrObject> pObj=maList[nObjNum];
RemoveObjectFromContainer(nObjNum);
DBG_ASSERT(pObj!=nullptr,"Object to remove not found.");
@@ -459,7 +464,7 @@ SdrObject* SdrObjList::RemoveObject(size_t nObjNum)
return pObj;
}
-SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
+rtl::Reference<SdrObject> SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
{
if (nObjNum >= maList.size())
{
@@ -472,7 +477,7 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
return nullptr;
}
- SdrObject* pObj=maList[nObjNum];
+ rtl::Reference<SdrObject> pObj=maList[nObjNum];
DBG_ASSERT(pObj!=nullptr,"SdrObjList::ReplaceObject: Could not find object to remove.");
if (pObj!=nullptr) {
DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: the object does not have status Inserted.");
@@ -532,8 +537,8 @@ SdrObject* SdrObjList::SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
return nullptr;
}
- SdrObject* pObj=maList[nOldObjNum];
- if (nOldObjNum==nNewObjNum) return pObj;
+ rtl::Reference<SdrObject> pObj=maList[nOldObjNum];
+ if (nOldObjNum==nNewObjNum) return pObj.get();
DBG_ASSERT(pObj!=nullptr,"SdrObjList::SetObjectOrdNum: Object not found.");
if (pObj!=nullptr) {
DBG_ASSERT(pObj->IsInserted(),"SdrObjList::SetObjectOrdNum: the object does not have status Inserted.");
@@ -552,7 +557,7 @@ SdrObject* SdrObjList::SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
pObj->getSdrModelFromSdrObject().Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
pObj->getSdrModelFromSdrObject().SetChanged();
}
- return pObj;
+ return pObj.get();
}
void SdrObjList::SetExistingObjectOrdNum(SdrObject* pObj, size_t nNewObjNum)
@@ -569,7 +574,7 @@ void SdrObjList::SetExistingObjectOrdNum(SdrObject* pObj, size_t nNewObjNum)
// Update the navigation positions.
if (HasObjectNavigationOrder())
{
- tools::WeakReference<SdrObject> aReference (pObj);
+ unotools::WeakReference<SdrObject> aReference (pObj);
auto iObject = ::std::find(
mxNavigationOrder->begin(),
mxNavigationOrder->end(),
@@ -635,7 +640,7 @@ void SdrObjList::sort( std::vector<sal_Int32>& sortOrder)
// example maList [T T S T T] ( T T = shape with textbox, S = just a shape )
// (shapes at positions 0 and 2 have a textbox)
- std::deque<SdrObject*> aNewList(maList.size());
+ std::deque<rtl::Reference<SdrObject>> aNewList(maList.size());
std::set<sal_Int32> aShapesWithTextbox;
std::vector<sal_Int32> aIncrements;
std::vector<sal_Int32> aDuplicates;
@@ -818,7 +823,7 @@ size_t SdrObjList::GetObjCount() const
SdrObject* SdrObjList::GetObj(size_t nNum) const
{
if (nNum < maList.size())
- return maList[nNum];
+ return maList[nNum].get();
return nullptr;
}
@@ -870,8 +875,8 @@ void SdrObjList::UnGroupObj( size_t nObjNum )
const size_t nCount = pSrcLst->GetObjCount();
for( size_t i=0; i<nCount; ++i )
{
- SdrObject* pObj = pSrcLst->RemoveObject(0);
- InsertObject(pObj, nInsertPos);
+ rtl::Reference<SdrObject> pObj = pSrcLst->RemoveObject(0);
+ InsertObject(pObj.get(), nInsertPos);
++nInsertPos;
}
@@ -900,7 +905,7 @@ void SdrObjList::SetObjectNavigationPosition (
OSL_ASSERT(bool(mxNavigationOrder));
OSL_ASSERT( mxNavigationOrder->size() == maList.size());
- tools::WeakReference<SdrObject> aReference (&rObject);
+ unotools::WeakReference<SdrObject> aReference (&rObject);
// Look up the object whose navigation position is to be changed.
auto iObject = ::std::find(
@@ -946,7 +951,7 @@ SdrObject* SdrObjList::GetObjectForNavigationPosition (const sal_uInt32 nNavigat
OSL_ASSERT(nNavigationPosition < mxNavigationOrder->size());
}
else
- return (*mxNavigationOrder)[nNavigationPosition].get();
+ return (*mxNavigationOrder)[nNavigationPosition].get().get();
}
else
{
@@ -957,7 +962,7 @@ SdrObject* SdrObjList::GetObjectForNavigationPosition (const sal_uInt32 nNavigat
OSL_ASSERT(nNavigationPosition < maList.size());
}
else
- return maList[nNavigationPosition];
+ return maList[nNavigationPosition].get();
}
return nullptr;
}
@@ -981,7 +986,7 @@ bool SdrObjList::RecalcNavigationPositions()
sal_uInt32 nIndex (0);
for (auto& rpObject : *mxNavigationOrder)
{
- rpObject->SetNavigationPosition(nIndex);
+ rpObject.get()->SetNavigationPosition(nIndex);
++nIndex;
}
}
@@ -1000,7 +1005,7 @@ void SdrObjList::SetNavigationOrder (const uno::Reference<container::XIndexAcces
return;
if (!mxNavigationOrder)
- mxNavigationOrder = std::vector<tools::WeakReference<SdrObject>>(nCount);
+ mxNavigationOrder = std::vector<unotools::WeakReference<SdrObject>>(nCount);
for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
{
@@ -1063,7 +1068,7 @@ void SdrObjList::ReplaceObjectInContainer (
// not transferred to the new object so erase the former and append
// the later object from/to the navigation order.
OSL_ASSERT(nObjectPosition < maList.size());
- tools::WeakReference<SdrObject> aReference (maList[nObjectPosition]);
+ unotools::WeakReference<SdrObject> aReference (maList[nObjectPosition].get());
auto iObject = ::std::find(
mxNavigationOrder->begin(),
mxNavigationOrder->end(),
@@ -1093,7 +1098,7 @@ void SdrObjList::RemoveObjectFromContainer (
// Update the navigation positions.
if (HasObjectNavigationOrder())
{
- tools::WeakReference<SdrObject> aReference (maList[nObjectPosition]);
+ unotools::WeakReference<SdrObject> aReference (maList[nObjectPosition]);
auto iObject = ::std::find(
mxNavigationOrder->begin(),
mxNavigationOrder->end(),
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index fb608bd2c5cf..56df7d94b437 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -247,9 +247,9 @@ size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, int nPageNumbe
// insert all objects cached in aTmpList now into rOL from nInsPos
nInsPos = std::min(nInsPos, rOL.GetObjCount());
- for (SdrObject* pObj : maTmpList)
+ for (rtl::Reference<SdrObject>& pObj : maTmpList)
{
- rOL.NbcInsertObject(pObj, nInsPos);
+ rOL.NbcInsertObject(pObj.get(), nInsPos);
nInsPos++;
if (pProgrInfo)
@@ -396,8 +396,9 @@ void ImpSdrPdfImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
}
}
-void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
+void ImpSdrPdfImport::InsertObj(SdrObject* pObj1, bool bScale)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if (bScale && !maScaleRect.IsEmpty())
{
if (mbSize)
@@ -417,8 +418,8 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
const basegfx::B2DRange aOldRange(aPoly.getB2DRange());
const SdrLayerID aOldLayer(pObj->GetLayer());
const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
- const SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(pObj);
- const SdrTextObj* pSdrTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ const SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(pObj.get());
+ const SdrTextObj* pSdrTextObj = dynamic_cast<SdrTextObj*>(pObj.get());
if (pSdrTextObj && pSdrTextObj->HasText())
{
@@ -433,7 +434,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
// no overlap -> completely outside
if (!aClipRange.overlaps(aTextRange))
{
- SdrObject::Free(pObj);
+ pObj.clear();
break;
}
@@ -446,9 +447,8 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
// here text needs to be clipped; to do so, convert to SdrObjects with polygons
// and add these recursively. Delete original object, do not add in this run
- SdrObjectUniquePtr pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
- SdrObject::Free(pObj);
-
+ rtl::Reference<SdrObject> pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
+ pObj.clear();
if (pConverted)
{
// recursively add created conversion; per definition this shall not
@@ -464,12 +464,12 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
SdrObject* pCandidate = aIter.Next();
OSL_ENSURE(pCandidate && dynamic_cast<SdrObjGroup*>(pCandidate) == nullptr,
"SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
- SdrObject* pNewClone(
+ rtl::Reference<SdrObject> pNewClone(
pCandidate->CloneSdrObject(pCandidate->getSdrModelFromSdrObject()));
if (pNewClone)
{
- InsertObj(pNewClone, false);
+ InsertObj(pNewClone.get(), false);
}
else
{
@@ -490,7 +490,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
aBitmapEx = pSdrGrafObj->GetGraphic().GetBitmapEx();
}
- SdrObject::Free(pObj);
+ pObj.clear();
if (!aOldRange.isEmpty())
{
@@ -564,7 +564,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
if (!bVisible)
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj.get());
if (pTextObj && pTextObj->HasText())
{
@@ -574,7 +574,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
if (!bVisible)
{
- SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pObj);
+ SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pObj.get());
if (pGrafObj)
{
@@ -585,15 +585,11 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
}
}
- if (!bVisible)
- {
- SdrObject::Free(pObj);
- }
- else
+ if (bVisible)
{
maTmpList.push_back(pObj);
- if (dynamic_cast<SdrPathObj*>(pObj))
+ if (dynamic_cast<SdrPathObj*>(pObj.get()))
{
const bool bClosed(pObj->IsClosedObj());
@@ -611,7 +607,7 @@ bool ImpSdrPdfImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygo
// #i73407# reformulation to use new B2DPolygon classes
if (mbLastObjWasPolyWithoutLine)
{
- SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1] : nullptr;
+ SdrObject* pTmpObj = !maTmpList.empty() ? maTmpList[maTmpList.size() - 1].get() : nullptr;
SdrPathObj* pLastPoly = dynamic_cast<SdrPathObj*>(pTmpObj);
if (pLastPoly)
@@ -799,7 +795,7 @@ void ImpSdrPdfImport::InsertTextObject(const Point& rPos, const Size& rSize, con
aPosition.AdjustY(-nTextHeight);
tools::Rectangle aTextRect(aPosition, aSize);
- SdrRectObj* pText = new SdrRectObj(*mpModel, SdrObjKind::Text, aTextRect);
+ rtl::Reference<SdrRectObj> pText = new SdrRectObj(*mpModel, SdrObjKind::Text, aTextRect);
pText->SetMergedItem(makeSdrTextUpperDistItem(0));
pText->SetMergedItem(makeSdrTextLowerDistItem(0));
@@ -820,7 +816,7 @@ void ImpSdrPdfImport::InsertTextObject(const Point& rPos, const Size& rSize, con
pText->SetLayer(mnLayer);
pText->NbcSetText(rStr);
- SetAttributes(pText, true);
+ SetAttributes(pText.get(), true);
pText->SetSnapRect(aTextRect);
if (!aFont.IsTransparent())
@@ -833,7 +829,7 @@ void ImpSdrPdfImport::InsertTextObject(const Point& rPos, const Size& rSize, con
Degree100 nAngle = to<Degree100>(aFont.GetOrientation());
if (nAngle)
pText->SdrAttrObj::NbcRotate(aPosition, nAngle);
- InsertObj(pText, false);
+ InsertObj(pText.get(), false);
}
void ImpSdrPdfImport::MapScaling()
@@ -847,7 +843,7 @@ void ImpSdrPdfImport::MapScaling()
{
for (size_t i = mnMapScalingOfs; i < nCount; i++)
{
- SdrObject* pObj = maTmpList[i];
+ SdrObject* pObj = maTmpList[i].get();
pObj->NbcMove(Size(aMapOrg.X(), aMapOrg.Y()));
}
@@ -908,12 +904,12 @@ void ImpSdrPdfImport::ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> co
aRect.AdjustRight(1);
aRect.AdjustBottom(1);
- SdrGrafObj* pGraf = new SdrGrafObj(*mpModel, Graphic(aBitmap), aRect);
+ rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(*mpModel, Graphic(aBitmap), aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE));
- InsertObj(pGraf);
+ InsertObj(pGraf.get());
}
void ImpSdrPdfImport::ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
@@ -1023,9 +1019,10 @@ void ImpSdrPdfImport::ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aPolyPoly))
{
- SdrPathObj* pPath = new SdrPathObj(*mpModel, SdrObjKind::Polygon, std::move(aPolyPoly));
- SetAttributes(pPath);
- InsertObj(pPath, false);
+ rtl::Reference<SdrPathObj> pPath
+ = new SdrPathObj(*mpModel, SdrObjKind::Polygon, std::move(aPolyPoly));
+ SetAttributes(pPath.get());
+ InsertObj(pPath.get(), false);
}
}
diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx
index bcf9168a47cf..b7365ea3b047 100644
--- a/svx/source/svdraw/svdpoev.cxx
+++ b/svx/source/svdraw/svdpoev.cxx
@@ -322,11 +322,6 @@ void SdrPolyEditView::DeleteMarkedPoints()
if( bUndo )
AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) );
pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum());
- if( !bUndo )
- {
- SdrObject* pObj = pPath;
- SdrObject::Free(pObj);
- }
}
}
}
@@ -367,14 +362,14 @@ void SdrPolyEditView::RipUpAtMarkedPoints()
for(SdrUShortCont::const_reverse_iterator it = rPts.rbegin(); it != rPts.rend(); ++it)
{
sal_uInt32 nNewPt0Idx(0);
- SdrObject* pNewObj = pObj->RipPoint(*it, nNewPt0Idx);
+ rtl::Reference<SdrPathObj> pNewObj = pObj->RipPoint(*it, nNewPt0Idx);
if(pNewObj)
{
- pM->GetPageView()->GetObjList()->InsertObject(pNewObj, pObj->GetOrdNum() + 1);
+ pM->GetPageView()->GetObjList()->InsertObject(pNewObj.get(), pObj->GetOrdNum() + 1);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
- MarkObj(pNewObj, pM->GetPageView(), false, true);
+ MarkObj(pNewObj.get(), pM->GetPageView(), false, true);
}
if(nNewPt0Idx)
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 9d104230b36e..7fe649ea6648 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -196,10 +196,12 @@ OUString SdrUndoGroup::GetSdrRepeatComment() const
SdrUndoObj::SdrUndoObj(SdrObject& rNewObj)
: SdrUndoAction(rNewObj.getSdrModelFromSdrObject())
- ,pObj(&rNewObj)
+ ,mxObj(&rNewObj)
{
}
+SdrUndoObj::~SdrUndoObj() {}
+
OUString SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject, TranslateId pStrCacheID, bool bRepeat )
{
const OUString rStr {SvxResId(pStrCacheID)};
@@ -216,18 +218,18 @@ OUString SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject
OUString SdrUndoObj::ImpGetDescriptionStr(TranslateId pStrCacheID, bool bRepeat) const
{
- if ( pObj )
- return GetDescriptionStringForObject( *pObj, pStrCacheID, bRepeat );
+ if ( mxObj )
+ return GetDescriptionStringForObject( *mxObj, pStrCacheID, bRepeat );
return OUString();
}
// common call method for possible change of the page when UNDO/REDO is triggered
void SdrUndoObj::ImpShowPageOfThisObject()
{
- if(pObj && pObj->IsInserted() && pObj->getSdrPageFromSdrObject())
+ if(mxObj && mxObj->IsInserted() && mxObj->getSdrPageFromSdrObject())
{
- SdrHint aHint(SdrHintKind::SwitchToPage, *pObj, pObj->getSdrPageFromSdrObject());
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ SdrHint aHint(SdrHintKind::SwitchToPage, *mxObj, mxObj->getSdrPageFromSdrObject());
+ mxObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
}
@@ -255,12 +257,12 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
SdrObjList* pOL = rNewObj.GetSubList();
bool bIsGroup(pOL!=nullptr && pOL->GetObjCount());
- bool bIs3DScene(bIsGroup && dynamic_cast< E3dScene* >(pObj) != nullptr);
+ bool bIs3DScene(bIsGroup && dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
if(bIsGroup)
{
// it's a group object!
- pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
+ pUndoGroup.reset(new SdrUndoGroup(mxObj->getSdrModelFromSdrObject()));
const size_t nObjCount(pOL->GetObjCount());
for(size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
@@ -273,14 +275,14 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
if(bIsGroup && !bIs3DScene)
return;
- moUndoSet.emplace( pObj->GetMergedItemSet() );
+ moUndoSet.emplace( mxObj->GetMergedItemSet() );
if(bStyleSheet)
- mxUndoStyleSheet = pObj->GetStyleSheet();
+ mxUndoStyleSheet = mxObj->GetStyleSheet();
if(bSaveText)
{
- auto p = pObj->GetOutlinerParaObject();
+ auto p = mxObj->GetOutlinerParaObject();
if(p)
pTextUndo = *p;
}
@@ -297,8 +299,8 @@ SdrUndoAttrObj::~SdrUndoAttrObj()
void SdrUndoAttrObj::Undo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pObj);
- bool bIs3DScene(dynamic_cast< E3dScene* >(pObj) != nullptr);
+ E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
+ bool bIs3DScene(dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
// Trigger PageChangeCall
ImpShowPageOfThisObject();
@@ -309,15 +311,15 @@ void SdrUndoAttrObj::Undo()
{
bHaveToTakeRedoSet = false;
- moRedoSet.emplace( pObj->GetMergedItemSet() );
+ moRedoSet.emplace( mxObj->GetMergedItemSet() );
if(bStyleSheet)
- mxRedoStyleSheet = pObj->GetStyleSheet();
+ mxRedoStyleSheet = mxObj->GetStyleSheet();
if(pTextUndo)
{
// #i8508#
- auto p = pObj->GetOutlinerParaObject();
+ auto p = mxObj->GetOutlinerParaObject();
if(p)
pTextRedo = *p;
}
@@ -325,13 +327,13 @@ void SdrUndoAttrObj::Undo()
if(bStyleSheet)
{
- mxRedoStyleSheet = pObj->GetStyleSheet();
+ mxRedoStyleSheet = mxObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxUndoStyleSheet.get());
- if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
+ if(pSheet && mxObj->getSdrModelFromSdrObject().GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
- pObj->SetStyleSheet(pSheet, true);
+ ensureStyleSheetInStyleSheetPool(*mxObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
+ mxObj->SetStyleSheet(pSheet, true);
}
else
{
@@ -339,7 +341,7 @@ void SdrUndoAttrObj::Undo()
}
}
- sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
+ sdr::properties::ItemChangeBroadcaster aItemChange(*mxObj);
// Since ClearItem sets back everything to normal
// it also sets fit-to-size text to non-fit-to-size text and
@@ -347,13 +349,13 @@ void SdrUndoAttrObj::Undo()
// losing the geometry size info for the object when it is
// laid out again from AdjustTextFrameWidthAndHeight(). This makes
// rescuing the size of the object necessary.
- const tools::Rectangle aSnapRect = pObj->GetSnapRect();
+ const tools::Rectangle aSnapRect = mxObj->GetSnapRect();
// SdrObjCustomShape::NbcSetSnapRect needs logic instead of snap rect
- const tools::Rectangle aLogicRect = pObj->GetLogicRect();
+ const tools::Rectangle aLogicRect = mxObj->GetLogicRect();
if(moUndoSet)
{
- if(dynamic_cast<const SdrCaptionObj*>( pObj) != nullptr)
+ if(dynamic_cast<const SdrCaptionObj*>( mxObj.get() ) != nullptr)
{
// do a more smooth item deletion here, else the text
// rect will be reformatted, especially when information regarding
@@ -367,7 +369,7 @@ void SdrUndoAttrObj::Undo()
{
if(SfxItemState::SET != aIter.GetItemState(false))
{
- pObj->ClearMergedItem(nWhich);
+ mxObj->ClearMergedItem(nWhich);
}
nWhich = aIter.NextWhich();
@@ -375,26 +377,26 @@ void SdrUndoAttrObj::Undo()
}
else
{
- pObj->ClearMergedItem();
+ mxObj->ClearMergedItem();
}
- pObj->SetMergedItemSet(*moUndoSet);
+ mxObj->SetMergedItemSet(*moUndoSet);
}
// Restore previous size here when it was changed.
- if(aSnapRect != pObj->GetSnapRect())
+ if(aSnapRect != mxObj->GetSnapRect())
{
- if(dynamic_cast<const SdrObjCustomShape*>(pObj))
- pObj->NbcSetSnapRect(aLogicRect);
+ if(dynamic_cast<const SdrObjCustomShape*>(mxObj.get()))
+ mxObj->NbcSetSnapRect(aLogicRect);
else
- pObj->NbcSetSnapRect(aSnapRect);
+ mxObj->NbcSetSnapRect(aSnapRect);
}
- pObj->GetProperties().BroadcastItemChange(aItemChange);
+ mxObj->GetProperties().BroadcastItemChange(aItemChange);
if(pTextUndo)
{
- pObj->SetOutlinerParaObject(*pTextUndo);
+ mxObj->SetOutlinerParaObject(*pTextUndo);
}
}
@@ -406,20 +408,20 @@ void SdrUndoAttrObj::Undo()
void SdrUndoAttrObj::Redo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pObj);
- bool bIs3DScene(dynamic_cast< E3dScene* >(pObj) != nullptr);
+ E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
+ bool bIs3DScene(dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
if(!pUndoGroup || bIs3DScene)
{
if(bStyleSheet)
{
- mxUndoStyleSheet = pObj->GetStyleSheet();
+ mxUndoStyleSheet = mxObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxRedoStyleSheet.get());
- if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
+ if(pSheet && mxObj->getSdrModelFromSdrObject().GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
- pObj->SetStyleSheet(pSheet, true);
+ ensureStyleSheetInStyleSheetPool(*mxObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
+ mxObj->SetStyleSheet(pSheet, true);
}
else
{
@@ -427,14 +429,14 @@ void SdrUndoAttrObj::Redo()
}
}
- sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
+ sdr::properties::ItemChangeBroadcaster aItemChange(*mxObj);
- const tools::Rectangle aSnapRect = pObj->GetSnapRect();
- const tools::Rectangle aLogicRect = pObj->GetLogicRect();
+ const tools::Rectangle aSnapRect = mxObj->GetSnapRect();
+ const tools::Rectangle aLogicRect = mxObj->GetLogicRect();
if(moRedoSet)
{
- if(dynamic_cast<const SdrCaptionObj*>( pObj) != nullptr)
+ if(dynamic_cast<const SdrCaptionObj*>( mxObj.get() ) != nullptr)
{
// do a more smooth item deletion here, else the text
// rect will be reformatted, especially when information regarding
@@ -448,7 +450,7 @@ void SdrUndoAttrObj::Redo()
{
if(SfxItemState::SET != aIter.GetItemState(false))
{
- pObj->ClearMergedItem(nWhich);
+ mxObj->ClearMergedItem(nWhich);
}
nWhich = aIter.NextWhich();
@@ -456,27 +458,27 @@ void SdrUndoAttrObj::Redo()
}
else
{
- pObj->ClearMergedItem();
+ mxObj->ClearMergedItem();
}
- pObj->SetMergedItemSet(*moRedoSet);
+ mxObj->SetMergedItemSet(*moRedoSet);
}
// Restore previous size here when it was changed.
- if(aSnapRect != pObj->GetSnapRect())
+ if(aSnapRect != mxObj->GetSnapRect())
{
- if(dynamic_cast<const SdrObjCustomShape*>(pObj))
- pObj->NbcSetSnapRect(aLogicRect);
+ if(dynamic_cast<const SdrObjCustomShape*>(mxObj.get()))
+ mxObj->NbcSetSnapRect(aLogicRect);
else
- pObj->NbcSetSnapRect(aSnapRect);
+ mxObj->NbcSetSnapRect(aSnapRect);
}
- pObj->GetProperties().BroadcastItemChange(aItemChange);
+ mxObj->GetProperties().BroadcastItemChange(aItemChange);
// #i8508#
if(pTextRedo)
{
- pObj->SetOutlinerParaObject(*pTextRedo);
+ mxObj->SetOutlinerParaObject(*pTextRedo);
}
}
@@ -521,12 +523,12 @@ void SdrUndoMoveObj::Undo()
// Trigger PageChangeCall
ImpShowPageOfThisObject();
- pObj->Move(Size(-aDistance.Width(),-aDistance.Height()));
+ mxObj->Move(Size(-aDistance.Width(),-aDistance.Height()));
}
void SdrUndoMoveObj::Redo()
{
- pObj->Move(Size(aDistance.Width(),aDistance.Height()));
+ mxObj->Move(Size(aDistance.Width(),aDistance.Height()));
// Trigger PageChangeCall
ImpShowPageOfThisObject();
@@ -563,7 +565,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
// this is a group object!
// If this were 3D scene, we'd only add an Undo for the scene itself
// (which we do elsewhere).
- pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
+ pUndoGroup.reset(new SdrUndoGroup(mxObj->getSdrModelFromSdrObject()));
const size_t nObjCount = pOL->GetObjCount();
for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
pUndoGroup->AddAction(std::make_unique<SdrUndoGeoObj>(*pOL->GetObj(nObjNum)));
@@ -571,7 +573,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
}
else
{
- pUndoGeo = pObj->GetGeoData();
+ pUndoGeo = mxObj->GetGeoData();
}
}
@@ -592,16 +594,16 @@ void SdrUndoGeoObj::Undo()
pUndoGroup->Undo();
// only repaint, no objectchange
- pObj->ActionChanged();
+ mxObj->ActionChanged();
}
else
{
- pRedoGeo = pObj->GetGeoData();
+ pRedoGeo = mxObj->GetGeoData();
- auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pObj);
+ auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(mxObj.get());
if (pTableObj && mbSkipChangeLayout)
pTableObj->SetSkipChangeLayout(true);
- pObj->SetGeoData(*pUndoGeo);
+ mxObj->SetGeoData(*pUndoGeo);
if (pTableObj && mbSkipChangeLayout)
pTableObj->SetSkipChangeLayout(false);
}
@@ -614,12 +616,12 @@ void SdrUndoGeoObj::Redo()
pUndoGroup->Redo();
// only repaint, no objectchange
- pObj->ActionChanged();
+ mxObj->ActionChanged();
}
else
{
- pUndoGeo = pObj->GetGeoData();
- pObj->SetGeoData(*pRedoGeo);
+ pUndoGeo = mxObj->GetGeoData();
+ mxObj->SetGeoData(*pRedoGeo);
}
// Trigger PageChangeCall
@@ -646,15 +648,15 @@ SdrUndoDiagramModelData::~SdrUndoDiagramModelData()
void SdrUndoDiagramModelData::implUndoRedo(bool bUndo)
{
- if(nullptr == pObj)
+ if(!mxObj)
return;
- if(!pObj->isDiagram())
+ if(!mxObj->isDiagram())
return;
- pObj->getDiagramHelper()->applyDiagramDataState(
+ mxObj->getDiagramHelper()->applyDiagramDataState(
bUndo ? m_aStartState : m_aEndState);
- pObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(pObj));
+ mxObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(mxObj.get()));
}
void SdrUndoDiagramModelData::Undo()
@@ -674,46 +676,29 @@ OUString SdrUndoDiagramModelData::GetComment() const
SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect)
: SdrUndoObj(rNewObj)
- , bOwner(false)
{
- pObjList=pObj->getParentSdrObjListFromSdrObject();
+ pObjList=mxObj->getParentSdrObjListFromSdrObject();
if (bOrdNumDirect)
{
- nOrdNum=pObj->GetOrdNumDirect();
+ nOrdNum=mxObj->GetOrdNumDirect();
}
else
{
- nOrdNum=pObj->GetOrdNum();
+ nOrdNum=mxObj->GetOrdNum();
}
}
SdrUndoObjList::~SdrUndoObjList()
{
- SolarMutexGuard aGuard;
-
- if (pObj!=nullptr && IsOwner())
- {
- // Attribute have to go back to the regular Pool
- SetOwner(false);
-
- // now delete
- SdrObject::Free( pObj );
- }
}
-void SdrUndoObjList::SetOwner(bool bNew)
-{
- bOwner = bNew;
-}
-
-
void SdrUndoRemoveObj::Undo()
{
// Trigger PageChangeCall
ImpShowPageOfThisObject();
- DBG_ASSERT(!pObj->IsInserted(),"UndoRemoveObj: pObj has already been inserted.");
- if (pObj->IsInserted())
+ DBG_ASSERT(!mxObj->IsInserted(),"UndoRemoveObj: mxObj has already been inserted.");
+ if (mxObj->IsInserted())
return;
// #i11426#
@@ -727,23 +712,23 @@ void SdrUndoRemoveObj::Undo()
}
E3DModifySceneSnapRectUpdater aUpdater(pObjList->getSdrObjectFromSdrObjList());
- pObjList->InsertObject(pObj,nOrdNum);
+ pObjList->InsertObject(mxObj.get(), nOrdNum);
// #i11426#
if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y())
{
- pObj->NbcSetAnchorPos(aOwnerAnchorPos);
+ mxObj->NbcSetAnchorPos(aOwnerAnchorPos);
}
}
void SdrUndoRemoveObj::Redo()
{
- DBG_ASSERT(pObj->IsInserted(),"RedoRemoveObj: pObj is not inserted.");
- if (pObj->IsInserted())
+ DBG_ASSERT(mxObj->IsInserted(),"RedoRemoveObj: mxObj is not inserted.");
+ if (mxObj->IsInserted())
{
- ImplUnmarkObject( pObj );
- E3DModifySceneSnapRectUpdater aUpdater(pObj);
- pObjList->RemoveObject(pObj->GetOrdNum());
+ ImplUnmarkObject( mxObj.get() );
+ E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
+ pObjList->RemoveObject(mxObj->GetOrdNum());
}
// Trigger PageChangeCall
@@ -760,20 +745,20 @@ void SdrUndoInsertObj::Undo()
// Trigger PageChangeCall
ImpShowPageOfThisObject();
- DBG_ASSERT(pObj->IsInserted(),"UndoInsertObj: pObj is not inserted.");
- if (pObj->IsInserted())
+ DBG_ASSERT(mxObj->IsInserted(),"UndoInsertObj: mxObj is not inserted.");
+ if (mxObj->IsInserted())
{
- ImplUnmarkObject( pObj );
+ ImplUnmarkObject( mxObj.get() );
- SdrObject* pChkObj= pObjList->RemoveObject(pObj->GetOrdNum());
- DBG_ASSERT(pChkObj==pObj,"UndoInsertObj: RemoveObjNum!=pObj");
+ rtl::Reference<SdrObject> pChkObj= pObjList->RemoveObject(mxObj->GetOrdNum());
+ DBG_ASSERT(pChkObj.get()==mxObj.get(),"UndoInsertObj: RemoveObjNum!=mxObj");
}
}
void SdrUndoInsertObj::Redo()
{
- DBG_ASSERT(!pObj->IsInserted(),"RedoInsertObj: pObj is already inserted");
- if (!pObj->IsInserted())
+ DBG_ASSERT(!mxObj->IsInserted(),"RedoInsertObj: mxObj is already inserted");
+ if (!mxObj->IsInserted())
{
// Restore anchor position of an object,
// which becomes a member of a group, because its cleared in method
@@ -782,15 +767,15 @@ void SdrUndoInsertObj::Redo()
if (dynamic_cast<const SdrObjGroup*>(pObjList->getSdrObjectFromSdrObjList()) != nullptr)
{
- aAnchorPos = pObj->GetAnchorPos();
+ aAnchorPos = mxObj->GetAnchorPos();
}
- pObjList->InsertObject(pObj,nOrdNum);
+ pObjList->InsertObject(mxObj.get(), nOrdNum);
// Arcs lose position when grouped (#i45952#)
if ( aAnchorPos.X() || aAnchorPos.Y() )
{
- pObj->NbcSetAnchorPos( aAnchorPos );
+ mxObj->NbcSetAnchorPos( aAnchorPos );
}
}
@@ -801,21 +786,16 @@ void SdrUndoInsertObj::Redo()
SdrUndoDelObj::SdrUndoDelObj(SdrObject& rNewObj, bool bOrdNumDirect)
: SdrUndoRemoveObj(rNewObj,bOrdNumDirect)
{
- SetOwner(true);
}
void SdrUndoDelObj::Undo()
{
SdrUndoRemoveObj::Undo();
- DBG_ASSERT(IsOwner(),"UndoDeleteObj: pObj does not belong to UndoAction");
- SetOwner(false);
}
void SdrUndoDelObj::Redo()
{
SdrUndoRemoveObj::Redo();
- DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj already belongs to UndoAction");
- SetOwner(true);
}
OUString SdrUndoDelObj::GetComment() const
@@ -842,15 +822,11 @@ OUString SdrUndoDelObj::GetSdrRepeatComment() const
void SdrUndoNewObj::Undo()
{
SdrUndoInsertObj::Undo();
- DBG_ASSERT(!IsOwner(),"RedoNewObj: pObj already belongs to UndoAction");
- SetOwner(true);
}
void SdrUndoNewObj::Redo()
{
SdrUndoInsertObj::Redo();
- DBG_ASSERT(IsOwner(),"RedoNewObj: pObj does not belong to UndoAction");
- SetOwner(false);
}
OUString SdrUndoNewObj::GetComment( const SdrObject& _rForObject )
@@ -865,32 +841,13 @@ OUString SdrUndoNewObj::GetComment() const
SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject& rOldObj1, SdrObject& rNewObj1)
: SdrUndoObj(rOldObj1)
- , bOldOwner(false)
- , bNewOwner(false)
- , pNewObj(&rNewObj1)
+ , mxNewObj(&rNewObj1)
{
- SetOldOwner(true);
- pObjList=pObj->getParentSdrObjListFromSdrObject();
+ pObjList=mxObj->getParentSdrObjListFromSdrObject();
}
SdrUndoReplaceObj::~SdrUndoReplaceObj()
{
- if (pObj!=nullptr && IsOldOwner())
- {
- // Attribute have to go back into the Pool
- SetOldOwner(false);
-
- // now delete
- SdrObject::Free( pObj );
- }
- if (pNewObj!=nullptr && IsNewOwner())
- {
- // Attribute have to go back into the Pool
- SetNewOwner(false);
-
- // now delete
- SdrObject::Free( pNewObj );
- }
}
void SdrUndoReplaceObj::Undo()
@@ -898,54 +855,22 @@ void SdrUndoReplaceObj::Undo()
// Trigger PageChangeCall
ImpShowPageOfThisObject();
- if (IsOldOwner() && !IsNewOwner())
- {
- DBG_ASSERT(!pObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Old object is already inserted!");
- DBG_ASSERT(pNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): New object is not inserted!");
- SetOldOwner(false);
- SetNewOwner(true);
+ DBG_ASSERT(!mxObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Old object is already inserted!");
+ DBG_ASSERT(mxNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): New object is not inserted!");
- ImplUnmarkObject( pNewObj );
- pObjList->ReplaceObject(pObj,pNewObj->GetOrdNum());
- }
- else
- {
- OSL_FAIL("SdrUndoReplaceObj::Undo(): Wrong IsMine flags. Did you call Undo twice?");
- }
+ ImplUnmarkObject( mxNewObj.get() );
+ pObjList->ReplaceObject(mxObj.get(), mxNewObj->GetOrdNum());
}
void SdrUndoReplaceObj::Redo()
{
- if (!IsOldOwner() && IsNewOwner())
- {
- DBG_ASSERT(!pNewObj->IsInserted(),"SdrUndoReplaceObj::Redo(): New object is already inserted!!");
- DBG_ASSERT(pObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Old object is not inserted!!");
- SetOldOwner(true);
- SetNewOwner(false);
-
- ImplUnmarkObject( pObj );
- pObjList->ReplaceObject(pNewObj,pObj->GetOrdNum());
-
- }
- else
- {
- OSL_FAIL("SdrUndoReplaceObj::Redo(): Wrong IsMine flags. Did you call Redo twice?");
- }
+ ImplUnmarkObject( mxObj.get() );
+ pObjList->ReplaceObject(mxNewObj.get(), mxObj->GetOrdNum());
// Trigger PageChangeCall
ImpShowPageOfThisObject();
}
-void SdrUndoReplaceObj::SetNewOwner(bool bNew)
-{
- bNewOwner = bNew;
-}
-
-void SdrUndoReplaceObj::SetOldOwner(bool bNew)
-{
- bOldOwner = bNew;
-}
-
OUString SdrUndoCopyObj::GetComment() const
{
@@ -965,12 +890,12 @@ SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject& rObj, SdrLayerID a
void SdrUndoObjectLayerChange::Undo()
{
ImpShowPageOfThisObject();
- pObj->SetLayer(maOldLayer);
+ mxObj->SetLayer(maOldLayer);
}
void SdrUndoObjectLayerChange::Redo()
{
- pObj->SetLayer(maNewLayer);
+ mxObj->SetLayer(maNewLayer);
ImpShowPageOfThisObject();
}
@@ -987,10 +912,10 @@ void SdrUndoObjOrdNum::Undo()
// Trigger PageChangeCall
ImpShowPageOfThisObject();
- SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject();
+ SdrObjList* pOL=mxObj->getParentSdrObjListFromSdrObject();
if (pOL==nullptr)
{
- OSL_FAIL("UndoObjOrdNum: pObj does not have an ObjList.");
+ OSL_FAIL("UndoObjOrdNum: mxObj does not have an ObjList.");
return;
}
pOL->SetObjectOrdNum(nNewOrdNum,nOldOrdNum);
@@ -998,10 +923,10 @@ void SdrUndoObjOrdNum::Undo()
void SdrUndoObjOrdNum::Redo()
{
- SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject();
+ SdrObjList* pOL=mxObj->getParentSdrObjListFromSdrObject();
if (pOL==nullptr)
{
- OSL_FAIL("RedoObjOrdNum: pObj does not have an ObjList.");
+ OSL_FAIL("RedoObjOrdNum: mxObj does not have an ObjList.");
return;
}
pOL->SetObjectOrdNum(nOldOrdNum,nNewOrdNum);
@@ -1088,7 +1013,7 @@ void SdrUndoObjSetText::AfterSetText()
{
if (!bNewTextAvailable)
{
- SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
+ SdrText* pText = static_cast< SdrTextObj*>( mxObj.get() )->getText(mnText);
if( pText && pText->GetOutlinerParaObject() )
pNewText = *pText->GetOutlinerParaObject();
bNewTextAvailable=true;
@@ -1098,7 +1023,7 @@ void SdrUndoObjSetText::AfterSetText()
void SdrUndoObjSetText::Undo()
{
// only works with SdrTextObj
- SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(mxObj.get());
if(!pTarget)
{
@@ -1140,7 +1065,7 @@ void SdrUndoObjSetText::Undo()
void SdrUndoObjSetText::Redo()
{
// only works with SdrTextObj
- SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(mxObj.get());
if(!pTarget)
{
@@ -1242,13 +1167,13 @@ void SdrUndoObjStrAttr::Undo()
switch ( meObjStrAttr )
{
case ObjStrAttrType::Name:
- pObj->SetName( msOldStr );
+ mxObj->SetName( msOldStr );
break;
case ObjStrAttrType::Title:
- pObj->SetTitle( msOldStr );
+ mxObj->SetTitle( msOldStr );
break;
case ObjStrAttrType::Description:
- pObj->SetDescription( msOldStr );
+ mxObj->SetDescription( msOldStr );
break;
}
}
@@ -1258,13 +1183,13 @@ void SdrUndoObjStrAttr::Redo()
switch ( meObjStrAttr )
{
case ObjStrAttrType::Name:
- pObj->SetName( msNewStr );
+ mxObj->SetName( msNewStr );
break;
case ObjStrAttrType::Title:
- pObj->SetTitle( msNewStr );
+ mxObj->SetTitle( msNewStr );
break;
case ObjStrAttrType::Description:
- pObj->SetDescription( msNewStr );
+ mxObj->SetDescription( msNewStr );
break;
}
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());
}
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 8c9aad400b0b..f7d80e433612 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -864,12 +864,16 @@ std::unique_ptr<sdr::contact::ViewContact> SdrTableObj::CreateObjectSpecificView
SdrTableObj::SdrTableObj(SdrModel& rSdrModel)
: SdrTextObj(rSdrModel)
{
+ osl_atomic_increment(&m_refCount); // other I get deleted during construction
init( 1, 1 );
+ osl_atomic_decrement(&m_refCount);
}
SdrTableObj::SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource)
: SdrTextObj(rSdrModel, rSource)
{
+ osl_atomic_increment(&m_refCount);
+
init( 1, 1 );
TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr );
@@ -887,6 +891,8 @@ SdrTableObj::SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource)
// use SdrTableObjImpl::operator= now to
// copy model data and other stuff (see there)
*mpImpl = *rSource.mpImpl;
+
+ osl_atomic_decrement(&m_refCount);
}
SdrTableObj::SdrTableObj(
@@ -897,6 +903,8 @@ SdrTableObj::SdrTableObj(
: SdrTextObj(rSdrModel, rNewRect)
,maLogicRect(rNewRect)
{
+ osl_atomic_increment(&m_refCount);
+
if( nColumns <= 0 )
nColumns = 1;
@@ -904,6 +912,8 @@ SdrTableObj::SdrTableObj(
nRows = 1;
init( nColumns, nRows );
+
+ osl_atomic_decrement(&m_refCount);
}
@@ -1786,7 +1796,7 @@ OUString SdrTableObj::TakeObjNamePlural() const
}
-SdrTableObj* SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrTableObj(rTargetModel, *this);
}
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index fb7b5907c19a..53426211beb1 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -187,10 +187,10 @@ SvxTableController::SvxTableController(
,mxTableObj(const_cast< SdrTableObj* >(&rObj))
,mnUpdateEvent( nullptr )
{
- mxTableObj->getActiveCellPos( maCursorFirstPos );
+ rObj.getActiveCellPos( maCursorFirstPos );
maCursorLastPos = maCursorFirstPos;
- Reference< XTable > xTable( mxTableObj->getTable() );
+ Reference< XTable > xTable( mxTableObj.get()->getTable() );
if( xTable.is() )
{
mxModifyListener = new SvxTableControllerModifyListener( this );
@@ -207,9 +207,9 @@ SvxTableController::~SvxTableController()
Application::RemoveUserEvent( mnUpdateEvent );
}
- if( mxModifyListener.is() && mxTableObj )
+ if( mxModifyListener.is() && mxTableObj.get() )
{
- Reference< XTable > xTable( mxTableObj->getTable() );
+ Reference< XTable > xTable( mxTableObj.get()->getTable() );
if( xTable.is() )
{
xTable->removeModifyListener( mxModifyListener );
@@ -223,7 +223,7 @@ bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow
if(!checkTableObject())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
// check if we are read only
@@ -287,7 +287,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
if( !rMEvt.IsRight() && mrView.PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle )
return false;
- TableHitKind eHit = mxTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow);
+ TableHitKind eHit = mxTableObj.get()->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow);
mbLeftButtonDown = (rMEvt.GetClicks() == 1) && rMEvt.IsLeft();
@@ -313,7 +313,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
}
else
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if (!pTableObj || eHit == TableHitKind::NONE)
{
@@ -364,7 +364,7 @@ bool SvxTableController::onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWind
if( !checkTableObject() )
return false;
- SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
CellPos aPos;
if (mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), aPos.mnCol, aPos.mnRow ) != TableHitKind::NONE)
{
@@ -394,7 +394,7 @@ void SvxTableController::onSelectionHasChanged()
{
bool bSelected = false;
- SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
if( pTableObj && pTableObj->IsTextEditActive() )
{
pTableObj->getActiveCellPos( maCursorFirstPos );
@@ -405,7 +405,7 @@ void SvxTableController::onSelectionHasChanged()
{
const SdrMarkList& rMarkList= mrView.GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
- bSelected = mxTableObj.get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
+ bSelected = mxTableObj.get().get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
}
if( bSelected )
@@ -419,7 +419,7 @@ void SvxTableController::onSelectionHasChanged()
}
void SvxTableController::onSelectAll()
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if ( pTableObj && !pTableObj->IsTextEditActive())
{
selectAll();
@@ -429,10 +429,10 @@ void SvxTableController::onSelectAll()
void SvxTableController::GetState( SfxItemSet& rSet )
{
- if(!mxTable.is() || !mxTableObj.is())
+ if(!mxTable.is() || !mxTableObj.get().is())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
std::optional<SfxItemSet> oSet;
bool bVertDone(false);
@@ -526,7 +526,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
bool bInsertAfter = true;
sal_uInt16 nCount = 0;
@@ -792,7 +792,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
void SvxTableController::onDelete( sal_uInt16 nSId )
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if( !pTableObj || !mxTable.is() )
return;
@@ -906,10 +906,10 @@ namespace
void SvxTableController::onFormatTable(const SfxRequest& rReq)
{
- if(!mxTableObj.is())
+ if(!mxTableObj.get().is())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const SfxItemSet* pArgs = rReq.GetArgs();
@@ -983,7 +983,7 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq)
if (checkTableObject() && mxTable.is())
{
// Create a single undo action when applying the result of the dialog.
- SdrTableObj& rTableObject(*mxTableObj);
+ SdrTableObj& rTableObject(*mxTableObj.get());
SdrModel& rSdrModel(rTableObject.getSdrModelFromSdrObject());
bool bUndo = rSdrModel.IsUndoEnabled() && !mrView.IsTextEdit();
if (bUndo)
@@ -1109,7 +1109,7 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
if(!pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)))
@@ -1197,7 +1197,7 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
TableStyleSettings aSettings(rTableObj.getTableStyleSettings() );
@@ -1243,7 +1243,7 @@ void SvxTableController::SetVertical( sal_uInt16 nSId )
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
TableModelNotifyGuard aGuard( mxTable.get() );
@@ -1301,7 +1301,7 @@ void SvxTableController::MergeMarkedCells()
{
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
- SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
if( pTableObj )
{
if( pTableObj->IsTextEditActive() )
@@ -1331,7 +1331,7 @@ void SvxTableController::SplitMarkedCells(const SfxRequest& rReq)
Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
const sal_Int32 nRowCount = mxTable->getRowCount();
const sal_Int32 nColCount = mxTable->getColumnCount();
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
if( rTableObj.IsTextEditActive() )
mrView.SdrEndTextEdit(true);
@@ -1372,7 +1372,7 @@ void SvxTableController::DistributeColumns(const bool bOptimize, const bool bMin
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
@@ -1395,7 +1395,7 @@ void SvxTableController::DistributeRows(const bool bOptimize, const bool bMinimi
if(!checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
@@ -1423,7 +1423,7 @@ bool SvxTableController::DeleteMarked()
if(!checkTableObject() || !HasMarked())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
bool bDeleteTable = false;
@@ -1550,7 +1550,7 @@ void SvxTableController::changeTableEdge(const SfxRequest& rReq)
const sal_uInt16 nIndex = pIndex->GetValue();
const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue());
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
sal_Int32 nEdgeIndex = -1;
bool bHorizontal = sType.startsWith("row");
@@ -1606,7 +1606,7 @@ void SvxTableController::changeTableEdge(const SfxRequest& rReq)
bool SvxTableController::checkTableObject()
{
- return mxTableObj.is();
+ return mxTableObj.get().is();
}
@@ -1618,7 +1618,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
TblAction nAction = TblAction::HandledByView;
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if( !pTableObj )
return nAction;
@@ -1799,7 +1799,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Window* pWindow)
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if( !pTableObj )
return false;
@@ -1908,14 +1908,15 @@ bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Win
void SvxTableController::gotoCell(const CellPos& rPos, bool bSelect, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
{
- if( mxTableObj.is() && mxTableObj->IsTextEditActive() )
+ auto pTable = mxTableObj.get();
+ if( pTable && pTable->IsTextEditActive() )
mrView.SdrEndTextEdit(true);
if( bSelect )
{
maCursorLastPos = rPos;
- if( mxTableObj.is() )
- mxTableObj->setActiveCell( rPos );
+ if( pTable )
+ pTable->setActiveCell( rPos );
if( !mbCellSelectionMode )
{
@@ -1965,7 +1966,7 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
if( xRange->isMergeable() )
{
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
@@ -2037,7 +2038,7 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
if(nullptr == pPV || !checkTableObject())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
if(rTableObj.getSdrPageFromSdrObject() != pPV->GetPage())
return;
@@ -2221,7 +2222,7 @@ bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList)
if(!checkTableObject() || !mxTable.is())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
if (mrView.IsTextEdit())
@@ -2321,7 +2322,7 @@ void SvxTableController::updateSelectionOverlay()
if( !mbCellSelectionMode )
return;
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
+ rtl::Reference<sdr::table::SdrTableObj> pTableObj = mxTableObj.get();
if( !pTableObj )
return;
@@ -2684,7 +2685,7 @@ void SvxTableController::ApplyBorderAttr( const SfxItemSet& rAttr )
void SvxTableController::UpdateTableShape()
{
- SdrObject* pTableObj = mxTableObj.get();
+ rtl::Reference<SdrObject> pTableObj = mxTableObj.get();
if( pTableObj )
{
pTableObj->ActionChanged();
@@ -2699,7 +2700,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
if(!checkTableObject() || !mxTable.is())
return;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
@@ -2767,7 +2768,7 @@ void SvxTableController::SetAttrToSelectedShape(const SfxItemSet& rAttr)
bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const
{
- if( mxTableObj.is() && hasSelectedCells() )
+ if( mxTableObj.get().is() && hasSelectedCells() )
{
MergeAttrFromSelectedCells( rTargetSet, bOnlyHardAttr );
@@ -2800,9 +2801,9 @@ bool SvxTableController::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
return false;
}
-SdrObject* SvxTableController::GetMarkedSdrObjClone(SdrModel& rTargetModel)
+rtl::Reference<SdrObject> SvxTableController::GetMarkedSdrObjClone(SdrModel& rTargetModel)
{
- SdrTableObj* pRetval(nullptr);
+ rtl::Reference<SdrTableObj> pRetval;
sdr::table::SdrTableObj* pCurrentSdrTableObj(GetTableObj());
if(nullptr == pCurrentSdrTableObj)
@@ -2810,7 +2811,7 @@ SdrObject* SvxTableController::GetMarkedSdrObjClone(SdrModel& rTargetModel)
return pRetval;
}
- if(!mxTableObj.is())
+ if(!mxTableObj.get().is())
{
return pRetval;
}
@@ -2825,7 +2826,7 @@ SdrObject* SvxTableController::GetMarkedSdrObjClone(SdrModel& rTargetModel)
if(aStart != aFullStart || aEnd != aFullEnd)
{
// create full clone
- pRetval = pCurrentSdrTableObj->CloneSdrObject(rTargetModel);
+ pRetval = SdrObject::Clone(*pCurrentSdrTableObj, rTargetModel);
// limit SdrObject's TableModel to partial selection
pRetval->CropTableModelToSelection(aStart, aEnd);
@@ -2836,7 +2837,7 @@ SdrObject* SvxTableController::GetMarkedSdrObjClone(SdrModel& rTargetModel)
bool SvxTableController::PasteObjModel( const SdrModel& rModel )
{
- if( mxTableObj.is() && (rModel.GetPageCount() >= 1) )
+ if( mxTableObj.get().is() && (rModel.GetPageCount() >= 1) )
{
const SdrPage* pPastePage = rModel.GetPage(0);
if( pPastePage && pPastePage->GetObjCount() == 1 )
@@ -2928,7 +2929,7 @@ bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNo
if(!checkTableObject())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const bool bUndo(rModel.IsUndoEnabled());
@@ -3310,7 +3311,7 @@ bool SvxTableController::isRowHeader()
if(!checkTableObject())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstRow;
@@ -3321,7 +3322,7 @@ bool SvxTableController::isColumnHeader()
if(!checkTableObject())
return false;
- SdrTableObj& rTableObj(*mxTableObj);
+ SdrTableObj& rTableObj(*mxTableObj.get());
TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstColumn;
@@ -3329,10 +3330,10 @@ bool SvxTableController::isColumnHeader()
bool SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPoint)
{
- if (mxTableObj->GetObjIdentifier() != SdrObjKind::Table)
+ rtl::Reference<SdrTableObj> pTableObj = mxTableObj.get();
+ if (pTableObj->GetObjIdentifier() != SdrObjKind::Table)
return false;
- SdrTableObj* pTableObj = mxTableObj.get();
CellPos aCellPos;
if (pTableObj->CheckTableHit(rPosition, aCellPos.mnCol, aCellPos.mnRow) != TableHitKind::NONE)
{
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index 66641469dd09..5138baa20a7c 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -40,17 +40,17 @@ CellUndo::CellUndo( SdrObject* pObjRef, const CellRef& xCell )
,mxCell( xCell )
,mbUndo( true )
{
- if( mxCell.is() && mxObjRef.is() )
+ if( mxCell.is() && pObjRef )
{
getDataFromCell( maUndoData );
- mxObjRef->AddObjectUser( *this );
+ pObjRef->AddObjectUser( *this );
}
}
CellUndo::~CellUndo()
{
- if( mxObjRef.is() )
- mxObjRef->RemoveObjectUser( *this );
+ if( auto pObj = mxObjRef.get() )
+ pObj->RemoveObjectUser( *this );
dispose();
}
@@ -100,7 +100,7 @@ bool CellUndo::Merge( SfxUndoAction *pNextAction )
void CellUndo::setDataToCell( const Data& rData )
{
if( rData.mpProperties )
- mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef, *mxCell ));
+ mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell ));
else
mxCell->mpProperties.reset();
@@ -116,22 +116,22 @@ void CellUndo::setDataToCell( const Data& rData )
mxCell->mnRowSpan = rData.mnRowSpan;
mxCell->mnColSpan = rData.mnColSpan;
- if(mxObjRef.is())
+ if(auto pObj = mxObjRef.get())
{
// #i120201# ActionChanged is not enough, we need to trigger TableLayouter::UpdateBorderLayout()
// and this is done best using ReformatText() for table objects
- mxObjRef->ActionChanged();
- mxObjRef->NbcReformatText();
+ pObj->ActionChanged();
+ pObj->NbcReformatText();
}
}
void CellUndo::getDataFromCell( Data& rData )
{
- if( !(mxObjRef.is() && mxCell.is()) )
+ if( !(mxObjRef.get().is() && mxCell.is()) )
return;
if( mxCell->mpProperties )
- rData.mpProperties = mxCell->CloneProperties( *mxObjRef, *mxCell);
+ rData.mpProperties = mxCell->CloneProperties( *mxObjRef.get(), *mxCell);
if( mxCell->GetOutlinerParaObject() )
rData.mpOutlinerParaObject = *mxCell->GetOutlinerParaObject();
@@ -493,7 +493,7 @@ void TableStyleUndo::Redo()
void TableStyleUndo::setData( const Data& rData )
{
- SdrTableObj* pTableObj = mxObjRef.get();
+ rtl::Reference<SdrTableObj> pTableObj = mxObjRef.get();
if( pTableObj )
{
pTableObj->setTableStyle( rData.mxTableStyle );
@@ -503,7 +503,7 @@ void TableStyleUndo::setData( const Data& rData )
void TableStyleUndo::getData( Data& rData )
{
- SdrTableObj* pTableObj = mxObjRef.get();
+ rtl::Reference<SdrTableObj> pTableObj = mxObjRef.get();
if( pTableObj )
{
rData.maSettings = pTableObj->getTableStyleSettings();
diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx
index 822f5ec642fa..4241950396ca 100644
--- a/svx/source/table/tableundo.hxx
+++ b/svx/source/table/tableundo.hxx
@@ -78,7 +78,7 @@ private:
void setDataToCell( const Data& rData );
void getDataFromCell( Data& rData );
- tools::WeakReference<SdrObject> mxObjRef;
+ unotools::WeakReference<SdrObject> mxObjRef;
CellRef mxCell;
Data maUndoData;
Data maRedoData;
@@ -235,7 +235,7 @@ public:
virtual void Redo() override;
private:
- tools::WeakReference<SdrTableObj> mxObjRef;
+ unotools::WeakReference<SdrTableObj> mxObjRef;
struct Data
{
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index 472bed1ecfc6..cd7d4158cef9 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -58,7 +58,6 @@ FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSd
, mnThemeId(0xffff)
, mrSdrView(rSdrView)
, mbInsertIntoPage(true)
- , mpSdrObject(nullptr)
, mpDestModel(nullptr)
, maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin"))
, mxOKButton(m_xBuilder->weld_button("ok"))
@@ -179,7 +178,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
return;
// Clone directly to target SdrModel (may be different due to user/caller (!))
- SdrObject* pNewObject(
+ rtl::Reference<SdrObject> pNewObject(
pPage->GetObj(0)->CloneSdrObject(
bUseSpecialCalcMode ? *mpDestModel : mrSdrView.getSdrModelFromSdrView()));
@@ -237,7 +236,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if (bUseSpecialCalcMode)
{
- mpSdrObject = pNewObject;
+ mxSdrObject = pNewObject;
}
else
{
@@ -245,12 +244,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if (nullptr != pPV)
{
- mrSdrView.InsertObjectAtView( pNewObject, *pPV );
- }
- else
- {
- // tdf#116993 no target -> delete clone
- SdrObject::Free(pNewObject);
+ mrSdrView.InsertObjectAtView( pNewObject.get(), *pPV );
}
}
}
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index b753c0ff399f..55eabdcd85fc 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -610,7 +610,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
EEControlBits nCntrl = nOldCntrl & ~EEControlBits::ONLINESPELLING;
rOutl.SetControlWord(nCntrl);
- SdrObject* pTempBackgroundShape = nullptr;
+ rtl::Reference<SdrObject> pTempBackgroundShape;
std::vector< SdrObject* > aShapes;
bool bRet = true;
@@ -629,7 +629,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet());
pTempBackgroundShape->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true);
- aShapes.push_back(pTempBackgroundShape);
+ aShapes.push_back(pTempBackgroundShape.get());
}
}
else
@@ -981,10 +981,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
}
}
- if(pTempBackgroundShape)
- {
- SdrObject::Free(pTempBackgroundShape);
- }
+ pTempBackgroundShape.clear();
rOutl.SetCalcFieldValueHdl( maOldCalcFieldValueHdl );
diff --git a/svx/source/unodraw/gluepts.cxx b/svx/source/unodraw/gluepts.cxx
index 584effb73711..a0fc6a1b7b92 100644
--- a/svx/source/unodraw/gluepts.cxx
+++ b/svx/source/unodraw/gluepts.cxx
@@ -42,7 +42,7 @@ namespace {
class SvxUnoGluePointAccess : public WeakImplHelper< container::XIndexContainer, container::XIdentifierContainer >
{
private:
- tools::WeakReference<SdrObject> mpObject;
+ unotools::WeakReference<SdrObject> mpObject;
public:
explicit SvxUnoGluePointAccess( SdrObject* pObject ) noexcept;
@@ -204,9 +204,9 @@ SvxUnoGluePointAccess::SvxUnoGluePointAccess( SdrObject* pObject ) noexcept
// XIdentifierContainer
sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement )
{
- if( mpObject.is() )
+ if( auto pObject = mpObject.get() )
{
- SdrGluePointList* pList = mpObject->ForceGluePointList();
+ SdrGluePointList* pList = pObject->ForceGluePointList();
if( pList )
{
// second, insert the new gluepoint
@@ -219,7 +219,7 @@ sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement )
sal_uInt16 nId = pList->Insert( aSdrGlue );
// only repaint, no objectchange
- mpObject->ActionChanged();
+ pObject->ActionChanged();
// mpObject->BroadcastObjectChange();
return static_cast<sal_Int32>((*pList)[nId].GetId() + NON_USER_DEFINED_GLUE_POINTS) - 1;
@@ -234,11 +234,12 @@ sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement )
void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier )
{
- if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
+ auto pObject = mpObject.get();
+ if( pObject && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
{
const sal_uInt16 nId = static_cast<sal_uInt16>(Identifier - NON_USER_DEFINED_GLUE_POINTS) + 1;
- SdrGluePointList* pList = const_cast<SdrGluePointList*>(mpObject->GetGluePointList());
+ SdrGluePointList* pList = const_cast<SdrGluePointList*>(pObject->GetGluePointList());
const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
sal_uInt16 i;
@@ -249,8 +250,8 @@ void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier )
pList->Delete( i );
// only repaint, no objectchange
- mpObject->ActionChanged();
- // mpObject->BroadcastObjectChange();
+ pObject->ActionChanged();
+ // pObject->BroadcastObjectChange();
return;
}
@@ -263,7 +264,8 @@ void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier )
// XIdentifierReplace
void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement )
{
- if( !mpObject.is() )
+ auto pObject = mpObject.get();
+ if( !pObject )
return;
struct drawing::GluePoint2 aGluePoint;
@@ -272,7 +274,7 @@ void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, c
const sal_uInt16 nId = static_cast<sal_uInt16>( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
- SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
+ SdrGluePointList* pList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
sal_uInt16 i;
for( i = 0; i < nCount; i++ )
@@ -284,8 +286,8 @@ void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, c
convert( aGluePoint, rTempPoint );
// only repaint, no objectchange
- mpObject->ActionChanged();
- // mpObject->BroadcastObjectChange();
+ pObject->ActionChanged();
+ // pObject->BroadcastObjectChange();
return;
}
@@ -297,13 +299,14 @@ void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, c
// XIdentifierAccess
uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier )
{
- if( mpObject.is() )
+ auto pObject = mpObject.get();
+ if( pObject )
{
struct drawing::GluePoint2 aGluePoint;
if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default gluepoint?
{
- SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( static_cast<sal_uInt16>(Identifier) );
+ SdrGluePoint aTempPoint = pObject->GetVertexGluePoint( static_cast<sal_uInt16>(Identifier) );
aGluePoint.IsUserDefined = false;
convert( aTempPoint, aGluePoint );
return uno::Any( aGluePoint );
@@ -312,7 +315,7 @@ uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier )
{
const sal_uInt16 nId = static_cast<sal_uInt16>( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
- const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const SdrGluePointList* pList = pObject->GetGluePointList();
const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
for( sal_uInt16 i = 0; i < nCount; i++ )
{
@@ -337,9 +340,10 @@ uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier )
uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers()
{
- if( mpObject.is() )
+ auto pObject = mpObject.get();
+ if( pObject )
{
- const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const SdrGluePointList* pList = pObject->GetGluePointList();
const sal_uInt16 nCount = pList ? pList->GetCount() : 0;
sal_uInt16 i;
@@ -367,9 +371,10 @@ uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers()
// XIndexContainer
void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element )
{
- if( mpObject.is() )
+ auto pObject = mpObject.get();
+ if( pObject )
{
- SdrGluePointList* pList = mpObject->ForceGluePointList();
+ SdrGluePointList* pList = pObject->ForceGluePointList();
if( pList )
{
drawing::GluePoint2 aUnoGlue;
@@ -381,8 +386,8 @@ void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& E
pList->Insert( aSdrGlue );
// only repaint, no objectchange
- mpObject->ActionChanged();
- // mpObject->BroadcastObjectChange();
+ pObject->ActionChanged();
+ // pObject->BroadcastObjectChange();
return;
}
@@ -396,9 +401,10 @@ void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& E
void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index )
{
- if( mpObject.is() )
+ auto pObject = mpObject.get();
+ if( pObject )
{
- SdrGluePointList* pList = mpObject->ForceGluePointList();
+ SdrGluePointList* pList = pObject->ForceGluePointList();
if( pList )
{
Index -= 4;
@@ -407,8 +413,8 @@ void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index )
pList->Delete( static_cast<sal_uInt16>(Index) );
// only repaint, no objectchange
- mpObject->ActionChanged();
- // mpObject->BroadcastObjectChange();
+ pObject->ActionChanged();
+ // pObject->BroadcastObjectChange();
return;
}
@@ -425,18 +431,19 @@ void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno:
if(!(Element >>= aUnoGlue))
throw lang::IllegalArgumentException();
+ auto pObject = mpObject.get();
Index -= 4;
- if( mpObject.is() && Index >= 0 )
+ if( pObject && Index >= 0 )
{
- SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
+ SdrGluePointList* pList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
if( pList && Index < pList->GetCount() )
{
SdrGluePoint& rGlue = (*pList)[static_cast<sal_uInt16>(Index)];
convert( aUnoGlue, rGlue );
// only repaint, no objectchange
- mpObject->ActionChanged();
- // mpObject->BroadcastObjectChange();
+ pObject->ActionChanged();
+ // pObject->BroadcastObjectChange();
}
}
@@ -446,14 +453,15 @@ void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno:
// XIndexAccess
sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
{
+ auto pObject = mpObject.get();
sal_Int32 nCount = 0;
- if( mpObject.is() )
+ if( pObject )
{
// each node has a default of 4 gluepoints
// and any number of user defined gluepoints
nCount += 4;
- const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const SdrGluePointList* pList = pObject->GetGluePointList();
if( pList )
nCount += pList->GetCount();
}
@@ -463,13 +471,14 @@ sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index )
{
- if( Index >= 0 && mpObject.is() )
+ auto pObject = mpObject.get();
+ if( Index >= 0 && pObject )
{
struct drawing::GluePoint2 aGluePoint;
if( Index < 4 ) // default gluepoint?
{
- SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( static_cast<sal_uInt16>(Index) );
+ SdrGluePoint aTempPoint = pObject->GetVertexGluePoint( static_cast<sal_uInt16>(Index) );
aGluePoint.IsUserDefined = false;
convert( aTempPoint, aGluePoint );
return uno::Any(aGluePoint);
@@ -477,7 +486,7 @@ uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index )
else
{
Index -= 4;
- const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const SdrGluePointList* pList = pObject->GetGluePointList();
if( pList && Index < pList->GetCount() )
{
const SdrGluePoint& rTempPoint = (*pList)[static_cast<sal_uInt16>(Index)];
@@ -499,7 +508,7 @@ uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType()
sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements()
{
- return mpObject.is();
+ return bool(mpObject.get());
}
/**
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index 2994e51c0b0f..c24b51c19690 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -186,24 +186,26 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
if( nullptr == pShape )
+ {
+ assert(false && "adding a non-SvxShape to a page?");
return;
+ }
- SdrObject *pObj = pShape->GetSdrObject();
+ rtl::Reference<SdrObject> pObj = pShape->GetSdrObject();
bool bNeededToClone(false);
- if(nullptr != pObj && &pObj->getSdrModelFromSdrObject() != &mpPage->getSdrModelFromSdrPage())
+ if(pObj && &pObj->getSdrModelFromSdrObject() != &mpPage->getSdrModelFromSdrPage())
{
// TTTT UNO API tries to add an existing SvxShape to this SvxDrawPage,
// but these use different SdrModels. It was possible before to completely
// 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
// stuff), but is no longer. We need to Clone the SdrObject to the target model
- // and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
- SdrObject* pClonedSdrShape(pObj->CloneSdrObject(mpPage->getSdrModelFromSdrPage()));
+ // and ::Create a new SvxShape (set SdrObject there, take over values, ...)
+ rtl::Reference<SdrObject> pClonedSdrShape(pObj->CloneSdrObject(mpPage->getSdrModelFromSdrPage()));
pObj->setUnoShape(nullptr);
- pClonedSdrShape->setUnoShape(xShape);
+ pClonedSdrShape->setUnoShape(pShape);
// pShape->InvalidateSdrObject();
// pShape->Create(pClonedSdrShape, this);
- SdrObject::Free(pObj);
pObj = pClonedSdrShape;
bNeededToClone = true;
}
@@ -215,28 +217,28 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
}
else if ( !pObj->IsInserted() )
{
- mpPage->InsertObject( pObj );
+ mpPage->InsertObject( pObj.get() );
if(bNeededToClone)
{
// TTTT Unfortunately in SdrObject::SetPage (see there) the
// xShape/UnoShape at the newly cloned SDrObject is *removed* again,
// so re-set it here, the caller *may need it* (e.g. Writer)
- uno::Reference< uno::XInterface > xShapeCheck(pObj->getWeakUnoShape());
+ uno::Reference< drawing::XShape > xShapeCheck(pObj->getWeakUnoShape());
if( !xShapeCheck.is() )
{
- pObj->setUnoShape(xShape);
+ pObj->setUnoShape(pShape);
}
}
}
- pShape->Create( pObj, this );
- OSL_ENSURE( pShape->GetSdrObject() == pObj, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
+ pShape->Create( pObj.get(), this );
+ OSL_ENSURE( pShape->GetSdrObject() == pObj.get(), "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
if ( !pObj->IsInserted() )
{
- mpPage->InsertObject( pObj );
+ mpPage->InsertObject( pObj.get() );
}
mpModel->SetChanged();
@@ -257,7 +259,10 @@ void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& x
SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
if( nullptr == pShape )
+ {
+ assert(false && "adding a non-SvxShape to a page?");
return;
+ }
SdrObject *pObj = pShape->GetSdrObject();
@@ -311,9 +316,6 @@ void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
- if (!bUndoEnabled)
- SdrObject::Free(pObj);
-
if (bUndoEnabled)
mpModel->EndUndo();
@@ -492,7 +494,7 @@ void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGr
mpModel->SetChanged();
}
-SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xShape)
+rtl::Reference<SdrObject> SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xShape)
{
SdrObjKind nType = SdrObjKind::NONE;
SdrInventor nInventor;
@@ -507,7 +509,7 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
awt::Point aPos = xShape->getPosition();
tools::Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
- SdrObject* pNewObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pNewObj = SdrObjFactory::MakeNewObject(
*mpModel,
nInventor,
nType,
@@ -518,7 +520,7 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
if( nType == SdrObjKind::E3D_Scene )
{
- auto pScene = static_cast<E3dScene* >(pNewObj);
+ auto pScene = static_cast<E3dScene* >(pNewObj.get());
// initialise scene
double fW = static_cast<double>(aSize.Width);
@@ -537,7 +539,7 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
}
else if(nType == SdrObjKind::E3D_Extrusion)
{
- auto pObj = static_cast<E3dExtrudeObj* >(pNewObj);
+ auto pObj = static_cast<E3dExtrudeObj* >(pNewObj.get());
basegfx::B2DPolygon aNewPolygon;
aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
@@ -550,7 +552,7 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
}
else if(nType == SdrObjKind::E3D_Lathe)
{
- auto pLatheObj = static_cast<E3dLatheObj* >(pNewObj);
+ auto pLatheObj = static_cast<E3dLatheObj* >(pNewObj.get());
basegfx::B2DPolygon aNewPolygon;
aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
@@ -832,19 +834,19 @@ Reference< drawing::XShape > SvxDrawPage::CreateShape( SdrObject *pObj ) const
SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape, bool bBeginning ) noexcept
{
- SdrObject* pObj = CreateSdrObject_( xShape );
+ rtl::Reference<SdrObject> pObj = CreateSdrObject_( xShape );
if( pObj)
{
if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() )
{
if(bBeginning)
- mpPage->InsertObject( pObj, 0 );
+ mpPage->InsertObject( pObj.get(), 0 );
else
- mpPage->InsertObject( pObj );
+ mpPage->InsertObject( pObj.get() );
}
}
- return pObj;
+ return pObj.get();
}
// css::lang::XServiceInfo
@@ -893,6 +895,7 @@ SdrPage* GetSdrPageFromXDrawPage( const uno::Reference< drawing::XDrawPage >& xD
{
return pDrawPage->GetSdrPage();
}
+ assert(false && "non-SvxDrawPage?");
}
return nullptr;
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index d00be27a474b..cf72530e6c7d 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -191,14 +191,14 @@ void SvxShapeGroup::addShape( SvxShape& rShape, size_t nPos )
return;
}
- SdrObject* pSdrShape = rShape.GetSdrObject();
+ rtl::Reference<SdrObject> pSdrShape = rShape.GetSdrObject();
if( pSdrShape == nullptr )
pSdrShape = mxPage->CreateSdrObject_( &rShape );
if( pSdrShape->IsInserted() )
pSdrShape->getParentSdrObjListFromSdrObject()->RemoveObject( pSdrShape->GetOrdNum() );
- GetSdrObject()->GetSubList()->InsertObject(pSdrShape, nPos);
+ GetSdrObject()->GetSubList()->InsertObject(pSdrShape.get(), nPos);
// TTTT Was created using mpModel in CreateSdrObject_ above
// TTTT may be good to add an assertion here for the future
// pSdrShape->SetModel(GetSdrObject()->GetModel());
@@ -214,7 +214,7 @@ void SvxShapeGroup::addShape( SvxShape& rShape, size_t nPos )
// Establish connection between new SdrObject and its wrapper before
// inserting the new shape into the group. There a new wrapper
// would be created when this connection would not already exist.
- rShape.Create( pSdrShape, mxPage.get() );
+ rShape.Create( pSdrShape.get(), mxPage.get() );
GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -264,8 +264,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xS
}
}
- SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
- SdrObject::Free( pObject );
+ rList.NbcRemoveObject( nObjNum );
}
else
{
diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx
index 0704a4e5caa1..8176451eb0ea 100644
--- a/svx/source/unodraw/unoshap3.cxx
+++ b/svx/source/unodraw/unoshap3.cxx
@@ -116,15 +116,15 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape
if(!HasSdrObject() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() )
throw uno::RuntimeException();
- SdrObject* pSdrShape = mxPage->CreateSdrObject_( xShape );
- if( dynamic_cast<const E3dObject* >(pSdrShape) != nullptr )
+ rtl::Reference<SdrObject> pSdrShape = mxPage->CreateSdrObject_( xShape );
+ if( dynamic_cast<const E3dObject* >(pSdrShape.get()) != nullptr )
{
- GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape );
- pShape->Create(pSdrShape, mxPage.get());
+ GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape.get() );
+ pShape->Create(pSdrShape.get(), mxPage.get());
}
else
{
- SdrObject::Free( pSdrShape );
+ pSdrShape.clear();
throw uno::RuntimeException();
}
@@ -138,15 +138,15 @@ void Svx3DSceneObject::addShape( SvxShape& rShape )
if(!HasSdrObject() || !mxPage.is() || nullptr != rShape.GetSdrObject() )
throw uno::RuntimeException();
- SdrObject* pSdrShape = mxPage->CreateSdrObject_( &rShape );
- if( dynamic_cast<const E3dObject* >(pSdrShape) != nullptr )
+ rtl::Reference<SdrObject> pSdrShape = mxPage->CreateSdrObject_( &rShape );
+ if( dynamic_cast<const E3dObject* >(pSdrShape.get()) != nullptr )
{
- GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape );
- rShape.Create(pSdrShape, mxPage.get());
+ GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape.get() );
+ rShape.Create(pSdrShape.get(), mxPage.get());
}
else
{
- SdrObject::Free( pSdrShape );
+ pSdrShape.clear();
throw uno::RuntimeException();
}
@@ -176,8 +176,7 @@ void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xSha
if( nObjNum < nObjCount )
{
- SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
- SdrObject::Free( pObject );
+ rList.NbcRemoveObject( nObjNum );
}
else
{
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 9eb3edfd5ab8..9ab5ef495f69 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -113,7 +113,6 @@ struct SvxShapeImpl
std::optional<SfxItemSet> mxItemSet;
SdrObjKind mnObjId;
SvxShapeMaster* mpMaster;
- bool mbHasSdrObjectOwnership;
bool mbDisposing;
/** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
@@ -121,7 +120,7 @@ struct SvxShapeImpl
* SdrObject so a multiple call to SvxShape::Create() with same SdrObject
* is prohibited.
*/
- ::tools::WeakReference< SdrObject > mpCreatedObj;
+ ::unotools::WeakReference< SdrObject > mxCreatedObj;
// for xComponent
::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> maDisposeListeners;
@@ -130,7 +129,6 @@ struct SvxShapeImpl
SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex )
:mnObjId( SdrObjKind::NONE )
,mpMaster( nullptr )
- ,mbHasSdrObjectOwnership( false )
,mbDisposing( false )
,maDisposeListeners( _rMutex )
,maPropertyNotifier( _rAntiImpl, _rMutex )
@@ -199,7 +197,7 @@ SvxShape::SvxShape( SdrObject* pObject )
, mbIsMultiPropertyCall(false)
, mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
, maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
-, mpSdrObjectWeakReference(pObject)
+, mxSdrObject(pObject)
, mnLockCount(0)
{
impl_construct();
@@ -212,7 +210,7 @@ SvxShape::SvxShape( SdrObject* pObject, o3tl::span<const SfxItemPropertyMapEntry
, mbIsMultiPropertyCall(false)
, mpPropSet(pPropertySet)
, maPropMapEntries(pEntries)
-, mpSdrObjectWeakReference(pObject)
+, mxSdrObject(pObject)
, mnLockCount(0)
{
impl_construct();
@@ -228,52 +226,26 @@ SvxShape::~SvxShape() noexcept
if ( mpImpl->mpMaster )
mpImpl->mpMaster->dispose();
- if ( HasSdrObject() )
- {
- EndListening(GetSdrObject()->getSdrModelFromSdrObject());
- GetSdrObject()->setUnoShape(nullptr);
- }
-
- if( HasSdrObjectOwnership() && HasSdrObject() )
+ if ( mxSdrObject )
{
- mpImpl->mbHasSdrObjectOwnership = false;
- SdrObject* pObject = GetSdrObject();
- SdrObject::Free( pObject );
+ EndListening(mxSdrObject->getSdrModelFromSdrObject());
+ mxSdrObject->setUnoShape(nullptr);
+ mxSdrObject.clear();
}
EndListeningAll(); // call explicitly within SolarMutexGuard
}
-void SvxShape::TakeSdrObjectOwnership()
-{
- mpImpl->mbHasSdrObjectOwnership = true;
-}
-
-
void SvxShape::InvalidateSdrObject()
{
- if(HasSdrObject())
+ if(mxSdrObject)
{
- EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+ EndListening(mxSdrObject->getSdrModelFromSdrObject());
+ mxSdrObject.clear();
}
-
- if (HasSdrObjectOwnership())
- return;
-
- mpSdrObjectWeakReference.reset(nullptr);
};
-bool SvxShape::HasSdrObjectOwnership() const
-{
- if ( !mpImpl->mbHasSdrObjectOwnership )
- return false;
-
- OSL_ENSURE( HasSdrObject(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
- return HasSdrObject();
-}
-
-
void SvxShape::setShapeKind( SdrObjKind nKind )
{
mpImpl->mnObjId = nKind;
@@ -388,7 +360,7 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
if ( !pNewObj )
return;
- SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get();
+ rtl::Reference<SdrObject> pCreatedObj = mpImpl->mxCreatedObj.get();
assert( ( !pCreatedObj || ( pCreatedObj == pNewObj ) ) &&
"SvxShape::Create: the same shape used for two different objects?! Strange ..." );
@@ -397,14 +369,14 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
return;
// Correct condition (#i52126#)
- mpImpl->mpCreatedObj = pNewObj;
+ mpImpl->mxCreatedObj = pNewObj;
if( HasSdrObject() )
{
EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
}
- mpSdrObjectWeakReference.reset( pNewObj );
+ mxSdrObject = pNewObj;
if( HasSdrObject() )
{
@@ -972,20 +944,20 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) noexcept
// do cheap checks first, this method is hot
if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
return;
- SdrObject* pSdrObject(mpSdrObjectWeakReference.get());
+ rtl::Reference<SdrObject> pSdrObject(mxSdrObject);
if( !pSdrObject )
return;
const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint);
// #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
if ((pSdrHint->GetKind() != SdrHintKind::ModelCleared) &&
- (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != pSdrObject ))
+ (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != pSdrObject.get() ))
return;
uno::Reference< uno::XInterface > xSelf( pSdrObject->getWeakUnoShape() );
if( !xSelf.is() )
{
EndListening(pSdrObject->getSdrModelFromSdrObject());
- mpSdrObjectWeakReference.reset(nullptr);
+ mxSdrObject.clear();
return;
}
@@ -995,18 +967,10 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) noexcept
}
else // (pSdrHint->GetKind() == SdrHintKind::ModelCleared)
{
- if(!HasSdrObjectOwnership())
- {
- EndListening(pSdrObject->getSdrModelFromSdrObject());
- pSdrObject->setUnoShape(nullptr);
-
- mpSdrObjectWeakReference.reset(nullptr);
-
- // SdrModel *is* going down, try to Free SdrObject even
- // when !HasSdrObjectOwnership
- if(!pSdrObject->IsInserted())
- SdrObject::Free(pSdrObject);
- }
+ EndListening(pSdrObject->getSdrModelFromSdrObject());
+ pSdrObject->setUnoShape(nullptr);
+ pSdrObject.clear();
+ mxSdrObject.clear();
if(!mpImpl->mbDisposing)
dispose();
@@ -1243,13 +1207,11 @@ void SAL_CALL SvxShape::dispose()
mpImpl->maDisposeListeners.disposeAndClear(aEvt);
mpImpl->maPropertyNotifier.disposing();
- if ( !HasSdrObject() )
+ rtl::Reference<SdrObject> pObject = mxSdrObject;
+ if (!pObject)
return;
- SdrObject* pObject = GetSdrObject();
-
EndListening( pObject->getSdrModelFromSdrObject() );
- bool bFreeSdrObject = false;
if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() )
{
@@ -1258,27 +1220,16 @@ void SAL_CALL SvxShape::dispose()
const size_t nCount = pPage->GetObjCount();
for ( size_t nNum = 0; nNum < nCount; ++nNum )
{
- if ( pPage->GetObj( nNum ) == pObject )
+ if ( pPage->GetObj( nNum ) == pObject.get() )
{
OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject );
- if (HasSdrObjectOwnership())
- {
- bFreeSdrObject = true;
- }
break;
}
}
}
+ mxSdrObject.clear();
pObject->setUnoShape(nullptr);
-
- if ( bFreeSdrObject )
- {
- // in case we have the ownership of the SdrObject, a Free
- // would do nothing. So ensure the ownership is reset.
- mpImpl->mbHasSdrObjectOwnership = false;
- SdrObject::Free( pObject );
- }
}
@@ -2034,6 +1985,7 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName )
bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue )
{
+ rtl::Reference<SdrObject> pSdrObject = GetSdrObject();
switch( pProperty->nWID )
{
case OWN_ATTR_CAPTION_POINT:
@@ -2050,18 +2002,18 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
// #90763# position is relative to top left, make it absolute
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ pSdrObject->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aVclPoint.AdjustX(basegfx::fround(aNewHomogenMatrix.get(0, 2)) );
aVclPoint.AdjustY(basegfx::fround(aNewHomogenMatrix.get(1, 2)) );
// #88491# position relative to anchor
- if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
{
- aVclPoint += GetSdrObject()->GetAnchorPos();
+ aVclPoint += pSdrObject->GetAnchorPos();
}
- static_cast<SdrCaptionObj*>(GetSdrObject())->SetTailPos(aVclPoint);
+ static_cast<SdrCaptionObj*>(pSdrObject.get())->SetTailPos(aVclPoint);
return true;
}
@@ -2076,7 +2028,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
basegfx::B2DHomMatrix aNewHomogenMatrix;
// tdf#117145 SdrModel data is app-specific
- GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ pSdrObject->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
@@ -2092,7 +2044,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
// Need to adapt aNewHomogenMatrix from 100thmm to app-specific
ForceMetricToItemPoolMetric(aNewHomogenMatrix);
- GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ pSdrObject->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
return true;
}
break;
@@ -2103,9 +2055,9 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
sal_Int32 nNewOrdNum = 0;
if(rValue >>= nNewOrdNum)
{
- SdrObjList* pObjList = GetSdrObject()->getParentSdrObjListFromSdrObject();
+ SdrObjList* pObjList = pSdrObject->getParentSdrObjListFromSdrObject();
if( pObjList )
- pObjList->SetExistingObjectOrdNum( GetSdrObject(), static_cast<size_t>(nNewOrdNum) );
+ pObjList->SetExistingObjectOrdNum( pSdrObject.get(), static_cast<size_t>(nNewOrdNum) );
return true;
}
break;
@@ -2122,7 +2074,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
tools::Rectangle aRect;
aRect.SetPos(aTopLeft);
aRect.SetSize(aObjSize);
- GetSdrObject()->SetSnapRect(aRect);
+ pSdrObject->SetSnapRect(aRect);
return true;
}
break;
@@ -2132,7 +2084,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
bool bMirror;
if(rValue >>= bMirror )
{
- SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( GetSdrObject() );
+ SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( pSdrObject.get() );
if( pObj )
pObj->SetMirrored(bMirror);
return true;
@@ -2147,7 +2099,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_EDGE_END_POS:
case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
{
- SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(GetSdrObject());
+ SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(pSdrObject.get());
if(pEdgeObj)
{
switch(pProperty->nWID)
@@ -2181,8 +2133,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
// perform metric change before applying anchor position,
// because the anchor position is in pool metric.
ForceMetricToItemPoolMetric( aPoint );
- if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
- aPoint += GetSdrObject()->GetAnchorPos();
+ if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
+ aPoint += pSdrObject->GetAnchorPos();
pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
return true;
@@ -2223,9 +2175,9 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
{
// Reintroduction of fix for issue i59051 (#i108851#)
ForceMetricToItemPoolMetric( aNewPolyPolygon );
- if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
{
- Point aPoint( GetSdrObject()->GetAnchorPos() );
+ Point aPoint( pSdrObject->GetAnchorPos() );
aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
}
pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
@@ -2239,7 +2191,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_MEASURE_START_POS:
case OWN_ATTR_MEASURE_END_POS:
{
- SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(GetSdrObject());
+ SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(pSdrObject.get());
awt::Point aUnoPoint;
if(pMeasureObj && ( rValue >>= aUnoPoint ) )
{
@@ -2247,8 +2199,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
// Reintroduction of fix for issue #i59051# (#i108851#)
ForceMetricToItemPoolMetric( aPoint );
- if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
- aPoint += GetSdrObject()->GetAnchorPos();
+ if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
+ aPoint += pSdrObject->GetAnchorPos();
pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 );
pMeasureObj->SetChanged();
@@ -2268,8 +2220,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
eMode = static_cast<drawing::BitmapMode>(nMode);
}
- GetSdrObject()->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
- GetSdrObject()->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
+ pSdrObject->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
+ pSdrObject->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
return true;
}
@@ -2278,10 +2230,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
sal_Int16 nLayerId = sal_Int16();
if( rValue >>= nLayerId )
{
- SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId));
+ SdrLayer* pLayer = pSdrObject->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId));
if( pLayer )
{
- GetSdrObject()->SetLayer(SdrLayerID(nLayerId));
+ pSdrObject->SetLayer(SdrLayerID(nLayerId));
return true;
}
}
@@ -2293,10 +2245,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
OUString aLayerName;
if( rValue >>= aLayerName )
{
- const SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName);
+ const SdrLayer* pLayer = pSdrObject->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName);
if( pLayer != nullptr )
{
- GetSdrObject()->SetLayer( pLayer->GetID() );
+ pSdrObject->SetLayer( pLayer->GetID() );
return true;
}
}
@@ -2308,13 +2260,13 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
if( rValue >>= nTmp )
{
Degree100 nAngle(nTmp);
- Point aRef1(GetSdrObject()->GetSnapRect().Center());
- nAngle -= GetSdrObject()->GetRotateAngle();
+ Point aRef1(pSdrObject->GetSnapRect().Center());
+ nAngle -= pSdrObject->GetRotateAngle();
if (nAngle)
{
double nSin = sin(toRadians(nAngle));
double nCos = cos(toRadians(nAngle));
- GetSdrObject()->Rotate(aRef1,nAngle,nSin,nCos);
+ pSdrObject->Rotate(aRef1,nAngle,nSin,nCos);
}
return true;
}
@@ -2328,12 +2280,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
if( rValue >>= nTmp )
{
Degree100 nShear(nTmp);
- nShear -= GetSdrObject()->GetShearAngle();
+ nShear -= pSdrObject->GetShearAngle();
if(nShear)
{
- Point aRef1(GetSdrObject()->GetSnapRect().Center());
+ Point aRef1(pSdrObject->GetSnapRect().Center());
double nTan = tan(toRadians(nShear));
- GetSdrObject()->Shear(aRef1,nShear,nTan,false);
+ pSdrObject->Shear(aRef1,nShear,nTan,false);
return true;
}
}
@@ -2343,7 +2295,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_INTEROPGRABBAG:
{
- GetSdrObject()->SetGrabBagItem(rValue);
+ pSdrObject->SetGrabBagItem(rValue);
return true;
}
@@ -2352,7 +2304,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
bool bMoveProtect;
if( rValue >>= bMoveProtect )
{
- GetSdrObject()->SetMoveProtect(bMoveProtect);
+ pSdrObject->SetMoveProtect(bMoveProtect);
return true;
}
break;
@@ -2362,7 +2314,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
OUString aName;
if( rValue >>= aName )
{
- GetSdrObject()->SetName( aName );
+ pSdrObject->SetName( aName );
return true;
}
break;
@@ -2373,9 +2325,9 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
sal_Int16 nMaxScale = 0;
if (rValue >>= nMaxScale)
{
- SdrTextFitToSizeTypeItem aItem(GetSdrObject()->GetMergedItem(SDRATTR_TEXT_FITTOSIZE));
+ SdrTextFitToSizeTypeItem aItem(pSdrObject->GetMergedItem(SDRATTR_TEXT_FITTOSIZE));
aItem.SetMaxScale(nMaxScale);
- GetSdrObject()->SetMergedItem(aItem);
+ pSdrObject->SetMergedItem(aItem);
return true;
}
break;
@@ -2387,7 +2339,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
OUString aTitle;
if( rValue >>= aTitle )
{
- GetSdrObject()->SetTitle( aTitle );
+ pSdrObject->SetTitle( aTitle );
return true;
}
break;
@@ -2397,7 +2349,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
OUString aDescription;
if( rValue >>= aDescription )
{
- GetSdrObject()->SetDescription( aDescription );
+ pSdrObject->SetDescription( aDescription );
return true;
}
break;
@@ -2408,7 +2360,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
bool bPrintable;
if( rValue >>= bPrintable )
{
- GetSdrObject()->SetPrintable(bPrintable);
+ pSdrObject->SetPrintable(bPrintable);
return true;
}
break;
@@ -2418,7 +2370,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
bool bVisible;
if( rValue >>= bVisible )
{
- GetSdrObject()->SetVisible(bVisible);
+ pSdrObject->SetVisible(bVisible);
return true;
}
break;
@@ -2428,7 +2380,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
bool bResizeProtect;
if( rValue >>= bResizeProtect )
{
- GetSdrObject()->SetResizeProtect(bResizeProtect);
+ pSdrObject->SetResizeProtect(bResizeProtect);
return true;
}
break;
@@ -2438,7 +2390,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
sal_Int32 nPageNum = 0;
if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
{
- SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(GetSdrObject());
+ SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(pSdrObject.get());
if( pPageObj )
{
SdrModel& rModel(pPageObj->getSdrModelFromSdrObject());
@@ -2483,7 +2435,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_TEXTCOLUMNS:
{
- if (auto pTextObj = dynamic_cast<SdrTextObj*>(GetSdrObject()))
+ if (auto pTextObj = dynamic_cast<SdrTextObj*>(pSdrObject.get()))
{
css::uno::Reference<css::text::XTextColumns> xTextColumns;
if (rValue >>= xTextColumns)
@@ -2506,7 +2458,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
OUString sHyperlink;
if (rValue >>= sHyperlink)
{
- GetSdrObject()->setHyperlink(sHyperlink);
+ pSdrObject->setHyperlink(sHyperlink);
return true;
}
break;
diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index 2dd945e4cd5c..35224efdc0b9 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -21,10 +21,10 @@
#include "swtypes.hxx"
#include "swrect.hxx"
+#include <svx/svdobj.hxx>
#include <libxml/xmlwriter.h>
struct SwPosition;
-class SdrObject;
class SwFrame;
class SwLayoutFrame;
class SwTextFrame;
@@ -45,7 +45,7 @@ class SW_DLLPUBLIC SwAnchoredObject
{
private:
// drawing object representing the anchored object in the drawing layer
- SdrObject* mpDrawObj;
+ rtl::Reference<SdrObject> mpDrawObj;
/// Frame the object is anchored at.
/// For at-char/at-para anchor, this is always the master SwTextFrame.
SwFrame* mpAnchorFrame;
@@ -197,8 +197,9 @@ class SW_DLLPUBLIC SwAnchoredObject
// accessors to member <mpDrawObj>
void SetDrawObj( SdrObject& _rDrawObj );
- const SdrObject* GetDrawObj() const { return mpDrawObj; }
- SdrObject* DrawObj() { return mpDrawObj; }
+ const SdrObject* GetDrawObj() const { return mpDrawObj.get(); }
+ SdrObject* DrawObj() { return mpDrawObj.get(); }
+ void ClearDrawObj() { mpDrawObj.clear(); }
// accessors to member <mpAnchorFrame>
const SwFrame* GetAnchorFrame() const { return mpAnchorFrame; }
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 8da7c9b545ac..b1025b447de5 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -175,9 +175,7 @@ public:
class SW_DLLPUBLIC SwFlyDrawContact final : public SwContact
{
private:
- typedef std::unique_ptr< SwFlyDrawObj, SdrObjectFreeOp > SwFlyDrawObjPtr;
-
- SwFlyDrawObjPtr mpMasterObj;
+ rtl::Reference<SwFlyDrawObj> mpMasterObj;
void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly, SwFrame const& rAnchorFrame);
@@ -241,7 +239,7 @@ class SwDrawVirtObj final : public SdrVirtObj
/// access to offset
virtual Point GetOffset() const override;
- virtual SwDrawVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
/// connection to writer layout
const SwAnchoredObject& GetAnchoredObj() const { return maAnchoredDrawObj; }
@@ -302,8 +300,6 @@ bool CheckControlLayer( const SdrObject *pObj );
/** ContactObject for connection of formats as representatives of draw objects
in SwClient and the objects themselves in Drawing (SDrObjUserCall). */
-typedef std::unique_ptr< SwDrawVirtObj, SdrObjectFreeOp > SwDrawVirtObjPtr;
-
class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
{
private:
@@ -312,7 +308,7 @@ class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
SwAnchoredDrawObject maAnchoredDrawObj;
/** container for 'virtual' drawing object supporting drawing objects in headers/footers. */
- std::vector< SwDrawVirtObjPtr > maDrawVirtObjs;
+ std::vector< rtl::Reference<SwDrawVirtObj> > maDrawVirtObjs;
/** boolean indicating set 'master' drawing
object has been cleared. */
@@ -332,8 +328,6 @@ class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
friend class NestedUserCallHdl;
- void RemoveAllVirtObjs();
-
void InvalidateObjs_( const bool _bUpdateSortedObjsList = false );
SwDrawContact( const SwDrawContact& ) = delete;
@@ -387,6 +381,8 @@ class SAL_DLLPUBLIC_RTTI SwDrawContact final : public SwContact
drawing object from drawing page. */
void RemoveMasterFromDrawPage();
+ void RemoveAllVirtObjs();
+
/** get drawing object ('master' or 'virtual')
by frame. */
SdrObject* GetDrawObjectByAnchorFrame( const SwFrame& _rAnchorFrame );
diff --git a/sw/inc/dobjfac.hxx b/sw/inc/dobjfac.hxx
index 1de1192a8bc9..33d55bdccf22 100644
--- a/sw/inc/dobjfac.hxx
+++ b/sw/inc/dobjfac.hxx
@@ -25,7 +25,7 @@
class SwObjectFactory
{
public:
- DECL_STATIC_LINK(SwObjectFactory, MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_STATIC_LINK(SwObjectFactory, MakeObject, SdrObjCreatorParams, rtl::Reference<SdrObject>);
};
extern SwObjectFactory aSwObjectFactory;
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
index 2f06a9c8d0fc..c5a5c45a9813 100644
--- a/sw/inc/dpage.hxx
+++ b/sw/inc/dpage.hxx
@@ -44,7 +44,7 @@ public:
// #i3694#
// This GetOffset() method is not needed anymore, it even leads to errors.
// virtual Point GetOffset() const;
- virtual SdrObject* ReplaceObject( SdrObject* pNewObj, size_t nObjNum ) override;
+ virtual rtl::Reference<SdrObject> ReplaceObject( SdrObject* pNewObj, size_t nObjNum ) override;
virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV,
const tools::Rectangle *pRect) const override;
diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index df4f739127c9..e252499f0453 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -43,7 +43,7 @@ class SwXShape;
class SwFmDrawPage final : public SvxFmDrawPage
{
SdrPageView* m_pPageView;
- std::vector<SwXShape*> m_vShapes;
+ std::vector<rtl::Reference<SwXShape>> m_vShapes;
public:
SwFmDrawPage( SdrPage* pPage );
virtual ~SwFmDrawPage() noexcept override;
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 65c1a56f80af..8caeb37e79db 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -118,30 +118,30 @@ SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool bMoveWithinDoc,
}
// TTTT Clone directly to target SdrModel
- SdrObject *pObj(rObj.CloneSdrObject(*getIDocumentDrawModelAccess().GetDrawModel()));
+ rtl::Reference<SdrObject> pObj(rObj.CloneSdrObject(*getIDocumentDrawModelAccess().GetDrawModel()));
if( bMoveWithinDoc && SdrInventor::FmForm == pObj->GetObjInventor() )
{
// We need to preserve the Name for Controls
- uno::Reference< awt::XControlModel > xModel = static_cast<SdrUnoObj*>(pObj)->GetUnoControlModel();
+ uno::Reference< awt::XControlModel > xModel = static_cast<SdrUnoObj*>(pObj.get())->GetUnoControlModel();
uno::Any aVal;
uno::Reference< beans::XPropertySet > xSet(xModel, uno::UNO_QUERY);
static const OUStringLiteral sName(u"Name");
if( xSet.is() )
aVal = xSet->getPropertyValue( sName );
if( bInsInPage )
- pPg->InsertObjectThenMakeNameUnique( pObj );
+ pPg->InsertObjectThenMakeNameUnique( pObj.get() );
if( xSet.is() )
xSet->setPropertyValue( sName, aVal );
}
else if( bInsInPage )
- pPg->InsertObjectThenMakeNameUnique( pObj );
+ pPg->InsertObjectThenMakeNameUnique( pObj.get() );
// For drawing objects: set layer of cloned object to invisible layer
SdrLayerID nLayerIdForClone = rObj.GetLayer();
- if ( dynamic_cast<const SwFlyDrawObj*>( pObj) == nullptr &&
- dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr &&
- !isType<SdrObject>(pObj) )
+ if ( dynamic_cast<const SwFlyDrawObj*>( pObj.get() ) == nullptr &&
+ dynamic_cast<const SwVirtFlyDrawObj*>( pObj.get() ) == nullptr &&
+ !isType<SdrObject>(pObj.get()) )
{
if ( getIDocumentDrawModelAccess().IsVisibleLayerId( nLayerIdForClone ) )
{
@@ -150,7 +150,7 @@ SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool bMoveWithinDoc,
}
pObj->SetLayer( nLayerIdForClone );
- return pObj;
+ return pObj.get();
}
SwFlyFrameFormat* SwDoc::MakeFlySection_( const SwPosition& rAnchPos,
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 048d841f6dd2..369c46e4ea80 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -93,7 +93,7 @@ namespace
: m_pAnchorFrame(FindFrame(pAnchorFrame))
{}
- bool operator()(const SwDrawVirtObjPtr& rpDrawVirtObj)
+ bool operator()(const rtl::Reference<SwDrawVirtObj>& rpDrawVirtObj)
{
return FindFrame(rpDrawVirtObj->GetAnchorFrame()) == m_pAnchorFrame;
}
@@ -532,7 +532,7 @@ SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly,
IDocumentDrawModelAccess& rIDDMA = pFormat->getIDocumentDrawModelAccess();
SwFlyDrawContact* pContact = pFormat->GetOrCreateContact();
- SwVirtFlyDrawObj* pDrawObj(
+ rtl::Reference<SwVirtFlyDrawObj> pDrawObj(
new SwVirtFlyDrawObj(
pContact->GetMaster()->getSdrModelFromSdrObject(),
*pContact->GetMaster(),
@@ -547,16 +547,16 @@ SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly,
if(nullptr != pPg)
{
const size_t nOrdNum = pContact->GetMaster()->GetOrdNum();
- pPg->ReplaceObject(pDrawObj, nOrdNum);
+ pPg->ReplaceObject(pDrawObj.get(), nOrdNum);
}
// #i27030# - insert new <SwVirtFlyDrawObj> instance
// into drawing page with correct order number
else
- rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj, pContact->GetOrdNumForNewRef(pFly, rAnchorFrame));
+ rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj.get(), pContact->GetOrdNumForNewRef(pFly, rAnchorFrame));
// #i38889# - assure, that new <SwVirtFlyDrawObj> instance
// is in a visible layer.
- pContact->MoveObjToVisibleLayer(pDrawObj);
- return pDrawObj;
+ pContact->MoveObjToVisibleLayer(pDrawObj.get());
+ return pDrawObj.get();
}
// #i26791#
@@ -746,10 +746,7 @@ SwDrawContact::~SwDrawContact()
RemoveAllVirtObjs();
if ( !mbMasterObjCleared )
- {
- SdrObject* pObject = const_cast< SdrObject* >( maAnchoredDrawObj.GetDrawObj() );
- SdrObject::Free( pObject );
- }
+ maAnchoredDrawObj.ClearDrawObj();
}
void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc& rDoc)
@@ -833,11 +830,10 @@ SwFrame* SwDrawContact::GetAnchorFrame(SdrObject const *const pDrawObj)
SwDrawVirtObj* SwDrawContact::AddVirtObj(SwFrame const& rAnchorFrame)
{
maDrawVirtObjs.push_back(
- SwDrawVirtObjPtr(
new SwDrawVirtObj(
GetMaster()->getSdrModelFromSdrObject(),
*GetMaster(),
- *this)));
+ *this));
maDrawVirtObjs.back()->AddToDrawingPage(rAnchorFrame);
return maDrawVirtObjs.back().get();
}
@@ -850,6 +846,8 @@ void SwDrawContact::RemoveAllVirtObjs()
// remove and destroy 'virtual object'
rpDrawVirtObj->RemoveFromWriterLayout();
rpDrawVirtObj->RemoveFromDrawingPage();
+ // to break the reference cycle
+ rpDrawVirtObj->AnchoredObj().ClearDrawObj();
}
maDrawVirtObjs.clear();
}
@@ -1755,7 +1753,7 @@ void SwDrawContact::DisconnectObjFromLayout( SdrObject* _pDrawObj )
else
{
const auto ppVirtDrawObj(std::find_if(maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
- [] (const SwDrawVirtObjPtr& pObj) { return pObj->IsConnected(); }));
+ [] (const rtl::Reference<SwDrawVirtObj>& pObj) { return pObj->IsConnected(); }));
if(ppVirtDrawObj != maDrawVirtObjs.end())
{
@@ -2280,7 +2278,7 @@ SwDrawVirtObj::~SwDrawVirtObj()
{
}
-SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SwDrawVirtObj(rTargetModel, *this);
}
@@ -2434,7 +2432,7 @@ void SwDrawVirtObj::RecalcBoundRect()
basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const
{
- basegfx::B2DPolyPolygon aRetval(rRefObj.TakeXorPoly());
+ basegfx::B2DPolyPolygon aRetval(mxRefObj->TakeXorPoly());
aRetval.transform(basegfx::utils::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
return aRetval;
@@ -2442,7 +2440,7 @@ basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const
basegfx::B2DPolyPolygon SwDrawVirtObj::TakeContour() const
{
- basegfx::B2DPolyPolygon aRetval(rRefObj.TakeContour());
+ basegfx::B2DPolyPolygon aRetval(mxRefObj->TakeContour());
aRetval.transform(basegfx::utils::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y()));
return aRetval;
@@ -2451,7 +2449,7 @@ basegfx::B2DPolyPolygon SwDrawVirtObj::TakeContour() const
void SwDrawVirtObj::AddToHdlList(SdrHdlList& rHdlList) const
{
SdrHdlList tmpList(nullptr);
- rRefObj.AddToHdlList(tmpList);
+ mxRefObj->AddToHdlList(tmpList);
size_t cnt = tmpList.GetHdlCount();
for(size_t i=0; i < cnt; ++i)
@@ -2470,25 +2468,25 @@ void SwDrawVirtObj::NbcMove(const Size& rSiz)
void SwDrawVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
- rRefObj.NbcResize(rRef - GetOffset(), xFact, yFact);
+ mxRefObj->NbcResize(rRef - GetOffset(), xFact, yFact);
SetBoundAndSnapRectsDirty();
}
void SwDrawVirtObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
{
- rRefObj.NbcRotate(rRef - GetOffset(), nAngle, sn, cs);
+ mxRefObj->NbcRotate(rRef - GetOffset(), nAngle, sn, cs);
SetBoundAndSnapRectsDirty();
}
void SwDrawVirtObj::NbcMirror(const Point& rRef1, const Point& rRef2)
{
- rRefObj.NbcMirror(rRef1 - GetOffset(), rRef2 - GetOffset());
+ mxRefObj->NbcMirror(rRef1 - GetOffset(), rRef2 - GetOffset());
SetBoundAndSnapRectsDirty();
}
void SwDrawVirtObj::NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
{
- rRefObj.NbcShear(rRef - GetOffset(), nAngle, tn, bVShear);
+ mxRefObj->NbcShear(rRef - GetOffset(), nAngle, tn, bVShear);
SetBoundAndSnapRectsDirty();
}
@@ -2502,7 +2500,7 @@ void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fract
if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator())
{
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
- rRefObj.Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative);
+ mxRefObj->Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2513,7 +2511,7 @@ void SwDrawVirtObj::Rotate(const Point& rRef, Degree100 nAngle, double sn, doubl
if(nAngle)
{
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
- rRefObj.Rotate(rRef - GetOffset(), nAngle, sn, cs);
+ mxRefObj->Rotate(rRef - GetOffset(), nAngle, sn, cs);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2522,7 +2520,7 @@ void SwDrawVirtObj::Rotate(const Point& rRef, Degree100 nAngle, double sn, doubl
void SwDrawVirtObj::Mirror(const Point& rRef1, const Point& rRef2)
{
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
- rRefObj.Mirror(rRef1 - GetOffset(), rRef2 - GetOffset());
+ mxRefObj->Mirror(rRef1 - GetOffset(), rRef2 - GetOffset());
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2532,7 +2530,7 @@ void SwDrawVirtObj::Shear(const Point& rRef, Degree100 nAngle, double tn, bool b
if(nAngle)
{
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
- rRefObj.Shear(rRef - GetOffset(), nAngle, tn, bVShear);
+ mxRefObj->Shear(rRef - GetOffset(), nAngle, tn, bVShear);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2540,13 +2538,13 @@ void SwDrawVirtObj::Shear(const Point& rRef, Degree100 nAngle, double tn, bool b
void SwDrawVirtObj::RecalcSnapRect()
{
- aSnapRect = rRefObj.GetSnapRect();
+ aSnapRect = mxRefObj->GetSnapRect();
aSnapRect += GetOffset();
}
const tools::Rectangle& SwDrawVirtObj::GetSnapRect() const
{
- const_cast<SwDrawVirtObj*>(this)->aSnapRect = rRefObj.GetSnapRect();
+ const_cast<SwDrawVirtObj*>(this)->aSnapRect = mxRefObj->GetSnapRect();
const_cast<SwDrawVirtObj*>(this)->aSnapRect += GetOffset();
return aSnapRect;
@@ -2557,7 +2555,7 @@ void SwDrawVirtObj::SetSnapRect(const tools::Rectangle& rRect)
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
tools::Rectangle aR(rRect);
aR -= GetOffset();
- rRefObj.SetSnapRect(aR);
+ mxRefObj->SetSnapRect(aR);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2567,12 +2565,12 @@ void SwDrawVirtObj::NbcSetSnapRect(const tools::Rectangle& rRect)
tools::Rectangle aR(rRect);
aR -= GetOffset();
SetBoundAndSnapRectsDirty();
- rRefObj.NbcSetSnapRect(aR);
+ mxRefObj->NbcSetSnapRect(aR);
}
const tools::Rectangle& SwDrawVirtObj::GetLogicRect() const
{
- const_cast<SwDrawVirtObj*>(this)->aSnapRect = rRefObj.GetLogicRect();
+ const_cast<SwDrawVirtObj*>(this)->aSnapRect = mxRefObj->GetLogicRect();
const_cast<SwDrawVirtObj*>(this)->aSnapRect += GetOffset();
return aSnapRect;
@@ -2583,7 +2581,7 @@ void SwDrawVirtObj::SetLogicRect(const tools::Rectangle& rRect)
tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
tools::Rectangle aR(rRect);
aR -= GetOffset();
- rRefObj.SetLogicRect(aR);
+ mxRefObj->SetLogicRect(aR);
SetBoundAndSnapRectsDirty();
SendUserCall(SdrUserCallType::Resize, aBoundRect0);
}
@@ -2592,13 +2590,13 @@ void SwDrawVirtObj::NbcSetLogicRect(const tools::Rectangle& rRect)
{
tools::Rectangle aR(rRect);
aR -= GetOffset();
- rRefObj.NbcSetLogicRect(aR);
+ mxRefObj->NbcSetLogicRect(aR);
SetBoundAndSnapRectsDirty();
}
Point SwDrawVirtObj::GetSnapPoint(sal_uInt32 i) const
{
- Point aP(rRefObj.GetSnapPoint(i));
+ Point aP(mxRefObj->GetSnapPoint(i));
aP += GetOffset();
return aP;
@@ -2606,20 +2604,20 @@ Point SwDrawVirtObj::GetSnapPoint(sal_uInt32 i) const
Point SwDrawVirtObj::GetPoint(sal_uInt32 i) const
{
- return rRefObj.GetPoint(i) + GetOffset();
+ return mxRefObj->GetPoint(i) + GetOffset();
}
void SwDrawVirtObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
{
Point aP(rPnt);
aP -= GetOffset();
- rRefObj.SetPoint(aP, i);
+ mxRefObj->SetPoint(aP, i);
SetBoundAndSnapRectsDirty();
}
bool SwDrawVirtObj::HasTextEdit() const
{
- return rRefObj.HasTextEdit();
+ return mxRefObj->HasTextEdit();
}
// override 'layer' methods for 'virtual' drawing object to assure
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index a580b8c176f9..467df8864a7c 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -432,8 +432,7 @@ SwVirtFlyDrawObj::SwVirtFlyDrawObj(
SwVirtFlyDrawObj::~SwVirtFlyDrawObj()
{
- if ( getSdrPageFromSdrObject() ) //Withdraw SdrPage the responsibility.
- getSdrPageFromSdrObject()->RemoveObject( GetOrdNum() );
+ assert (!getSdrPageFromSdrObject() && "should have already been removed");
}
const SwFrameFormat *SwVirtFlyDrawObj::GetFormat() const
@@ -1191,10 +1190,10 @@ Degree100 SwVirtFlyDrawObj::GetRotateAngle() const
}
}
-SdrObjectUniquePtr SwVirtFlyDrawObj::getFullDragClone() const
+rtl::Reference<SdrObject> SwVirtFlyDrawObj::getFullDragClone() const
{
// call parent
- SdrObjectUniquePtr pRetval = SdrVirtObj::getFullDragClone();
+ rtl::Reference<SdrObject> pRetval = SdrVirtObj::getFullDragClone();
if(pRetval && GetFlyFrame() && ContainsSwGrfNode())
{
diff --git a/sw/source/core/draw/dobjfac.cxx b/sw/source/core/draw/dobjfac.cxx
index 818b870da72a..4532ed82a9fc 100644
--- a/sw/source/core/draw/dobjfac.cxx
+++ b/sw/source/core/draw/dobjfac.cxx
@@ -24,7 +24,7 @@
SwObjectFactory aSwObjectFactory;
IMPL_STATIC_LINK(
- SwObjectFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
+ SwObjectFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> )
{
if ( aParams.nInventor == SdrInventor::Swg )
{
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index ea3c0c83f191..93b5e42cbce1 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -78,7 +78,7 @@ rtl::Reference<SdrPage> SwDPage::CloneSdrPage(SdrModel& rTargetModel) const
return pClonedSwDPage;
}
-SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum )
+rtl::Reference<SdrObject> SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum )
{
SdrObject *pOld = GetObj( nObjNum );
OSL_ENSURE( pOld, "Oups, Object not replaced" );
diff --git a/sw/source/core/draw/drawdoc.cxx b/sw/source/core/draw/drawdoc.cxx
index 4c3050ebf5b7..0f4d16116f45 100644
--- a/sw/source/core/draw/drawdoc.cxx
+++ b/sw/source/core/draw/drawdoc.cxx
@@ -27,6 +27,7 @@
#include <dpage.hxx>
#include <docsh.hxx>
#include <hintids.hxx>
+#include <dcontact.hxx>
#include <DocumentSettingManager.hxx>
using namespace com::sun::star;
@@ -84,6 +85,27 @@ SwDrawModel::~SwDrawModel()
{
Broadcast(SdrHint(SdrHintKind::ModelCleared));
+ // We have a nasty situation, where SwDrawVirtObj has a SwAnchoredObject field,
+ // which points back to the SwDrawVirtObj via the rtl::Reference<SdrObject> mpDrawObj field.
+ // Which creates a reference loop.
+ // But other code also uses SwAnchoredObject, and does
+ // so in a way which expects the mpDrawObj to keep things alive.
+ // So we cannot change that.
+ // So to prevent leaks on shutdown, we have to remove all of the SwDrawVirtObj objects.
+ sal_uInt16 nPageCount=GetPageCount();
+ for (sal_uInt16 i=0; i < nPageCount; ++i)
+ {
+ SdrPage* pPage = GetPage(i);
+ const size_t nObjCount = pPage->GetObjCount();
+ for (size_t j=0; j < nObjCount; ++j)
+ {
+ SdrObject* pSdrObj = pPage->GetObj(j);
+ SwDrawContact* pContact = dynamic_cast<SwDrawContact*>(pSdrObj->GetUserCall());
+ if (pContact)
+ pContact->RemoveAllVirtObjs();
+ }
+ }
+
ClearModel(true);
}
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 0f301dd4b95d..d45a2d2eb8ec 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1333,7 +1333,7 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SdrModel& _rModel )
pOle2Obj->Disconnect();
// create new graphic shape with the ole graphic and shape size
- SdrGrafObj* pGraphicObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(
_rModel,
aGraphic,
pOle2Obj->GetCurrentBoundRect());
@@ -1341,8 +1341,7 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SdrModel& _rModel )
pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
// replace ole2 shape with the new graphic object and delete the ol2 shape
- SdrObject* pRemovedObject = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
- SdrObject::Free( pRemovedObject );
+ pObjList->ReplaceObject( pGraphicObj.get(), pOle2Obj->GetOrdNum() );
}
}
}
@@ -1410,7 +1409,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
}
}
- SdrObject* pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrObject> pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
tools::Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
Size aOldObjSize( aOldObjRect.GetSize() );
tools::Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
@@ -1423,7 +1422,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft();
pNewObj->NbcMove(Size(aVec.getX(), aVec.getY()));
- if( dynamic_cast<const SdrUnoObj*>( pNewObj) != nullptr )
+ if( dynamic_cast<const SdrUnoObj*>( pNewObj.get()) != nullptr )
pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
else if( dynamic_cast<const SdrUnoObj*>( pOldObj) != nullptr )
pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
@@ -1468,7 +1467,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
// #i123922# for handling MasterObject and virtual ones correctly, SW
// wants us to call ReplaceObject at the page, but that also
// triggers the same assertion (I tried it), so stay at the view method
- pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj);
+ pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj.get());
}
}
break;
@@ -1590,21 +1589,21 @@ bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
// OLE object in focus
SdrObject* pResult = pObj;
- if(dynamic_cast< SdrGrafObj* >(pObj))
+ if(auto pGrafObj = dynamic_cast< SdrGrafObj* >(pObj))
{
- SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
+ rtl::Reference<SdrGrafObj> pNewGrafObj = SdrObject::Clone(*pGrafObj, pGrafObj->getSdrModelFromSdrObject());
pNewGrafObj->SetGraphic(rGrf);
// #i123922# for handling MasterObject and virtual ones correctly, SW
// wants us to call ReplaceObject at the page, but that also
// triggers the same assertion (I tried it), so stay at the view method
- pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj);
+ pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj.get());
// set in all cases - the Clone() will have copied an existing link (!)
pNewGrafObj->SetGraphicLink(rURL);
- pResult = pNewGrafObj;
+ pResult = pNewGrafObj.get();
}
else
{
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index f32645ae8316..c17c51873e95 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -2100,8 +2100,7 @@ bool SwFEShell::ImpEndCreate()
pPg = pNewPage.get();
}
pPg->RecalcObjOrdNums();
- SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
- SdrObject::Free( pRemovedObject );
+ pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
SwFlyFrame* pFlyFrame;
@@ -3039,7 +3038,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
{
SdrView* pDrawView = GetDrawView();
SdrModel* pDrawModel = pDrawView->GetModel();
- SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj = SdrObjFactory::MakeNewObject(
*pDrawModel,
SdrInventor::Default,
eSdrObjectKind);
@@ -3068,14 +3067,14 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
Point aStart = aRect.TopLeft();
Point aEnd = aRect.BottomRight();
- if(dynamic_cast<const SdrCircObj*>( pObj) != nullptr)
+ if(dynamic_cast<const SdrCircObj*>( pObj.get()) != nullptr)
{
SfxItemSet aAttr(pDrawModel->GetItemPool());
aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
pObj->SetMergedItemSet(aAttr);
}
- else if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj))
+ else if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj.get()))
{
basegfx::B2DPolyPolygon aPoly;
@@ -3173,7 +3172,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
pPathObj->SetPathPoly(aPoly);
}
- else if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj))
+ else if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj.get()))
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
@@ -3183,7 +3182,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
SetLineEnds(aAttr, *pObj, nSlotId);
pObj->SetMergedItemSet(aAttr);
}
- else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj))
+ else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj.get()))
{
bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
SID_DRAW_CAPTION_VERTICAL == nSlotId );
@@ -3200,7 +3199,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
pCaptionObj->SetTailPos(
aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
}
- else if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
+ else if(auto pText = dynamic_cast<SdrTextObj*>( pObj.get()))
{
pText->SetLogicRect(aRect);
@@ -3232,12 +3231,12 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
}
}
SdrPageView* pPageView = pDrawView->GetSdrPageView();
- SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj);
+ SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj.get());
// switch undo off or this combined with ImpEndCreate will cause two undos
// see comment made in SwFEShell::EndCreate (we create our own undo-object!)
const bool bUndo(GetDoc()->GetIDocumentUndoRedo().DoesUndo());
GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
- pDrawView->InsertObjectAtView(pObj, *pPageView);
+ pDrawView->InsertObjectAtView(pObj.get(), *pPageView);
GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
}
ImpEndCreate();
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index 682a77e84aef..3858f8901850 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -119,7 +119,7 @@ public:
virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
// FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
const SwFrameFormat *GetFormat() const;
SwFrameFormat *GetFormat();
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index c38cfcb03931..2c4459dbe704 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -68,7 +68,6 @@ SwObjPositioningInProgress::~SwObjPositioningInProgress()
SwAnchoredObject::SwAnchoredObject() :
- mpDrawObj( nullptr ),
mpAnchorFrame( nullptr ),
// --> #i28701#
mpPageFrame( nullptr ),
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 4ce1b6510af6..ee779ce678a2 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -41,6 +41,7 @@
#include <ndole.hxx>
#include <swtable.hxx>
#include <svx/svdoashp.hxx>
+#include <svx/svdpage.hxx>
#include <layouter.hxx>
#include <pagefrm.hxx>
#include <rootfrm.hxx>
@@ -439,13 +440,13 @@ void SwFlyFrame::FinitDrawObj()
}
}
+ SwVirtFlyDrawObj* pVirtDrawObj = GetVirtDrawObj();
// Else calls delete of the ContactObj
- GetVirtDrawObj()->SetUserCall(nullptr);
+ pVirtDrawObj->SetUserCall(nullptr);
- // Deregisters itself at the Master
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(GetVirtDrawObj());
- SdrObject::Free(pTemp);
+ if ( pVirtDrawObj->getSdrPageFromSdrObject() )
+ pVirtDrawObj->getSdrPageFromSdrObject()->RemoveObject( pVirtDrawObj->GetOrdNum() );
+ ClearDrawObj();
}
void SwFlyFrame::ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 8dccfbe08c1b..8b001ded5f0d 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -298,11 +298,11 @@ uno::Reference<drawing::XShape> SwFmDrawPage::GetShape(SdrObject* pObj)
SwFmDrawPage* pPage = dynamic_cast<SwFmDrawPage*>(pFormat);
if(!pPage || pPage->m_vShapes.empty())
return uno::Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY);
- for(auto pShape : pPage->m_vShapes)
+ for(const auto & pShape : pPage->m_vShapes)
{
SvxShape* pSvxShape = pShape->GetSvxShape();
if (pSvxShape && pSvxShape->GetSdrObject() == pObj)
- return uno::Reference<drawing::XShape>(static_cast<::cppu::OWeakObject*>(pShape), uno::UNO_QUERY);
+ return pShape;
}
return nullptr;
}
@@ -373,7 +373,7 @@ uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) c
pShape = new SwXShape(xCreate, nullptr);
xRet = pShape;
}
- const_cast<std::vector<SwXShape*>*>(&m_vShapes)->push_back(pShape.get());
+ const_cast<std::vector<rtl::Reference<SwXShape>>*>(&m_vShapes)->push_back(pShape);
pShape->m_pPage = this;
}
return xRet;
@@ -961,7 +961,6 @@ SwXShape::~SwXShape()
EndListeningAll();
if(m_pPage)
const_cast<SwFmDrawPage*>(m_pPage)->RemoveShape(this);
- m_pPage = nullptr;
}
uno::Any SwXShape::queryInterface( const uno::Type& aType )
@@ -2182,8 +2181,11 @@ void SwXShape::dispose()
xComp->dispose();
}
if(m_pPage)
- const_cast<SwFmDrawPage*>(m_pPage)->RemoveShape(this);
- m_pPage = nullptr;
+ {
+ auto pPage = const_cast<SwFmDrawPage*>(m_pPage);
+ m_pPage = nullptr;
+ pPage->RemoveShape(this);
+ }
}
void SwXShape::addEventListener(
diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx
index 9e0a707ea21e..ac4582e55bd5 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -354,7 +354,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
if( !m_pMarquee )
return;
- pPg->InsertObject( m_pMarquee );
+ pPg->InsertObject( m_pMarquee.get() );
if( !aId.isEmpty() )
InsertBookmark( aId );
@@ -508,7 +508,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
m_pMarquee->SetLogicRect( tools::Rectangle( 0, 0, aTwipSz.Width(), aTwipSz.Height() ) );
// and insert the object into the document
- InsertDrawObject( m_pMarquee, aSpace, eVertOri, eHoriOri, aStyleItemSet,
+ InsertDrawObject( m_pMarquee.get(), aSpace, eVertOri, eHoriOri, aStyleItemSet,
aPropInfo );
// Register the drawing object at the table. Is a little bit complicated,
@@ -517,7 +517,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
// The global pTable also can't be used, because the marquee can also be
// in a sub-table.
if( pCurTable && bPercentWidth)
- RegisterDrawObjectToTable( pCurTable, m_pMarquee, static_cast<sal_uInt8>(nWidth) );
+ RegisterDrawObjectToTable( pCurTable, m_pMarquee.get(), static_cast<sal_uInt8>(nWidth) );
}
void SwHTMLParser::EndMarquee()
@@ -535,13 +535,13 @@ void SwHTMLParser::EndMarquee()
}
// insert the collected text
- static_cast<SdrTextObj*>(m_pMarquee)->SetText( m_aContents );
+ static_cast<SdrTextObj*>(m_pMarquee.get())->SetText( m_aContents );
m_pMarquee->SetMergedItemSetAndBroadcast( m_pMarquee->GetMergedItemSet() );
if( m_bFixMarqueeWidth )
{
// adjust the size to the text
- static_cast<SdrTextObj*>(m_pMarquee)->FitFrameToTextSize();
+ static_cast<SdrTextObj*>(m_pMarquee.get())->FitFrameToTextSize();
}
m_aContents.clear();
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index f63d00a95980..bf8167b3f5ba 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -4942,7 +4942,7 @@ void SwHTMLParser::DeleteSection(SwStartNode* pSttNd)
{
//if section to be deleted contains a pending m_pMarquee, it will be deleted
//so clear m_pMarquee pointer if that's the case
- SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr;
+ SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee.get()) : nullptr;
FrameDeleteWatch aWatch(pObjectFormat);
//similarly for footnotes
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 0b14b44e128d..bb3413d19418 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -268,7 +268,6 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_pActionViewShell( nullptr ),
m_pSttNdIdx( nullptr ),
m_pFormImpl( nullptr ),
- m_pMarquee( nullptr ),
m_pImageMap( nullptr ),
m_nBaseFontStMin( 0 ),
m_nFontStMin( 0 ),
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index caecde9cedac..a4bf93f2f36d 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -398,7 +398,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
std::vector<HTMLTable*> m_aTables;
std::shared_ptr<HTMLTable> m_xTable; // current "outermost" table
SwHTMLForm_Impl* m_pFormImpl; // current form
- SdrObject *m_pMarquee; // current marquee
+ rtl::Reference<SdrObject> m_pMarquee; // current marquee
std::unique_ptr<SwField> m_xField; // current field
ImageMap *m_pImageMap; // current image map
std::unique_ptr<ImageMaps> m_pImageMaps; ///< all Image-Maps that have been read
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index c3524d3c74d3..3a0ff11b3962 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -303,7 +303,7 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
// polygon acts on the untransformed shape in Word. We do here similar as in
// GetLineGeometry(), but without transformations.
EnhancedCustomShape2d aCustomShape2d(*static_cast<SdrObjCustomShape*>(pSdrObj));
- SdrObjectUniquePtr pLineGeometryObj = aCustomShape2d.CreateLineGeometry();
+ rtl::Reference<SdrObject> pLineGeometryObj = aCustomShape2d.CreateLineGeometry();
if (!pLineGeometryObj)
break;
@@ -317,7 +317,8 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
aPP = pPathObj->GetPathPoly();
else
{
- SdrObjectUniquePtr pNewObj = pLineGeometryObj->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pNewObj
+ = pLineGeometryObj->ConvertToPolyObj(false, false);
SdrPathObj* pPath = dynamic_cast<SdrPathObj*>(pNewObj.get());
if (pPath)
aPP = pPath->GetPathPoly();
@@ -363,12 +364,12 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
// case OBJ_PLIN: disabled for unknown reason; related bug 75254.
{
// Includes removing any control points
- SdrObjectUniquePtr pNewObj = pSdrObj->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pNewObj = pSdrObj->ConvertToPolyObj(false, false);
SdrPathObj* pConverted = dynamic_cast<SdrPathObj*>(pNewObj.get());
if (!pConverted)
break;
aPolyPolygon = pConverted->GetPathPoly();
- pNewObj.reset();
+ pNewObj.clear();
// Word adds a line from last to first point. That will cut of indentations from being
// filled. To prevent this, the wrap polygon is lead along the path back to the first
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 3ad22c34e0ac..93560463a261 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -130,7 +130,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
if ( pOLENd )
nAspect = pOLENd->GetAspect();
- SdrOle2Obj *pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
+ rtl::Reference<SdrOle2Obj> pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
*m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(),
rStorageName,
xObjStg,
@@ -183,10 +183,6 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
}
}
}
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pRet);
- SdrObject::Free(pTemp);
}
}
else
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 730c3171ae46..e3482a290a2f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -308,7 +308,7 @@ static void SetLineEndAttr( SfxItemSet& rSet, WW8_DP_LINEEND const & rLe,
}
// start of routines for the different objects
-SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_LINE aLine;
@@ -332,7 +332,7 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
::basegfx::B2DPolygon aPolygon;
aPolygon.append(::basegfx::B2DPoint(aP[0].X(), aP[0].Y()));
aPolygon.append(::basegfx::B2DPoint(aP[1].X(), aP[1].Y()));
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
SdrObjKind::Line,
::basegfx::B2DPolyPolygon(aPolygon));
@@ -343,7 +343,7 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_RECT aRect;
@@ -356,7 +356,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrRectObj(
+ rtl::Reference<SdrObject> pObj = new SdrRectObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1));
@@ -366,7 +366,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ELLIPSE aEllipse;
@@ -379,7 +379,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Full,
tools::Rectangle(aP0, aP1));
@@ -390,7 +390,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ARC aArc;
@@ -414,7 +414,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
aP1.AdjustX( -static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
}
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Section,
tools::Rectangle(aP0, aP1),
@@ -427,7 +427,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_POLYLINE aPoly;
@@ -454,7 +454,7 @@ SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &
}
xP.reset();
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
(SVBT16ToUInt16(aPoly.aBits1) & 0x1) ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
::basegfx::B2DPolyPolygon(aP.getB2DPolygon()));
@@ -1133,12 +1133,12 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
// SdrTextObj in this Group
Graphic aGraph;
- SdrObject* pNew = ImportOleBase(aGraph);
+ rtl::Reference<SdrObject> pNew = ImportOleBase(aGraph);
if( !pNew )
{
pNew = new SdrGrafObj(*m_pDrawModel);
- static_cast<SdrGrafObj*>(pNew)->SetGraphic(aGraph);
+ static_cast<SdrGrafObj*>(pNew.get())->SetGraphic(aGraph);
}
GraphicCtor();
@@ -1147,7 +1147,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
pNew->SetLayer( pTextObj->GetLayer() );
pTextObj->getParentSdrObjectFromSdrObject()->GetSubList()->
- ReplaceObject(pNew, pTextObj->GetOrdNum());
+ ReplaceObject(pNew.get(), pTextObj->GetOrdNum());
}
else
pFlyFormat = ImportOle();
@@ -1246,7 +1246,7 @@ bool SwWW8ImplReader::TxbxChainContainsRealText(sal_uInt16 nTxBxS, tools::Long&
}
// TextBoxes only for Ver67 !!
-SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
bool bDummy;
WW8_DP_TXTBOX aTextB;
@@ -1260,7 +1260,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrRectObj* pObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(
*m_pDrawModel,
SdrObjKind::Text,
tools::Rectangle(aP0, aP1));
@@ -1271,7 +1271,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
tools::Long nStartCpFly,nEndCpFly;
bool bContainsGraphics;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false,
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false,
bDummy,nullptr,&nStartCpFly,&nEndCpFly,&bContainsGraphics);
SetStdAttr( rSet, aTextB.aLnt, aTextB.aShd );
@@ -1288,7 +1288,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
static const SdrCaptionType aCaptA[] = { SdrCaptionType::Type1, SdrCaptionType::Type2,
SdrCaptionType::Type3, SdrCaptionType::Type4 };
@@ -1333,7 +1333,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
+ m_nDrawYOfs2 + static_cast<sal_Int16>(SVBT16ToUInt16( xP[1] )) );
xP.reset();
- SdrCaptionObj* pObj = new SdrCaptionObj(
+ rtl::Reference<SdrCaptionObj> pObj = new SdrCaptionObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1),
aP2);
@@ -1343,7 +1343,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
static_cast<sal_Int16>(SVBT16ToUInt16( aCallB.dpheadTxbx.dya )) );
bool bEraseThisObject;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
if( SVBT16ToUInt16( aCallB.dptxbx.aLnt.lnps ) != 5 ) // Is border visible ?
SetStdAttr( rSet, aCallB.dptxbx.aLnt, aCallB.dptxbx.aShd );
@@ -1355,7 +1355,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
return pObj;
}
-SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
sal_Int16 nGrouped;
@@ -1369,19 +1369,19 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
m_nDrawXOfs = m_nDrawXOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->xa ));
m_nDrawYOfs = m_nDrawYOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->ya ));
- SdrObject* pObj = new SdrObjGroup(*m_pDrawModel);
+ rtl::Reference<SdrObject> pObj = new SdrObjGroup(*m_pDrawModel);
short nLeft = static_cast<sal_Int16>(SVBT16ToUInt16( pHd->cb )) - sizeof( WW8_DPHEAD );
for (int i = 0; i < nGrouped && nLeft >= static_cast<short>(sizeof(WW8_DPHEAD)); ++i)
{
SfxAllItemSet aSet(m_pDrawModel->GetItemPool());
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
// first add and then set ItemSet
SdrObjList *pSubGroup = pObj->GetSubList();
OSL_ENSURE(pSubGroup, "Why no sublist available?");
if (pSubGroup)
- pSubGroup->InsertObject(pObject, 0);
+ pSubGroup->InsertObject(pObject.get(), 0);
pObject->SetMergedItemSetAndBroadcast(aSet);
}
}
@@ -1392,11 +1392,11 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
{
// This whole archaic word 6 graphic import can probably be refactored
// into an object hierarchy with a little effort.
- SdrObject *pRet=nullptr;
+ rtl::Reference<SdrObject> pRet;
WW8_DPHEAD aHd; // Read Draw-Primitive-Header
bool bCouldRead = checkRead(*m_pStrm, &aHd, sizeof(WW8_DPHEAD)) &&
SVBT16ToUInt16(aHd.cb) >= sizeof(WW8_DPHEAD);
@@ -1491,9 +1491,9 @@ void SwWW8ImplReader::ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAncho
while (nLeft > static_cast<short>(sizeof(WW8_DPHEAD)))
{
SfxAllItemSet aSet( m_pDrawModel->GetItemPool() );
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
- m_xWWZOrder->InsertDrawingObject(pObject, SVBT16ToUInt16(aDo.dhgt));
+ m_xWWZOrder->InsertDrawingObject(pObject.get(), SVBT16ToUInt16(aDo.dhgt));
tools::Rectangle aRect(pObject->GetSnapRect());
@@ -2571,7 +2571,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
SwDocShell* pPersist = m_rDoc.GetDocShell();
m_rDoc.SetDocShell(nullptr); // #i20540# Persist guard
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
bool bOk = (m_xMSDffManager->GetShape(aFSFA.nSpId, pObject, aData) && pObject);
m_rDoc.SetDocShell(pPersist); // #i20540# Persist guard
@@ -2594,7 +2594,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
}
bool bDone = false;
- SdrObject* pOurNewObject = nullptr;
+ rtl::Reference<SdrObject> pOurNewObject;
bool bReplaceable = false;
switch (pObject->GetObjIdentifier())
@@ -2678,14 +2678,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
Get the record for top level object, so we can get the word anchoring
and wrapping information for it.
*/
- SvxMSDffImportRec* pRecord = aData.find(pObject);
+ SvxMSDffImportRec* pRecord = aData.find(pObject.get());
OSL_ENSURE(pRecord, "how did that happen?");
if (!pRecord)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
const bool bLayoutInTableCell =
@@ -2704,9 +2702,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pRecord->bHidden)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
@@ -2800,12 +2796,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
{
/* Need to make sure that the correct layer ordering is applied. */
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(pObject, aFSFA.nSpId, pRecord->bDrawHell,
+ m_xWWZOrder->InsertEscherObject(pObject.get(), aFSFA.nSpId, pRecord->bDrawHell,
m_bIsHeader || m_bIsFooter);
}
else
{
- m_xWWZOrder->InsertTextLayerObject(pObject);
+ m_xWWZOrder->InsertTextLayerObject(pObject.get());
}
pRetFrameFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pObject, aFlySet );
@@ -2869,12 +2865,12 @@ SwFrameFormat *SwWW8ImplReader::AddAutoAnchor(SwFrameFormat *pFormat)
SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
tools::Long nGrafAnchorCp, SwFrameFormat* pRetFrameFormat)
{
- SdrObject* pTrueObject = rRecord.pObj;
+ rtl::Reference<SdrObject> pTrueObject = rRecord.pObj;
- SdrTextObj* pSdrTextObj;
+ rtl::Reference<SdrTextObj> pSdrTextObj;
// check for group object (e.g. two parentheses)
- if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj))
+ if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj.get()))
{
// Group objects don't have text. Insert a text object into
// the group for holding the text.
@@ -2891,10 +2887,10 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
aSet.Put(makeSdrTextAutoGrowWidthItem(false));
pSdrTextObj->SetMergedItemSet(aSet);
pSdrTextObj->NbcSetLayer( pThisGroup->GetLayer() );
- pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj);
+ pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj.get());
}
else
- pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj);
+ pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj.get());
if( pSdrTextObj )
{
@@ -2906,27 +2902,25 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
const size_t nOrdNum = pSdrTextObj->GetOrdNum();
bool bEraseThisObject;
- InsertTxbxText(pSdrTextObj, &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
+ InsertTxbxText(pSdrTextObj.get(), &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
nGrafAnchorCp, pRetFrameFormat,
- (pSdrTextObj != pTrueObject) || (nullptr != pGroupObject), bEraseThisObject,
+ (pSdrTextObj.get() != pTrueObject.get()) || (nullptr != pGroupObject), bEraseThisObject,
nullptr, nullptr, nullptr, nullptr, &rRecord);
// was this object replaced ??
if (bEraseThisObject)
{
- if( pGroupObject || (pSdrTextObj != pTrueObject) )
+ if( pGroupObject || (pSdrTextObj.get() != pTrueObject.get()) )
{
// Object is already replaced by a new SdrGrafObj (in the group
// and) the Drawing-Page.
SdrObject* pNewObj = pGroupObject ?
- pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject;
- if (pSdrTextObj != pNewObj)
+ pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject.get();
+ if (pSdrTextObj.get() != pNewObj)
{
// Replace object in the Z-Order-List
- m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj, 0, pNewObj);
- // now delete object
- SdrObject::Free(rRecord.pObj);
+ m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj.get(), 0, pNewObj);
// and save the new object.
rRecord.pObj = pNewObj;
}
@@ -2934,7 +2928,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
else
{
// remove the object from Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj );
+ m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj.get() );
// take the object from the drawing page
if( pSdrTextObj->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( pSdrTextObj->GetOrdNum() );
@@ -2961,8 +2955,8 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
return pRetFrameFormat;
}
-SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
- SdrObject*& rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject,
+ rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord,
RndStdIds eAnchor, const WW8_FSPA& rF,
SfxItemSet &rFlySet)
@@ -2989,10 +2983,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
: SwFrameSize::Fixed);
rFlySet.Put(aFrameSize);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
- SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject);
+ SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject.get());
if (pSdrTextObj && pSdrTextObj->IsVerticalWriting())
rFlySet.Put(SvxFrameDirectionItem(SvxFrameDirection::Vertical_RL_TB, RES_FRAMEDIR));
@@ -3005,10 +2999,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
/*
NB: only query pOrgShapeObject starting here!
*/
@@ -3035,7 +3029,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
@@ -3084,8 +3078,8 @@ void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord, SfxItemSet &r
}
}
-SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObject,
- SdrObject* &rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(rtl::Reference<SdrObject> &rpObject,
+ rtl::Reference<SdrObject> &rpOurNewObject,
SvxMSDffImportRec& rRecord,
WW8_FSPA& rF,
SfxItemSet &rFlySet )
@@ -3108,17 +3102,17 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
// word for textboxes, not for graphics and ole objects.
tools::Rectangle aInnerDist(0, 0, 0, 0);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
MatchEscherMirrorIntoFlySet(rRecord, aGrSet);
OUString aObjectName(rpObject->GetName());
if (SdrObjKind::OLE2 == rpObject->GetObjIdentifier())
- pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject), rFlySet, &aGrSet);
+ pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject.get()), rFlySet, &aGrSet);
else
{
- const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject);
+ const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject.get());
bool bDone = false;
if (pGrf->IsLinkedGraphic() && !pGrf->GetFileName().isEmpty())
{
@@ -3159,13 +3153,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from Z-Order-List
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// remove from Drawing-Page
if( rpObject->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( rpObject->GetOrdNum() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
+
/*
Warning: from now on query only pOrgShapeObject!
*/
@@ -3174,14 +3169,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
if (rpOurNewObject)
{
if (!m_bHdFtFootnoteEdn)
- m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject);
+ m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject.get());
// The Contact-Object MUST be set in the Draw-Page, so that in
// SwWW8ImplReader::LoadDoc1() the Z-Order can be defined !!!
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 4a229de9097d..a2de36616a3e 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -524,7 +524,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
{
// linked graphic in ESCHER-Object
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
WW8PicDesc aPD( aPic );
if (!m_xMSDffManager)
@@ -608,7 +608,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Modified for i120716,for graf importing from MS Word 2003
// binary format, there is no border distance.
tools::Rectangle aInnerDist(0,0,0,0);
- MatchSdrItemsIntoFlySet( pObject, aAttrSet,
+ MatchSdrItemsIntoFlySet( pObject.get(), aAttrSet,
pRecord->eLineStyle, pRecord->eLineDashing,
pRecord->eShapeType, aInnerDist );
@@ -654,11 +654,11 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
if (SdrObjKind::OLE2 == pObject->GetObjIdentifier())
{
// the size from BLIP, if there is any, should be already set
- pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject), aAttrSet, &aGrSet);
+ pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject.get()), aAttrSet, &aGrSet);
}
else
{
- if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject) )
+ if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject.get()) )
{
// Now add the link or rather the graphic to the doc
const Graphic& rGraph = pGraphObject->GetGraphic();
@@ -694,22 +694,22 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Z-order-list accordingly (or delete entry)
if (SdrObject* pOurNewObject = CreateContactObject(pRet))
{
- if (pOurNewObject != pObject)
+ if (pOurNewObject != pObject.get())
{
- m_xMSDffManager->ExchangeInShapeOrder( pObject, 0,
+ m_xMSDffManager->ExchangeInShapeOrder( pObject.get(), 0,
pOurNewObject );
// delete and destroy old SdrGrafObj from page
if (pObject->getSdrPageFromSdrObject())
m_pDrawPg->RemoveObject(pObject->GetOrdNum());
- SdrObject::Free( pObject );
+ pObject.clear();
}
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
// also delete this from the page if not grouped
if (pTextObj && !bTextObjWasGrouped && pTextObj->getSdrPageFromSdrObject())
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index fc9d7a64d780..ecb4d0c899a2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -506,7 +506,7 @@ sal_uInt32 SwMSDffManager::GetFilterFlags()
* native nonOLE Form Control Objects.
*/
// #i32596# - consider new parameter <_nCalledByGroup>
-SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -520,7 +520,7 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
return nullptr;
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString sStorageName;
tools::SvRef<SotStorage> xSrcStg;
uno::Reference < embed::XStorage > xDstStg;
@@ -595,13 +595,14 @@ void SwWW8ImplReader::SetToggleBiDiAttrFlags(sal_uInt16 nFlags)
m_xCtrlStck->SetToggleBiDiAttrFlags(nFlags);
}
-SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
+rtl::Reference<SdrObject> SwMSDffManager::ProcessObj(SvStream& rSt,
DffObjData& rObjData,
SvxMSDffClientData& rData,
tools::Rectangle& rTextRect,
- SdrObject* pObj
+ SdrObject* pObj1
)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if( !rTextRect.IsEmpty() )
{
SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
@@ -780,7 +781,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bIsSimpleDrawingTextBox)
{
- SdrObject::Free( pObj );
pObj = new SdrRectObj(
*pSdrModel,
SdrObjKind::Text,
@@ -910,7 +910,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bVerticalText)
{
- SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
if (pTextObj)
pTextObj->SetVerticalWriting(true);
}
@@ -929,9 +929,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
}
}
- if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) )
+ if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj.get() ) )
{
- SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj );
+ SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj.get() );
if (pCustomShape)
{
double fExtraTextRotation = 0.0;
@@ -1086,7 +1086,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
&& (rObjData.nCalledByGroup < 2) )
)
{
- StoreShapeOrder(nShapeId, nShapeOrder, pObj);
+ StoreShapeOrder(nShapeId, nShapeOrder, pObj.get());
}
}
else
@@ -1120,7 +1120,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (pObj && !hlStr.hLinkAddr.isEmpty())
{
- SwMacroInfo* pInfo = GetMacroInfo( pObj );
+ SwMacroInfo* pInfo = GetMacroInfo( pObj.get() );
if( pInfo )
{
pInfo->SetShapeId( rObjData.nShapeId );
@@ -4380,7 +4380,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
{
tools::Rectangle aRect(0, 0, 100, 100); // A dummy, we don't care about the size
SvxMSDffImportData aData(aRect);
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
if (mrReader.m_xMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty())
{
// Only handle shape if it is a background shape
@@ -4388,7 +4388,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
{
SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND,XATTR_START, XATTR_END>
aSet(rFormat.GetDoc()->GetAttrPool());
- mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple,
+ mrReader.MatchSdrItemsIntoFlySet(pObject.get(), aSet, mso_lineSimple,
mso_lineSolid, mso_sptRectangle, aRect);
if ( aSet.HasItem(RES_BACKGROUND) )
rFormat.SetFormatAttr(aSet.Get(RES_BACKGROUND));
@@ -4396,7 +4396,6 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
rFormat.SetFormatAttr(aSet);
}
}
- SdrObject::Free(pObject);
}
wwULSpaceData aULData;
GetPageULData(rSection, aULData);
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index e40d0e8d6b33..fc0dcd521cdb 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -754,7 +754,7 @@ private:
virtual bool ShapeHasText( sal_uLong nShapeId, sal_uLong nFilePos ) const override;
// #i32596# - new parameter <_nCalledByGroup>, which
// indicates, if the OLE object is imported inside a group object
- virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
+ virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -770,7 +770,7 @@ public:
void DisableFallbackStream();
void EnableFallbackStream();
protected:
- virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
};
class wwSection
@@ -1559,7 +1559,7 @@ private:
SwFrameFormat* ImportGraf1(WW8_PIC const & rPic, SvStream* pSt, sal_uLong nFilePos);
SwFrameFormat* ImportGraf(SdrTextObj const * pTextObj = nullptr, SwFrameFormat const * pFlyFormat = nullptr);
- SdrObject* ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
+ rtl::Reference<SdrObject> ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
const SfxItemSet* pFlySet=nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
SwFrameFormat* ImportOle( const Graphic* = nullptr, const SfxItemSet* pFlySet = nullptr,
@@ -1613,11 +1613,11 @@ private:
bool ReadGrafStart(void* pData, short nDataSiz, WW8_DPHEAD const * pHd,
SfxAllItemSet &rSet);
- SdrObject *ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
void InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl );
void InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType, bool bONLYnPicLocFc=false);
@@ -1634,20 +1634,20 @@ private:
bool TxbxChainContainsRealText( sal_uInt16 nTxBxS,
tools::Long& rStartCp,
tools::Long& rEndCp );
- SdrObject *ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
void ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAnchorCp);
SdrObject* CreateContactObject(SwFrameFormat* pFlyFormat);
RndStdIds ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FSPA& rFSPA, SfxItemSet& rFlySet);
bool MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
sal_Int16 eHoriOri, sal_Int16 eHoriRel);
SwFrameFormat* Read_GrafLayer( tools::Long nGrafAnchorCp );
- SwFlyFrameFormat* ImportReplaceableDrawables(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ImportReplaceableDrawables(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
SvxMSDffImportRec& rRecord, WW8_FSPA& rF,
SfxItemSet& rFlySet);
- SwFlyFrameFormat* ConvertDrawTextToFly(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord, RndStdIds eAnchor,
const WW8_FSPA& rF, SfxItemSet& rFlySet);
SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord, tools::Long nGrafAnchorCp,
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index 613025003d7a..46bfa7325d68 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -245,7 +245,7 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
GraphicCtor();
Graphic aGraph;
- SdrObject* pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
+ rtl::Reference<SdrObject> pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
// create flyset
std::optional<SfxItemSet> pTempSet;
@@ -280,10 +280,10 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
if (pRet) // OLE object was inserted
{
- if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet))
+ if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet.get()))
{
pFormat = InsertOle(*pOleObj, *pFlySet, pGrfSet);
- SdrObject::Free(pRet); // we don't need this anymore
+ pRet.clear(); // we don't need this anymore
}
else
pFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pRet, *pFlySet );
@@ -323,7 +323,7 @@ bool SwWW8ImplReader::ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMet
return bOk;
}
-SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
+rtl::Reference<SdrObject> SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
const Graphic* pGrf, const SfxItemSet* pFlySet, const tools::Rectangle& aVisArea )
{
if (!m_pStg)
@@ -379,7 +379,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
}
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
if (!(m_bIsHeader || m_bIsFooter))
{
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 92ede94a8cc9..9abaebaf5d15 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -450,7 +450,7 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc)
pOle2Obj->Disconnect();
// create new graphic shape with the ole graphic and shape size
- SdrGrafObj* pGraphicObj = new SdrGrafObj(
+ rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(
pOle2Obj->getSdrModelFromSdrObject(),
aGraphic,
pOle2Obj->GetCurrentBoundRect());
@@ -459,8 +459,7 @@ static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc)
pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
// replace ole2 shape with the new graphic object and delete the ol2 shape
- SdrObject* pReplaced = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
- SdrObject::Free( pReplaced );
+ pObjList->ReplaceObject( pGraphicObj.get(), pOle2Obj->GetOrdNum() );
}
}
}
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index c6610e387ca0..79837db672b3 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3223,10 +3223,10 @@ bool SwTransferable::PasteDBData( const TransferableDataHelper& rData,
if (pFmView && pDragPt)
{
const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
- SdrObjectUniquePtr pObj = pFmView->CreateXFormsControl(rDesc);
+ rtl::Reference<SdrObject> pObj = pFmView->CreateXFormsControl(rDesc);
if(pObj)
{
- rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
+ rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
}
}
}
@@ -3280,9 +3280,9 @@ bool SwTransferable::PasteDBData( const TransferableDataHelper& rData,
FmFormView* pFmView = dynamic_cast<FmFormView*>( rSh.GetDrawView() );
if (pFmView && bHaveColumnDescriptor && pDragPt)
{
- SdrObjectUniquePtr pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) );
+ rtl::Reference<SdrObject> pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) );
if (pObj)
- rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
+ rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
}
}
bRet = true;
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx
index 4ef80f3b86ba..0d235828e8e9 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -133,20 +133,20 @@ void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject))
{
- SdrGrafObj* pNewGrafObj(pSdrGrafObj->CloneSdrObject(pSdrGrafObj->getSdrModelFromSdrObject()));
+ rtl::Reference<SdrGrafObj> pNewGrafObj = SdrObject::Clone(*pSdrGrafObj, pSdrGrafObj->getSdrModelFromSdrObject());
pNewGrafObj->SetGraphic(aGraphic);
// #i123922# for handling MasterObject and virtual ones correctly, SW
// wants us to call ReplaceObject at the page, but that also
// triggers the same assertion (I tried it), so stay at the view method
- pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj);
+ pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj.get());
// set in all cases - the Clone() will have copied an existing link (!)
pNewGrafObj->SetGraphicLink(
bAsLink ? aDlg.GetPath() : OUString());
- pResult = pNewGrafObj;
+ pResult = pNewGrafObj.get();
}
else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject))
{
diff --git a/sw/source/uibase/shells/grfshex.cxx b/sw/source/uibase/shells/grfshex.cxx
index f00a10755d11..24f80f29fcc3 100644
--- a/sw/source/uibase/shells/grfshex.cxx
+++ b/sw/source/uibase/shells/grfshex.cxx
@@ -136,7 +136,7 @@ bool SwTextShell::InsertMediaDlg( SfxRequest const & rReq )
if (!bRet) { return bRet; }
}
- SdrMediaObj* pObj = new SdrMediaObj(
+ rtl::Reference<SdrMediaObj> pObj = new SdrMediaObj(
*rSh.GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(),
tools::Rectangle(aPos, aSize));
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index c0214b893f19..4925a137f06b 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -112,7 +112,7 @@ void SwView::ExecDraw(const SfxRequest& rReq)
if( pDescriptorItem )
{
svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
- SdrObjectUniquePtr pObj = pFormView->CreateFieldControl( aDescriptor );
+ rtl::Reference<SdrObject> pObj = pFormView->CreateFieldControl( aDescriptor );
if ( pObj )
{
@@ -134,7 +134,7 @@ void SwView::ExecDraw(const SfxRequest& rReq)
// TODO: unmark all other
m_pWrtShell->EnterStdMode();
- m_pWrtShell->SwFEShell::InsertDrawObj( *(pObj.release()), aStartPos );
+ m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
}
}
}