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 .
22 #include <com/sun/star/datatransfer/XTransferable.hpp>
23 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
25 #if !defined WIN32_LEAN_AND_MEAN
26 # define WIN32_LEAN_AND_MEAN
31 #include <systools/win32/comtools.hxx>
33 /*--------------------------------------------------------------------------
34 To implement the lostOwnership mechanism cleanly we need this wrapper
36 ----------------------------------------------------------------------------*/
41 class CXNotifyingDataObject final
: public IDataObject
44 CXNotifyingDataObject(
45 const IDataObjectPtr
& aIDataObject
,
46 const css::uno::Reference
< css::datatransfer::XTransferable
>& aXTransferable
,
47 const css::uno::Reference
< css::datatransfer::clipboard::XClipboardOwner
>& aXClipOwner
,
48 CWinClipboard
* const theWinClipoard
);
50 virtual ~CXNotifyingDataObject() {}
52 // ole interface implementation
54 //IUnknown interface methods
55 STDMETHODIMP
QueryInterface(REFIID iid
, void** ppvObject
) override
;
56 STDMETHODIMP_( ULONG
) AddRef( ) override
;
57 STDMETHODIMP_( ULONG
) Release( ) override
;
59 // IDataObject interface methods
60 STDMETHODIMP
GetData( FORMATETC
* pFormatetc
, STGMEDIUM
* pmedium
) override
;
61 STDMETHODIMP
GetDataHere( FORMATETC
* pFormatetc
, STGMEDIUM
* pmedium
) override
;
62 STDMETHODIMP
QueryGetData( FORMATETC
* pFormatetc
) override
;
63 STDMETHODIMP
GetCanonicalFormatEtc( FORMATETC
* pFormatectIn
, FORMATETC
* pFormatetcOut
) override
;
64 STDMETHODIMP
SetData( FORMATETC
* pFormatetc
, STGMEDIUM
* pmedium
, BOOL fRelease
) override
;
65 STDMETHODIMP
EnumFormatEtc( DWORD dwDirection
, IEnumFORMATETC
** ppenumFormatetc
) override
;
66 STDMETHODIMP
DAdvise( FORMATETC
* pFormatetc
, DWORD advf
, IAdviseSink
* pAdvSink
, DWORD
* pdwConnection
) override
;
67 STDMETHODIMP
DUnadvise( DWORD dwConnection
) override
;
68 STDMETHODIMP
EnumDAdvise( IEnumSTATDATA
** ppenumAdvise
) override
;
70 operator IDataObject
*( );
73 void lostOwnership( );
76 IDataObjectPtr m_aIDataObject
;
77 const css::uno::Reference
< css::datatransfer::XTransferable
> m_XTransferable
;
78 const css::uno::Reference
< css::datatransfer::clipboard::XClipboardOwner
> m_XClipboardOwner
;
79 CWinClipboard
* const m_pWinClipImpl
;
81 friend class CWinClipboard
;
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */