From: Piotr Caban <piotr(a)codeweavers.com> --- dlls/msado15/recordset.c | 31 +++++++++++++++++++++++++++++-- dlls/msado15/tests/msado15.c | 19 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index 78015b9a3ba..ae7289527f9 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -2975,8 +2975,35 @@ static HRESULT WINAPI recordset_put_Index( _Recordset *iface, BSTR index ) static HRESULT WINAPI recordset_get_Index( _Recordset *iface, BSTR *index ) { - FIXME( "%p, %p\n", iface, index ); - return E_NOTIMPL; + struct recordset *recordset = impl_from_Recordset( iface ); + HRESULT hr; + DBID *dbid; + + TRACE( "%p, %p\n", iface, index ); + + if (!index) return MAKE_ADO_HRESULT( adErrInvalidArgument ); + + if (!recordset->rowset_cur_idx) + { + hr = IRowset_QueryInterface( recordset->row_set, &IID_IRowsetCurrentIndex, (void **)&recordset->rowset_cur_idx ); + if (FAILED(hr) || !recordset->rowset_cur_idx) + recordset->rowset_cur_idx = NO_INTERFACE; + } + if (recordset->rowset_cur_idx == NO_INTERFACE) + return MAKE_ADO_HRESULT( adErrFeatureNotAvailable ); + + hr = IRowsetCurrentIndex_GetIndex( recordset->rowset_cur_idx, &dbid ); + if (FAILED(hr)) return hr; + + if (dbid->eKind == DBKIND_GUID_NAME || dbid->eKind == DBKIND_NAME) + { + *index = SysAllocString( dbid->uName.pwszName ); + CoTaskMemFree( dbid->uName.pwszName ); + } + else + *index = NULL; + CoTaskMemFree( dbid ); + return S_OK; } static HRESULT WINAPI recordset_Save( _Recordset *iface, VARIANT destination, PersistFormatEnum persist_format ) diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 910a1f13899..02228237e1f 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -87,6 +87,7 @@ DEFINE_EXPECT(rowset_view_CreateView); DEFINE_EXPECT(view_chapter_OpenViewChapter); DEFINE_EXPECT(view_filter_SetFilter); DEFINE_EXPECT(chaptered_rowset_ReleaseChapter); +DEFINE_EXPECT(rowset_current_index_GetIndex); DEFINE_EXPECT(rowset_current_index_SetIndex); static BOOL is_bof( _Recordset *recordset ) @@ -1223,8 +1224,15 @@ static HRESULT WINAPI rowset_current_index_SetRange(IRowsetCurrentIndex *iface, static HRESULT WINAPI rowset_current_index_GetIndex(IRowsetCurrentIndex *iface, DBID **ppIndexID) { - ok(0, "unexpected call\n"); - return E_NOTIMPL; + CHECK_EXPECT(rowset_current_index_GetIndex); + ok(ppIndexID != NULL, "ppIndexID = NULL\n"); + + *ppIndexID = CoTaskMemAlloc(sizeof(**ppIndexID)); + memset(*ppIndexID, 0, sizeof(**ppIndexID)); + (*ppIndexID)->eKind = DBKIND_NAME; + (*ppIndexID)->uName.pwszName = CoTaskMemAlloc(sizeof(L"abc")); + wcscpy((*ppIndexID)->uName.pwszName, L"abc"); + return S_OK; } static HRESULT WINAPI rowset_current_index_SetIndex(IRowsetCurrentIndex *iface, DBID *pIndexID) @@ -1948,6 +1956,13 @@ static void test_ADORecordsetConstruction(BOOL exact_scroll) else CHECK_CALLED( rowset_GetRowsAt ); ok( hr == MAKE_ADO_HRESULT(adErrNoCurrentRecord), "got %08lx\n", hr ); + SET_EXPECT( rowset_current_index_GetIndex ); + hr = _Recordset_get_Index( recordset, &bstr ); + ok( hr == S_OK, "got %08lx\n", hr ); + CHECK_CALLED( rowset_current_index_GetIndex ); + ok( !wcscmp( bstr, L"abc"), "bstr = %s\n", wine_dbgstr_w(bstr) ); + SysFreeString( bstr ); + bstr = SysAllocString( L"test" ); SET_EXPECT( rowset_current_index_SetIndex ); if (!exact_scroll) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9667