Commit c6106428 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

d3dxof: Add support for case sensitive legacy type indexColor.

parent cf2c506b
...@@ -237,7 +237,7 @@ static void test_type_index_color(void) ...@@ -237,7 +237,7 @@ static void test_type_index_color(void)
/* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */ /* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1); ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1);
todo_wine ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret); ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1); ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1);
ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x instead of %#x\n", ret, D3DXFERR_PARSEERROR); ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x instead of %#x\n", ret, D3DXFERR_PARSEERROR);
......
...@@ -46,6 +46,9 @@ static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImp ...@@ -46,6 +46,9 @@ static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImp
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj); static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj);
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj); static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
#define TOKEN_DWORD 41
#define TOKEN_FLOAT 42
HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj) HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
{ {
IDirectXFileImpl* object; IDirectXFileImpl* object;
...@@ -62,6 +65,17 @@ HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj) ...@@ -62,6 +65,17 @@ HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
object->IDirectXFile_iface.lpVtbl = &IDirectXFile_Vtbl; object->IDirectXFile_iface.lpVtbl = &IDirectXFile_Vtbl;
object->ref = 1; object->ref = 1;
/* Reserve first template to handle the case sensitive legacy type indexColor */
object->nb_xtemplates = 1;
strcpy(object->xtemplates[0].name, "indexColor");
object->xtemplates[0].nb_members = 2;
object->xtemplates[0].members[0].type = TOKEN_DWORD;
object->xtemplates[0].members[0].nb_dims = 0;
object->xtemplates[0].members[1].type = TOKEN_FLOAT;
object->xtemplates[0].members[1].nb_dims = 1;
object->xtemplates[0].members[1].dim_fixed[0] = TRUE;
object->xtemplates[0].members[1].dim_value[0] = 4;
*ppObj = &object->IDirectXFile_iface; *ppObj = &object->IDirectXFile_iface;
return S_OK; return S_OK;
...@@ -252,7 +266,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV ...@@ -252,7 +266,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
{ {
ULONG i; ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates); TRACE("Registered templates (%d):\n", This->nb_xtemplates);
for (i = 0; i < This->nb_xtemplates; i++) for (i = 1; i < This->nb_xtemplates; i++)
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id)); DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
} }
...@@ -330,7 +344,7 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP ...@@ -330,7 +344,7 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
{ {
ULONG i; ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates); TRACE("Registered templates (%d):\n", This->nb_xtemplates);
for (i = 0; i < This->nb_xtemplates; i++) for (i = 1; i < This->nb_xtemplates; i++)
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id)); DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
} }
......
...@@ -961,17 +961,25 @@ static BOOL parse_template_members_list(parse_buffer * buf) ...@@ -961,17 +961,25 @@ static BOOL parse_template_members_list(parse_buffer * buf)
if (check_TOKEN(buf) == TOKEN_NAME) if (check_TOKEN(buf) == TOKEN_NAME)
{ {
cur_member->type = get_TOKEN(buf); cur_member->type = get_TOKEN(buf);
cur_member->idx_template = 0; if (!strcmp((char*)buf->value, "indexColor"))
while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
{ {
if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name)) /* Case sensitive legacy type indexColor is described in the first template */
break; cur_member->idx_template = 0;
cur_member->idx_template++;
} }
if (cur_member->idx_template == buf->pdxf->nb_xtemplates) else
{ {
ERR("Reference to a nonexistent template '%s'\n", (char*)buf->value); cur_member->idx_template = 1;
return FALSE; while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
{
if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
break;
cur_member->idx_template++;
}
if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
{
WARN("Reference to a nonexistent template '%s'\n", (char*)buf->value);
return FALSE;
}
} }
} }
else if (is_primitive_type(check_TOKEN(buf))) else if (is_primitive_type(check_TOKEN(buf)))
......
...@@ -1103,7 +1103,7 @@ static void test_type_index_color(void) ...@@ -1103,7 +1103,7 @@ static void test_type_index_color(void)
/* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */ /* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */
ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1); ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1);
todo_wine ok(ret == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates failed with %#x\n", ret); ok(ret == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates failed with %#x\n", ret);
ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1); ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1);
ok(ret == DXFILEERR_PARSEERROR, "IDirectXFileImpl_RegisterTemplates returned %#x instead of %#x\n", ret, DXFILEERR_PARSEERROR); ok(ret == DXFILEERR_PARSEERROR, "IDirectXFileImpl_RegisterTemplates returned %#x instead of %#x\n", ret, DXFILEERR_PARSEERROR);
......
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