From 7fa47cd3f50faf4c871c7a6a0e2c6f4651ffe76d Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Thu, 21 May 2009 13:45:36 -0500 Subject: [PATCH] msctf: Beginning implementation of ITfContext::GetEnd. --- dlls/msctf/context.c | 27 +++++++++++++++++++++++++-- dlls/msctf/tests/inputprocessor.c | 20 +++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c index ce5463fe91b..8c83798d244 100644 --- a/dlls/msctf/context.c +++ b/dlls/msctf/context.c @@ -321,8 +321,31 @@ static HRESULT WINAPI Context_GetEnd (ITfContext *iface, TfEditCookie ec, ITfRange **ppEnd) { Context *This = (Context *)iface; - FIXME("STUB:(%p)\n",This); - return E_NOTIMPL; + EditCookie *cookie; + LONG end; + TRACE("(%p) %i %p\n",This,ec,ppEnd); + + if (!ppEnd) + return E_INVALIDARG; + + *ppEnd = NULL; + + if (!This->connected) + return TF_E_DISCONNECTED; + + if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE) + return TF_E_NOLOCK; + + if (!This->pITextStoreACP) + { + FIXME("Context does not have a ITextStoreACP\n"); + return E_NOTIMPL; + } + + cookie = get_Cookie_data(ec); + ITextStoreACP_GetEndACP(This->pITextStoreACP,&end); + + return Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, end, end, ppEnd); } static HRESULT WINAPI Context_GetActiveView (ITfContext *iface, diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c index 2fff5045ff5..f488e82af47 100644 --- a/dlls/msctf/tests/inputprocessor.c +++ b/dlls/msctf/tests/inputprocessor.c @@ -57,6 +57,7 @@ static INT test_KEV_OnSetFocus = SINK_UNEXPECTED; static INT test_ACP_AdviseSink = SINK_UNEXPECTED; static INT test_ACP_GetStatus = SINK_UNEXPECTED; static INT test_ACP_RequestLock = SINK_UNEXPECTED; +static INT test_ACP_GetEndACP = SINK_UNEXPECTED; static INT test_DoEditSession = SINK_UNEXPECTED; @@ -269,7 +270,8 @@ static HRESULT WINAPI TextStoreACP_RetrieveRequestedAttrs(ITextStoreACP *iface, static HRESULT WINAPI TextStoreACP_GetEndACP(ITextStoreACP *iface, LONG *pacp) { - trace("\n"); + ok(test_ACP_GetEndACP == SINK_EXPECTED,"Unexpected TextStoreACP_GetEndACP\n"); + test_ACP_GetEndACP = SINK_FIRED; return S_OK; } static HRESULT WINAPI TextStoreACP_GetActiveView(ITextStoreACP *iface, @@ -1397,6 +1399,22 @@ TfEditCookie ec) ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr); ok(range != NULL,"Range set to NULL\n"); + ITfRange_Release(range); + + hr = ITfContext_GetEnd(cxt,ec,NULL); + ok(hr == E_INVALIDARG,"Unexpected return code %x\n",hr); + + range = (ITfRange*)0xdeaddead; + hr = ITfContext_GetEnd(cxt,0xdeadcafe,&range); + ok(hr == TF_E_NOLOCK,"Unexpected return code %x\n",hr); + ok(range == NULL,"Range not set to NULL\n"); + + test_ACP_GetEndACP = SINK_EXPECTED; + hr = ITfContext_GetEnd(cxt,ec,&range); + ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr); + ok(range != NULL,"Range set to NULL\n"); + ok(test_ACP_GetEndACP == SINK_FIRED, "GetEndACP not fired as expected\n"); + ITfRange_Release(range); ITfContext_Release(cxt); ITfDocumentMgr_Release(dm);