1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "../clipb/WinClipbImpl.hxx"
23 #include "../clipb/WinClipboard.hxx"
25 using namespace com::sun::star::datatransfer
;
26 using namespace com::sun::star::datatransfer::clipboard
;
27 using com::sun::star::uno::RuntimeException
;
28 using com::sun::star::uno::Reference
;
30 CXNotifyingDataObject::CXNotifyingDataObject(
31 const IDataObjectPtr
& aIDataObject
,
32 const Reference
< XTransferable
>& aXTransferable
,
33 const Reference
< XClipboardOwner
>& aXClipOwner
,
34 CWinClipbImpl
* theWinClipImpl
) :
36 m_aIDataObject( aIDataObject
),
37 m_XTransferable( aXTransferable
),
38 m_XClipboardOwner( aXClipOwner
),
39 m_pWinClipImpl( theWinClipImpl
)
43 STDMETHODIMP
CXNotifyingDataObject::QueryInterface( REFIID iid
, void** ppvObject
)
45 if ( nullptr == ppvObject
)
48 HRESULT hr
= E_NOINTERFACE
;
51 if ( ( __uuidof( IUnknown
) == iid
) ||
52 ( __uuidof( IDataObject
) == iid
) )
54 *ppvObject
= static_cast< IUnknown
* >( this );
55 static_cast<LPUNKNOWN
>(*ppvObject
)->AddRef( );
62 STDMETHODIMP_(ULONG
) CXNotifyingDataObject::AddRef( )
64 return static_cast< ULONG
>( InterlockedIncrement( &m_nRefCnt
) );
67 STDMETHODIMP_(ULONG
) CXNotifyingDataObject::Release( )
70 static_cast< ULONG
>( InterlockedDecrement( &m_nRefCnt
) );
75 m_pWinClipImpl
->onReleaseDataObject( this );
83 STDMETHODIMP
CXNotifyingDataObject::GetData( FORMATETC
* pFormatetc
, STGMEDIUM
* pmedium
)
85 return m_aIDataObject
->GetData(pFormatetc
, pmedium
);
88 STDMETHODIMP
CXNotifyingDataObject::EnumFormatEtc(
89 DWORD dwDirection
, IEnumFORMATETC
** ppenumFormatetc
)
91 return m_aIDataObject
->EnumFormatEtc(dwDirection
, ppenumFormatetc
);
94 STDMETHODIMP
CXNotifyingDataObject::QueryGetData( FORMATETC
* pFormatetc
)
96 return m_aIDataObject
->QueryGetData(pFormatetc
);
99 STDMETHODIMP
CXNotifyingDataObject::GetDataHere( FORMATETC
* lpFetc
, STGMEDIUM
* lpStgMedium
)
101 return m_aIDataObject
->GetDataHere(lpFetc
, lpStgMedium
);
104 STDMETHODIMP
CXNotifyingDataObject::GetCanonicalFormatEtc( FORMATETC
* lpFetc
, FORMATETC
* lpCanonicalFetc
)
106 return m_aIDataObject
->GetCanonicalFormatEtc(lpFetc
, lpCanonicalFetc
);
109 STDMETHODIMP
CXNotifyingDataObject::SetData( FORMATETC
* lpFetc
, STGMEDIUM
* lpStgMedium
, BOOL bRelease
)
111 return m_aIDataObject
->SetData( lpFetc
, lpStgMedium
, bRelease
);
114 STDMETHODIMP
CXNotifyingDataObject::DAdvise(
115 FORMATETC
* lpFetc
, DWORD advf
, IAdviseSink
* lpAdvSink
, DWORD
* pdwConnection
)
117 return m_aIDataObject
->DAdvise( lpFetc
, advf
, lpAdvSink
, pdwConnection
);
120 STDMETHODIMP
CXNotifyingDataObject::DUnadvise( DWORD dwConnection
)
122 return m_aIDataObject
->DUnadvise( dwConnection
);
125 STDMETHODIMP
CXNotifyingDataObject::EnumDAdvise( IEnumSTATDATA
** ppenumAdvise
)
127 return m_aIDataObject
->EnumDAdvise( ppenumAdvise
);
130 CXNotifyingDataObject::operator IDataObject
*( )
132 return static_cast< IDataObject
* >( this );
135 void CXNotifyingDataObject::lostOwnership( )
139 if (m_XClipboardOwner
.is())
140 m_XClipboardOwner
->lostOwnership(
141 static_cast<XClipboardEx
*>(m_pWinClipImpl
->m_pWinClipboard
), m_XTransferable
);
143 catch(RuntimeException
&)
145 OSL_FAIL( "RuntimeException caught" );
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */