1 | /* $Id: UIDnDDataObject_win.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDnDDataObject class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h
|
---|
29 | #define FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/critsect.h>
|
---|
35 |
|
---|
36 | #include <QString>
|
---|
37 | #include <QStringList>
|
---|
38 | #include <QVariant>
|
---|
39 |
|
---|
40 | /* COM includes: */
|
---|
41 | #include "CDndSource.h"
|
---|
42 | #include "CSession.h"
|
---|
43 |
|
---|
44 | /* Forward declarations: */
|
---|
45 | class UIDnDHandler;
|
---|
46 |
|
---|
47 | class UIDnDDataObject : public IDataObject
|
---|
48 | {
|
---|
49 | public:
|
---|
50 |
|
---|
51 | enum Status
|
---|
52 | {
|
---|
53 | Status_Uninitialized = 0,
|
---|
54 | Status_Initialized,
|
---|
55 | Status_Dropping,
|
---|
56 | Status_Dropped,
|
---|
57 | Status_Aborted,
|
---|
58 | Status_32Bit_Hack = 0x7fffffff
|
---|
59 | };
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | UIDnDDataObject(UIDnDHandler *pDnDHandler, const QStringList &lstFormats);
|
---|
64 | virtual ~UIDnDDataObject(void);
|
---|
65 |
|
---|
66 | public: /* IUnknown methods. */
|
---|
67 |
|
---|
68 | STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
|
---|
69 | STDMETHOD_(ULONG, AddRef)(void);
|
---|
70 | STDMETHOD_(ULONG, Release)(void);
|
---|
71 |
|
---|
72 | public: /* IDataObject methods. */
|
---|
73 |
|
---|
74 | STDMETHOD(GetData)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium);
|
---|
75 | STDMETHOD(GetDataHere)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium);
|
---|
76 | STDMETHOD(QueryGetData)(LPFORMATETC pFormatEtc);
|
---|
77 | STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pFormatEtc, LPFORMATETC pFormatEtcOut);
|
---|
78 | STDMETHOD(SetData)(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium, BOOL fRelease);
|
---|
79 | STDMETHOD(EnumFormatEtc)(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc);
|
---|
80 | STDMETHOD(DAdvise)(LPFORMATETC pFormatEtc, DWORD fAdvise, IAdviseSink *pAdvSink, DWORD *pdwConnection);
|
---|
81 | STDMETHOD(DUnadvise)(DWORD dwConnection);
|
---|
82 | STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppEnumAdvise);
|
---|
83 |
|
---|
84 | public:
|
---|
85 |
|
---|
86 | static const char *ClipboardFormatToString(CLIPFORMAT fmt);
|
---|
87 |
|
---|
88 | int Abort(void);
|
---|
89 | void Signal(void);
|
---|
90 | int Signal(const QString &strFormat, const void *pvData, uint32_t cbData);
|
---|
91 |
|
---|
92 | protected:
|
---|
93 |
|
---|
94 | void SetStatus(Status enmStatus);
|
---|
95 |
|
---|
96 | bool LookupFormatEtc(LPFORMATETC pFormatEtc, ULONG *puIndex);
|
---|
97 | void RegisterFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL,
|
---|
98 | LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL);
|
---|
99 |
|
---|
100 | /** Pointe rto drag and drop handler. */
|
---|
101 | UIDnDHandler *m_pDnDHandler;
|
---|
102 | /** Current drag and drop status. */
|
---|
103 | Status m_enmStatus;
|
---|
104 | /** Internal reference count of this object. */
|
---|
105 | LONG m_cRefs;
|
---|
106 | /** Number of native formats registered. This can be a different number than supplied with m_lstFormats. */
|
---|
107 | ULONG m_cFormats;
|
---|
108 | /** Array of registered FORMATETC structs. Matches m_cFormats. */
|
---|
109 | FORMATETC *m_pFormatEtc;
|
---|
110 | /** Array of registered STGMEDIUM structs. Matches m_cFormats. */
|
---|
111 | STGMEDIUM *m_pStgMedium;
|
---|
112 | /** Event semaphore used for waiting on status changes. */
|
---|
113 | RTSEMEVENT m_SemEvent;
|
---|
114 | /** List of supported formats. */
|
---|
115 | QStringList m_lstFormats;
|
---|
116 | /** Format of currently retrieved data. */
|
---|
117 | QString m_strFormat;
|
---|
118 | /** The retrieved data as a QVariant. Needed for buffering in case a second format needs the same data,
|
---|
119 | * e.g. CF_TEXT and CF_UNICODETEXT. */
|
---|
120 | QVariant m_vaData;
|
---|
121 | /** Whether the data already was retrieved or not. */
|
---|
122 | bool m_fDataRetrieved;
|
---|
123 | /** The retrieved data as a raw buffer. */
|
---|
124 | void *m_pvData;
|
---|
125 | /** Raw buffer size (in bytes). */
|
---|
126 | uint32_t m_cbData;
|
---|
127 | };
|
---|
128 |
|
---|
129 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIDnDDataObject_win_h */
|
---|
130 |
|
---|