summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-27 10:27:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-29 13:44:02 +0200
commit8611f6e259b807b4f19c8dc0eab86ca648891ce3 (patch)
treefa2b0e463aafb51df754768f916ca9104969a557 /svx
parent25a997c15d39fb30676a375df8ea4ce1ed2e1acd (diff)
ref-count SdrObject
Which means we can get rid of the majestic hack of ScCaptionPtr Previously, SdrObject was manually managed, and the ownership passed around in very complicated fashion. Notes: (*) SvxShape has a strong reference to SdrObject, where previously it had a weak reference. It is now strong since otherwise the SdrObject will go away very eagerly. (*) SdrObject still has a weak reference to SvxShape (*) In the existing places that an SdrObject is being deleted, we now just clear the reference (*) instead of SwVirtFlyDrawObj removing itself from the page that contains inside it's destructor, make the call site do the removing from the page. (*) Needed to take the SolarMutex in UndoManagerHelper_Impl::impl_clear because this can be called from UNO (e.g. sfx2_complex JUnit test) and the SdrObjects need the SolarMutex when destructing. (*) handle a tricky situation with SwDrawVirtObj in the SwDrawModel destructor because the existing code wants mpDrawObj in SwAnchoredObject to be sometimes owning, sometimes not, which results in a cycle with the new code. Change-Id: I4d79df1660e386388e5d51030653755bca02a163 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138837 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-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
89 files changed, 1162 insertions, 1447 deletions
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;