oleaut32: Implement a better stub for IPicture::SaveAsFile.
Based on OLEPictureImpl_Save implementation. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b2de694878
commit
212dd9c226
|
@ -833,19 +833,6 @@ static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* OLEPictureImpl_SaveAsFile
|
||||
*/
|
||||
static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
|
||||
IStream *pstream,
|
||||
BOOL SaveMemCopy,
|
||||
LONG *pcbSize)
|
||||
{
|
||||
OLEPictureImpl *This = impl_from_IPicture(iface);
|
||||
FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This, pstream, SaveMemCopy, pcbSize);
|
||||
return IStream_Write(pstream,This->data,This->datalen,(ULONG*)pcbSize);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* OLEPictureImpl_get_Attributes
|
||||
*/
|
||||
|
@ -1859,6 +1846,85 @@ static HRESULT WINAPI OLEPictureImpl_GetSizeMax(
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* OLEPictureImpl_SaveAsFile
|
||||
*/
|
||||
static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
|
||||
IStream *stream, BOOL mem_copy, LONG *size)
|
||||
{
|
||||
OLEPictureImpl *This = impl_from_IPicture(iface);
|
||||
void *data;
|
||||
unsigned data_size;
|
||||
ULONG written;
|
||||
HRESULT hr;
|
||||
|
||||
FIXME("(%p)->(%p,%d,%p): semi-stub\n", This, stream, mem_copy, size);
|
||||
|
||||
switch (This->desc.picType)
|
||||
{
|
||||
case PICTYPE_NONE:
|
||||
return S_OK;
|
||||
|
||||
case PICTYPE_ICON:
|
||||
if (!mem_copy) return E_FAIL;
|
||||
|
||||
if (This->bIsDirty || !This->data)
|
||||
{
|
||||
if (!serializeIcon(This->desc.u.icon.hicon, &data, &data_size))
|
||||
return E_FAIL;
|
||||
HeapFree(GetProcessHeap(), 0, This->data);
|
||||
This->data = data;
|
||||
This->datalen = data_size;
|
||||
}
|
||||
hr = IStream_Write(stream, This->data, This->datalen, &written);
|
||||
if (hr == S_OK && size) *size = written;
|
||||
return hr;
|
||||
|
||||
case PICTYPE_BITMAP:
|
||||
if (!mem_copy) return E_FAIL;
|
||||
|
||||
if (This->bIsDirty || !This->data)
|
||||
{
|
||||
switch (This->keepOrigFormat ? This->loadtime_format : BITMAP_FORMAT_BMP)
|
||||
{
|
||||
case BITMAP_FORMAT_BMP:
|
||||
if (!serializeBMP(This->desc.u.bmp.hbitmap, &data, &data_size))
|
||||
return E_FAIL;
|
||||
break;
|
||||
case BITMAP_FORMAT_JPEG:
|
||||
FIXME("BITMAP_FORMAT_JPEG is not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
case BITMAP_FORMAT_GIF:
|
||||
FIXME("BITMAP_FORMAT_GIF is not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
case BITMAP_FORMAT_PNG:
|
||||
FIXME("BITMAP_FORMAT_PNG is not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
default:
|
||||
FIXME("PICTYPE_BITMAP/%#x is not implemented\n", This->loadtime_format);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->data);
|
||||
This->data = data;
|
||||
This->datalen = data_size;
|
||||
}
|
||||
hr = IStream_Write(stream, This->data, This->datalen, &written);
|
||||
if (hr == S_OK && size) *size = written;
|
||||
return hr;
|
||||
|
||||
case PICTYPE_METAFILE:
|
||||
FIXME("PICTYPE_METAFILE is not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
case PICTYPE_ENHMETAFILE:
|
||||
FIXME("ENHMETAFILE is not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
default:
|
||||
FIXME("%#x is not implemented\n", This->desc.picType);
|
||||
break;
|
||||
}
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* IDispatch
|
||||
|
|
|
@ -1079,18 +1079,14 @@ static void test_load_save_bmp(void)
|
|||
size = -1;
|
||||
hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
|
||||
ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
|
||||
todo_wine
|
||||
ok(size == 66, "expected 66, got %d\n", size);
|
||||
mem = GlobalLock(hmem);
|
||||
todo_wine
|
||||
ok(!memcmp(&mem[0], "BM", 2), "got wrong bmp header %04x\n", mem[0]);
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
size = -1;
|
||||
hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
|
||||
todo_wine
|
||||
ok(hr == E_FAIL, "expected E_FAIL, got %#x\n", hr);
|
||||
todo_wine
|
||||
ok(size == -1, "expected -1, got %d\n", size);
|
||||
|
||||
offset.QuadPart = 0;
|
||||
|
@ -1157,15 +1153,12 @@ static void test_load_save_icon(void)
|
|||
todo_wine
|
||||
ok(size == 766, "expected 766, got %d\n", size);
|
||||
mem = GlobalLock(hmem);
|
||||
todo_wine
|
||||
ok(mem[0] == 0x00010000, "got wrong icon header %04x\n", mem[0]);
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
size = -1;
|
||||
hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
|
||||
todo_wine
|
||||
ok(hr == E_FAIL, "expected E_FAIL, got %#x\n", hr);
|
||||
todo_wine
|
||||
ok(size == -1, "expected -1, got %d\n", size);
|
||||
|
||||
offset.QuadPart = 0;
|
||||
|
@ -1231,13 +1224,11 @@ static void test_load_save_empty_picture(void)
|
|||
size = -1;
|
||||
hr = IPicture_SaveAsFile(pic, dst_stream, TRUE, &size);
|
||||
ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
|
||||
todo_wine
|
||||
ok(size == -1, "expected -1, got %d\n", size);
|
||||
|
||||
size = -1;
|
||||
hr = IPicture_SaveAsFile(pic, dst_stream, FALSE, &size);
|
||||
ok(hr == S_OK, "IPicture_SaveasFile error %#x\n", hr);
|
||||
todo_wine
|
||||
ok(size == -1, "expected -1, got %d\n", size);
|
||||
|
||||
hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream);
|
||||
|
|
Loading…
Reference in New Issue