11 if (medium->pstm == NULL)
return E_INVALIDARG;
14 state = medium->pstm->Write(blockPtr, pfc::downcast_guarded<ULONG>(blockSize),&written);
15 if (FAILED(state))
return state;
16 if (written != blockSize)
return STG_E_MEDIUMFULL;
23 if (tymed & TYMED_HGLOBAL) {
25 if (hMem == NULL)
return E_OUTOFMEMORY;
26 medium->tymed = TYMED_HGLOBAL;
27 medium->hGlobal = hMem;
28 medium->pUnkForRelease = NULL;
31 if (tymed & TYMED_ISTREAM) {
34 if (hMem == NULL)
return E_OUTOFMEMORY;
35 medium->tymed = TYMED_ISTREAM;
37 if (FAILED( state = CreateStreamOnHGlobal(hMem,TRUE,stream.
receive_ptr()) ) ) {
42 LARGE_INTEGER wtf = {};
43 if (FAILED( state = stream->Seek(wtf,STREAM_SEEK_END,NULL) ) ) {
47 medium->pstm = stream.
detach();
48 medium->pUnkForRelease = NULL;
53 }
catch(pfc::exception_not_implemented) {
55 }
catch(std::bad_alloc) {
64 HGLOBAL handle = GlobalAlloc(GMEM_MOVEABLE,size);
66 void * destptr = GlobalLock(handle);
67 if (destptr == NULL) {
71 memcpy(destptr,ptr,size);
80 fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index;
81 fmt.tymed = TYMED_HGLOBAL ;
85 if (FAILED( state = obj->GetData(&fmt,&med) ) )
return state;
101 IStream * stream = med.pstm;
102 LARGE_INTEGER offset = {};
104 if (FAILED( state = stream->Stat(&stats,STATFLAG_NONAME ) ) )
return state;
105 t_size toRead = pfc::downcast_guarded<t_size>(stats.cbSize.QuadPart);
107 if (FAILED( state = stream->Seek(offset,STREAM_SEEK_SET,NULL) ) )
return state;
109 if (FAILED( state = stream->Read(out.
get_ptr(), pfc::downcast_guarded<ULONG>(toRead), &cbRead) ) )
return state;
110 if (cbRead != toRead)
return E_UNEXPECTED;
124 fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index;
125 for(
t_uint32 walk = 0; walk < 32; ++walk) {
126 const DWORD tymed = 1 << walk;
129 HRESULT state = obj->QueryGetData(&fmt);
130 if (SUCCEEDED(state)) {
131 if (state == S_OK)
return S_OK;
133 if (state != DV_E_TYMED)
return state;
148 if (SUCCEEDED(state)) {
153 if (SUCCEEDED(state)) {
163 fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index; fmt.tymed = TYMED_HGLOBAL;
166 return obj->SetData(&fmt,&med,TRUE);
178 if (buffer.
get_size() <
sizeof(val))
return E_UNEXPECTED;
179 val = *(DWORD*) buffer.
get_ptr();
186 return SetDataObjectDWORD(obj, RegisterClipboardFormat(CFSTR_PASTESUCCEEDED), effect);
const t_item * get_ptr() const
HRESULT DataBlockToSTGMEDIUM(const void *blockPtr, t_size blockSize, STGMEDIUM *medium, DWORD tymed, bool bHere)
HRESULT SetDataObjectString(pfc::com_ptr_t< IDataObject > obj, const char *str)
HRESULT ExtractDataObjectString(pfc::com_ptr_t< IDataObject > obj, pfc::string_base &out)
HRESULT ExtractDataObjectContentTest(pfc::com_ptr_t< IDataObject > obj, UINT format, DWORD aspect, LONG index)
HRESULT ExtractDataObjectContent(pfc::com_ptr_t< IDataObject > obj, UINT format, DWORD aspect, LONG index, pfc::array_t< t_uint8 > &out)
HRESULT PasteSucceeded(pfc::com_ptr_t< IDataObject > obj, DWORD effect)
void set_size(t_size p_size)
const wchar_t * get_ptr() const
HRESULT ExtractDataObjectDWORD(pfc::com_ptr_t< IDataObject > obj, UINT format, DWORD &val)
HRESULT STGMEDIUMToDataBlock(const STGMEDIUM &med, pfc::array_t< t_uint8 > &out)
HRESULT SetDataObjectContent(pfc::com_ptr_t< IDataObject > obj, UINT format, DWORD aspect, LONG index, const void *data, t_size dataSize)
void set_data_fromptr(const t_source *p_buffer, t_size p_count)
Warning: buffer pointer must not point to buffer allocated by this array (fixme). ...
HGLOBAL HGlobalFromMemblock(const void *ptr, t_size size)
HRESULT SetDataObjectDWORD(pfc::com_ptr_t< IDataObject > obj, UINT format, DWORD val)
static const DWORD ExtractDataObjectContent_SupportedTymeds