include/systools/win32/comtools.hxx |    1 -
 vcl/win/dtrans/APNDataObject.cxx    |   25 +++++++++----------------
 vcl/win/dtrans/APNDataObject.hxx    |    6 ++----
 3 files changed, 11 insertions(+), 21 deletions(-)

New commits:
commit 8843e4c441b881a68b46bc08019ff994c9aa574d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun May 21 10:14:24 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun May 21 12:12:24 2023 +0200

    Simplify a bit
    
    Change-Id: I4be66ff1ea2a15d3345134f4131bd0fabb5de9ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152028
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/systools/win32/comtools.hxx 
b/include/systools/win32/comtools.hxx
index d54b1a22ce02..1d618051d2c7 100644
--- a/include/systools/win32/comtools.hxx
+++ b/include/systools/win32/comtools.hxx
@@ -263,6 +263,5 @@ namespace sal::systools
 
 /* Typedefs for some popular COM interfaces */
 typedef sal::systools::COMReference<IDataObject> IDataObjectPtr;
-typedef sal::systools::COMReference<IStream> IStreamPtr;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/dtrans/APNDataObject.cxx b/vcl/win/dtrans/APNDataObject.cxx
index 53342f21f379..2492647f26c5 100644
--- a/vcl/win/dtrans/APNDataObject.cxx
+++ b/vcl/win/dtrans/APNDataObject.cxx
@@ -38,7 +38,7 @@ CAPNDataObject::CAPNDataObject( IDataObjectPtr rIDataObject ) 
:
     // we marshal the IDataObject interface pointer here so
     // that it can be unmarshalled multiple times when this
     // class will be used from another apartment
-    IStreamPtr pStm;
+    sal::systools::COMReference<IStream> pStm;
     HRESULT hr = CreateStreamOnHGlobal( nullptr, KEEP_HGLOB_ON_RELEASE, &pStm 
);
 
     OSL_ENSURE( E_INVALIDARG != hr, "invalid args passed to 
CreateStreamOnHGlobal" );
@@ -46,9 +46,9 @@ CAPNDataObject::CAPNDataObject( IDataObjectPtr rIDataObject ) 
:
     if ( SUCCEEDED( hr ) )
     {
         HRESULT hr_marshal = CoMarshalInterface(
-            pStm.get(),
+            pStm,
             __uuidof(IDataObject),
-            static_cast<LPUNKNOWN>(m_rIDataObjectOrg.get()),
+            m_rIDataObjectOrg,
             MSHCTX_LOCAL,
             nullptr,
             MSHLFLAGS_TABLEWEAK );
@@ -60,7 +60,7 @@ CAPNDataObject::CAPNDataObject( IDataObjectPtr rIDataObject ) 
:
         // error or because of stream errors which are runtime
         // errors for instance E_OUTOFMEMORY etc.
 
-        hr = GetHGlobalFromStream(pStm.get(), &m_hGlobal );
+        hr = GetHGlobalFromStream(pStm, &m_hGlobal );
 
         OSL_ENSURE( E_INVALIDARG != hr, "invalid stream passed to 
GetHGlobalFromStream" );
 
@@ -83,14 +83,14 @@ CAPNDataObject::~CAPNDataObject( )
 {
     if (m_hGlobal)
     {
-        IStreamPtr pStm;
+        sal::systools::COMReference<IStream> pStm;
         HRESULT  hr = CreateStreamOnHGlobal(m_hGlobal, FREE_HGLOB_ON_RELEASE, 
&pStm);
 
         OSL_ENSURE( E_INVALIDARG != hr, "invalid args passed to 
CreateStreamOnHGlobal" );
 
         if (SUCCEEDED(hr))
         {
-            hr = CoReleaseMarshalData(pStm.get());
+            hr = CoReleaseMarshalData(pStm);
             OSL_ENSURE(SUCCEEDED(hr), "CoReleaseMarshalData failed");
         }
     }
@@ -111,7 +111,7 @@ STDMETHODIMP CAPNDataObject::QueryInterface( REFIID iid, 
void** ppvObject )
     if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) 
)
     {
         *ppvObject = static_cast< IUnknown* >( this );
-        static_cast<LPUNKNOWN>(*ppvObject)->AddRef( );
+        AddRef( );
         hr = S_OK;
     }
 
@@ -292,13 +292,6 @@ STDMETHODIMP CAPNDataObject::EnumDAdvise( IEnumSTATDATA ** 
ppenumAdvise )
     return hr;
 }
 
-// for our convenience
-
-CAPNDataObject::operator IDataObject*( )
-{
-    return static_cast< IDataObject* >( this );
-}
-
 // helper function
 
 HRESULT CAPNDataObject::MarshalIDataObjectIntoCurrentApartment( IDataObject** 
ppIDataObj )
@@ -310,14 +303,14 @@ HRESULT 
CAPNDataObject::MarshalIDataObjectIntoCurrentApartment( IDataObject** pp
 
     if (m_hGlobal)
     {
-        IStreamPtr pStm;
+        sal::systools::COMReference<IStream> pStm;
         hr = CreateStreamOnHGlobal(m_hGlobal, KEEP_HGLOB_ON_RELEASE, &pStm);
 
         OSL_ENSURE(E_INVALIDARG != hr, "CreateStreamOnHGlobal with invalid 
args called");
 
         if (SUCCEEDED(hr))
         {
-            hr = CoUnmarshalInterface(pStm.get(), __uuidof(IDataObject), 
reinterpret_cast<void**>(ppIDataObj));
+            hr = CoUnmarshalInterface(pStm, IID_PPV_ARGS(ppIDataObj));
             OSL_ENSURE(CO_E_NOTINITIALIZED != hr, "COM is not initialized");
         }
     }
diff --git a/vcl/win/dtrans/APNDataObject.hxx b/vcl/win/dtrans/APNDataObject.hxx
index 2d3c583ec312..5de8ccfcc8d1 100644
--- a/vcl/win/dtrans/APNDataObject.hxx
+++ b/vcl/win/dtrans/APNDataObject.hxx
@@ -57,8 +57,6 @@ public:
     STDMETHODIMP DUnadvise( DWORD dwConnection ) override;
     STDMETHODIMP EnumDAdvise( IEnumSTATDATA** ppenumAdvise ) override;
 
-    operator IDataObject*( );
-
 private:
     HRESULT MarshalIDataObjectIntoCurrentApartment( IDataObject** ppIDataObj );
 
@@ -69,8 +67,8 @@ private:
 
 // prevent copy and assignment
 private:
-    CAPNDataObject( const CAPNDataObject& theOther );
-    CAPNDataObject& operator=( const CAPNDataObject& theOther );
+    CAPNDataObject( const CAPNDataObject& theOther ) = delete;
+    CAPNDataObject& operator=( const CAPNDataObject& theOther ) = delete;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to