Aric Stewart : msctf: Beginning implementation of ITfContext::GetSelection.
Alexandre Julliard
julliard at winehq.org
Fri May 22 08:25:32 CDT 2009
Module: wine
Branch: master
Commit: 13d6aa2bb72d9d90e239d6e3001948ed0e2f9be1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=13d6aa2bb72d9d90e239d6e3001948ed0e2f9be1
Author: Aric Stewart <aric at codeweavers.com>
Date: Thu May 21 13:45:57 2009 -0500
msctf: Beginning implementation of ITfContext::GetSelection.
---
dlls/msctf/context.c | 55 +++++++++++++++++++++++++++++++++++-
dlls/msctf/tests/inputprocessor.c | 23 +++++++++++++++-
include/textstor.idl | 2 +
3 files changed, 77 insertions(+), 3 deletions(-)
diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c
index 8c83798..8e14a72 100644
--- a/dlls/msctf/context.c
+++ b/dlls/msctf/context.c
@@ -283,8 +283,59 @@ static HRESULT WINAPI Context_GetSelection (ITfContext *iface,
TF_SELECTION *pSelection, ULONG *pcFetched)
{
Context *This = (Context *)iface;
- FIXME("STUB:(%p)\n",This);
- return E_NOTIMPL;
+ EditCookie *cookie;
+ ULONG count, i;
+ ULONG totalFetched = 0;
+ HRESULT hr = S_OK;
+
+ if (!pSelection || !pcFetched)
+ return E_INVALIDARG;
+
+ *pcFetched = 0;
+
+ 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);
+
+ if (ulIndex == TF_DEFAULT_SELECTION)
+ count = 1;
+ else
+ count = ulCount;
+
+ for (i = 0; i < count; i++)
+ {
+ DWORD fetched;
+ TS_SELECTION_ACP acps;
+
+ hr = ITextStoreACP_GetSelection(This->pITextStoreACP, ulIndex + i,
+ 1, &acps, &fetched);
+
+ if (hr == TS_E_NOLOCK)
+ return TF_E_NOLOCK;
+ else if (SUCCEEDED(hr))
+ {
+ pSelection[totalFetched].style.ase = acps.style.ase;
+ pSelection[totalFetched].style.fInterimChar = acps.style.fInterimChar;
+ Range_Constructor(iface, This->pITextStoreACP, cookie->lockType, acps.acpStart, acps.acpEnd, &pSelection[totalFetched].range);
+ totalFetched ++;
+ }
+ else
+ break;
+ }
+
+ *pcFetched = totalFetched;
+
+ return hr;
}
static HRESULT WINAPI Context_SetSelection (ITfContext *iface,
diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c
index f488e82..5884a30 100644
--- a/dlls/msctf/tests/inputprocessor.c
+++ b/dlls/msctf/tests/inputprocessor.c
@@ -58,6 +58,7 @@ 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_ACP_GetSelection = SINK_UNEXPECTED;
static INT test_DoEditSession = SINK_UNEXPECTED;
@@ -171,7 +172,15 @@ static HRESULT WINAPI TextStoreACP_QueryInsert(ITextStoreACP *iface,
static HRESULT WINAPI TextStoreACP_GetSelection(ITextStoreACP *iface,
ULONG ulIndex, ULONG ulCount, TS_SELECTION_ACP *pSelection, ULONG *pcFetched)
{
- trace("\n");
+ ok(test_ACP_GetSelection == SINK_EXPECTED, "Unexpected TextStoreACP_GetSelection\n");
+ test_ACP_GetSelection = SINK_FIRED;
+
+ pSelection->acpStart = 10;
+ pSelection->acpEnd = 20;
+ pSelection->style.fInterimChar = 0;
+ pSelection->style.ase = TS_AE_NONE;
+ *pcFetched = 1;
+
return S_OK;
}
static HRESULT WINAPI TextStoreACP_SetSelection(ITextStoreACP *iface,
@@ -1378,6 +1387,8 @@ TfEditCookie ec)
ITfContext *cxt;
ITfDocumentMgr *dm;
ITfRange *range;
+ TF_SELECTION selection;
+ ULONG fetched;
HRESULT hr;
ok(test_DoEditSession == SINK_EXPECTED, "Unexpected DoEditSession\n");
@@ -1416,6 +1427,16 @@ TfEditCookie ec)
ok(test_ACP_GetEndACP == SINK_FIRED, "GetEndACP not fired as expected\n");
ITfRange_Release(range);
+
+ selection.range = NULL;
+ test_ACP_GetSelection = SINK_EXPECTED;
+ hr = ITfContext_GetSelection(cxt, ec, TF_DEFAULT_SELECTION, 1, &selection, &fetched);
+ ok(SUCCEEDED(hr),"ITfContext_GetSelection failed\n");
+ ok(fetched == 1,"fetched incorrect\n");
+ ok(selection.range != NULL,"NULL range\n");
+ ok(test_ACP_GetSelection == SINK_FIRED," expected ACP_GetSepection not fired\n");
+ ITfRange_Release(selection.range);
+
ITfContext_Release(cxt);
ITfDocumentMgr_Release(dm);
return 0xdeadcafe;
diff --git a/include/textstor.idl b/include/textstor.idl
index 262dc53..2e79e3c 100644
--- a/include/textstor.idl
+++ b/include/textstor.idl
@@ -21,6 +21,8 @@ import "oaidl.idl";
#endif
cpp_quote("#define TS_E_READONLY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0209)")
+cpp_quote("#define TS_E_NOLOCK MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0201)")
+
const ULONG TS_DEFAULT_SELECTION = ~0u;
More information about the wine-cvs
mailing list