From d09888b835825085319d7b6855c3d5509539f42f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 2 Jan 2017 15:13:20 +0000 Subject: use std::unique_ptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1c4f81e0ba0529b9e365c6ddb3d77a8a6a6d5741 Reviewed-on: https://gerrit.libreoffice.org/32649 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svl/source/svdde/ddecli.cxx | 10 +++---- svl/source/svdde/ddedata.cxx | 63 +++++++++++++++++++-------------------- svl/source/svdde/ddesvr.cxx | 16 +++++----- svl/unx/source/svdde/ddedummy.cxx | 8 ++--- 4 files changed, 47 insertions(+), 50 deletions(-) (limited to 'svl') diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx index c9f9b0774089..d26191859feb 100644 --- a/svl/source/svdde/ddecli.cxx +++ b/svl/source/svdde/ddecli.cxx @@ -133,8 +133,8 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( UINT nCode, UINT nCbType, } DdeData d; - d.pImp->hData = hData; - d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); + d.xImp->hData = hData; + d.xImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.Lock(); (*iter)->Data( &d ); nRet = reinterpret_cast(DDE_FACK); @@ -274,7 +274,7 @@ void DdeTransaction::Execute() HSZ hItem = pName->getHSZ(); void const * pData = aDdeData.getData(); DWORD nData = (DWORD)aDdeData.getSize(); - SotClipboardFormatId nIntFmt = aDdeData.pImp->nFmt; + SotClipboardFormatId nIntFmt = aDdeData.xImp->nFmt; UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt ); DdeInstData* pInst = ImpGetInstData(); @@ -297,8 +297,8 @@ void DdeTransaction::Execute() { { DdeData d; - d.pImp->hData = hData; - d.pImp->nFmt = nIntFmt; + d.xImp->hData = hData; + d.xImp->nFmt = nIntFmt; d.Lock(); Data( &d ); } diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx index ccfc5a3ad0d1..d6cd5341e64d 100644 --- a/svl/source/svdde/ddedata.cxx +++ b/svl/source/svdde/ddedata.cxx @@ -32,82 +32,79 @@ DdeData::DdeData() { - pImp = new DdeDataImp; - pImp->hData = nullptr; - pImp->nData = 0; - pImp->pData = nullptr; - pImp->nFmt = SotClipboardFormatId::STRING; + xImp.reset(new DdeDataImp); + xImp->hData = nullptr; + xImp->nData = 0; + xImp->pData = nullptr; + xImp->nFmt = SotClipboardFormatId::STRING; } DdeData::DdeData(const void* p, long n, SotClipboardFormatId f) { - pImp = new DdeDataImp; - pImp->hData = nullptr; - pImp->pData = p; - pImp->nData = n; - pImp->nFmt = f; + xImp.reset(new DdeDataImp); + xImp->hData = nullptr; + xImp->pData = p; + xImp->nData = n; + xImp->nFmt = f; } DdeData::DdeData( const OUString& s ) { - pImp = new DdeDataImp; - pImp->hData = nullptr; - pImp->pData = s.getStr(); - pImp->nData = s.getLength()+1; - pImp->nFmt = SotClipboardFormatId::STRING; + xImp.reset(new DdeDataImp); + xImp->hData = nullptr; + xImp->pData = s.getStr(); + xImp->nData = s.getLength()+1; + xImp->nFmt = SotClipboardFormatId::STRING; } DdeData::DdeData( const DdeData& rData ) { - pImp = new DdeDataImp; - pImp->hData = rData.pImp->hData; - pImp->nData = rData.pImp->nData; - pImp->pData = rData.pImp->pData; - pImp->nFmt = rData.pImp->nFmt; + xImp.reset(new DdeDataImp); + xImp->hData = rData.xImp->hData; + xImp->nData = rData.xImp->nData; + xImp->pData = rData.xImp->pData; + xImp->nFmt = rData.xImp->nFmt; Lock(); } DdeData::~DdeData() { - if ( pImp && pImp->hData ) - DdeUnaccessData( pImp->hData ); - delete pImp; + if (xImp && xImp->hData) + DdeUnaccessData(xImp->hData); } void DdeData::Lock() { - if ( pImp->hData ) - pImp->pData = DdeAccessData( pImp->hData, &pImp->nData ); + if (xImp->hData) + xImp->pData = DdeAccessData(xImp->hData, &xImp->nData); } SotClipboardFormatId DdeData::GetFormat() const { - return pImp->nFmt; + return xImp->nFmt; } void DdeData::SetFormat(SotClipboardFormatId nFmt) { - pImp->nFmt = nFmt; + xImp->nFmt = nFmt; } void const * DdeData::getData() const { - return pImp->pData; + return xImp->pData; } long DdeData::getSize() const { - return pImp->nData; + return xImp->nData; } DdeData& DdeData::operator = ( const DdeData& rData ) { if ( &rData != this ) { - DdeData tmp( rData ); - delete pImp; - pImp = tmp.pImp; - tmp.pImp = nullptr; + DdeData tmp(rData); + xImp = std::move(tmp.xImp); } return *this; diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 4235c78d2853..8ece1071cf20 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -263,11 +263,11 @@ found: if ( pData ) { return DdeCreateDataHandle( pInst->hDdeInstSvr, - static_cast(const_cast(pData->pImp->pData)), - pData->pImp->nData, + static_cast(const_cast(pData->xImp->pData)), + pData->xImp->nData, 0, hText2, DdeData::GetExternalFormat( - pData->pImp->nFmt ), + pData->xImp->nFmt ), 0 ); } } @@ -277,8 +277,8 @@ found: if ( !pTopic->IsSystemTopic() ) { DdeData d; - d.pImp->hData = hData; - d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); + d.xImp->hData = hData; + d.xImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.Lock(); if( DDEGETPUTITEM == pItem->nType ) bRes = static_cast(pItem)->Put( &d ); @@ -337,12 +337,12 @@ found: case XTYP_EXECUTE: { DdeData aExec; - aExec.pImp->hData = hData; - aExec.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); + aExec.xImp->hData = hData; + aExec.xImp->nFmt = DdeData::GetInternalFormat( nCbType ); aExec.Lock(); OUString aName; - aName = static_cast(aExec.pImp->pData); + aName = static_cast(aExec.xImp->pData); if( pTopic->IsSystemTopic() ) bRes = false; diff --git a/svl/unx/source/svdde/ddedummy.cxx b/svl/unx/source/svdde/ddedummy.cxx index 8714e9201be8..393759545a19 100644 --- a/svl/unx/source/svdde/ddedummy.cxx +++ b/svl/unx/source/svdde/ddedummy.cxx @@ -20,23 +20,23 @@ #include #include +struct DdeDataImp +{ +}; + DdeData::DdeData() - : pImp(nullptr) { } DdeData::DdeData( const OUString& ) - : pImp(nullptr) { } DdeData::DdeData( const DdeData& ) - : pImp(nullptr) { } DdeData::DdeData( const void*, long, SotClipboardFormatId) - : pImp(nullptr) { } -- cgit