https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f53f1334eda2daeb94e2c…
commit f53f1334eda2daeb94e2cf2d7722f4e6a76e06fa
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Feb 22 15:46:05 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Feb 22 15:46:05 2024 +0900
[MSCTFIME][CICERO] Implement CFnDocFeed (#6513)
Supporting TIPs...
JIRA issue: CORE-19360
- Add missing CicInputContext methods.
- Implement CFnDocFeed class.
---
dll/ime/msctfime/bridge.cpp | 13 ++---
dll/ime/msctfime/functions.cpp | 100 +++++++++++++++++++++++++++++++++++---
dll/ime/msctfime/inputcontext.cpp | 41 +++++++++++++---
dll/ime/msctfime/inputcontext.h | 12 ++++-
dll/ime/msctfime/msctfime.cpp | 35 +++----------
dll/ime/msctfime/msctfime.h | 8 +++
dll/ime/msctfime/ui.cpp | 2 -
sdk/lib/cicero/cicimc.h | 3 +-
8 files changed, 156 insertions(+), 58 deletions(-)
diff --git a/dll/ime/msctfime/bridge.cpp b/dll/ime/msctfime/bridge.cpp
index de9e6ba10ef..e7801024cf9 100644
--- a/dll/ime/msctfime/bridge.cpp
+++ b/dll/ime/msctfime/bridge.cpp
@@ -87,11 +87,8 @@ CicBridge::CreateInputContext(
_In_ HIMC hIMC)
{
CicIMCLock imcLock(hIMC);
- HRESULT hr = imcLock.m_hr;
- if (!imcLock)
- hr = E_FAIL;
- if (FAILED(hr))
- return hr;
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
if (!imcLock.get().hCtfImeContext)
{
@@ -126,7 +123,7 @@ CicBridge::CreateInputContext(
imeContext.get().m_pCicIC = pCicIC;
}
- hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock);
+ HRESULT hr = pCicIC->CreateInputContext(pTLS->m_pThreadMgr, imcLock);
if (FAILED(hr))
{
pCicIC->Release();
@@ -149,8 +146,6 @@ HRESULT CicBridge::DestroyInputContext(TLS *pTLS, HIMC hIMC)
{
CicIMCLock imcLock(hIMC);
HRESULT hr = imcLock.m_hr;
- if (!imcLock)
- hr = E_FAIL;
if (FAILED(hr))
return hr;
@@ -217,8 +212,6 @@ CicBridge::SelectEx(
return imcLock.m_hr;
CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
- if (!imeContext)
- imeContext.m_hr = E_FAIL;
if (FAILED(imeContext.m_hr))
return imeContext.m_hr;
diff --git a/dll/ime/msctfime/functions.cpp b/dll/ime/msctfime/functions.cpp
index c9832f90cff..2852aece1cd 100644
--- a/dll/ime/msctfime/functions.cpp
+++ b/dll/ime/msctfime/functions.cpp
@@ -150,26 +150,112 @@ STDMETHODIMP_(ULONG) CFnDocFeed::Release()
return m_cRefs;
}
-/// @unimplemented
+/// @implemented
STDMETHODIMP CFnDocFeed::DocFeed()
{
- return E_NOTIMPL;
+ TLS *pTLS = TLS::GetTLS();
+ if (!pTLS)
+ return E_OUTOFMEMORY;
+
+ HIMC hIMC = GetActiveContext();
+ CicIMCLock imcLock(hIMC);
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
+
+ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
+ if (FAILED(imeContext.m_hr))
+ return imeContext.m_hr;
+ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
+ if (!pCicIC)
+ return E_FAIL;
+
+ UINT uCodePage = CP_ACP;
+ pTLS->m_pProfile->GetCodePageA(&uCodePage);
+ pCicIC->SetupDocFeedString(imcLock, uCodePage);
+ return S_OK;
}
-/// @unimplemented
+/// @implemented
STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer()
{
- return E_NOTIMPL;
+ if (!TLS::GetTLS())
+ return E_OUTOFMEMORY;
+
+ HIMC hIMC = GetActiveContext();
+ CicIMCLock imcLock(hIMC);
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
+
+ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
+ if (FAILED(imeContext.m_hr))
+ return imeContext.m_hr;
+
+ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
+ if (!pCicIC)
+ return E_FAIL;
+
+ pCicIC->EscbClearDocFeedBuffer(imcLock, TRUE);
+ return S_OK;
}
/// @unimplemented
STDMETHODIMP CFnDocFeed::StartReconvert()
{
- return E_NOTIMPL;
+ TLS *pTLS = TLS::GetTLS();
+ if (!pTLS)
+ return E_OUTOFMEMORY;
+ auto *pThreadMgr = pTLS->m_pThreadMgr;
+ if (!pThreadMgr)
+ return E_OUTOFMEMORY;
+
+ HIMC hIMC = GetActiveContext();
+ CicIMCLock imcLock(hIMC);
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
+
+ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
+ if (FAILED(imeContext.m_hr))
+ return imeContext.m_hr;
+ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
+ if (!pCicIC)
+ return E_FAIL;
+
+ UINT uCodePage = CP_ACP;
+ pTLS->m_pProfile->GetCodePageA(&uCodePage);
+
+ pCicIC->m_bReconverting = TRUE;
+ pCicIC->SetupReconvertString(imcLock, pThreadMgr, uCodePage, 0, 0);
+ pCicIC->EndReconvertString(imcLock);
+ pCicIC->m_bReconverting = FALSE;
+ return S_OK;
}
-/// @unimplemented
+/// @implemented
STDMETHODIMP CFnDocFeed::StartUndoCompositionString()
{
- return E_NOTIMPL;
+ TLS *pTLS = TLS::GetTLS();
+ if (!pTLS)
+ return E_OUTOFMEMORY;
+ auto *pThreadMgr = pTLS->m_pThreadMgr;
+ if (!pThreadMgr)
+ return E_OUTOFMEMORY;
+
+ HIMC hIMC = GetActiveContext();
+ CicIMCLock imcLock(hIMC);
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
+
+ CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCtfImeContext);
+ if (FAILED(imeContext.m_hr))
+ return imeContext.m_hr;
+ CicInputContext *pCicIC = imeContext.get().m_pCicIC;
+ if (!pCicIC)
+ return E_FAIL;
+
+ UINT uCodePage = CP_ACP;
+ pTLS->m_pProfile->GetCodePageA(&uCodePage);
+
+ pCicIC->SetupReconvertString(imcLock, pThreadMgr, uCodePage, 0, TRUE);
+ pCicIC->EndReconvertString(imcLock);
+ return S_OK;
}
diff --git a/dll/ime/msctfime/inputcontext.cpp b/dll/ime/msctfime/inputcontext.cpp
index 1bdf64cb62e..81344d26545 100644
--- a/dll/ime/msctfime/inputcontext.cpp
+++ b/dll/ime/msctfime/inputcontext.cpp
@@ -65,7 +65,7 @@ CicInputContext::OnStartComposition(
ITfCompositionView *pComposition,
BOOL *pfOk)
{
- if ((m_cCompLocks <= 0) || m_dwUnknown6_5)
+ if ((m_cCompLocks <= 0) || m_bReconverting)
{
*pfOk = TRUE;
++m_cCompLocks;
@@ -103,13 +103,10 @@ CicInputContext::GetGuidAtom(
_Out_opt_ LPDWORD pdwGuidAtom)
{
CicIMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr);
- HRESULT hr = imeContext.m_hr;
- if (!imeContext)
- hr = E_FAIL;
- if (FAILED(hr))
- return hr;
+ if (FAILED(imeContext.m_hr))
+ return imeContext.m_hr;
- hr = E_FAIL;
+ HRESULT hr = E_FAIL;
if (iAtom < m_cGuidAtoms)
{
*pdwGuidAtom = m_adwGuidAtoms[iAtom];
@@ -251,6 +248,36 @@ CicInputContext::OnCleanupContext(
return S_OK;
}
+/// @unimplemented
+HRESULT CicInputContext::SetupDocFeedString(CicIMCLock& imcLock, UINT uCodePage)
+{
+ return E_NOTIMPL;
+}
+
+/// @unimplemented
+HRESULT CicInputContext::EscbClearDocFeedBuffer(CicIMCLock& imcLock, BOOL bFlag)
+{
+ return E_NOTIMPL;
+}
+
+/// @unimplemented
+HRESULT
+CicInputContext::SetupReconvertString(
+ CicIMCLock& imcLock,
+ ITfThreadMgr_P *pThreadMgr,
+ UINT uCodePage,
+ DWORD dwUnknown61,
+ BOOL bUndo)
+{
+ return E_NOTIMPL;
+}
+
+/// @unimplemented
+HRESULT CicInputContext::EndReconvertString(CicIMCLock& imcLock)
+{
+ return E_NOTIMPL;
+}
+
/// Retrieves the IME information.
/// @implemented
HRESULT
diff --git a/dll/ime/msctfime/inputcontext.h b/dll/ime/msctfime/inputcontext.h
index 2273161926e..b567304b779 100644
--- a/dll/ime/msctfime/inputcontext.h
+++ b/dll/ime/msctfime/inputcontext.h
@@ -47,7 +47,7 @@ public:
GUID m_guid;
DWORD m_dwUnknown6[11];
BOOL m_bSelecting;
- DWORD m_dwUnknown6_5;
+ BOOL m_bReconverting;
LONG m_cCompLocks;
DWORD m_dwUnknown7[5];
WORD m_cGuidAtoms;
@@ -88,4 +88,14 @@ public:
HRESULT CreateInputContext(_Inout_ ITfThreadMgr *pThreadMgr, _Inout_ CicIMCLock&
imcLock);
HRESULT DestroyInputContext();
+
+ HRESULT SetupDocFeedString(CicIMCLock& imcLock, UINT uCodePage);
+ HRESULT EscbClearDocFeedBuffer(CicIMCLock& imcLock, BOOL bFlag);
+ HRESULT SetupReconvertString(
+ CicIMCLock& imcLock,
+ ITfThreadMgr_P *pThreadMgr,
+ UINT uCodePage,
+ DWORD dwUnknown61,
+ BOOL bUndo);
+ HRESULT EndReconvertString(CicIMCLock& imcLock);
};
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index 445998d6a9c..87ca208819c 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -142,14 +142,6 @@ HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
return hr;
}
-HIMC GetActiveContext(VOID)
-{
- HWND hwndFocus = ::GetFocus();
- if (!hwndFocus)
- hwndFocus = ::GetActiveWindow();
- return ::ImmGetContext(hwndFocus);
-}
-
/// @implemented
HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
{
@@ -184,8 +176,6 @@ InternalSelectEx(
_In_ LANGID LangID)
{
CicIMCLock imcLock(hIMC);
- if (!imcLock)
- imcLock.m_hr = E_FAIL;
if (FAILED(imcLock.m_hr))
return imcLock.m_hr;
@@ -608,25 +598,17 @@ CtfImeGetGuidAtom(
TRACE("(%p, 0x%lX, %p)\n", hIMC, dwUnknown, pdwGuidAtom);
CicIMCLock imcLock(hIMC);
-
- HRESULT hr = imcLock.m_hr;
- if (!imcLock)
- hr = E_FAIL;
- if (FAILED(hr))
- return hr;
+ if (FAILED(imcLock.m_hr))
+ return imcLock.m_hr;
CicIMCCLock<CTFIMECONTEXT> imccLock(imcLock.get().hCtfImeContext);
- hr = imccLock.m_hr;
- if (!imccLock)
- hr = E_FAIL;
- if (FAILED(hr))
- return hr;
+ if (FAILED(imccLock.m_hr))
+ return imccLock.m_hr;
if (!imccLock.get().m_pCicIC)
return E_OUTOFMEMORY;
- hr = imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
- return hr;
+ return imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
}
/***********************************************************************
@@ -641,13 +623,8 @@ CtfImeIsGuidMapEnable(
TRACE("(%p)\n", hIMC);
BOOL ret = FALSE;
- HRESULT hr;
CicIMCLock imcLock(hIMC);
-
- hr = imcLock.m_hr;
- if (!imcLock)
- hr = E_FAIL;
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(imcLock.m_hr))
ret = !!(imcLock.get().fdwInit & INIT_GUIDMAP);
return ret;
diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h
index 7b2f2fff822..cb482318830 100644
--- a/dll/ime/msctfime/msctfime.h
+++ b/dll/ime/msctfime/msctfime.h
@@ -40,6 +40,14 @@ EXTERN_C BOOLEAN WINAPI DllShutdownInProgress(VOID);
HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread);
HRESULT UninitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread);
+static inline HIMC GetActiveContext(VOID)
+{
+ HWND hwndFocus = ::GetFocus();
+ if (!hwndFocus)
+ hwndFocus = ::GetActiveWindow();
+ return ::ImmGetContext(hwndFocus);
+}
+
DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95,
0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9);
DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8,
0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF);
diff --git a/dll/ime/msctfime/ui.cpp b/dll/ime/msctfime/ui.cpp
index 660d20824d6..2fec663f97f 100644
--- a/dll/ime/msctfime/ui.cpp
+++ b/dll/ime/msctfime/ui.cpp
@@ -357,8 +357,6 @@ STDMETHODIMP_(LRESULT)
CDefCompFrameWindow::OnWindowPosChanged(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
CicIMCLock imcLock(m_hIMC);
- if (!imcLock)
- imcLock.m_hr = E_FAIL;
if (SUCCEEDED(imcLock.m_hr))
::SendMessage(imcLock.get().hWnd, WM_IME_NOTIFY, 0xF, (LPARAM)m_hIMC);
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
diff --git a/sdk/lib/cicero/cicimc.h b/sdk/lib/cicero/cicimc.h
index 779884abfdd..7db0783cee5 100644
--- a/sdk/lib/cicero/cicimc.h
+++ b/sdk/lib/cicero/cicimc.h
@@ -45,8 +45,7 @@ class CicIMCCLock : public CIC_IMCC_LOCK<T_DATA>
public:
CicIMCCLock(HIMCC hIMCC) : CIC_IMCC_LOCK<T_DATA>(hIMCC)
{
- if (hIMCC)
- _LockIMCC(this->m_hIMCC, &this->m_pIMCC);
+ this->m_hr = _LockIMCC(this->m_hIMCC, &this->m_pIMCC);
}
~CicIMCCLock()
{