nss: upgrade to release 3.73
[LibreOffice.git] / vcl / win / dtrans / XNotifyingDataObject.cxx
bloba989b47e938d6fe166ae6c64ed4ca3906ab5a4c5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/diagnose.h>
21 #include "XNotifyingDataObject.hxx"
22 #include "WinClipboard.hxx"
24 using namespace com::sun::star::datatransfer;
25 using namespace com::sun::star::datatransfer::clipboard;
26 using com::sun::star::uno::RuntimeException;
27 using com::sun::star::uno::Reference;
29 CXNotifyingDataObject::CXNotifyingDataObject(
30 const IDataObjectPtr& aIDataObject,
31 const Reference< XTransferable >& aXTransferable,
32 const Reference< XClipboardOwner >& aXClipOwner,
33 CWinClipboard* const theWinClipoard) :
34 m_nRefCnt( 0 ),
35 m_aIDataObject( aIDataObject ),
36 m_XTransferable( aXTransferable ),
37 m_XClipboardOwner( aXClipOwner ),
38 m_pWinClipImpl( theWinClipoard )
42 STDMETHODIMP CXNotifyingDataObject::QueryInterface( REFIID iid, void** ppvObject )
44 if ( nullptr == ppvObject )
45 return E_INVALIDARG;
47 HRESULT hr = E_NOINTERFACE;
49 *ppvObject = nullptr;
50 if ( ( __uuidof( IUnknown ) == iid ) ||
51 ( __uuidof( IDataObject ) == iid ) )
53 *ppvObject = static_cast< IUnknown* >( this );
54 static_cast<LPUNKNOWN>(*ppvObject)->AddRef( );
55 hr = S_OK;
58 return hr;
61 STDMETHODIMP_(ULONG) CXNotifyingDataObject::AddRef( )
63 return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
66 STDMETHODIMP_(ULONG) CXNotifyingDataObject::Release( )
68 ULONG nRefCnt =
69 static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
71 if ( 0 == nRefCnt )
73 if ( m_pWinClipImpl )
74 m_pWinClipImpl->onReleaseDataObject( this );
76 delete this;
79 return nRefCnt;
82 STDMETHODIMP CXNotifyingDataObject::GetData( FORMATETC * pFormatetc, STGMEDIUM * pmedium )
84 return m_aIDataObject->GetData(pFormatetc, pmedium);
87 STDMETHODIMP CXNotifyingDataObject::EnumFormatEtc(
88 DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
90 return m_aIDataObject->EnumFormatEtc(dwDirection, ppenumFormatetc);
93 STDMETHODIMP CXNotifyingDataObject::QueryGetData( FORMATETC * pFormatetc )
95 return m_aIDataObject->QueryGetData(pFormatetc);
98 STDMETHODIMP CXNotifyingDataObject::GetDataHere( FORMATETC * lpFetc, STGMEDIUM * lpStgMedium )
100 return m_aIDataObject->GetDataHere(lpFetc, lpStgMedium);
103 STDMETHODIMP CXNotifyingDataObject::GetCanonicalFormatEtc( FORMATETC * lpFetc, FORMATETC * lpCanonicalFetc )
105 return m_aIDataObject->GetCanonicalFormatEtc(lpFetc, lpCanonicalFetc);
108 STDMETHODIMP CXNotifyingDataObject::SetData( FORMATETC * lpFetc, STGMEDIUM * lpStgMedium, BOOL bRelease )
110 return m_aIDataObject->SetData( lpFetc, lpStgMedium, bRelease );
113 STDMETHODIMP CXNotifyingDataObject::DAdvise(
114 FORMATETC * lpFetc, DWORD advf, IAdviseSink * lpAdvSink, DWORD* pdwConnection )
116 return m_aIDataObject->DAdvise( lpFetc, advf, lpAdvSink, pdwConnection );
119 STDMETHODIMP CXNotifyingDataObject::DUnadvise( DWORD dwConnection )
121 return m_aIDataObject->DUnadvise( dwConnection );
124 STDMETHODIMP CXNotifyingDataObject::EnumDAdvise( IEnumSTATDATA ** ppenumAdvise )
126 return m_aIDataObject->EnumDAdvise( ppenumAdvise );
129 CXNotifyingDataObject::operator IDataObject*( )
131 return static_cast< IDataObject* >( this );
134 void CXNotifyingDataObject::lostOwnership( )
138 if (m_XClipboardOwner.is())
139 m_XClipboardOwner->lostOwnership(
140 static_cast<XClipboardEx*>(m_pWinClipImpl), m_XTransferable);
142 catch(RuntimeException&)
144 OSL_FAIL( "RuntimeException caught" );
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */