Changeset 78725 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
- Timestamp:
- May 24, 2019 1:15:59 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r78476 r78725 42 42 #include <VBox/log.h> 43 43 44 VBoxClipboardWinDataObject::VBoxClipboardWinDataObject(LPFORMATETC pFormatEtc, LPSTGMEDIUM pStgMed, ULONG cFormats) 45 : mStatus(Uninitialized) 46 , mRefCount(0) 47 , mcFormats(0) 48 , muClientID(0) 49 { 44 VBoxClipboardWinDataObject::VBoxClipboardWinDataObject(SharedClipboardProvider *pProvider, 45 LPFORMATETC pFormatEtc, LPSTGMEDIUM pStgMed, ULONG cFormats) 46 : m_enmStatus(Uninitialized) 47 , m_lRefCount(0) 48 , m_cFormats(0) 49 , m_pProvider(pProvider) 50 { 51 AssertPtr(pProvider); 52 50 53 HRESULT hr; 51 54 … … 55 58 try 56 59 { 57 m pFormatEtc = new FORMATETC[cAllFormats];58 RT_BZERO(m pFormatEtc, sizeof(FORMATETC) * cAllFormats);59 m pStgMedium = new STGMEDIUM[cAllFormats];60 RT_BZERO(m pStgMedium, sizeof(STGMEDIUM) * cAllFormats);60 m_pFormatEtc = new FORMATETC[cAllFormats]; 61 RT_BZERO(m_pFormatEtc, sizeof(FORMATETC) * cAllFormats); 62 m_pStgMedium = new STGMEDIUM[cAllFormats]; 63 RT_BZERO(m_pStgMedium, sizeof(STGMEDIUM) * cAllFormats); 61 64 62 65 /** @todo Do we need CFSTR_FILENAME / CFSTR_SHELLIDLIST here? */ … … 67 70 68 71 /* IStream interface, implemented in ClipboardStreamImpl-win.cpp. */ 69 registerFormat(&m pFormatEtc[FormatIndex_FileDescriptorA],72 registerFormat(&m_pFormatEtc[FormatIndex_FileDescriptorA], 70 73 RegisterClipboardFormat(CFSTR_FILEDESCRIPTORA)); 71 registerFormat(&m pFormatEtc[FormatIndex_FileDescriptorW],74 registerFormat(&m_pFormatEtc[FormatIndex_FileDescriptorW], 72 75 RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)); 73 registerFormat(&m pFormatEtc[FormatIndex_FileContents],76 registerFormat(&m_pFormatEtc[FormatIndex_FileContents], 74 77 RegisterClipboardFormat(CFSTR_FILECONTENTS), 75 78 TYMED_ISTREAM, 0 /* lIndex */); … … 88 91 LogFlowFunc(("Format %RU32: cfFormat=%RI16, tyMed=%RU32, dwAspect=%RU32\n", 89 92 i, pFormatEtc[i].cfFormat, pFormatEtc[i].tymed, pFormatEtc[i].dwAspect)); 90 m pFormatEtc[cFixedFormats + i] = pFormatEtc[i];91 m pStgMedium[cFixedFormats + i] = pStgMed[i];93 m_pFormatEtc[cFixedFormats + i] = pFormatEtc[i]; 94 m_pStgMedium[cFixedFormats + i] = pStgMed[i]; 92 95 } 93 96 } … … 102 105 if (SUCCEEDED(hr)) 103 106 { 104 mcFormats = cAllFormats; 105 mStatus = Initialized; 107 m_cFormats = cAllFormats; 108 m_enmStatus = Initialized; 109 110 m_pProvider->AddRef(); 106 111 } 107 112 … … 111 116 VBoxClipboardWinDataObject::~VBoxClipboardWinDataObject(void) 112 117 { 113 if (mpStream) 114 mpStream->Release(); 115 116 if (mpFormatEtc) 117 delete[] mpFormatEtc; 118 119 if (mpStgMedium) 120 delete[] mpStgMedium; 121 122 LogFlowFunc(("mRefCount=%RI32\n", mRefCount)); 118 if (m_pProvider) 119 m_pProvider->Release(); 120 121 if (m_pStream) 122 m_pStream->Release(); 123 124 if (m_pFormatEtc) 125 delete[] m_pFormatEtc; 126 127 if (m_pStgMedium) 128 delete[] m_pStgMedium; 129 130 LogFlowFunc(("mRefCount=%RI32\n", m_lRefCount)); 123 131 } 124 132 … … 129 137 STDMETHODIMP_(ULONG) VBoxClipboardWinDataObject::AddRef(void) 130 138 { 131 LONG lCount = InterlockedIncrement(&m RefCount);139 LONG lCount = InterlockedIncrement(&m_lRefCount); 132 140 LogFlowFunc(("lCount=%RI32\n", lCount)); 133 141 return lCount; … … 136 144 STDMETHODIMP_(ULONG) VBoxClipboardWinDataObject::Release(void) 137 145 { 138 LONG lCount = InterlockedDecrement(&m RefCount);139 LogFlowFunc(("lCount=%RI32\n", m RefCount));146 LONG lCount = InterlockedDecrement(&m_lRefCount); 147 LogFlowFunc(("lCount=%RI32\n", m_lRefCount)); 140 148 if (lCount == 0) 141 149 { … … 186 194 } 187 195 188 int VBoxClipboardWinDataObject::createFileGroupDescriptor(const SharedClipboardURIList &URIList, HGLOBAL *phGlobal) 196 int VBoxClipboardWinDataObject::createFileGroupDescriptor(const SharedClipboardURIList &URIList, 197 bool fUnicode, HGLOBAL *phGlobal) 189 198 { 190 199 // AssertReturn(URIList.GetRootCount(), VERR_INVALID_PARAMETER); 191 200 AssertPtrReturn(phGlobal, VERR_INVALID_POINTER); 201 202 RT_NOREF(fUnicode); 192 203 193 204 int rc; … … 275 286 if (!lookupFormatEtc(pFormatEtc, &lIndex)) /* Format supported? */ 276 287 return DV_E_FORMATETC; 277 if (lIndex >= m cFormats) /* Paranoia. */288 if (lIndex >= m_cFormats) /* Paranoia. */ 278 289 return DV_E_LINDEX; 279 290 280 LPFORMATETC pThisFormat = &m pFormatEtc[lIndex];291 LPFORMATETC pThisFormat = &m_pFormatEtc[lIndex]; 281 292 AssertPtr(pThisFormat); 282 293 283 LPSTGMEDIUM pThisMedium = &m pStgMedium[lIndex];294 LPSTGMEDIUM pThisMedium = &m_pStgMedium[lIndex]; 284 295 AssertPtr(pThisMedium); 285 296 … … 288 299 HRESULT hr = DV_E_FORMATETC; /* Play safe. */ 289 300 290 LogRel 3(("Clipboard: cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32 -> lIndex=%u\n",301 LogRel2(("Clipboard: cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32 -> lIndex=%u\n", 291 302 pThisFormat->cfFormat, VBoxClipboardWinDataObject::ClipboardFormatToString(pFormatEtc->cfFormat), 292 303 pThisFormat->tymed, pThisFormat->dwAspect, lIndex)); … … 300 311 switch (lIndex) 301 312 { 302 case FormatIndex_FileDescriptorA: 313 case FormatIndex_FileDescriptorA: /* ANSI */ 314 case FormatIndex_FileDescriptorW: /* Unicode */ 303 315 { 304 LogFlowFunc(("FormatIndex_FileDescriptorA\n")); 305 306 SharedClipboardURIList mURIList; 307 // mURIList.AppendURIPath() 308 309 HGLOBAL hGlobal; 310 int rc = createFileGroupDescriptor(mURIList, &hGlobal); 316 const bool fUnicode = lIndex == FormatIndex_FileDescriptorW; 317 318 LogFlowFunc(("FormatIndex_FileDescriptor%s\n", fUnicode ? "W" : "A")); 319 320 SharedClipboardURIList uriList; 321 int rc = m_pProvider->ReadMetaData(uriList, 0 /* fFlags */); 311 322 if (RT_SUCCESS(rc)) 312 323 { 313 pMedium->tymed = TYMED_HGLOBAL; 314 pMedium->hGlobal = hGlobal; 315 316 hr = S_OK; 324 HGLOBAL hGlobal; 325 rc = createFileGroupDescriptor(uriList, fUnicode, &hGlobal); 326 if (RT_SUCCESS(rc)) 327 { 328 pMedium->tymed = TYMED_HGLOBAL; 329 pMedium->hGlobal = hGlobal; 330 /* Note: hGlobal now is being owned by pMedium / the caller. */ 331 332 hr = S_OK; 333 } 317 334 } 318 335 break; 319 336 } 320 337 321 case FormatIndex_FileDescriptorW:322 LogFlowFunc(("FormatIndex_FileDescriptorW\n"));323 break;324 325 338 case FormatIndex_FileContents: 326 339 { 327 340 LogFlowFunc(("FormatIndex_FileContents\n")); 328 341 329 hr = VBoxClipboardWinStreamImpl::Create( &mpStream);342 hr = VBoxClipboardWinStreamImpl::Create(m_pProvider, &m_pStream); 330 343 if (SUCCEEDED(hr)) 331 344 { 332 345 /* Hand over the stream to the caller. */ 333 346 pMedium->tymed = TYMED_ISTREAM; 334 pMedium->pstm = m pStream;347 pMedium->pstm = m_pStream; 335 348 } 336 349 … … 406 419 STDMETHODIMP VBoxClipboardWinDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc) 407 420 { 408 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n", dwDirection, m cFormats, mpFormatEtc));421 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n", dwDirection, m_cFormats, m_pFormatEtc)); 409 422 410 423 HRESULT hr; 411 424 if (dwDirection == DATADIR_GET) 412 hr = VBoxClipboardWinEnumFormatEtc::CreateEnumFormatEtc(m cFormats, mpFormatEtc, ppEnumFormatEtc);425 hr = VBoxClipboardWinEnumFormatEtc::CreateEnumFormatEtc(m_cFormats, m_pFormatEtc, ppEnumFormatEtc); 413 426 else 414 427 hr = E_NOTIMPL; … … 476 489 */ 477 490 478 int VBoxClipboardWinDataObject::Init(uint32_t idClient) 479 { 480 muClientID = idClient; 481 491 int VBoxClipboardWinDataObject::Init(void) 492 { 482 493 LogFlowFuncLeaveRC(VINF_SUCCESS); 483 494 return VINF_SUCCESS; … … 572 583 /* puIndex is optional. */ 573 584 574 for (ULONG i = 0; i < m cFormats; i++)575 { 576 if( (pFormatEtc->tymed & m pFormatEtc[i].tymed)577 && pFormatEtc->cfFormat == m pFormatEtc[i].cfFormat578 && pFormatEtc->dwAspect == m pFormatEtc[i].dwAspect)585 for (ULONG i = 0; i < m_cFormats; i++) 586 { 587 if( (pFormatEtc->tymed & m_pFormatEtc[i].tymed) 588 && pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat 589 && pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect) 579 590 { 580 591 LogRel3(("Clipboard: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n", 581 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxClipboardWinDataObject::ClipboardFormatToString(m pFormatEtc[i].cfFormat),592 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxClipboardWinDataObject::ClipboardFormatToString(m_pFormatEtc[i].cfFormat), 582 593 pFormatEtc->dwAspect, i)); 583 594 if (puIndex)
Note:
See TracChangeset
for help on using the changeset viewer.