https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b7288df782bb70c237cf…
commit 9b7288df782bb70c237cf839fbfe40f6194cf631
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Aug 12 12:31:06 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Aug 12 12:31:06 2021 +0900
[IMM32] Rewrite ImmUnregisterWordW (#3894)
Implementing Japanese input... CORE-11700
---
dll/win32/imm32/imm.c | 66 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 47 insertions(+), 19 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index a64f38246f7..50820ba5601 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -4163,28 +4163,56 @@ Quit:
BOOL WINAPI ImmUnregisterWordW(
HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister)
{
- ImmHkl *immHkl = IMM_GetImmHkl(hKL);
- TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle,
- debugstr_w(lpszUnregister));
- if (immHkl->hIME && immHkl->pImeUnregisterWord)
+ BOOL ret = FALSE;
+ PIMEDPI pImeDpi;
+ LPSTR pszReadingA = NULL, pszUnregisterA = NULL;
+ INT cchW, cchA;
+
+ TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
+ debugstr_w(lpszUnregister));
+
+ pImeDpi = ImmLockOrLoadImeDpi(hKL);
+ if (!pImeDpi)
+ return FALSE;
+
+ if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)
{
- if (is_kbd_ime_unicode(immHkl))
- return immHkl->pImeUnregisterWord(lpszReading,dwStyle,lpszUnregister);
- else
- {
- LPSTR lpszaReading = strdupWtoA(lpszReading);
- LPSTR lpszaUnregister = strdupWtoA(lpszUnregister);
- BOOL rc;
+ ret = pImeDpi->ImeUnregisterWord(lpszReading, dwStyle, lpszUnregister);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+ }
- rc = immHkl->pImeUnregisterWord((LPCWSTR)lpszaReading,dwStyle,
- (LPCWSTR)lpszaUnregister);
- HeapFree(GetProcessHeap(),0,lpszaReading);
- HeapFree(GetProcessHeap(),0,lpszaUnregister);
- return rc;
- }
+ if (lpszReading)
+ {
+ cchW = lstrlenW(lpszReading);
+ cchA = (cchW + 1) * sizeof(WCHAR);
+ pszReadingA = Imm32HeapAlloc(0, cchA);
+ if (!pszReadingA)
+ goto Quit;
+ cchA = WideCharToMultiByte(CP_ACP, 0, lpszReading, cchW, pszReadingA, cchA, NULL,
NULL);
+ pszReadingA[cchA] = 0;
}
- else
- return FALSE;
+
+ if (lpszUnregister)
+ {
+ cchW = lstrlenW(lpszUnregister);
+ cchA = (cchW + 1) * sizeof(WCHAR);
+ pszUnregisterA = Imm32HeapAlloc(0, cchA);
+ if (!pszUnregisterA)
+ goto Quit;
+ cchA = WideCharToMultiByte(CP_ACP, 0, lpszUnregister, cchW, pszUnregisterA, cchA,
NULL, NULL);
+ pszUnregisterA[cchA] = 0;
+ }
+
+ ret = pImeDpi->ImeUnregisterWord(pszReadingA, dwStyle, pszUnregisterA);
+
+Quit:
+ if (pszReadingA)
+ HeapFree(g_hImm32Heap, 0, pszReadingA);
+ if (pszUnregisterA)
+ HeapFree(g_hImm32Heap, 0, pszUnregisterA);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
}
/***********************************************************************