Kaydet (Commit) 8a304fe8 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in XclEscherEx

Change-Id: I8f56bad91c7128a1907e72cd457d43b5937d743a
Reviewed-on: https://gerrit.libreoffice.org/57527
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 1aff15fa
...@@ -122,10 +122,10 @@ private: ...@@ -122,10 +122,10 @@ private:
private: private:
XclExpObjectManager& mrObjMgr; XclExpObjectManager& mrObjMgr;
std::stack< std::pair< XclObj*, XclEscherHostAppData* > > aStack; std::stack< std::pair< XclObj*, std::unique_ptr<XclEscherHostAppData> > > aStack;
XclObj* pCurrXclObj; XclObj* pCurrXclObj;
XclEscherHostAppData* pCurrAppData; std::unique_ptr<XclEscherHostAppData> pCurrAppData;
XclEscherClientData* pTheClientData; // always the same std::unique_ptr<XclEscherClientData> pTheClientData; // always the same
XclEscherClientTextbox* pAdditionalText; XclEscherClientTextbox* pAdditionalText;
sal_uInt16 nAdditionalText; sal_uInt16 nAdditionalText;
sal_uInt32 mnNextKey; sal_uInt32 mnNextKey;
......
...@@ -110,7 +110,7 @@ XclEscherEx::~XclEscherEx() ...@@ -110,7 +110,7 @@ XclEscherEx::~XclEscherEx()
{ {
OSL_ENSURE( aStack.empty(), "~XclEscherEx: stack not empty" ); OSL_ENSURE( aStack.empty(), "~XclEscherEx: stack not empty" );
DeleteCurrAppData(); DeleteCurrAppData();
delete pTheClientData; pTheClientData.reset();
} }
sal_uInt32 XclEscherEx::InitNextDffFragment() sal_uInt32 XclEscherEx::InitNextDffFragment()
...@@ -199,8 +199,8 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape ...@@ -199,8 +199,8 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
UpdateDffFragmentEnd(); UpdateDffFragmentEnd();
} }
} }
aStack.push( std::make_pair( pCurrXclObj, pCurrAppData ) ); aStack.push( std::make_pair( pCurrXclObj, std::move(pCurrAppData) ) );
pCurrAppData = new XclEscherHostAppData; pCurrAppData.reset( new XclEscherHostAppData );
SdrObject* pObj = GetSdrObjectFromXShape( rxShape ); SdrObject* pObj = GetSdrObjectFromXShape( rxShape );
//added for exporting OCX control //added for exporting OCX control
sal_Int16 nMsCtlType = 0; sal_Int16 nMsCtlType = 0;
...@@ -272,7 +272,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape ...@@ -272,7 +272,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
} }
else else
{ {
pCurrAppData->SetClientData( pTheClientData ); pCurrAppData->SetClientData( pTheClientData.get() );
if ( nAdditionalText == 0 ) if ( nAdditionalText == 0 )
{ {
if ( pObj ) if ( pObj )
...@@ -340,7 +340,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape ...@@ -340,7 +340,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
} }
if ( !pCurrXclObj ) if ( !pCurrXclObj )
pCurrAppData->SetDontWriteShape( true ); pCurrAppData->SetDontWriteShape( true );
return pCurrAppData; return pCurrAppData.get();
} }
void XclEscherEx::EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID ) void XclEscherEx::EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID )
...@@ -382,8 +382,7 @@ void XclEscherEx::EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID ) ...@@ -382,8 +382,7 @@ void XclEscherEx::EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID )
else else
{ {
pCurrXclObj = aStack.top().first; pCurrXclObj = aStack.top().first;
pCurrAppData = aStack.top().second; pCurrAppData = std::move(aStack.top().second);
aStack.pop();
} }
if( nAdditionalText == 3 ) if( nAdditionalText == 3 )
nAdditionalText = 0; nAdditionalText = 0;
...@@ -394,7 +393,7 @@ EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup() ...@@ -394,7 +393,7 @@ EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup()
nAdditionalText = 1; nAdditionalText = 1;
pAdditionalText = static_cast<XclEscherClientTextbox*>( pCurrAppData->GetClientTextbox() ); pAdditionalText = static_cast<XclEscherClientTextbox*>( pCurrAppData->GetClientTextbox() );
pCurrAppData->SetClientTextbox( nullptr ); pCurrAppData->SetClientTextbox( nullptr );
return pCurrAppData; return pCurrAppData.get();
} }
void XclEscherEx::EndDocument() void XclEscherEx::EndDocument()
...@@ -511,8 +510,8 @@ void XclEscherEx::DeleteCurrAppData() ...@@ -511,8 +510,8 @@ void XclEscherEx::DeleteCurrAppData()
delete pCurrAppData->GetClientAnchor(); delete pCurrAppData->GetClientAnchor();
// delete pCurrAppData->GetClientData(); // delete pCurrAppData->GetClientData();
delete pCurrAppData->GetClientTextbox(); delete pCurrAppData->GetClientTextbox();
delete pCurrAppData->GetInteractionInfo(); delete pCurrAppData->GetInteractionInfo();
delete pCurrAppData; pCurrAppData.reset();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment