summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-01-02 15:13:20 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-01-02 16:35:58 +0000
commitd09888b835825085319d7b6855c3d5509539f42f (patch)
tree8aa1fd0e6af7d0d8fd00757ea8903936205af0b8
parentf61f34c900534b960f19425d1fe51608d6a4f12d (diff)
use std::unique_ptr
Change-Id: I1c4f81e0ba0529b9e365c6ddb3d77a8a6a6d5741 Reviewed-on: https://gerrit.libreoffice.org/32649 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svl/svdde.hxx3
-rw-r--r--svl/source/svdde/ddecli.cxx10
-rw-r--r--svl/source/svdde/ddedata.cxx63
-rw-r--r--svl/source/svdde/ddesvr.cxx16
-rw-r--r--svl/unx/source/svdde/ddedummy.cxx8
5 files changed, 49 insertions, 51 deletions
diff --git a/include/svl/svdde.hxx b/include/svl/svdde.hxx
index 766430f488fc..e59aea050ce2 100644
--- a/include/svl/svdde.hxx
+++ b/include/svl/svdde.hxx
@@ -26,6 +26,7 @@
#include <sot/exchange.hxx>
#include <tools/solar.h>
#include <tools/link.hxx>
+#include <memory>
#include <vector>
class DdeString;
@@ -56,7 +57,7 @@ class SVL_DLLPUBLIC DdeData
friend class DdeService;
friend class DdeConnection;
friend class DdeTransaction;
- DdeDataImp* pImp;
+ std::unique_ptr<DdeDataImp> xImp;
SVL_DLLPRIVATE void Lock();
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<HDDEDATA>(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<LPBYTE>(const_cast<void *>(pData->pImp->pData)),
- pData->pImp->nData,
+ static_cast<LPBYTE>(const_cast<void *>(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<DdeGetPutItem*>(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<const sal_Unicode *>(aExec.pImp->pData);
+ aName = static_cast<const sal_Unicode *>(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 <svl/svdde.hxx>
#include <rtl/instance.hxx>
+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)
{
}