https://git.reactos.org/?p=reactos.git;a=commitdiff;h=94285dce4d54e2782a3c2…
commit 94285dce4d54e2782a3c2795c46ca25dc5130156
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Aug 12 12:29:02 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Aug 12 12:29:02 2021 +0900
[IMM32] Rewrite ImmRegisterWordW (#3892)
Implementing Japanese input... CORE-11700
---
dll/win32/imm32/imm.c | 68 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 48 insertions(+), 20 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 963ebb9acab..f7ec97bcc42 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -3394,7 +3394,7 @@ BOOL WINAPI ImmRegisterWordA(
pszRegisterW[cch] = 0;
}
- ret = ImmRegisterWordW(hKL, pszReadingW, dwStyle, pszRegisterW);
+ ret = pImeDpi->ImeRegisterWord(pszReadingW, dwStyle, pszRegisterW);
Quit:
if (pszReadingW)
@@ -3411,28 +3411,56 @@ Quit:
BOOL WINAPI ImmRegisterWordW(
HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister)
{
- ImmHkl *immHkl = IMM_GetImmHkl(hKL);
- TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle,
- debugstr_w(lpszRegister));
- if (immHkl->hIME && immHkl->pImeRegisterWord)
+ BOOL ret = FALSE;
+ PIMEDPI pImeDpi;
+ LPSTR pszReadingA = NULL, pszRegisterA = NULL;
+ INT cchW, cchA;
+
+ TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_w(lpszReading), dwStyle,
+ debugstr_w(lpszRegister));
+
+ pImeDpi = ImmLockOrLoadImeDpi(hKL);
+ if (!pImeDpi)
+ return FALSE;
+
+ if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)
{
- if (is_kbd_ime_unicode(immHkl))
- return immHkl->pImeRegisterWord(lpszReading,dwStyle,lpszRegister);
- else
- {
- LPSTR lpszaReading = strdupWtoA(lpszReading);
- LPSTR lpszaRegister = strdupWtoA(lpszRegister);
- BOOL rc;
+ ret = pImeDpi->ImeRegisterWord(lpszReading, dwStyle, lpszRegister);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+ }
- rc = immHkl->pImeRegisterWord((LPCWSTR)lpszaReading,dwStyle,
- (LPCWSTR)lpszaRegister);
- HeapFree(GetProcessHeap(),0,lpszaReading);
- HeapFree(GetProcessHeap(),0,lpszaRegister);
- 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 (lpszRegister)
+ {
+ cchW = lstrlenW(lpszRegister);
+ cchA = (cchW + 1) * sizeof(WCHAR);
+ pszRegisterA = Imm32HeapAlloc(0, cchA);
+ if (!pszRegisterA)
+ goto Quit;
+ cchA = WideCharToMultiByte(CP_ACP, 0, lpszRegister, cchW, pszRegisterA, cchA,
NULL, NULL);
+ pszRegisterA[cchA] = 0;
+ }
+
+ ret = pImeDpi->ImeRegisterWord(pszReadingA, dwStyle, pszRegisterA);
+
+Quit:
+ if (pszReadingA)
+ HeapFree(g_hImm32Heap, 0, pszReadingA);
+ if (pszRegisterA)
+ HeapFree(g_hImm32Heap, 0, pszRegisterA);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
}
/***********************************************************************