oledb32: Implement GetRowPosition().

This commit is contained in:
Nikolay Sivov 2013-08-23 10:33:59 +04:00 committed by Alexandre Julliard
parent 149c392e09
commit 05528ea01b
2 changed files with 52 additions and 4 deletions

View file

@ -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;

View file

@ -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);
}