1 | /* $Id: UIDnDDataObject_win.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDnDDataObject class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h
|
---|
19 | #define FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/critsect.h>
|
---|
25 |
|
---|
26 | #include <QString>
|
---|
27 | #include <QStringList>
|
---|
28 | #include <QVariant>
|
---|
29 |
|
---|
30 | /* COM includes: */
|
---|
31 | #include "COMEnums.h"
|
---|
32 | #include "CDndSource.h"
|
---|
33 | #include "CSession.h"
|
---|
34 |
|
---|
35 | /* Forward declarations: */
|
---|
36 | class UIDnDHandler;
|
---|
37 |
|
---|
38 | class UIDnDDataObject : public IDataObject
|
---|
39 | {
|
---|
40 | public:
|
---|
41 |
|
---|
42 | enum DnDDataObjectStatus
|
---|
43 | {
|
---|
44 | DnDDataObjectStatus_Uninitialized = 0,
|
---|
45 | DnDDataObjectStatus_Initialized,
|
---|
46 | DnDDataObjectStatus_Dropping,
|
---|
47 | DnDDataObjectStatus_Dropped,
|
---|
48 | DnDDataObjectStatus_Aborted,
|
---|
49 | DnDDataObjectStatus_32Bit_Hack = 0x7fffffff
|
---|
50 | };
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | UIDnDDataObject(UIDnDHandler *pDnDHandler, const QStringList &lstFormats);
|
---|
55 | virtual ~UIDnDDataObject(void);
|
---|
56 |
|
---|
57 | public: /* IUnknown methods. */
|
---|
58 |
|
---|
59 | STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
|
---|
60 | STDMETHOD_(ULONG, AddRef)(void);
|
---|
61 | STDMETHOD_(ULONG, Release)(void);
|
---|
62 |
|
---|
63 | public: /* IDataObject methods. */
|
---|
64 |
|
---|
65 | STDMETHOD(GetData)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium);
|
---|
66 | STDMETHOD(GetDataHere)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium);
|
---|
67 | STDMETHOD(QueryGetData)(LPFORMATETC pFormatEtc);
|
---|
68 | STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pFormatEtc, LPFORMATETC pFormatEtcOut);
|
---|
69 | STDMETHOD(SetData)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium, BOOL fRelease);
|
---|
70 | STDMETHOD(EnumFormatEtc)(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc);
|
---|
71 | STDMETHOD(DAdvise)(LPFORMATETC pFormatEtc, DWORD fAdvise, IAdviseSink *pAdvSink, DWORD *pdwConnection);
|
---|
72 | STDMETHOD(DUnadvise)(DWORD dwConnection);
|
---|
73 | STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppEnumAdvise);
|
---|
74 |
|
---|
75 | public:
|
---|
76 |
|
---|
77 | static const char *ClipboardFormatToString(CLIPFORMAT fmt);
|
---|
78 |
|
---|
79 | int Abort(void);
|
---|
80 | void Signal(void);
|
---|
81 | int Signal(const QString &strFormat, const void *pvData, uint32_t cbData);
|
---|
82 |
|
---|
83 | protected:
|
---|
84 |
|
---|
85 | void SetStatus(DnDDataObjectStatus enmStatus);
|
---|
86 |
|
---|
87 | bool LookupFormatEtc(LPFORMATETC pFormatEtc, ULONG *puIndex);
|
---|
88 | void RegisterFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL,
|
---|
89 | LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL);
|
---|
90 |
|
---|
91 | /** Pointe rto drag and drop handler. */
|
---|
92 | UIDnDHandler *m_pDnDHandler;
|
---|
93 | /** Current drag and drop status. */
|
---|
94 | DnDDataObjectStatus m_enmStatus;
|
---|
95 | /** Internal reference count of this object. */
|
---|
96 | LONG m_cRefs;
|
---|
97 | /** Number of native formats registered. This can be a different number than supplied with mlstFormats. */
|
---|
98 | ULONG m_cFormats;
|
---|
99 | FORMATETC *m_pFormatEtc;
|
---|
100 | STGMEDIUM *m_pStgMedium;
|
---|
101 | RTSEMEVENT m_SemEvent;
|
---|
102 | QStringList m_lstFormats;
|
---|
103 | QString m_strFormat;
|
---|
104 | /** The retrieved data as a QVariant. Needed for buffering in case a second format needs the same data,
|
---|
105 | * e.g. CF_TEXT and CF_UNICODETEXT. */
|
---|
106 | QVariant m_vaData;
|
---|
107 | /** Whether the data already was retrieved or not. */
|
---|
108 | bool m_fDataRetrieved;
|
---|
109 | /** The retrieved data as a raw buffer. */
|
---|
110 | void *m_pvData;
|
---|
111 | /** Raw buffer size (in bytes). */
|
---|
112 | uint32_t m_cbData;
|
---|
113 | };
|
---|
114 |
|
---|
115 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h */
|
---|
116 |
|
---|