Commit 33be9fc7 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: Correctly save the remaining formats if their data has not been set.

parent 179daf67
...@@ -829,17 +829,16 @@ static HRESULT save_dib(DataCacheEntry *entry, BOOL contents, IStream *stream) ...@@ -829,17 +829,16 @@ static HRESULT save_dib(DataCacheEntry *entry, BOOL contents, IStream *stream)
if (hr == S_OK && data_size) if (hr == S_OK && data_size)
hr = IStream_Write(stream, bmi, data_size, NULL); hr = IStream_Write(stream, bmi, data_size, NULL);
} }
else else if(data_size)
{ {
BITMAPFILEHEADER bmp_fhdr; BITMAPFILEHEADER bmp_fhdr;
bmp_fhdr.bfType = 0x4d42; bmp_fhdr.bfType = 0x4d42;
bmp_fhdr.bfSize = data_size + sizeof(BITMAPFILEHEADER); bmp_fhdr.bfSize = data_size + sizeof(BITMAPFILEHEADER);
bmp_fhdr.bfReserved1 = bmp_fhdr.bfReserved2 = 0; bmp_fhdr.bfReserved1 = bmp_fhdr.bfReserved2 = 0;
if (data_size)
bmp_fhdr.bfOffBits = bitmap_info_size(bmi, DIB_RGB_COLORS) + sizeof(BITMAPFILEHEADER); bmp_fhdr.bfOffBits = bitmap_info_size(bmi, DIB_RGB_COLORS) + sizeof(BITMAPFILEHEADER);
hr = IStream_Write(stream, &bmp_fhdr, sizeof(BITMAPFILEHEADER), NULL); hr = IStream_Write(stream, &bmp_fhdr, sizeof(BITMAPFILEHEADER), NULL);
if (hr == S_OK && data_size) if (hr == S_OK)
hr = IStream_Write(stream, bmi, data_size, NULL); hr = IStream_Write(stream, bmi, data_size, NULL);
} }
...@@ -897,13 +896,11 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream ...@@ -897,13 +896,11 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream
hr = IStream_Write(stream, data, data_size, NULL); hr = IStream_Write(stream, data, data_size, NULL);
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
else else if (entry->stgmedium.tymed != TYMED_NULL)
{ {
struct meta_placeable meta_place_rec; struct meta_placeable meta_place_rec;
WORD *check; WORD *check;
if (entry->stgmedium.tymed != TYMED_NULL)
{
mfpict = GlobalLock(entry->stgmedium.u.hMetaFilePict); mfpict = GlobalLock(entry->stgmedium.u.hMetaFilePict);
if (!mfpict) if (!mfpict)
return DV_E_STGMEDIUM; return DV_E_STGMEDIUM;
...@@ -915,7 +912,6 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream ...@@ -915,7 +912,6 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
GetMetaFileBitsEx(mfpict->hMF, data_size, data); GetMetaFileBitsEx(mfpict->hMF, data_size, data);
}
/* units are in 1/8th of a point (1 point is 1/72th of an inch) */ /* units are in 1/8th of a point (1 point is 1/72th of an inch) */
meta_place_rec.key = 0x9ac6cdd7; meta_place_rec.key = 0x9ac6cdd7;
...@@ -927,13 +923,12 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream ...@@ -927,13 +923,12 @@ static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream
meta_place_rec.bounding_box[3] = 0; meta_place_rec.bounding_box[3] = 0;
meta_place_rec.checksum = 0; meta_place_rec.checksum = 0;
meta_place_rec.reserved = 0; meta_place_rec.reserved = 0;
if (mfpict)
{
/* These values are rounded down so MulDiv won't do the right thing */ /* These values are rounded down so MulDiv won't do the right thing */
meta_place_rec.bounding_box[2] = (LONGLONG)mfpict->xExt * meta_place_rec.inch / 2540; meta_place_rec.bounding_box[2] = (LONGLONG)mfpict->xExt * meta_place_rec.inch / 2540;
meta_place_rec.bounding_box[3] = (LONGLONG)mfpict->yExt * meta_place_rec.inch / 2540; meta_place_rec.bounding_box[3] = (LONGLONG)mfpict->yExt * meta_place_rec.inch / 2540;
GlobalUnlock(entry->stgmedium.u.hMetaFilePict); GlobalUnlock(entry->stgmedium.u.hMetaFilePict);
}
for (check = (WORD *)&meta_place_rec; check != (WORD *)&meta_place_rec.checksum; check++) for (check = (WORD *)&meta_place_rec; check != (WORD *)&meta_place_rec.checksum; check++)
meta_place_rec.checksum ^= *check; meta_place_rec.checksum ^= *check;
hr = IStream_Write(stream, &meta_place_rec, sizeof(struct meta_placeable), NULL); hr = IStream_Write(stream, &meta_place_rec, sizeof(struct meta_placeable), NULL);
...@@ -982,7 +977,7 @@ static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream) ...@@ -982,7 +977,7 @@ static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream)
hr = IStream_Write(stream, data, data_size, NULL); hr = IStream_Write(stream, data, data_size, NULL);
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
else else if (entry->stgmedium.tymed != TYMED_NULL)
{ {
data_size = GetEnhMetaFileBits(entry->stgmedium.u.hEnhMetaFile, 0, NULL); data_size = GetEnhMetaFileBits(entry->stgmedium.u.hEnhMetaFile, 0, NULL);
data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size); data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
...@@ -991,7 +986,6 @@ static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream) ...@@ -991,7 +986,6 @@ static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream)
GetEnhMetaFileBits(entry->stgmedium.u.hEnhMetaFile, data_size, data + sizeof(DWORD) + sizeof(ENHMETAHEADER)); GetEnhMetaFileBits(entry->stgmedium.u.hEnhMetaFile, data_size, data + sizeof(DWORD) + sizeof(ENHMETAHEADER));
memcpy(data + sizeof(DWORD), data + sizeof(DWORD) + sizeof(ENHMETAHEADER), sizeof(ENHMETAHEADER)); memcpy(data + sizeof(DWORD), data + sizeof(DWORD) + sizeof(ENHMETAHEADER), sizeof(ENHMETAHEADER));
data_size += sizeof(DWORD) + sizeof(ENHMETAHEADER); data_size += sizeof(DWORD) + sizeof(ENHMETAHEADER);
if (hr == S_OK && data_size)
hr = IStream_Write(stream, data, data_size, NULL); hr = IStream_Write(stream, data, data_size, NULL);
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
......
...@@ -4226,35 +4226,64 @@ static void test_data_cache_save_data(void) ...@@ -4226,35 +4226,64 @@ static void test_data_cache_save_data(void)
{ {
{ {
{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
}, },
1, 1, &CLSID_WineTest, 3, 3, &CLSID_WineTest,
{ {
&CLSID_WineTestOld, 1, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 } } &CLSID_WineTestOld, 3, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } }
} }
}, },
/* without setting data */
{ {
{ {
{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT }, { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
},
3, 0, &CLSID_WineTest,
{
&CLSID_WineTestOld, 3, { { "\2OlePres000", CF_DIB, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres001", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 },
{ "\2OlePres002", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } }
}
}, },
1, 1, &CLSID_WineTest, /* static picture clsids */
{ {
&CLSID_WineTestOld, 1, { { "\2OlePres000", CF_METAFILEPICT, DVASPECT_CONTENT, 0, NULL, 0 } } {
{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
},
1, 1, &CLSID_Picture_Dib,
{
&CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
}
},
{
{
{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
},
1, 1, &CLSID_Picture_Metafile,
{
&CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
} }
}, },
{ {
{ {
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF }, { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
}, },
1, 1, &CLSID_WineTest, 1, 1, &CLSID_Picture_EnhMetafile,
{ {
&CLSID_WineTestOld, 1, { { "\2OlePres000", CF_ENHMETAFILE, DVASPECT_CONTENT, 0, NULL, 0 } } &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
} }
}, },
/* static picture clsids without setting any data */
{ {
{ {
{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
}, },
1, 1, &CLSID_Picture_Dib, 1, 0, &CLSID_Picture_Dib,
{ {
&CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } } &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
} }
...@@ -4263,7 +4292,7 @@ static void test_data_cache_save_data(void) ...@@ -4263,7 +4292,7 @@ static void test_data_cache_save_data(void)
{ {
{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT }, { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT },
}, },
1, 1, &CLSID_Picture_Metafile, 1, 0, &CLSID_Picture_Metafile,
{ {
&CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } } &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
} }
...@@ -4272,7 +4301,7 @@ static void test_data_cache_save_data(void) ...@@ -4272,7 +4301,7 @@ static void test_data_cache_save_data(void)
{ {
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF }, { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF },
}, },
1, 1, &CLSID_Picture_EnhMetafile, 1, 0, &CLSID_Picture_EnhMetafile,
{ {
&CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } } &CLSID_WineTestOld, 1, { { "CONTENTS", -1, 0, 0, NULL, 0 } }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment