From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/metadataquery.c | 20 ++++++-- dlls/windowscodecs/tests/metadata.c | 71 ++++++++++++----------------- 2 files changed, 44 insertions(+), 47 deletions(-)
diff --git a/dlls/windowscodecs/metadataquery.c b/dlls/windowscodecs/metadataquery.c index e535103d001..1759e34c997 100644 --- a/dlls/windowscodecs/metadataquery.c +++ b/dlls/windowscodecs/metadataquery.c @@ -509,7 +509,10 @@ static HRESULT parser_set_top_level_metadata_handler(struct query_handler *query
for (i = 0; i < count; ++i) { - hr = IWICMetadataBlockReader_GetReaderByIndex(query_handler->object.block_reader, i, &handler); + if (is_writer_handler(query_handler)) + hr = IWICMetadataBlockWriter_GetWriterByIndex(query_handler->object.block_writer, i, (IWICMetadataWriter **)&handler); + else + hr = IWICMetadataBlockReader_GetReaderByIndex(query_handler->object.block_reader, i, &handler);
if (FAILED(hr)) break; @@ -577,7 +580,8 @@ static void parser_resolve_component_handlers(struct query_handler *query_handle
if (value.vt == VT_UNKNOWN) { - parser->hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataReader, (void **)&comp->handler); + parser->hr = IUnknown_QueryInterface(value.punkVal, is_writer_handler(query_handler) ? + &IID_IWICMetadataWriter : &IID_IWICMetadataReader, (void **)&comp->handler); } PropVariantClear(&value);
@@ -678,8 +682,16 @@ static HRESULT WINAPI query_handler_GetMetadataByName(IWICMetadataQueryWriter *i if (comp->handler) { value.vt = VT_UNKNOWN; - hr = MetadataQueryReader_CreateInstance(handler->object.block_reader, parser.query, - (IWICMetadataQueryReader **)&value.punkVal); + if (is_writer_handler(handler)) + { + hr = MetadataQueryWriter_CreateInstance(handler->object.block_writer, parser.query, + (IWICMetadataQueryWriter **)&value.punkVal); + } + else + { + hr = MetadataQueryReader_CreateInstance(handler->object.block_reader, parser.query, + (IWICMetadataQueryReader **)&value.punkVal); + } } else { diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c index f70df520c22..053e5b28b17 100644 --- a/dlls/windowscodecs/tests/metadata.c +++ b/dlls/windowscodecs/tests/metadata.c @@ -5131,19 +5131,14 @@ static void test_metadata_App1(void) ok(value.vt == VT_UNKNOWN, "Unexpected value type: %u.\n", value.vt);
check_interface(value.punkVal, &IID_IWICMetadataQueryReader, TRUE); - todo_wine check_interface(value.punkVal, &IID_IWICMetadataQueryWriter, TRUE);
hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryWriter, (void **)&query_writer2); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(path, L"/app1"), "Unexpected path %s.\n", wine_dbgstr_w(path)); - IWICMetadataQueryWriter_Release(query_writer2); - } + hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(path, L"/app1"), "Unexpected path %s.\n", wine_dbgstr_w(path)); + IWICMetadataQueryWriter_Release(query_writer2); PropVariantClear(&value);
PropVariantInit(&value); @@ -5151,18 +5146,15 @@ static void test_metadata_App1(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value.vt == VT_UNKNOWN, "Unexpected value type: %u.\n", value.vt); hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryWriter, (void **)&query_writer2); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(path, L"/app1/ifd"), "Unexpected path %s.\n", wine_dbgstr_w(path)); - hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(IsEqualGUID(&format, &GUID_MetadataFormatIfd), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); - IWICMetadataQueryWriter_Release(query_writer2); - } + hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(path, L"/app1/ifd"), "Unexpected path %s.\n", wine_dbgstr_w(path)); + hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(IsEqualGUID(&format, &GUID_MetadataFormatIfd), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); + IWICMetadataQueryWriter_Release(query_writer2); PropVariantClear(&value);
PropVariantInit(&value); @@ -5170,18 +5162,15 @@ static void test_metadata_App1(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value.vt == VT_UNKNOWN, "Unexpected value type: %u.\n", value.vt); hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryWriter, (void **)&query_writer2); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(path, L"/app1/ifd/gps"), "Unexpected path %s.\n", wine_dbgstr_w(path)); - hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(IsEqualGUID(&format, &GUID_MetadataFormatGps), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); - IWICMetadataQueryWriter_Release(query_writer2); - } + hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(path, L"/app1/ifd/gps"), "Unexpected path %s.\n", wine_dbgstr_w(path)); + hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(IsEqualGUID(&format, &GUID_MetadataFormatGps), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); + IWICMetadataQueryWriter_Release(query_writer2); PropVariantClear(&value);
PropVariantInit(&value); @@ -5189,18 +5178,15 @@ static void test_metadata_App1(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value.vt == VT_UNKNOWN, "Unexpected value type: %u.\n", value.vt); hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryWriter, (void **)&query_writer2); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(path, L"/app1/ifd/exif"), "Unexpected path %s.\n", wine_dbgstr_w(path)); - hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(IsEqualGUID(&format, &GUID_MetadataFormatExif), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); - IWICMetadataQueryWriter_Release(query_writer2); - } + hr = IWICMetadataQueryWriter_GetLocation(query_writer2, ARRAY_SIZE(path), path, &length); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(path, L"/app1/ifd/exif"), "Unexpected path %s.\n", wine_dbgstr_w(path)); + hr = IWICMetadataQueryWriter_GetContainerFormat(query_writer2, &format); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(IsEqualGUID(&format, &GUID_MetadataFormatExif), "Unexpected format %s.\n", wine_dbgstr_guid(&format)); + IWICMetadataQueryWriter_Release(query_writer2); PropVariantClear(&value);
PropVariantInit(&value); @@ -5226,7 +5212,6 @@ static void test_metadata_App1(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value.vt == VT_UNKNOWN, "Unexpected value type: %u.\n", value.vt); check_interface(value.punkVal, &IID_IWICMetadataQueryReader, TRUE); - todo_wine check_interface(value.punkVal, &IID_IWICMetadataQueryWriter, TRUE); PropVariantClear(&value);