oleaut32-OLEPictureImpl_SaveAsFile: Implement SaveAsFile for PICTYPE_ENHMETAFILE.

This commit is contained in:
Sebastian Lackner 2016-05-15 19:09:59 +02:00
parent fd89a1b64c
commit 2dff0d6075
3 changed files with 95 additions and 18 deletions

View File

@ -0,0 +1,64 @@
From 517bb10261069abd3ffd642dddd6338b7cacd094 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 15 May 2016 19:08:44 +0200
Subject: oleaut32: Implement SaveAsFile for PICTYPE_ENHMETAFILE.
---
dlls/oleaut32/olepicture.c | 17 +++++++++++++++--
dlls/oleaut32/tests/olepicture.c | 3 ---
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 7d13942..db90c4c 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -1961,9 +1961,22 @@ static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
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;
+ if (!mem_copy) return E_FAIL;
+
+ if (This->bIsDirty || !This->data)
+ {
+ if (!serializeEMF(This->desc.u.emf.hemf, &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;
+
default:
FIXME("%#x is not implemented\n", This->desc.picType);
break;
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 29d787e..7b1178e 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -1338,7 +1338,6 @@ static void test_load_save_emf(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 == 128, "expected 128, got %d\n", size);
emh = GlobalLock(hmem);
if (size)
@@ -1350,9 +1349,7 @@ if (size)
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;
--
2.8.0

View File

@ -1 +1,2 @@
Fixes: [8532] Implement a better stub for IPicture::SaveAsFile
Depends: oleaut32-Load_Save_EMF

View File

@ -2222,6 +2222,13 @@ if test "$enable_gdiplus_GdipCreateMetafileFromStream" -eq 1; then
enable_oleaut32_OLEPictureImpl_SaveAsFile=1
fi
if test "$enable_oleaut32_OLEPictureImpl_SaveAsFile" -eq 1; then
if test "$enable_oleaut32_Load_Save_EMF" -gt 1; then
abort "Patchset oleaut32-Load_Save_EMF disabled, but oleaut32-OLEPictureImpl_SaveAsFile depends on that."
fi
enable_oleaut32_Load_Save_EMF=1
fi
if test "$enable_dxva2_Video_Decoder" -eq 1; then
if test "$enable_winecfg_Staging" -gt 1; then
abort "Patchset winecfg-Staging disabled, but dxva2-Video_Decoder depends on that."
@ -3692,8 +3699,28 @@ if test "$enable_gdi32_Symbol_Truetype_Font" -eq 1; then
) >> "$patchlist"
fi
# Patchset oleaut32-Load_Save_EMF
# |
# | This patchset fixes the following Wine bugs:
# | * [#40523] Implement support for loading and saving EMF to IPicture interface
# |
# | Modified files:
# | * dlls/oleaut32/olepicture.c, dlls/oleaut32/tests/olepicture.c
# |
if test "$enable_oleaut32_Load_Save_EMF" -eq 1; then
patch_apply oleaut32-Load_Save_EMF/0001-oleaut32-tests-Add-some-tests-for-loading-and-saving.patch
patch_apply oleaut32-Load_Save_EMF/0002-oleaut32-Add-support-for-loading-and-saving-EMF-to-I.patch
(
echo '+ { "Dmitry Timoshkov", "oleaut32/tests: Add some tests for loading and saving EMF using IPicture interface.", 1 },';
echo '+ { "Dmitry Timoshkov", "oleaut32: Add support for loading and saving EMF to IPicture interface.", 1 },';
) >> "$patchlist"
fi
# Patchset oleaut32-OLEPictureImpl_SaveAsFile
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * oleaut32-Load_Save_EMF
# |
# | This patchset fixes the following Wine bugs:
# | * [#8532] Implement a better stub for IPicture::SaveAsFile
# |
@ -3704,16 +3731,18 @@ fi
if test "$enable_oleaut32_OLEPictureImpl_SaveAsFile" -eq 1; then
patch_apply oleaut32-OLEPictureImpl_SaveAsFile/0001-gdiplus-Reimplement-metafile-loading-using-gdi32-ins.patch
patch_apply oleaut32-OLEPictureImpl_SaveAsFile/0002-oleaut32-Implement-a-better-stub-for-IPicture-SaveAs.patch
patch_apply oleaut32-OLEPictureImpl_SaveAsFile/0003-oleaut32-Implement-SaveAsFile-for-PICTYPE_ENHMETAFIL.patch
(
echo '+ { "Dmitry Timoshkov", "gdiplus: Reimplement metafile loading using gdi32 instead of IPicture.", 2 },';
echo '+ { "Dmitry Timoshkov", "oleaut32: Implement a better stub for IPicture::SaveAsFile.", 1 },';
echo '+ { "Sebastian Lackner", "oleaut32: Implement SaveAsFile for PICTYPE_ENHMETAFILE.", 1 },';
) >> "$patchlist"
fi
# Patchset gdiplus-GdipCreateMetafileFromStream
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * oleaut32-OLEPictureImpl_SaveAsFile
# | * oleaut32-Load_Save_EMF, oleaut32-OLEPictureImpl_SaveAsFile
# |
# | This patchset fixes the following Wine bugs:
# | * [#40325] Implement GdipCreateMetafileFromStream
@ -5535,23 +5564,6 @@ if test "$enable_oleaut32_CreateTypeLib" -eq 1; then
) >> "$patchlist"
fi
# Patchset oleaut32-Load_Save_EMF
# |
# | This patchset fixes the following Wine bugs:
# | * [#40523] Implement support for loading and saving EMF to IPicture interface
# |
# | Modified files:
# | * dlls/oleaut32/olepicture.c, dlls/oleaut32/tests/olepicture.c
# |
if test "$enable_oleaut32_Load_Save_EMF" -eq 1; then
patch_apply oleaut32-Load_Save_EMF/0001-oleaut32-tests-Add-some-tests-for-loading-and-saving.patch
patch_apply oleaut32-Load_Save_EMF/0002-oleaut32-Add-support-for-loading-and-saving-EMF-to-I.patch
(
echo '+ { "Dmitry Timoshkov", "oleaut32/tests: Add some tests for loading and saving EMF using IPicture interface.", 1 },';
echo '+ { "Dmitry Timoshkov", "oleaut32: Add support for loading and saving EMF to IPicture interface.", 1 },';
) >> "$patchlist"
fi
# Patchset oleaut32-OleLoadPicture
# |
# | This patchset fixes the following Wine bugs: