[Libreoffice-commits] core.git: include/svl svl/source svl/unx

Caolán McNamara caolanm at redhat.com
Mon Jan 2 16:36:22 UTC 2017


 include/svl/svdde.hxx             |    3 +
 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 ++--
 5 files changed, 49 insertions(+), 51 deletions(-)

New commits:
commit d09888b835825085319d7b6855c3d5509539f42f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jan 2 15:13:20 2017 +0000

    use std::unique_ptr
    
    Change-Id: I1c4f81e0ba0529b9e365c6ddb3d77a8a6a6d5741
    Reviewed-on: https://gerrit.libreoffice.org/32649
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svl/svdde.hxx b/include/svl/svdde.hxx
index 766430f..e59aea0 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 c9f9b07..d261918 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 ccfc5a3..d6cd534 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 4235c78..8ece107 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 8714e92..393759545 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)
 {
 }
 


More information about the Libreoffice-commits mailing list