From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 24 +++++++++++++++++++++++- dlls/msado15/rowset.c | 7 +++++-- dlls/msado15/tests/msado15.c | 6 +++--- 3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index 79db8c55147..8e2e0edba14 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -81,6 +81,7 @@ struct recordset CursorLocationEnum cursor_location; CursorTypeEnum cursor_type; IRowset *row_set; + IRowsetExactScroll *rowset_es; IRowsetChange *rowset_change; IAccessor *accessor; EditModeEnum editmode; @@ -1272,6 +1273,9 @@ static void close_recordset( struct recordset *recordset )
if ( recordset->row_set ) IRowset_Release( recordset->row_set ); recordset->row_set = NULL; + if ( recordset->rowset_es && recordset->rowset_es != NO_INTERFACE ) + IRowsetExactScroll_Release( recordset->rowset_es ); + recordset->rowset_es = NULL; if ( recordset->rowset_change && recordset->rowset_change != NO_INTERFACE ) IRowsetChange_Release( recordset->rowset_change ); recordset->rowset_change = NULL; @@ -1630,10 +1634,28 @@ static HRESULT WINAPI recordset_put_MaxRecords( _Recordset *iface, ADO_LONGPTR m static HRESULT WINAPI recordset_get_RecordCount( _Recordset *iface, ADO_LONGPTR *count ) { struct recordset *recordset = impl_from_Recordset( iface ); + DBCOUNTITEM rows; + HRESULT hr;
TRACE( "%p, %p\n", recordset, count );
- *count = recordset->count; + *count = -1; + + if (recordset->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed ); + + if (!recordset->rowset_es) + { + hr = IUnknown_QueryInterface( recordset->row_set, &IID_IRowsetExactScroll, + (void**)&recordset->rowset_es ); + if (FAILED(hr) || !recordset->rowset_es) + recordset->rowset_es = NO_INTERFACE; + } + if (recordset->rowset_es == NO_INTERFACE) + return S_OK; + + hr = IRowsetExactScroll_GetExactPosition( recordset->rowset_es, 0, 0, 0, 0, &rows ); + if (SUCCEEDED(hr)) + *count = rows; return S_OK; }
diff --git a/dlls/msado15/rowset.c b/dlls/msado15/rowset.c index c776f6c3b3d..286d86871fd 100644 --- a/dlls/msado15/rowset.c +++ b/dlls/msado15/rowset.c @@ -248,8 +248,11 @@ static HRESULT WINAPI rowset_GetExactPosition(IRowsetExactScroll *iface, HCHAPTE { struct rowset *rowset = impl_from_IRowsetExactScroll(iface);
- FIXME("%p, %Id, %Iu, %p, %p, %p\n", rowset, chapter, bookmark_cnt, bookmarks, position, rows); - return E_NOTIMPL; + TRACE("%p, %Id, %Iu, %p, %p, %p\n", rowset, chapter, bookmark_cnt, bookmarks, position, rows); + + if (position) FIXME("not setting position\n"); + if (rows) *rows = rowset->row_cnt; + return S_OK; }
static const struct IRowsetExactScrollVtbl rowset_vtbl = diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 111c93d99f7..cbc0feda12f 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -1110,10 +1110,10 @@ static void test_ADORecordsetConstruction(BOOL exact_scroll) SET_EXPECT( rowset_QI_IRowsetExactScroll ); if (exact_scroll) SET_EXPECT( rowset_GetExactPosition ); hr = _Recordset_get_RecordCount( recordset, &size ); - todo_wine CHECK_CALLED( rowset_QI_IRowsetExactScroll ); - if (exact_scroll) todo_wine CHECK_CALLED( rowset_GetExactPosition ); + CHECK_CALLED( rowset_QI_IRowsetExactScroll ); + if (exact_scroll) CHECK_CALLED( rowset_GetExactPosition ); ok( hr == S_OK, "got %08lx\n", hr ); - todo_wine ok( size == (exact_scroll ? 3 : -1), "size = %Id\n", size ); + ok( size == (exact_scroll ? 3 : -1), "size = %Id\n", size );
if (!exact_scroll) SET_EXPECT( rowset_GetNextRows ); else SET_EXPECT( rowset_GetRowsAt );