Module: wine Branch: master Commit: 432db51ac36b4cc635bcd2f268d1a546c8815a7e URL: http://source.winehq.org/git/wine.git/?a=commit;h=432db51ac36b4cc635bcd2f268...
Author: Aric Stewart aric@codeweavers.com Date: Wed Jun 3 11:27:24 2009 -0500
msctf: Implement ITfInsertAtSelection::InsertTextAtSelection.
---
dlls/msctf/context.c | 31 +++++++++++++++++++++++++++++-- dlls/msctf/tests/inputprocessor.c | 24 +++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c index 9a0c8fe..d8322e6 100644 --- a/dlls/msctf/context.c +++ b/dlls/msctf/context.c @@ -613,8 +613,35 @@ static WINAPI HRESULT InsertAtSelection_InsertTextAtSelection( const WCHAR *pchText, LONG cch, ITfRange **ppRange) { Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); - FIXME("STUB:(%p)\n",This); - return E_NOTIMPL; + EditCookie *cookie; + LONG acpStart, acpEnd; + TS_TEXTCHANGE change; + HRESULT hr; + + TRACE("(%p) %i %x %s %p\n",This, ec, dwFlags, debugstr_wn(pchText,cch), ppRange); + + if (!This->connected) + return TF_E_DISCONNECTED; + + if (get_Cookie_magic(ec)!=COOKIE_MAGIC_EDITCOOKIE) + return TF_E_NOLOCK; + + cookie = get_Cookie_data(ec); + + if ((cookie->lockType & TS_LF_READWRITE) != TS_LF_READWRITE ) + return TS_E_READONLY; + + if (!This->pITextStoreACP) + { + FIXME("Context does not have a ITextStoreACP\n"); + return E_NOTIMPL; + } + + hr = ITextStoreACP_InsertTextAtSelection(This->pITextStoreACP, dwFlags, pchText, cch, &acpStart, &acpEnd, &change); + if (SUCCEEDED(hr)) + Range_Constructor((ITfContext*)This, This->pITextStoreACP, cookie->lockType, change.acpStart, change.acpNewEnd, ppRange); + + return hr; }
static WINAPI HRESULT InsertAtSelection_InsertEmbeddedAtSelection( diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c index bdb9a62..284980e 100644 --- a/dlls/msctf/tests/inputprocessor.c +++ b/dlls/msctf/tests/inputprocessor.c @@ -63,6 +63,7 @@ static INT test_ACP_RequestLock = SINK_UNEXPECTED; static INT test_ACP_GetEndACP = SINK_UNEXPECTED; static INT test_ACP_GetSelection = SINK_UNEXPECTED; static INT test_DoEditSession = SINK_UNEXPECTED; +static INT test_ACP_InsertTextAtSelection = SINK_UNEXPECTED;
/********************************************************************** @@ -223,7 +224,8 @@ static HRESULT WINAPI TextStoreACP_InsertTextAtSelection(ITextStoreACP *iface, DWORD dwFlags, const WCHAR *pchText, ULONG cch, LONG *pacpStart, LONG *pacpEnd, TS_TEXTCHANGE *pChange) { - trace("\n"); + ok(test_ACP_InsertTextAtSelection == SINK_EXPECTED,"Unexpected TextStoreACP_InsertTextAtSelection\n"); + test_ACP_InsertTextAtSelection = SINK_FIRED; return S_OK; } static HRESULT WINAPI TextStoreACP_InsertEmbeddedAtSelection(ITextStoreACP *iface, @@ -1371,6 +1373,24 @@ static ULONG WINAPI EditSession_Release(ITfEditSession *iface) return ret; }
+static void test_InsertAtSelection(TfEditCookie ec, ITfContext *cxt) +{ + HRESULT hr; + ITfInsertAtSelection *iis; + ITfRange *range=NULL; + static const WCHAR txt[] = {'H','e','l','l','o',' ','W','o','r','l','d',0}; + + hr = ITfContext_QueryInterface(cxt, &IID_ITfInsertAtSelection , (LPVOID*)&iis); + ok(SUCCEEDED(hr),"Failed to get ITfInsertAtSelection interface\n"); + test_ACP_InsertTextAtSelection = SINK_EXPECTED; + hr = ITfInsertAtSelection_InsertTextAtSelection(iis, ec, 0, txt, 11, &range); + ok(SUCCEEDED(hr),"ITfInsertAtSelection_InsertTextAtSelection failed %x\n",hr); + ok(test_ACP_InsertTextAtSelection == SINK_FIRED,"expected InsertTextAtSelection not fired\n"); + ok(range != NULL,"No range returned\n"); + ITfRange_Release(range); + ITfInsertAtSelection_Release(iis); +} + static HRESULT WINAPI EditSession_DoEditSession(ITfEditSession *iface, TfEditCookie ec) { @@ -1427,6 +1447,8 @@ TfEditCookie ec) ok(test_ACP_GetSelection == SINK_FIRED," expected ACP_GetSepection not fired\n"); ITfRange_Release(selection.range);
+ test_InsertAtSelection(ec, cxt); + ITfContext_Release(cxt); ITfDocumentMgr_Release(dm); return 0xdeadcafe;