diff --git a/dlls/oledb32/rowpos.c b/dlls/oledb32/rowpos.c index cca31920892..2b932c91591 100644 --- a/dlls/oledb32/rowpos.c +++ b/dlls/oledb32/rowpos.c @@ -47,6 +47,9 @@ struct rowpos LONG ref; IRowset *rowset; + HROW row; + HCHAPTER chapter; + DBPOSITIONFLAGS flags; rowpos_cp cp; }; @@ -83,6 +86,13 @@ static HRESULT rowpos_fireevent(rowpos *rp, DBREASON reason, DBEVENTPHASE phase) return hr; } +static void rowpos_clearposition(rowpos *rp) +{ + rp->row = DB_NULL_HROW; + rp->chapter = DB_NULL_HCHAPTER; + rp->flags = DBPOSITION_NOROW; +} + static HRESULT WINAPI rowpos_QueryInterface(IRowPosition* iface, REFIID riid, void **obj) { rowpos *This = impl_from_IRowPosition(iface); @@ -152,8 +162,7 @@ static HRESULT WINAPI rowpos_ClearRowPosition(IRowPosition* iface) if (hr != S_OK) return rowpos_fireevent(This, DBREASON_ROWPOSITION_CLEARED, DBEVENTPHASE_FAILEDTODO); - /* FIXME: actually clear stored data */ - + rowpos_clearposition(This); return S_OK; } @@ -161,8 +170,16 @@ static HRESULT WINAPI rowpos_GetRowPosition(IRowPosition *iface, HCHAPTER *chapt HROW *row, DBPOSITIONFLAGS *flags) { rowpos *This = impl_from_IRowPosition(iface); - FIXME("(%p)->(%p %p %p): stub\n", This, chapter, row, flags); - return E_NOTIMPL; + + TRACE("(%p)->(%p %p %p)\n", This, chapter, row, flags); + + *chapter = This->chapter; + *row = This->row; + *flags = This->flags; + + if (!This->rowset) return E_UNEXPECTED; + + return S_OK; } static HRESULT WINAPI rowpos_GetRowset(IRowPosition *iface, REFIID riid, IUnknown **rowset) @@ -417,6 +434,7 @@ HRESULT create_oledb_rowpos(IUnknown *outer, void **obj) This->IConnectionPointContainer_iface.lpVtbl = &rowpos_cpc_vtbl; This->ref = 1; This->rowset = NULL; + rowpos_clearposition(This); rowposchange_cp_init(&This->cp, This); *obj = &This->IRowPosition_iface; diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c index ac809efd35d..7801bf84773 100644 --- a/dlls/oledb32/tests/database.c +++ b/dlls/oledb32/tests/database.c @@ -471,9 +471,12 @@ static void init_onchange_sink(IRowPosition *rowpos) static void test_rowpos_clearrowposition(void) { + DBPOSITIONFLAGS flags; IRowPosition *rowpos; + HCHAPTER chapter; IUnknown *unk; HRESULT hr; + HROW row; hr = CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IRowPosition, (void**)&rowpos); ok(hr == S_OK, "got %08x\n", hr); @@ -484,10 +487,28 @@ static void test_rowpos_clearrowposition(void) hr = IRowPosition_GetRowset(rowpos, &IID_IStream, &unk); ok(hr == E_UNEXPECTED, "got %08x\n", hr); + chapter = 1; + row = 1; + flags = DBPOSITION_OK; + hr = IRowPosition_GetRowPosition(rowpos, &chapter, &row, &flags); + ok(hr == E_UNEXPECTED, "got %08x\n", hr); + ok(chapter == DB_NULL_HCHAPTER, "got %ld\n", chapter); + ok(row == DB_NULL_HROW, "got %ld\n", row); + ok(flags == DBPOSITION_NOROW, "got %d\n", flags); + init_test_rset(); hr = IRowPosition_Initialize(rowpos, (IUnknown*)&test_rset.IRowset_iface); ok(hr == S_OK, "got %08x\n", hr); + chapter = 1; + row = 1; + flags = DBPOSITION_OK; + hr = IRowPosition_GetRowPosition(rowpos, &chapter, &row, &flags); + ok(hr == S_OK, "got %08x\n", hr); + ok(chapter == DB_NULL_HCHAPTER, "got %ld\n", chapter); + ok(row == DB_NULL_HROW, "got %ld\n", row); + ok(flags == DBPOSITION_NOROW, "got %d\n", flags); + hr = IRowPosition_GetRowset(rowpos, &IID_IRowset, &unk); ok(hr == S_OK, "got %08x\n", hr); @@ -495,6 +516,15 @@ static void test_rowpos_clearrowposition(void) hr = IRowPosition_ClearRowPosition(rowpos); ok(hr == S_OK, "got %08x\n", hr); + chapter = 1; + row = 1; + flags = DBPOSITION_OK; + hr = IRowPosition_GetRowPosition(rowpos, &chapter, &row, &flags); + ok(hr == S_OK, "got %08x\n", hr); + ok(chapter == DB_NULL_HCHAPTER, "got %ld\n", chapter); + ok(row == DB_NULL_HROW, "got %ld\n", row); + ok(flags == DBPOSITION_NOROW, "got %d\n", flags); + IRowPosition_Release(rowpos); }