Changeset 78474 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
- Timestamp:
- May 13, 2019 7:44:15 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r78440 r78474 87 87 int rc; 88 88 89 LogFlowFuncEnter(); 90 89 91 const BOOL fRc = CloseClipboard(); 90 92 if (RT_UNLIKELY(!fRc)) 91 93 { 92 94 const DWORD dwLastErr = GetLastError(); 93 rc = RTErrConvertFromWin32(dwLastErr); 95 if (dwLastErr == ERROR_CLIPBOARD_NOT_OPEN) 96 rc = VERR_INVALID_STATE; 97 else 98 rc = RTErrConvertFromWin32(dwLastErr); 99 94 100 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr)); 95 101 } … … 108 114 { 109 115 int rc; 116 117 LogFlowFuncEnter(); 110 118 111 119 const BOOL fRc = EmptyClipboard(); … … 113 121 { 114 122 const DWORD dwLastErr = GetLastError(); 115 rc = RTErrConvertFromWin32(dwLastErr); 123 if (dwLastErr == ERROR_CLIPBOARD_NOT_OPEN) 124 rc = VERR_INVALID_STATE; 125 else 126 rc = RTErrConvertFromWin32(dwLastErr); 127 116 128 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr)); 117 129 } … … 265 277 } 266 278 279 VBOXCLIPBOARDFORMAT VBoxClipboardWinClipboardFormatToVBox(UINT uFormat) 280 { 281 /* Insert the requested clipboard format data into the clipboard. */ 282 VBOXCLIPBOARDFORMAT vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_NONE; 283 284 switch (uFormat) 285 { 286 case CF_UNICODETEXT: 287 vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT; 288 break; 289 290 case CF_DIB: 291 vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_BITMAP; 292 break; 293 294 default: 295 if (uFormat >= 0xC000) /** Formats registered with RegisterClipboardFormat() start at this index. */ 296 { 297 TCHAR szFormatName[256]; /** @todo r=andy Do we need Unicode support here as well? */ 298 int cActual = GetClipboardFormatName(uFormat, szFormatName, sizeof(szFormatName) / sizeof(TCHAR)); 299 if (cActual) 300 { 301 LogFunc(("szFormatName=%s\n", szFormatName)); 302 303 if (RTStrCmp(szFormatName, VBOX_CLIPBOARD_WIN_REGFMT_HTML) == 0) 304 vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_HTML; 305 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 306 else if (RTStrCmp(szFormatName, VBOX_CLIPBOARD_WIN_REGFMT_URI_LIST) == 0) 307 vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_URI_LIST; 308 #endif 309 } 310 } 311 break; 312 } 313 314 return vboxFormat; 315 } 316 267 317 /** 268 318 * Retrieves all supported clipboard formats of a specific clipboard. … … 270 320 * @returns VBox status code. 271 321 * @param pCtx Windows clipboard context to retrieve formats for. 272 * @param p uFormats Where to store the retrieved formats of type VBOX_SHARED_CLIPBOARD_FMT_ (bitmask).273 */ 274 int VBoxClipboardWinGetFormats(PVBOXCLIPBOARDWINCTX pCtx, uint32_t *puFormats)322 * @param pfFormats Where to store the retrieved formats of type VBOX_SHARED_CLIPBOARD_FMT_ (bitmask). 323 */ 324 int VBoxClipboardWinGetFormats(PVBOXCLIPBOARDWINCTX pCtx, PVBOXCLIPBOARDFORMATS pfFormats) 275 325 { 276 326 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 277 AssertPtrReturn(p uFormats, VERR_INVALID_POINTER);278 279 uint32_t uFormats = VBOX_SHARED_CLIPBOARD_FMT_NONE;327 AssertPtrReturn(pfFormats, VERR_INVALID_POINTER); 328 329 VBOXCLIPBOARDFORMATS fFormats = VBOX_SHARED_CLIPBOARD_FMT_NONE; 280 330 281 331 /* Query list of available formats and report to host. */ … … 283 333 if (RT_SUCCESS(rc)) 284 334 { 285 UINT uCurFormat = 0; 335 UINT uCurFormat = 0; /* Must be set to zero for EnumClipboardFormats(). */ 286 336 while ((uCurFormat = EnumClipboardFormats(uCurFormat)) != 0) 287 { 288 LogFlowFunc(("uFormat = 0x%08X\n", uCurFormat)); 289 switch (uCurFormat) 290 { 291 case CF_UNICODETEXT: 292 case CF_TEXT: 293 uFormats |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT; 294 break; 295 296 case CF_DIB: 297 case CF_BITMAP: 298 uFormats |= VBOX_SHARED_CLIPBOARD_FMT_BITMAP; 299 break; 300 301 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 302 case CF_HDROP: 303 uFormats |= VBOX_SHARED_CLIPBOARD_FMT_URI_LIST; 304 break; 305 #endif 306 default: 307 { 308 if (uCurFormat >= 0xC000) /** @todo r=andy Find a define for this. */ 309 { 310 TCHAR szFormatName[256]; /** @todo r=andy Is this enough? */ 311 int cActual = GetClipboardFormatName(uCurFormat, szFormatName, sizeof(szFormatName)/sizeof (TCHAR)); 312 if (cActual) 313 { 314 if (strcmp (szFormatName, "HTML Format") == 0) 315 { 316 uFormats |= VBOX_SHARED_CLIPBOARD_FMT_HTML; 317 } 318 } 319 } 320 break; 321 } 322 } 323 } 337 fFormats |= VBoxClipboardWinClipboardFormatToVBox(uCurFormat); 324 338 325 339 int rc2 = VBoxClipboardWinClose(); … … 333 347 else 334 348 { 335 LogFlowFunc((" uFormats = 0x%08X\n", uFormats));336 *p uFormats = uFormats;337 } 338 339 return rc; 340 } 341 349 LogFlowFunc(("pfFormats=0x%08X\n", pfFormats)); 350 *pfFormats = fFormats; 351 } 352 353 return rc; 354 } 355
Note:
See TracChangeset
for help on using the changeset viewer.