Commit 6634b315 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Support BYREF index in FolderItems::Item().

parent 824837ec
...@@ -1129,19 +1129,24 @@ static HRESULT WINAPI FolderItemsImpl_get_Parent(FolderItems3 *iface, IDispatch ...@@ -1129,19 +1129,24 @@ static HRESULT WINAPI FolderItemsImpl_get_Parent(FolderItems3 *iface, IDispatch
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, FolderItem **item) static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT var, FolderItem **item)
{ {
FolderItemsImpl *This = impl_from_FolderItems(iface); FolderItemsImpl *This = impl_from_FolderItems(iface);
BSTR display_name = NULL; BSTR display_name = NULL;
VARIANT index;
HRESULT hr; HRESULT hr;
TRACE("(%p,%s,%p)\n", iface, debugstr_variant(&index), item); TRACE("(%p,%s,%p)\n", iface, debugstr_variant(&var), item);
*item = NULL; *item = NULL;
if (!shellfolder_exists(This->folder->path)) if (!shellfolder_exists(This->folder->path))
return S_FALSE; return S_FALSE;
VariantInit(&index);
if (FAILED(hr = VariantCopyInd(&index, &var)))
return hr;
switch (V_VT(&index)) switch (V_VT(&index))
{ {
case VT_I2: case VT_I2:
...@@ -1163,8 +1168,9 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F ...@@ -1163,8 +1168,9 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F
if (!V_BSTR(&index)) if (!V_BSTR(&index))
return S_FALSE; return S_FALSE;
if (FAILED(hr = IShellFolder2_ParseDisplayName(This->folder->folder, NULL, NULL, V_BSTR(&index), hr = IShellFolder2_ParseDisplayName(This->folder->folder, NULL, NULL, V_BSTR(&index), NULL, &pidl, NULL);
NULL, &pidl, NULL))) VariantClear(&index);
if (FAILED(hr))
return S_FALSE; return S_FALSE;
if (IShellFolder2_GetDisplayNameOf(This->folder->folder, pidl, SHGDN_FORPARSING, &strret) == S_OK) if (IShellFolder2_GetDisplayNameOf(This->folder->folder, pidl, SHGDN_FORPARSING, &strret) == S_OK)
...@@ -1176,7 +1182,8 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F ...@@ -1176,7 +1182,8 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F
break; break;
default: default:
FIXME("Index type %d not handled.\n", V_VT(&index)); FIXME("Index type %#x not handled.\n", V_VT(&index));
VariantClear(&index);
/* fall through */ /* fall through */
case VT_EMPTY: case VT_EMPTY:
return E_NOTIMPL; return E_NOTIMPL;
......
...@@ -382,7 +382,7 @@ static void test_items(void) ...@@ -382,7 +382,7 @@ static void test_items(void)
FolderItems3 *items3 = NULL; FolderItems3 *items3 = NULL;
FolderItem *item = (FolderItem*)0xdeadbeef, *item2; FolderItem *item = (FolderItem*)0xdeadbeef, *item2;
FolderItemVerbs *verbs = (FolderItemVerbs*)0xdeadbeef; FolderItemVerbs *verbs = (FolderItemVerbs*)0xdeadbeef;
VARIANT var, int_index, str_index, str_index2; VARIANT var, var2, int_index, str_index, str_index2;
IDispatch *disp, *disp2; IDispatch *disp, *disp2;
LONG count = -1; LONG count = -1;
IUnknown *unk; IUnknown *unk;
...@@ -543,12 +543,14 @@ static void test_items(void) ...@@ -543,12 +543,14 @@ static void test_items(void)
ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r); ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r);
ok(count == ARRAY_SIZE(file_defs), "got %d files\n", count); ok(count == ARRAY_SIZE(file_defs), "got %d files\n", count);
/* VT_EMPTY */
V_VT(&var) = VT_EMPTY; V_VT(&var) = VT_EMPTY;
item = (FolderItem*)0xdeadbeef; item = (FolderItem*)0xdeadbeef;
r = FolderItems_Item(items, var, &item); r = FolderItems_Item(items, var, &item);
ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r); ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r);
ok(!item, "item is not null\n"); ok(!item, "item is not null\n");
/* VT_I2 */
V_VT(&var) = VT_I2; V_VT(&var) = VT_I2;
V_I2(&var) = 0; V_I2(&var) = 0;
...@@ -571,6 +573,20 @@ static void test_items(void) ...@@ -571,6 +573,20 @@ static void test_items(void)
FolderItem_Release(item); FolderItem_Release(item);
/* VT_VARIANT | VT_BYREF */
V_VT(&var2) = VT_I2;
V_I2(&var2) = 0;
V_VT(&var) = VT_BYREF | VT_VARIANT;
V_VARIANTREF(&var) = &var2;
item = NULL;
r = FolderItems_Item(items, var, &item);
ok(r == S_OK, "FolderItems::Item failed: %08x\n", r);
ok(!!item, "item is null\n");
FolderItem_Release(item);
/* VT_I4 */
V_VT(&var) = VT_I4; V_VT(&var) = VT_I4;
V_I4(&var) = 0; V_I4(&var) = 0;
item = NULL; item = NULL;
......
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