///////////////////////////////////////////////////////
| 42 | { |
| 43 | //////////////////////////////////////////////////////////// |
| 44 | String ClipboardImpl::getString() |
| 45 | { |
| 46 | String text; |
| 47 | |
| 48 | if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) |
| 49 | { |
| 50 | err() << "Failed to get the clipboard data in Unicode format: " << getErrorString(GetLastError()) << std::endl; |
| 51 | return text; |
| 52 | } |
| 53 | |
| 54 | if (!OpenClipboard(nullptr)) |
| 55 | { |
| 56 | err() << "Failed to open the Win32 clipboard: " << getErrorString(GetLastError()) << std::endl; |
| 57 | return text; |
| 58 | } |
| 59 | |
| 60 | HANDLE clipboardHandle = GetClipboardData(CF_UNICODETEXT); |
| 61 | |
| 62 | if (!clipboardHandle) |
| 63 | { |
| 64 | err() << "Failed to get Win32 handle for clipboard content: " << getErrorString(GetLastError()) << std::endl; |
| 65 | CloseClipboard(); |
| 66 | return text; |
| 67 | } |
| 68 | |
| 69 | const std::u16string_view string(static_cast<const char16_t*>(GlobalLock(clipboardHandle))); |
| 70 | text = String::fromUtf16(string.begin(), string.end()); |
| 71 | GlobalUnlock(clipboardHandle); |
| 72 | |
| 73 | CloseClipboard(); |
| 74 | return text; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected