diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-21 10:14:24 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-21 12:12:24 +0200 |
commit | 8843e4c441b881a68b46bc08019ff994c9aa574d (patch) | |
tree | 54f466a0c70e846ab9c5607ba41423fe7dd484be /vcl/win | |
parent | 1fec168aff4569827d4822c9fcff7bc4ecd0d04b (diff) |
Simplify a bit
Change-Id: I4be66ff1ea2a15d3345134f4131bd0fabb5de9ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152028
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/dtrans/APNDataObject.cxx | 25 | ||||
-rw-r--r-- | vcl/win/dtrans/APNDataObject.hxx | 6 |
2 files changed, 11 insertions, 20 deletions
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: */ |