summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
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 /sw/source/filter/ww8
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 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx9
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx6
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx131
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx18
-rw-r--r--sw/source/filter/ww8/ww8par.cxx25
-rw-r--r--sw/source/filter/ww8/ww8par.hxx28
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx10
7 files changed, 109 insertions, 118 deletions
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index c3524d3c74d3..3a0ff11b3962 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -303,7 +303,7 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
// polygon acts on the untransformed shape in Word. We do here similar as in
// GetLineGeometry(), but without transformations.
EnhancedCustomShape2d aCustomShape2d(*static_cast<SdrObjCustomShape*>(pSdrObj));
- SdrObjectUniquePtr pLineGeometryObj = aCustomShape2d.CreateLineGeometry();
+ rtl::Reference<SdrObject> pLineGeometryObj = aCustomShape2d.CreateLineGeometry();
if (!pLineGeometryObj)
break;
@@ -317,7 +317,8 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
aPP = pPathObj->GetPathPoly();
else
{
- SdrObjectUniquePtr pNewObj = pLineGeometryObj->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pNewObj
+ = pLineGeometryObj->ConvertToPolyObj(false, false);
SdrPathObj* pPath = dynamic_cast<SdrPathObj*>(pNewObj.get());
if (pPath)
aPP = pPath->GetPathPoly();
@@ -363,12 +364,12 @@ tools::Polygon lcl_CreateContourPolygon(SdrObject* pSdrObj)
// case OBJ_PLIN: disabled for unknown reason; related bug 75254.
{
// Includes removing any control points
- SdrObjectUniquePtr pNewObj = pSdrObj->ConvertToPolyObj(false, false);
+ rtl::Reference<SdrObject> pNewObj = pSdrObj->ConvertToPolyObj(false, false);
SdrPathObj* pConverted = dynamic_cast<SdrPathObj*>(pNewObj.get());
if (!pConverted)
break;
aPolyPolygon = pConverted->GetPathPoly();
- pNewObj.reset();
+ pNewObj.clear();
// Word adds a line from last to first point. That will cut of indentations from being
// filled. To prevent this, the wrap polygon is lead along the path back to the first
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 3ad22c34e0ac..93560463a261 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -130,7 +130,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
if ( pOLENd )
nAspect = pOLENd->GetAspect();
- SdrOle2Obj *pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
+ rtl::Reference<SdrOle2Obj> pRet = SvxMSDffManager::CreateSdrOLEFromStorage(
*m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(),
rStorageName,
xObjStg,
@@ -183,10 +183,6 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStora
}
}
}
-
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pRet);
- SdrObject::Free(pTemp);
}
}
else
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 730c3171ae46..e3482a290a2f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -308,7 +308,7 @@ static void SetLineEndAttr( SfxItemSet& rSet, WW8_DP_LINEEND const & rLe,
}
// start of routines for the different objects
-SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_LINE aLine;
@@ -332,7 +332,7 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
::basegfx::B2DPolygon aPolygon;
aPolygon.append(::basegfx::B2DPoint(aP[0].X(), aP[0].Y()));
aPolygon.append(::basegfx::B2DPoint(aP[1].X(), aP[1].Y()));
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
SdrObjKind::Line,
::basegfx::B2DPolyPolygon(aPolygon));
@@ -343,7 +343,7 @@ SdrObject* SwWW8ImplReader::ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_RECT aRect;
@@ -356,7 +356,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrRectObj(
+ rtl::Reference<SdrObject> pObj = new SdrRectObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1));
@@ -366,7 +366,7 @@ SdrObject* SwWW8ImplReader::ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ELLIPSE aEllipse;
@@ -379,7 +379,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Full,
tools::Rectangle(aP0, aP1));
@@ -390,7 +390,7 @@ SdrObject* SwWW8ImplReader::ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_ARC aArc;
@@ -414,7 +414,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
aP1.AdjustX( -static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
}
- SdrObject* pObj = new SdrCircObj(
+ rtl::Reference<SdrObject> pObj = new SdrCircObj(
*m_pDrawModel,
SdrCircKind::Section,
tools::Rectangle(aP0, aP1),
@@ -427,7 +427,7 @@ SdrObject* SwWW8ImplReader::ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
WW8_DP_POLYLINE aPoly;
@@ -454,7 +454,7 @@ SdrObject* SwWW8ImplReader::ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &
}
xP.reset();
- SdrObject* pObj = new SdrPathObj(
+ rtl::Reference<SdrObject> pObj = new SdrPathObj(
*m_pDrawModel,
(SVBT16ToUInt16(aPoly.aBits1) & 0x1) ? SdrObjKind::Polygon : SdrObjKind::PolyLine,
::basegfx::B2DPolyPolygon(aP.getB2DPolygon()));
@@ -1133,12 +1133,12 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
// SdrTextObj in this Group
Graphic aGraph;
- SdrObject* pNew = ImportOleBase(aGraph);
+ rtl::Reference<SdrObject> pNew = ImportOleBase(aGraph);
if( !pNew )
{
pNew = new SdrGrafObj(*m_pDrawModel);
- static_cast<SdrGrafObj*>(pNew)->SetGraphic(aGraph);
+ static_cast<SdrGrafObj*>(pNew.get())->SetGraphic(aGraph);
}
GraphicCtor();
@@ -1147,7 +1147,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
pNew->SetLayer( pTextObj->GetLayer() );
pTextObj->getParentSdrObjectFromSdrObject()->GetSubList()->
- ReplaceObject(pNew, pTextObj->GetOrdNum());
+ ReplaceObject(pNew.get(), pTextObj->GetOrdNum());
}
else
pFlyFormat = ImportOle();
@@ -1246,7 +1246,7 @@ bool SwWW8ImplReader::TxbxChainContainsRealText(sal_uInt16 nTxBxS, tools::Long&
}
// TextBoxes only for Ver67 !!
-SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
bool bDummy;
WW8_DP_TXTBOX aTextB;
@@ -1260,7 +1260,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
aP1.AdjustX(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dxa )) );
aP1.AdjustY(static_cast<sal_Int16>(SVBT16ToUInt16( pHd->dya )) );
- SdrRectObj* pObj = new SdrRectObj(
+ rtl::Reference<SdrRectObj> pObj = new SdrRectObj(
*m_pDrawModel,
SdrObjKind::Text,
tools::Rectangle(aP0, aP1));
@@ -1271,7 +1271,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
tools::Long nStartCpFly,nEndCpFly;
bool bContainsGraphics;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false,
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false,
bDummy,nullptr,&nStartCpFly,&nEndCpFly,&bContainsGraphics);
SetStdAttr( rSet, aTextB.aLnt, aTextB.aShd );
@@ -1288,7 +1288,7 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
static const SdrCaptionType aCaptA[] = { SdrCaptionType::Type1, SdrCaptionType::Type2,
SdrCaptionType::Type3, SdrCaptionType::Type4 };
@@ -1333,7 +1333,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
+ m_nDrawYOfs2 + static_cast<sal_Int16>(SVBT16ToUInt16( xP[1] )) );
xP.reset();
- SdrCaptionObj* pObj = new SdrCaptionObj(
+ rtl::Reference<SdrCaptionObj> pObj = new SdrCaptionObj(
*m_pDrawModel,
tools::Rectangle(aP0, aP1),
aP2);
@@ -1343,7 +1343,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
static_cast<sal_Int16>(SVBT16ToUInt16( aCallB.dpheadTxbx.dya )) );
bool bEraseThisObject;
- InsertTxbxText(pObj, &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
+ InsertTxbxText(pObj.get(), &aSize, 0, 0, 0, nullptr, false, bEraseThisObject );
if( SVBT16ToUInt16( aCallB.dptxbx.aLnt.lnps ) != 5 ) // Is border visible ?
SetStdAttr( rSet, aCallB.dptxbx.aLnt, aCallB.dptxbx.aShd );
@@ -1355,7 +1355,7 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet
return pObj;
}
-SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet)
{
sal_Int16 nGrouped;
@@ -1369,19 +1369,19 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
m_nDrawXOfs = m_nDrawXOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->xa ));
m_nDrawYOfs = m_nDrawYOfs + static_cast<sal_Int16>(SVBT16ToUInt16( pHd->ya ));
- SdrObject* pObj = new SdrObjGroup(*m_pDrawModel);
+ rtl::Reference<SdrObject> pObj = new SdrObjGroup(*m_pDrawModel);
short nLeft = static_cast<sal_Int16>(SVBT16ToUInt16( pHd->cb )) - sizeof( WW8_DPHEAD );
for (int i = 0; i < nGrouped && nLeft >= static_cast<short>(sizeof(WW8_DPHEAD)); ++i)
{
SfxAllItemSet aSet(m_pDrawModel->GetItemPool());
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
// first add and then set ItemSet
SdrObjList *pSubGroup = pObj->GetSubList();
OSL_ENSURE(pSubGroup, "Why no sublist available?");
if (pSubGroup)
- pSubGroup->InsertObject(pObject, 0);
+ pSubGroup->InsertObject(pObject.get(), 0);
pObject->SetMergedItemSetAndBroadcast(aSet);
}
}
@@ -1392,11 +1392,11 @@ SdrObject *SwWW8ImplReader::ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSe
return pObj;
}
-SdrObject* SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
+rtl::Reference<SdrObject> SwWW8ImplReader::ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet)
{
// This whole archaic word 6 graphic import can probably be refactored
// into an object hierarchy with a little effort.
- SdrObject *pRet=nullptr;
+ rtl::Reference<SdrObject> pRet;
WW8_DPHEAD aHd; // Read Draw-Primitive-Header
bool bCouldRead = checkRead(*m_pStrm, &aHd, sizeof(WW8_DPHEAD)) &&
SVBT16ToUInt16(aHd.cb) >= sizeof(WW8_DPHEAD);
@@ -1491,9 +1491,9 @@ void SwWW8ImplReader::ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAncho
while (nLeft > static_cast<short>(sizeof(WW8_DPHEAD)))
{
SfxAllItemSet aSet( m_pDrawModel->GetItemPool() );
- if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet))
+ if (rtl::Reference<SdrObject> pObject = ReadGrafPrimitive(nLeft, aSet))
{
- m_xWWZOrder->InsertDrawingObject(pObject, SVBT16ToUInt16(aDo.dhgt));
+ m_xWWZOrder->InsertDrawingObject(pObject.get(), SVBT16ToUInt16(aDo.dhgt));
tools::Rectangle aRect(pObject->GetSnapRect());
@@ -2571,7 +2571,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
SwDocShell* pPersist = m_rDoc.GetDocShell();
m_rDoc.SetDocShell(nullptr); // #i20540# Persist guard
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
bool bOk = (m_xMSDffManager->GetShape(aFSFA.nSpId, pObject, aData) && pObject);
m_rDoc.SetDocShell(pPersist); // #i20540# Persist guard
@@ -2594,7 +2594,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
}
bool bDone = false;
- SdrObject* pOurNewObject = nullptr;
+ rtl::Reference<SdrObject> pOurNewObject;
bool bReplaceable = false;
switch (pObject->GetObjIdentifier())
@@ -2678,14 +2678,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
Get the record for top level object, so we can get the word anchoring
and wrapping information for it.
*/
- SvxMSDffImportRec* pRecord = aData.find(pObject);
+ SvxMSDffImportRec* pRecord = aData.find(pObject.get());
OSL_ENSURE(pRecord, "how did that happen?");
if (!pRecord)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
const bool bLayoutInTableCell =
@@ -2704,9 +2702,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
if (pRecord->bHidden)
{
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder(pObject);
- // and delete the object
- SdrObject::Free(pObject);
+ m_xMSDffManager->RemoveFromShapeOrder(pObject.get());
return nullptr;
}
@@ -2800,12 +2796,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
{
/* Need to make sure that the correct layer ordering is applied. */
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(pObject, aFSFA.nSpId, pRecord->bDrawHell,
+ m_xWWZOrder->InsertEscherObject(pObject.get(), aFSFA.nSpId, pRecord->bDrawHell,
m_bIsHeader || m_bIsFooter);
}
else
{
- m_xWWZOrder->InsertTextLayerObject(pObject);
+ m_xWWZOrder->InsertTextLayerObject(pObject.get());
}
pRetFrameFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pObject, aFlySet );
@@ -2869,12 +2865,12 @@ SwFrameFormat *SwWW8ImplReader::AddAutoAnchor(SwFrameFormat *pFormat)
SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
tools::Long nGrafAnchorCp, SwFrameFormat* pRetFrameFormat)
{
- SdrObject* pTrueObject = rRecord.pObj;
+ rtl::Reference<SdrObject> pTrueObject = rRecord.pObj;
- SdrTextObj* pSdrTextObj;
+ rtl::Reference<SdrTextObj> pSdrTextObj;
// check for group object (e.g. two parentheses)
- if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj))
+ if (SdrObjGroup* pThisGroup = dynamic_cast<SdrObjGroup*>(rRecord.pObj.get()))
{
// Group objects don't have text. Insert a text object into
// the group for holding the text.
@@ -2891,10 +2887,10 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
aSet.Put(makeSdrTextAutoGrowWidthItem(false));
pSdrTextObj->SetMergedItemSet(aSet);
pSdrTextObj->NbcSetLayer( pThisGroup->GetLayer() );
- pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj);
+ pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj.get());
}
else
- pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj);
+ pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj.get());
if( pSdrTextObj )
{
@@ -2906,27 +2902,25 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
const size_t nOrdNum = pSdrTextObj->GetOrdNum();
bool bEraseThisObject;
- InsertTxbxText(pSdrTextObj, &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
+ InsertTxbxText(pSdrTextObj.get(), &aObjSize, rRecord.aTextId.nTxBxS, rRecord.aTextId.nSequence,
nGrafAnchorCp, pRetFrameFormat,
- (pSdrTextObj != pTrueObject) || (nullptr != pGroupObject), bEraseThisObject,
+ (pSdrTextObj.get() != pTrueObject.get()) || (nullptr != pGroupObject), bEraseThisObject,
nullptr, nullptr, nullptr, nullptr, &rRecord);
// was this object replaced ??
if (bEraseThisObject)
{
- if( pGroupObject || (pSdrTextObj != pTrueObject) )
+ if( pGroupObject || (pSdrTextObj.get() != pTrueObject.get()) )
{
// Object is already replaced by a new SdrGrafObj (in the group
// and) the Drawing-Page.
SdrObject* pNewObj = pGroupObject ?
- pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject;
- if (pSdrTextObj != pNewObj)
+ pGroupObject->GetSubList()->GetObj(nOrdNum) : pTrueObject.get();
+ if (pSdrTextObj.get() != pNewObj)
{
// Replace object in the Z-Order-List
- m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj, 0, pNewObj);
- // now delete object
- SdrObject::Free(rRecord.pObj);
+ m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj.get(), 0, pNewObj);
// and save the new object.
rRecord.pObj = pNewObj;
}
@@ -2934,7 +2928,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
else
{
// remove the object from Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj );
+ m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj.get() );
// take the object from the drawing page
if( pSdrTextObj->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( pSdrTextObj->GetOrdNum() );
@@ -2961,8 +2955,8 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord,
return pRetFrameFormat;
}
-SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
- SdrObject*& rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject,
+ rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord,
RndStdIds eAnchor, const WW8_FSPA& rF,
SfxItemSet &rFlySet)
@@ -2989,10 +2983,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
: SwFrameSize::Fixed);
rFlySet.Put(aFrameSize);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
- SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject);
+ SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject.get());
if (pSdrTextObj && pSdrTextObj->IsVerticalWriting())
rFlySet.Put(SvxFrameDirectionItem(SvxFrameDirection::Vertical_RL_TB, RES_FRAMEDIR));
@@ -3005,10 +2999,10 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from the Z-Order list
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
/*
NB: only query pOrgShapeObject starting here!
*/
@@ -3035,7 +3029,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject*& rpObject,
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
@@ -3084,8 +3078,8 @@ void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord, SfxItemSet &r
}
}
-SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObject,
- SdrObject* &rpOurNewObject,
+SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(rtl::Reference<SdrObject> &rpObject,
+ rtl::Reference<SdrObject> &rpOurNewObject,
SvxMSDffImportRec& rRecord,
WW8_FSPA& rF,
SfxItemSet &rFlySet )
@@ -3108,17 +3102,17 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
// word for textboxes, not for graphics and ole objects.
tools::Rectangle aInnerDist(0, 0, 0, 0);
- MatchSdrItemsIntoFlySet(rpObject, rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
+ MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing,
rRecord.eShapeType, aInnerDist);
MatchEscherMirrorIntoFlySet(rRecord, aGrSet);
OUString aObjectName(rpObject->GetName());
if (SdrObjKind::OLE2 == rpObject->GetObjIdentifier())
- pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject), rFlySet, &aGrSet);
+ pRetFrameFormat = InsertOle(*static_cast<SdrOle2Obj*>(rpObject.get()), rFlySet, &aGrSet);
else
{
- const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject);
+ const SdrGrafObj *pGrf = static_cast<const SdrGrafObj*>(rpObject.get());
bool bDone = false;
if (pGrf->IsLinkedGraphic() && !pGrf->GetFileName().isEmpty())
{
@@ -3159,13 +3153,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
rpOurNewObject = CreateContactObject(pRetFrameFormat);
// remove old object from Z-Order-List
- m_xMSDffManager->RemoveFromShapeOrder( rpObject );
+ m_xMSDffManager->RemoveFromShapeOrder( rpObject.get() );
// remove from Drawing-Page
if( rpObject->getSdrPageFromSdrObject() )
m_pDrawPg->RemoveObject( rpObject->GetOrdNum() );
// and delete the object
- SdrObject::Free( rpObject );
+ rpObject.clear();
+
/*
Warning: from now on query only pOrgShapeObject!
*/
@@ -3174,14 +3169,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables(SdrObject* &rpObje
if (rpOurNewObject)
{
if (!m_bHdFtFootnoteEdn)
- m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject);
+ m_xMSDffManager->StoreShapeOrder(rF.nSpId, 0, rpOurNewObject.get());
// The Contact-Object MUST be set in the Draw-Page, so that in
// SwWW8ImplReader::LoadDoc1() the Z-Order can be defined !!!
if (!rpOurNewObject->IsInserted())
{
// pass information, if object is in page header|footer to method.
- m_xWWZOrder->InsertEscherObject(rpOurNewObject, rF.nSpId, rRecord.bDrawHell,
+ m_xWWZOrder->InsertEscherObject(rpOurNewObject.get(), rF.nSpId, rRecord.bDrawHell,
m_bIsHeader || m_bIsFooter);
}
}
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 4a229de9097d..a2de36616a3e 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -524,7 +524,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
else if((0x64 == aPic.MFP.mm) || (0x66 == aPic.MFP.mm))
{
// linked graphic in ESCHER-Object
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
WW8PicDesc aPD( aPic );
if (!m_xMSDffManager)
@@ -608,7 +608,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Modified for i120716,for graf importing from MS Word 2003
// binary format, there is no border distance.
tools::Rectangle aInnerDist(0,0,0,0);
- MatchSdrItemsIntoFlySet( pObject, aAttrSet,
+ MatchSdrItemsIntoFlySet( pObject.get(), aAttrSet,
pRecord->eLineStyle, pRecord->eLineDashing,
pRecord->eShapeType, aInnerDist );
@@ -654,11 +654,11 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
if (SdrObjKind::OLE2 == pObject->GetObjIdentifier())
{
// the size from BLIP, if there is any, should be already set
- pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject), aAttrSet, &aGrSet);
+ pRet = InsertOle(*static_cast<SdrOle2Obj*>(pObject.get()), aAttrSet, &aGrSet);
}
else
{
- if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject) )
+ if (SdrGrafObj* pGraphObject = dynamic_cast<SdrGrafObj*>( pObject.get()) )
{
// Now add the link or rather the graphic to the doc
const Graphic& rGraph = pGraphObject->GetGraphic();
@@ -694,22 +694,22 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
// Z-order-list accordingly (or delete entry)
if (SdrObject* pOurNewObject = CreateContactObject(pRet))
{
- if (pOurNewObject != pObject)
+ if (pOurNewObject != pObject.get())
{
- m_xMSDffManager->ExchangeInShapeOrder( pObject, 0,
+ m_xMSDffManager->ExchangeInShapeOrder( pObject.get(), 0,
pOurNewObject );
// delete and destroy old SdrGrafObj from page
if (pObject->getSdrPageFromSdrObject())
m_pDrawPg->RemoveObject(pObject->GetOrdNum());
- SdrObject::Free( pObject );
+ pObject.clear();
}
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
}
else
- m_xMSDffManager->RemoveFromShapeOrder( pObject );
+ m_xMSDffManager->RemoveFromShapeOrder( pObject.get() );
// also delete this from the page if not grouped
if (pTextObj && !bTextObjWasGrouped && pTextObj->getSdrPageFromSdrObject())
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index fc9d7a64d780..ecb4d0c899a2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -506,7 +506,7 @@ sal_uInt32 SwMSDffManager::GetFilterFlags()
* native nonOLE Form Control Objects.
*/
// #i32596# - consider new parameter <_nCalledByGroup>
-SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -520,7 +520,7 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId,
return nullptr;
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString sStorageName;
tools::SvRef<SotStorage> xSrcStg;
uno::Reference < embed::XStorage > xDstStg;
@@ -595,13 +595,14 @@ void SwWW8ImplReader::SetToggleBiDiAttrFlags(sal_uInt16 nFlags)
m_xCtrlStck->SetToggleBiDiAttrFlags(nFlags);
}
-SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
+rtl::Reference<SdrObject> SwMSDffManager::ProcessObj(SvStream& rSt,
DffObjData& rObjData,
SvxMSDffClientData& rData,
tools::Rectangle& rTextRect,
- SdrObject* pObj
+ SdrObject* pObj1
)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if( !rTextRect.IsEmpty() )
{
SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
@@ -780,7 +781,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bIsSimpleDrawingTextBox)
{
- SdrObject::Free( pObj );
pObj = new SdrRectObj(
*pSdrModel,
SdrObjKind::Text,
@@ -910,7 +910,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (bVerticalText)
{
- SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+ SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
if (pTextObj)
pTextObj->SetVerticalWriting(true);
}
@@ -929,9 +929,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
}
}
- if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) )
+ if ( ( ( rObjData.nSpFlags & ShapeFlag::FlipV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj.get() ) )
{
- SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj );
+ SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj.get() );
if (pCustomShape)
{
double fExtraTextRotation = 0.0;
@@ -1086,7 +1086,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
&& (rObjData.nCalledByGroup < 2) )
)
{
- StoreShapeOrder(nShapeId, nShapeOrder, pObj);
+ StoreShapeOrder(nShapeId, nShapeOrder, pObj.get());
}
}
else
@@ -1120,7 +1120,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if (pObj && !hlStr.hLinkAddr.isEmpty())
{
- SwMacroInfo* pInfo = GetMacroInfo( pObj );
+ SwMacroInfo* pInfo = GetMacroInfo( pObj.get() );
if( pInfo )
{
pInfo->SetShapeId( rObjData.nShapeId );
@@ -4380,7 +4380,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
{
tools::Rectangle aRect(0, 0, 100, 100); // A dummy, we don't care about the size
SvxMSDffImportData aData(aRect);
- SdrObject* pObject = nullptr;
+ rtl::Reference<SdrObject> pObject;
if (mrReader.m_xMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty())
{
// Only handle shape if it is a background shape
@@ -4388,7 +4388,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
{
SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND,XATTR_START, XATTR_END>
aSet(rFormat.GetDoc()->GetAttrPool());
- mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple,
+ mrReader.MatchSdrItemsIntoFlySet(pObject.get(), aSet, mso_lineSimple,
mso_lineSolid, mso_sptRectangle, aRect);
if ( aSet.HasItem(RES_BACKGROUND) )
rFormat.SetFormatAttr(aSet.Get(RES_BACKGROUND));
@@ -4396,7 +4396,6 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
rFormat.SetFormatAttr(aSet);
}
}
- SdrObject::Free(pObject);
}
wwULSpaceData aULData;
GetPageULData(rSection, aULData);
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index e40d0e8d6b33..fc0dcd521cdb 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -754,7 +754,7 @@ private:
virtual bool ShapeHasText( sal_uLong nShapeId, sal_uLong nFilePos ) const override;
// #i32596# - new parameter <_nCalledByGroup>, which
// indicates, if the OLE object is imported inside a group object
- virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
+ virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
@@ -770,7 +770,7 @@ public:
void DisableFallbackStream();
void EnableFallbackStream();
protected:
- virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
+ virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
};
class wwSection
@@ -1559,7 +1559,7 @@ private:
SwFrameFormat* ImportGraf1(WW8_PIC const & rPic, SvStream* pSt, sal_uLong nFilePos);
SwFrameFormat* ImportGraf(SdrTextObj const * pTextObj = nullptr, SwFrameFormat const * pFlyFormat = nullptr);
- SdrObject* ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
+ rtl::Reference<SdrObject> ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
const SfxItemSet* pFlySet=nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
SwFrameFormat* ImportOle( const Graphic* = nullptr, const SfxItemSet* pFlySet = nullptr,
@@ -1613,11 +1613,11 @@ private:
bool ReadGrafStart(void* pData, short nDataSiz, WW8_DPHEAD const * pHd,
SfxAllItemSet &rSet);
- SdrObject *ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
void InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl );
void InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType, bool bONLYnPicLocFc=false);
@@ -1634,20 +1634,20 @@ private:
bool TxbxChainContainsRealText( sal_uInt16 nTxBxS,
tools::Long& rStartCp,
tools::Long& rEndCp );
- SdrObject *ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
- SdrObject *ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
+ rtl::Reference<SdrObject> ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
void ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAnchorCp);
SdrObject* CreateContactObject(SwFrameFormat* pFlyFormat);
RndStdIds ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FSPA& rFSPA, SfxItemSet& rFlySet);
bool MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
sal_Int16 eHoriOri, sal_Int16 eHoriRel);
SwFrameFormat* Read_GrafLayer( tools::Long nGrafAnchorCp );
- SwFlyFrameFormat* ImportReplaceableDrawables(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ImportReplaceableDrawables(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
SvxMSDffImportRec& rRecord, WW8_FSPA& rF,
SfxItemSet& rFlySet);
- SwFlyFrameFormat* ConvertDrawTextToFly(SdrObject*& rpObject, SdrObject*& rpOurNewObject,
+ SwFlyFrameFormat* ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
const SvxMSDffImportRec& rRecord, RndStdIds eAnchor,
const WW8_FSPA& rF, SfxItemSet& rFlySet);
SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord, tools::Long nGrafAnchorCp,
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index 613025003d7a..46bfa7325d68 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -245,7 +245,7 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
GraphicCtor();
Graphic aGraph;
- SdrObject* pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
+ rtl::Reference<SdrObject> pRet = ImportOleBase(aGraph, pGrf, pFlySet, aVisArea );
// create flyset
std::optional<SfxItemSet> pTempSet;
@@ -280,10 +280,10 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
if (pRet) // OLE object was inserted
{
- if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet))
+ if (SdrOle2Obj *pOleObj = dynamic_cast<SdrOle2Obj*>(pRet.get()))
{
pFormat = InsertOle(*pOleObj, *pFlySet, pGrfSet);
- SdrObject::Free(pRet); // we don't need this anymore
+ pRet.clear(); // we don't need this anymore
}
else
pFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pRet, *pFlySet );
@@ -323,7 +323,7 @@ bool SwWW8ImplReader::ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMet
return bOk;
}
-SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
+rtl::Reference<SdrObject> SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
const Graphic* pGrf, const SfxItemSet* pFlySet, const tools::Rectangle& aVisArea )
{
if (!m_pStg)
@@ -379,7 +379,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
}
}
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
if (!(m_bIsHeader || m_bIsFooter))
{