[IMM32] Rewrite ImmGetRegisterWordStyleA/W (#3901)

- Rewrite ImmGetRegisterWordStyleA and ImmGetRegisterWordStyleW functions.
- Modify win32ss/include/imetable.h.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2021-08-14 10:39:20 +09:00 committed by GitHub
parent 1da5d7a305
commit 19d24143e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 98 additions and 35 deletions

View file

@ -3087,26 +3087,58 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
UINT WINAPI ImmGetRegisterWordStyleA(
HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf)
{
ImmHkl *immHkl = IMM_GetImmHkl(hKL);
TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf);
if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle)
{
if (!is_kbd_ime_unicode(immHkl))
return immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)lpStyleBuf);
else
{
STYLEBUFW sbw;
UINT rc;
UINT iItem, ret = 0;
PIMEDPI pImeDpi;
LPSTYLEBUFA pDestA;
LPSTYLEBUFW pSrcW, pNewStylesW = NULL;
size_t cchW;
INT cchA;
rc = immHkl->pImeGetRegisterWordStyle(nItem,&sbw);
WideCharToMultiByte(CP_ACP, 0, sbw.szDescription, -1,
lpStyleBuf->szDescription, 32, NULL, NULL);
lpStyleBuf->dwStyle = sbw.dwStyle;
return rc;
TRACE("(%p, %u, %p)\n", hKL, nItem, lpStyleBuf);
pImeDpi = ImmLockOrLoadImeDpi(hKL);
if (!pImeDpi)
return 0;
if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE))
{
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, lpStyleBuf);
goto Quit;
}
if (nItem > 0)
{
pNewStylesW = Imm32HeapAlloc(0, nItem * sizeof(STYLEBUFW));
if (!pNewStylesW)
goto Quit;
}
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, pNewStylesW);
if (nItem > 0)
{
/* lpStyleBuf <-- pNewStylesW */
for (iItem = 0; iItem < ret; ++iItem)
{
pSrcW = &pNewStylesW[iItem];
pDestA = &lpStyleBuf[iItem];
pDestA->dwStyle = pSrcW->dwStyle;
StringCchLengthW(pSrcW->szDescription, _countof(pSrcW->szDescription), &cchW);
cchA = WideCharToMultiByte(CP_ACP, MB_PRECOMPOSED,
pSrcW->szDescription, (INT)cchW,
pDestA->szDescription, _countof(pDestA->szDescription),
NULL, NULL);
if (cchA > _countof(pDestA->szDescription) - 1)
cchA = _countof(pDestA->szDescription) - 1;
pDestA->szDescription[cchA] = 0;
}
}
else
return 0;
Quit:
if (pNewStylesW)
HeapFree(g_hImm32Heap, 0, pNewStylesW);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
/***********************************************************************
@ -3115,26 +3147,57 @@ UINT WINAPI ImmGetRegisterWordStyleA(
UINT WINAPI ImmGetRegisterWordStyleW(
HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf)
{
ImmHkl *immHkl = IMM_GetImmHkl(hKL);
TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf);
if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle)
{
if (is_kbd_ime_unicode(immHkl))
return immHkl->pImeGetRegisterWordStyle(nItem,lpStyleBuf);
else
{
STYLEBUFA sba;
UINT rc;
UINT iItem, ret = 0;
PIMEDPI pImeDpi;
LPSTYLEBUFA pSrcA, pNewStylesA = NULL;
LPSTYLEBUFW pDestW;
size_t cchA;
INT cchW;
rc = immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)&sba);
MultiByteToWideChar(CP_ACP, 0, sba.szDescription, -1,
lpStyleBuf->szDescription, 32);
lpStyleBuf->dwStyle = sba.dwStyle;
return rc;
TRACE("(%p, %u, %p)\n", hKL, nItem, lpStyleBuf);
pImeDpi = ImmLockOrLoadImeDpi(hKL);
if (!pImeDpi)
return 0;
if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)
{
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, lpStyleBuf);
goto Quit;
}
if (nItem > 0)
{
pNewStylesA = Imm32HeapAlloc(0, nItem * sizeof(STYLEBUFA));
if (!pNewStylesA)
goto Quit;
}
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, pNewStylesA);
if (nItem > 0)
{
/* lpStyleBuf <-- pNewStylesA */
for (iItem = 0; iItem < ret; ++iItem)
{
pSrcA = &pNewStylesA[iItem];
pDestW = &lpStyleBuf[iItem];
pDestW->dwStyle = pSrcA->dwStyle;
StringCchLengthA(pSrcA->szDescription, _countof(pSrcA->szDescription), &cchA);
cchW = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
pSrcA->szDescription, (INT)cchA,
pDestW->szDescription, _countof(pDestW->szDescription));
if (cchW > _countof(pDestW->szDescription) - 1)
cchW = _countof(pDestW->szDescription) - 1;
pDestW->szDescription[cchW] = 0;
}
}
else
return 0;
Quit:
if (pNewStylesA)
HeapFree(g_hImm32Heap, 0, pNewStylesA);
ImmUnlockImeDpi(pImeDpi);
return ret;
}
/***********************************************************************

View file

@ -3,7 +3,7 @@ DEFINE_IME_ENTRY(BOOL, ImeInquire, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DW
DEFINE_IME_ENTRY(DWORD, ImeConversionList, (HIMC hIMC, LPCVOID lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeRegisterWord, (LPCVOID lpszReading, DWORD dwStyle, LPCVOID lpszString), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeUnregisterWord, (LPCVOID lpszReading, DWORD dwStyle, LPCVOID lpszString), FALSE)
DEFINE_IME_ENTRY(UINT, ImeGetRegisterWordStyle, (UINT nItem, LPSTYLEBUFW lpStyleBuf), FALSE)
DEFINE_IME_ENTRY(UINT, ImeGetRegisterWordStyle, (UINT nItem, LPVOID lpStyleBuf), FALSE)
DEFINE_IME_ENTRY(UINT, ImeEnumRegisterWord, (HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc, LPCVOID lpszReading, DWORD dwStyle, LPCVOID lpszString, LPVOID lpData), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeConfigure, (HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeDestroy, (UINT uReserved), FALSE)