summaryrefslogtreecommitdiff
path: root/filter/source/msfilter
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 /filter/source/msfilter
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 'filter/source/msfilter')
-rw-r--r--filter/source/msfilter/escherex.cxx4
-rw-r--r--filter/source/msfilter/msdffimp.cxx119
-rw-r--r--filter/source/msfilter/svdfppt.cxx101
3 files changed, 111 insertions, 113 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 52326112d994..3044762de92a 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4565,7 +4565,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
else if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::SEGMENTS )
{
tools::PolyPolygon aPolyPoly;
- SdrObjectUniquePtr pTemporaryConvertResultObject(pSdrObjCustomShape->DoConvertToPolyObj(true, true));
+ rtl::Reference<SdrObject> pTemporaryConvertResultObject(pSdrObjCustomShape->DoConvertToPolyObj(true, true));
SdrPathObj* pSdrPathObj(dynamic_cast< SdrPathObj* >(pTemporaryConvertResultObject.get()));
if(pSdrPathObj)
@@ -4576,7 +4576,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
}
// do *not* forget to delete the temporary used SdrObject - possible memory leak (!)
- pTemporaryConvertResultObject.reset();
+ pTemporaryConvertResultObject.clear();
pSdrPathObj = nullptr;
if(0 != aPolyPoly.Count())
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 58032e65ee7b..3705429218bd 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3819,9 +3819,9 @@ static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, Gra
}
}
-SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& rObjData )
+rtl::Reference<SdrObject> SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& rObjData )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString aLinkFileName;
tools::Rectangle aVisArea;
@@ -4018,7 +4018,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
{
pRet = new SdrGrafObj(*pSdrModel);
if( bGrfRead )
- static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraf );
+ static_cast<SdrGrafObj*>(pRet.get())->SetGraphic( aGraf );
if( bLinkGrf && !bGrfRead ) // sj: #i55484# if the graphic was embedded ( bGrfRead == true ) then
{ // we do not need to set a link. TODO: not to lose the information where the graphic is linked from
@@ -4057,7 +4057,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
}
pRet->NbcSetLogicRect( rObjData.aBoundRect );
- if (SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pRet))
+ if (SdrGrafObj* pGrafObj = dynamic_cast<SdrGrafObj*>(pRet.get()))
{
if( aLinkFileName.getLength() )
{
@@ -4077,10 +4077,10 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
}
// PptSlidePersistEntry& rPersistEntry, SdPage* pPage
-SdrObject* SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect, int nCalledByGroup, sal_Int32* pShapeId )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
DffRecordHeader aObjHd;
bool bOk = ReadDffRecordHeader(rSt, aObjHd);
if (bOk && aObjHd.nRecType == DFF_msofbtSpgrContainer)
@@ -4095,7 +4095,7 @@ SdrObject* SvxMSDffManager::ImportObj( SvStream& rSt, SvxMSDffClientData& rClien
return pRet;
}
-SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup, sal_Int32* pShapeId )
{
@@ -4105,7 +4105,7 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
if (!rHd.SeekToContent(rSt))
return nullptr;
- SdrObjectUniquePtr xRet;
+ rtl::Reference<SdrObject> xRet;
DffRecordHeader aRecHd; // the first atom has to be the SpContainer for the GroupObject
bool bOk = ReadDffRecordHeader(rSt, aRecHd);
@@ -4113,8 +4113,8 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
{
mnFix16Angle = 0_deg100;
if (!aRecHd.SeekToBegOfRecord(rSt))
- return xRet.release();
- xRet.reset(ImportObj(rSt, rClientData, rClientRect, rGlobalChildRect, nCalledByGroup + 1, pShapeId));
+ return xRet;
+ xRet = ImportObj(rSt, rClientData, rClientRect, rGlobalChildRect, nCalledByGroup + 1, pShapeId);
if (xRet)
{
Degree100 nGroupRotateAngle(0);
@@ -4145,7 +4145,7 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
// now importing the inner objects of the group
if (!aRecHd.SeekToEndOfRecord(rSt))
- return xRet.release();
+ return xRet;
while (rSt.good() && ( rSt.Tell() < rHd.GetRecEndFilePos()))
{
@@ -4157,43 +4157,43 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
tools::Rectangle aGroupClientAnchor, aGroupChildAnchor;
GetGroupAnchors( aRecHd2, rSt, aGroupClientAnchor, aGroupChildAnchor, aClientRect, aGlobalChildRect );
if (!aRecHd2.SeekToBegOfRecord(rSt))
- return xRet.release();
+ return xRet;
sal_Int32 nShapeId;
- SdrObject* pTmp = ImportGroup( aRecHd2, rSt, rClientData, aGroupClientAnchor, aGroupChildAnchor, nCalledByGroup + 1, &nShapeId );
+ rtl::Reference<SdrObject> pTmp = ImportGroup( aRecHd2, rSt, rClientData, aGroupClientAnchor, aGroupChildAnchor, nCalledByGroup + 1, &nShapeId );
if (pTmp)
{
SdrObjGroup* pGroup = dynamic_cast<SdrObjGroup*>(xRet.get());
if (pGroup && pGroup->GetSubList())
{
- pGroup->GetSubList()->NbcInsertObject(pTmp);
+ pGroup->GetSubList()->NbcInsertObject(pTmp.get());
if (nShapeId)
- insertShapeId(nShapeId, pTmp);
+ insertShapeId(nShapeId, pTmp.get());
}
else
- FreeObj(rClientData, pTmp);
+ FreeObj(rClientData, pTmp.get());
}
}
else if ( aRecHd2.nRecType == DFF_msofbtSpContainer )
{
if (!aRecHd2.SeekToBegOfRecord(rSt))
- return xRet.release();
+ return xRet;
sal_Int32 nShapeId;
- SdrObject* pTmp = ImportShape( aRecHd2, rSt, rClientData, aClientRect, aGlobalChildRect, nCalledByGroup + 1, &nShapeId );
+ rtl::Reference<SdrObject> pTmp = ImportShape( aRecHd2, rSt, rClientData, aClientRect, aGlobalChildRect, nCalledByGroup + 1, &nShapeId );
if (pTmp)
{
SdrObjGroup* pGroup = dynamic_cast<SdrObjGroup*>(xRet.get());
if (pGroup && pGroup->GetSubList())
{
- pGroup->GetSubList()->NbcInsertObject(pTmp);
+ pGroup->GetSubList()->NbcInsertObject(pTmp.get());
if (nShapeId)
- insertShapeId(nShapeId, pTmp);
+ insertShapeId(nShapeId, pTmp.get());
}
else
- FreeObj(rClientData, pTmp);
+ FreeObj(rClientData, pTmp.get());
}
}
if (!aRecHd2.SeekToEndOfRecord(rSt))
- return xRet.release();
+ return xRet;
}
if ( nGroupRotateAngle )
@@ -4215,13 +4215,13 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r
if (o3tl::make_unsigned(nCalledByGroup) < maPendingGroupData.size())
{
// finalization for this group is pending, do it now
- xRet.reset(FinalizeObj(maPendingGroupData.back().first, xRet.release()));
+ xRet = FinalizeObj(maPendingGroupData.back().first, xRet.get());
maPendingGroupData.pop_back();
}
- return xRet.release();
+ return xRet;
}
-SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& rSt, SvxMSDffClientData& rClientData,
tools::Rectangle& rClientRect, const tools::Rectangle& rGlobalChildRect,
int nCalledByGroup, sal_Int32* pShapeId )
{
@@ -4335,7 +4335,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( aObjData.nSpFlags & ShapeFlag::Background )
aObjData.aBoundRect = tools::Rectangle( Point(), Size( 1, 1 ) );
- SdrObjectUniquePtr xRet;
+ rtl::Reference<SdrObject> xRet;
tools::Rectangle aTextRect;
if ( !aObjData.aBoundRect.IsEmpty() )
@@ -4361,7 +4361,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( aObjData.nSpFlags & ShapeFlag::Group )
{
- xRet.reset(new SdrObjGroup(*pSdrModel));
+ xRet = new SdrObjGroup(*pSdrModel);
/* After CWS aw033 has been integrated, an empty group object
cannot store its resulting bounding rectangle anymore. We have
to return this rectangle via rClientRect now, but only, if
@@ -4381,7 +4381,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( bGraphic )
{
if (!mbSkipImages) {
- xRet.reset(ImportGraphic(rSt, aSet, aObjData)); // SJ: #68396# is no longer true (fixed in ppt2000)
+ xRet = ImportGraphic(rSt, aSet, aObjData); // SJ: #68396# is no longer true (fixed in ppt2000)
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetMergedItemSet(aSet);
}
@@ -4391,10 +4391,10 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
basegfx::B2DPolygon aPoly;
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top()));
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Right(), aObjData.aBoundRect.Bottom()));
- xRet.reset(new SdrPathObj(
+ xRet = new SdrPathObj(
*pSdrModel,
SdrObjKind::Line,
- basegfx::B2DPolyPolygon(aPoly)));
+ basegfx::B2DPolyPolygon(aPoly));
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetMergedItemSet(aSet);
}
@@ -4405,7 +4405,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
ApplyAttributes( rSt, aSet, aObjData );
- xRet.reset(new SdrObjCustomShape(*pSdrModel));
+ xRet = new SdrObjCustomShape(*pSdrModel);
sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 );
bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0;
@@ -4797,7 +4797,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
basegfx::B2DPolyPolygon aPoly( static_cast<SdrObjCustomShape*>(xRet.get())->GetLineGeometry( true ) );
- xRet.reset(new SdrEdgeObj(*pSdrModel));
+ xRet = new SdrEdgeObj(*pSdrModel);
ApplyAttributes( rSt, aSet, aObjData );
xRet->SetLogicRect( aObjData.aBoundRect );
xRet->SetMergedItemSet(aSet);
@@ -4914,7 +4914,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
xRet->SetName(aObjName);
}
- xRet.reset(ProcessObj(rSt, aObjData, rClientData, aTextRect, xRet.release()));
+ xRet = ProcessObj(rSt, aObjData, rClientData, aTextRect, xRet.get());
if (xRet)
{
@@ -4950,9 +4950,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
else
{
- xRet.reset(FinalizeObj(aObjData, xRet.release()));
+ xRet = FinalizeObj(aObjData, xRet.get());
}
- return xRet.release();
+ return xRet;
}
tools::Rectangle SvxMSDffManager::GetGlobalChildAnchor( const DffRecordHeader& rHd, SvStream& rSt, tools::Rectangle& aClientRect )
@@ -5114,7 +5114,7 @@ void SvxMSDffImportData::insert(std::unique_ptr<SvxMSDffImportRec> pImpRec)
if (bSuccess)
{
SvxMSDffImportRec* pRec = aRet.first->get();
- m_ObjToRecMap[pRec->pObj] = pRec;
+ m_ObjToRecMap[pRec->pObj.get()] = pRec;
}
}
@@ -5143,16 +5143,16 @@ void SvxMSDffManager::NotifyFreeObj(SvxMSDffClientData& rData, SdrObject* pObj)
void SvxMSDffManager::FreeObj(SvxMSDffClientData& rData, SdrObject* pObj)
{
NotifyFreeObj(rData, pObj);
- SdrObject::Free(pObj);
}
-SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
+rtl::Reference<SdrObject> SvxMSDffManager::ProcessObj(SvStream& rSt,
DffObjData& rObjData,
SvxMSDffClientData& rData,
tools::Rectangle& rTextRect,
- SdrObject* pObj
+ SdrObject* pObj1
)
{
+ rtl::Reference<SdrObject> pObj = pObj1;
if( !rTextRect.IsEmpty() )
{
SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
@@ -5229,8 +5229,8 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
}
// text frame, also Title or Outline
- SdrObject* pOrgObj = pObj;
- SdrRectObj* pTextObj = nullptr;
+ rtl::Reference<SdrObject> pOrgObj = pObj;
+ rtl::Reference<SdrRectObj> pTextObj;
sal_uInt32 nTextId = GetPropertyValue( DFF_Prop_lTxid, 0 );
if( nTextId )
{
@@ -5259,8 +5259,8 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
if (bTextFrame)
{
- SdrObject::Free( pObj );
- pObj = pOrgObj = nullptr;
+ pObj = nullptr;
+ pOrgObj = nullptr;
}
// Distance of Textbox to its surrounding Customshape
@@ -5497,20 +5497,20 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
if( !pObj )
{
- pObj = pTextObj;
+ pObj = pTextObj.get();
}
else
{
- if( pTextObj != pObj )
+ if( pTextObj.get() != pObj.get() )
{
- SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
- pGroup->GetSubList()->NbcInsertObject( pObj );
- pGroup->GetSubList()->NbcInsertObject( pTextObj );
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(*pSdrModel);
+ pGroup->GetSubList()->NbcInsertObject( pObj.get() );
+ pGroup->GetSubList()->NbcInsertObject( pTextObj.get() );
if (pOrgObj == pObj)
pOrgObj = pGroup;
else
pOrgObj = pObj;
- pObj = pGroup;
+ pObj = pGroup.get();
}
}
}
@@ -5623,7 +5623,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
// amend the import record list
if( pOrgObj )
{
- pImpRec->pObj = pOrgObj;
+ pImpRec->pObj = pOrgObj.get();
rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pImpRec));
bDeleteImpRec = false;
if (pImpRec == pTextImpRec)
@@ -5634,7 +5634,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
{
// Modify ShapeId (must be unique)
pImpRec->nShapeId |= 0x8000000;
- pTextImpRec->pObj = pTextObj;
+ pTextImpRec->pObj = pTextObj.get();
rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pTextImpRec));
bDeleteTextImpRec = false;
if (pTextImpRec == pImpRec)
@@ -5650,7 +5650,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
)
StoreShapeOrder( pImpRec->nShapeId,
( static_cast<sal_uLong>(pImpRec->aTextId.nTxBxS) << 16 )
- + pImpRec->aTextId.nSequence, pObj );
+ + pImpRec->aTextId.nSequence, pObj.get() );
}
if (bDeleteImpRec)
@@ -6354,7 +6354,7 @@ bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
Access to a shape at runtime (via the Shape-Id)
----------------------------
******************************************************************************/
-bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
+bool SvxMSDffManager::GetShape(sal_uLong nId, rtl::Reference<SdrObject>& rpShape,
SvxMSDffImportData& rData)
{
auto const pTmpRec = std::make_shared<SvxMSDffShapeInfo>(0, nId);
@@ -6384,7 +6384,7 @@ bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
rStCtrl.Seek( nOldPosCtrl );
if( &rStCtrl != pStData && pStData )
pStData->Seek( nOldPosData );
- return ( nullptr != rpShape );
+ return bool( rpShape );
}
@@ -6733,13 +6733,13 @@ bool SvxMSDffManager::ShapeHasText( sal_uLong /* nShapeId */, sal_uLong /* nFile
}
// #i32596# - add new parameter <_nCalledByGroup>
-SdrObject* SvxMSDffManager::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SvxMSDffManager::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGrf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
const int /* _nCalledByGroup */ ) const
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
OUString sStorageName;
tools::SvRef<SotStorage> xSrcStg;
ErrCode nError = ERRCODE_NONE;
@@ -7254,7 +7254,7 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo
}
// TODO/MBA: code review and testing!
-SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
+rtl::Reference<SdrOle2Obj> SvxMSDffManager::CreateSdrOLEFromStorage(
SdrModel& rSdrModel,
const OUString& rStorageName,
tools::SvRef<SotStorage> const & rSrcStorage,
@@ -7269,7 +7269,7 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
OUString const& rBaseURL)
{
sal_Int64 nAspect = nRecommendedAspect;
- SdrOle2Obj* pRet = nullptr;
+ rtl::Reference<SdrOle2Obj> pRet;
if( rSrcStorage.is() && xDestStorage.is() && rStorageName.getLength() )
{
comphelper::EmbeddedObjectContainer aCnt( xDestStorage );
@@ -7476,8 +7476,7 @@ bool SvxMSDffManager::SetPropValue( const uno::Any& rAny, const uno::Reference<
}
SvxMSDffImportRec::SvxMSDffImportRec()
- : pObj( nullptr ),
- nClientAnchorLen( 0 ),
+ : nClientAnchorLen( 0 ),
nClientDataLen( 0 ),
nXAlign( 0 ), // position n cm from left
nYAlign( 0 ), // position n cm below
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index d5ee7986b242..4511789b0586 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -494,7 +494,6 @@ PptSlidePersistEntry::PptSlidePersistEntry() :
nSlidePersistEndOffset ( 0 ),
nBackgroundOffset ( 0 ),
nDrawingDgId ( 0xffffffff ),
- pBObj ( nullptr ),
ePageKind ( PPT_MASTERPAGE ),
bNotesMaster ( false ),
bHandoutMaster ( false ),
@@ -729,13 +728,13 @@ void ProcessData::NotifyFreeObj(SdrObject* pObj)
The parameter pOriginalObj is the object as it was imported by our general escher import, it must either
be deleted or it can be returned to be inserted into the sdr page.
*/
-SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pOriginalObj )
+rtl::Reference<SdrObject> SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rClientData, tools::Rectangle& rTextRect, SdrObject* pOriginalObj )
{
if ( dynamic_cast<const SdrObjCustomShape* >(pOriginalObj) != nullptr )
pOriginalObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
// we are initializing our return value with the object that was imported by our escher import
- SdrObject* pRet = pOriginalObj;
+ rtl::Reference<SdrObject> pRet = pOriginalObj;
ProcessData& rData = static_cast<ProcessData&>(rClientData);
PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry;
@@ -780,7 +779,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
case PPT_PST_RecolorInfoAtom :
{
- if ( auto pSdrGrafObj = dynamic_cast<SdrGrafObj* >(pRet) )
+ if ( auto pSdrGrafObj = dynamic_cast<SdrGrafObj* >(pRet.get()) )
if ( pSdrGrafObj->HasGDIMetaFile() )
{
Graphic aGraphic( pSdrGrafObj->GetGraphic() );
@@ -801,7 +800,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
nPageNum--;
// replacing the object which we will return with a SdrPageObj
- SdrObject::Free( pRet );
pRet = new SdrPageObj(
*pSdrModel,
rObjData.aBoundRect,
@@ -849,10 +847,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
if ( pRet )
{
bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != nullptr;
- if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet) == nullptr // we are not allowed to get
- && dynamic_cast<const SdrObjGroup* >(pRet) == nullptr // grouped placeholder objects
- && dynamic_cast<const SdrOle2Obj* >(pRet) == nullptr )
- SdrObject::Free( pRet );
+ if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet.get()) == nullptr // we are not allowed to get
+ && dynamic_cast<const SdrObjGroup* >(pRet.get()) == nullptr // grouped placeholder objects
+ && dynamic_cast<const SdrOle2Obj* >(pRet.get()) == nullptr )
+ {
+ pRet = nullptr;
+ }
}
sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
@@ -1049,11 +1049,11 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
eTextKind = SdrObjKind::Rectangle;
}
}
- SdrObject* pTObj = nullptr;
+ rtl::Reference<SdrObject> pTObj;
bool bWordWrap = GetPropertyValue(DFF_Prop_WrapText, mso_wrapSquare) != mso_wrapNone;
bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape, 0 ) & 2 ) != 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr && ( eTextKind == SdrObjKind::Rectangle ) )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pRet.get()) != nullptr && ( eTextKind == SdrObjKind::Rectangle ) )
{
bAutoGrowHeight = bFitShapeToText;
bAutoGrowWidth = !bWordWrap;
@@ -1062,9 +1062,8 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
}
else
{
- if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pRet.get()) != nullptr )
{
- SdrObject::Free( pRet );
pRet = nullptr;
}
pTObj = new SdrRectObj(
@@ -1103,7 +1102,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
}
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
{
pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
@@ -1119,12 +1118,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
if ( nMinFrameHeight < 0 )
nMinFrameHeight = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
if ( nMinFrameWidth < 0 )
nMinFrameWidth = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
// set margins at the borders of the textbox
@@ -1134,9 +1133,9 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr )
pTObj->SetSnapRect( rTextRect );
- pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
+ pTObj = ReadObjText( &aTextObj, pTObj.get(), rData.pPage );
if ( pTObj )
{
@@ -1146,9 +1145,9 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
snaprect of the object. Then we will use
ADJUST_CENTER instead of ADJUST_BLOCK.
*/
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr && !bFitShapeToText && !bWordWrap )
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj.get()) == nullptr && !bFitShapeToText && !bWordWrap )
{
- SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj );
+ SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj.get() );
if ( pText )
{
if ( bVerticalText )
@@ -1179,7 +1178,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
Degree100 nAngle = ( rObjData.nSpFlags & ShapeFlag::FlipV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
nAngle += nTextRotationAngle;
- if ( dynamic_cast< const SdrObjCustomShape* >(pTObj) == nullptr )
+ if ( dynamic_cast< const SdrObjCustomShape* >(pTObj.get()) == nullptr )
{
if ( rObjData.nSpFlags & ShapeFlag::FlipV )
{
@@ -1192,13 +1191,13 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
}
if ( pRet )
{
- SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
- pGroup->GetSubList()->NbcInsertObject( pRet );
- pGroup->GetSubList()->NbcInsertObject( pTObj );
+ rtl::Reference<SdrObject> pGroup = new SdrObjGroup(*pSdrModel);
+ pGroup->GetSubList()->NbcInsertObject( pRet.get() );
+ pGroup->GetSubList()->NbcInsertObject( pTObj.get() );
pRet = pGroup;
}
else
- pRet = pTObj;
+ pRet = pTObj.get();
}
}
}
@@ -1254,11 +1253,11 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
for (auto & pPtr : rPersistEntry.xSolverContainer->aCList)
{
if ( rObjData.nShapeId == pPtr->nShapeC )
- pPtr->pCObj = pRet;
+ pPtr->pCObj = pRet.get();
else
{
- SdrObject* pConnectObj = pRet;
- if ( pOriginalObj && dynamic_cast< const SdrObjGroup* >(pRet) != nullptr )
+ SdrObject* pConnectObj = pRet.get();
+ if ( pOriginalObj && dynamic_cast< const SdrObjGroup* >(pRet.get()) != nullptr )
{ /* check if the original object from the escherimport is part of the group object,
if this is the case, we will use the original object to connect to */
SdrObjListIter aIter( *pRet, SdrIterMode::DeepWithGroups );
@@ -1796,13 +1795,13 @@ static bool SdrPowerPointOLEDecompress( SvStream& rOutput, SvStream& rInput, sal
}
// #i32596# - add new parameter <_nCalledByGroup>
-SdrObject* SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
+rtl::Reference<SdrObject> SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
const Graphic& rGraf,
const tools::Rectangle& rBoundRect,
const tools::Rectangle& rVisArea,
const int /*_nCalledByGroup*/ ) const
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
sal_uInt32 nOldPos = rStCtrl.Tell();
@@ -2908,16 +2907,16 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
aShapeHd.SeekToBegOfRecord( rStCtrl );
sal_Int32 nShapeId;
aProcessData.pTableRowProperties.reset();
- SdrObject* pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, 0, &nShapeId );
+ rtl::Reference<SdrObject> pObj = ImportObj( rStCtrl, aProcessData, aEmpty, aEmpty, 0, &nShapeId );
if ( pObj )
{
if ( aProcessData.pTableRowProperties )
- pObj = CreateTable(pObj, aProcessData.pTableRowProperties.get(), aProcessData.rPersistEntry.xSolverContainer.get(), aProcessData.aBackgroundColoredObjects);
+ pObj = CreateTable(pObj.get(), aProcessData.pTableRowProperties.get(), aProcessData.rPersistEntry.xSolverContainer.get(), aProcessData.aBackgroundColoredObjects);
- pRet->NbcInsertObject( pObj );
+ pRet->NbcInsertObject( pObj.get() );
if( nShapeId )
- insertShapeId( nShapeId, pObj );
+ insertShapeId( nShapeId, pObj.get() );
}
}
bool bSuccess = aShapeHd.SeekToEndOfRecord(rStCtrl);
@@ -2942,7 +2941,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
{
if (!rSlidePersist.pBObj)
{
- for (auto pObject : aProcessData.aBackgroundColoredObjects)
+ for (auto const & pObject : aProcessData.aBackgroundColoredObjects)
{
// The shape wants a background, but the slide doesn't have
// one: default to white.
@@ -2966,15 +2965,15 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
for (auto & pPtr : rSlidePersist.xSolverContainer->aCList)
{
// check connections to the group object
- if (pPtr->pAObj == rSlidePersist.pBObj)
+ if (pPtr->pAObj == rSlidePersist.pBObj.get())
pPtr->pAObj = nullptr;
- if (pPtr->pBObj == rSlidePersist.pBObj)
+ if (pPtr->pBObj == rSlidePersist.pBObj.get())
pPtr->pBObj = nullptr;
- if (pPtr->pCObj == rSlidePersist.pBObj)
+ if (pPtr->pCObj == rSlidePersist.pBObj.get())
pPtr->pCObj = nullptr;
}
}
- SdrObject::Free(rSlidePersist.pBObj);
+ rSlidePersist.pBObj.clear();
}
}
}
@@ -3048,9 +3047,9 @@ sal_uInt16 SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum, PptPage
return nIdx;
}
-SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset )
+rtl::Reference<SdrObject> SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset )
{
- SdrObject* pRet = nullptr;
+ rtl::Reference<SdrObject> pRet;
std::optional<SfxItemSet> pSet;
sal_uInt64 nOldFPos = rStCtrl.Tell(); // remember FilePos for restoring it later
DffRecordHeader aPageHd;
@@ -7517,9 +7516,12 @@ static void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >
}
}
-SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32* pTableArry, SvxMSDffSolverContainer* pSolverContainer, std::vector<SdrObject*>& rBackgroundColoredObjects)
+rtl::Reference<SdrObject> SdrPowerPointImport::CreateTable(
+ SdrObject* pGroup, const sal_uInt32* pTableArry,
+ SvxMSDffSolverContainer* pSolverContainer,
+ std::vector<rtl::Reference<SdrObject>>& rBackgroundColoredObjects)
{
- SdrObject* pRet = pGroup;
+ rtl::Reference<SdrObject> pRet = pGroup;
sal_uInt32 nRows = pTableArry[ 1 ];
if (!nRows)
@@ -7551,7 +7553,7 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
if (aRows.empty())
return pRet;
- sdr::table::SdrTableObj* pTable = new sdr::table::SdrTableObj(*pSdrModel);
+ rtl::Reference<sdr::table::SdrTableObj> pTable = new sdr::table::SdrTableObj(*pSdrModel);
pTable->uno_lock();
Reference< XTable > xTable( pTable->getTable() );
@@ -7656,9 +7658,9 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
//table when export by us. We should process this
//situation when importing.
if ( pPtr->pAObj == pGroup )
- pPtr->pAObj = pTable;
+ pPtr->pAObj = pTable.get();
if ( pPtr->pBObj == pGroup )
- pPtr->pBObj = pTable;
+ pPtr->pBObj = pTable.get();
}
}
pTable->uno_unlock();
@@ -7672,16 +7674,13 @@ SdrObject* SdrPowerPointImport::CreateTable(SdrObject* pGroup, const sal_uInt32*
SdrObject* pPartObj = aIter.Next();
removeShapeId(pPartObj);
// ofz#41510 make sure rBackgroundColoredObjects doesn't contain deleted objects
- std::replace(rBackgroundColoredObjects.begin(), rBackgroundColoredObjects.end(), pPartObj, pRet);
+ std::replace(rBackgroundColoredObjects.begin(), rBackgroundColoredObjects.end(), pPartObj, pRet.get());
}
-
- SdrObject::Free( pGroup );
}
catch( const Exception& )
{
pTable->uno_unlock();
- SdrObject* pObj = pTable;
- SdrObject::Free( pObj );
+ pTable = nullptr;
}
return pRet;