https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e9939bd42aa9eb6535bf…
commit 0e9939bd42aa9eb6535bf9278f3959164cb522a5
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jan 3 10:50:48 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jan 3 10:50:48 2024 +0900
[MSCTFIME] Implement CTextEventSink::_Advise and _Unadvise (#6284)
Supporting TIPs...
JIRA issue: CORE-19360
---
dll/ime/msctfime/msctfime.cpp | 69 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 10 deletions(-)
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index c9f235937bc..e1c2fd9cd62 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -609,7 +609,11 @@ protected:
IUnknown *m_pUnknown;
DWORD m_dwEditSinkCookie;
DWORD m_dwLayoutSinkCookie;
- FN_LAYOUTCHANGE m_fnLayoutChange;
+ union
+ {
+ UINT m_uFlags;
+ FN_LAYOUTCHANGE m_fnLayoutChange;
+ };
FN_ENDEDIT m_fnEndEdit;
LPVOID m_pCallbackPV;
@@ -742,18 +746,63 @@ STDMETHODIMP CTextEventSink::OnLayoutChange(
}
/**
- * @unimplemented
+ * @implemented
*/
HRESULT CTextEventSink::_Advise(IUnknown *pUnknown, UINT uFlags)
{
- return E_NOTIMPL;
+ m_pUnknown = NULL;
+ m_uFlags = uFlags;
+
+ ITfSource *pSource = NULL;
+ HRESULT hr = pUnknown->QueryInterface(IID_ITfSource, (void**)&pSource);
+ if (SUCCEEDED(hr))
+ {
+ ITfTextEditSink *pSink = static_cast<ITfTextEditSink*>(this);
+ if (uFlags & 1)
+ hr = pSource->AdviseSink(IID_ITfTextEditSink, pSink,
&m_dwEditSinkCookie);
+ if (SUCCEEDED(hr) && (uFlags & 2))
+ hr = pSource->AdviseSink(IID_ITfTextLayoutSink, pSink,
&m_dwLayoutSinkCookie);
+
+ if (SUCCEEDED(hr))
+ {
+ m_pUnknown = pUnknown;
+ pUnknown->AddRef();
+ }
+ else
+ {
+ pSource->UnadviseSink(m_dwEditSinkCookie);
+ }
+ }
+
+ if (pSource)
+ pSource->Release();
+
+ return hr;
}
/**
- * @unimplemented
+ * @implemented
*/
HRESULT CTextEventSink::_Unadvise()
{
+ if (!m_pUnknown)
+ return E_FAIL;
+
+ ITfSource *pSource = NULL;
+ HRESULT hr = m_pUnknown->QueryInterface(IID_ITfSource, (void**)&pSource);
+ if (SUCCEEDED(hr))
+ {
+ if (m_uFlags & 1)
+ hr = pSource->UnadviseSink(m_dwEditSinkCookie);
+ if (m_uFlags & 2)
+ hr = pSource->UnadviseSink(m_dwLayoutSinkCookie);
+
+ pSource->Release();
+ }
+
+ m_pUnknown->Release();
+ m_pUnknown = NULL;
+
return E_NOTIMPL;
}
@@ -772,7 +821,7 @@ public:
HIMC m_hIMC;
ITfDocumentMgr *m_pDocumentMgr;
ITfContext *m_pContext;
- IUnknown *m_pUnknown1;
+ ITfContextOwnerServices *m_pContextOwnerServices;
CInputContextOwnerCallBack *m_pICOwnerCallback;
CTextEventSink *m_pTextEventSink;
CCompartmentEventSink *m_pCompEventSink1;
@@ -988,14 +1037,14 @@ CicInputContext::DestroyInputContext()
if (m_pCompEventSink2)
{
- //FIXME: m_pCompEventSink2->_Unadvise();
+ m_pCompEventSink2->_Unadvise();
m_pCompEventSink2->Release();
m_pCompEventSink2 = NULL;
}
if (m_pCompEventSink1)
{
- //FIXME: m_pCompEventSink1->_Unadvise();
+ m_pCompEventSink1->_Unadvise();
m_pCompEventSink1->Release();
m_pCompEventSink1 = NULL;
}
@@ -1012,10 +1061,10 @@ CicInputContext::DestroyInputContext()
m_pContext = NULL;
}
- if (m_pUnknown1)
+ if (m_pContextOwnerServices)
{
- m_pUnknown1->Release();
- m_pUnknown1 = NULL;
+ m_pContextOwnerServices->Release();
+ m_pContextOwnerServices = NULL;
}
// FIXME: m_pICOwnerCallback