mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[IMM32] Rewrite ImmGetCompositionFontA/W (#3813)
- Rewrite ImmGetCompositionFontA and ImmGetCompositionFontW functions. - Add INIT_* macro definitions in <ddk/imm.h>. CORE-11700
This commit is contained in:
parent
ee3b5b44c1
commit
1558e6d0b3
2 changed files with 82 additions and 14 deletions
|
@ -1457,24 +1457,64 @@ BOOL WINAPI ImmGetCandidateWindow(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
|
||||
{
|
||||
size_t cch;
|
||||
RtlCopyMemory(plfW, plfA, offsetof(LOGFONTA, lfFaceName));
|
||||
StringCchLengthA(plfA->lfFaceName, _countof(plfA->lfFaceName), &cch);
|
||||
cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, plfA->lfFaceName, (INT)cch,
|
||||
plfW->lfFaceName, _countof(plfW->lfFaceName));
|
||||
if (cch > _countof(plfW->lfFaceName) - 1)
|
||||
cch = _countof(plfW->lfFaceName) - 1;
|
||||
plfW->lfFaceName[cch] = 0;
|
||||
}
|
||||
|
||||
static VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
|
||||
{
|
||||
size_t cch;
|
||||
RtlCopyMemory(plfA, plfW, offsetof(LOGFONTW, lfFaceName));
|
||||
StringCchLengthW(plfW->lfFaceName, _countof(plfW->lfFaceName), &cch);
|
||||
cch = WideCharToMultiByte(CP_ACP, 0, plfW->lfFaceName, (INT)cch,
|
||||
plfA->lfFaceName, _countof(plfA->lfFaceName), NULL, NULL);
|
||||
if (cch > _countof(plfA->lfFaceName) - 1)
|
||||
cch = _countof(plfA->lfFaceName) - 1;
|
||||
plfA->lfFaceName[cch] = 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ImmGetCompositionFontA (IMM32.@)
|
||||
*/
|
||||
BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
||||
{
|
||||
LOGFONTW lfW;
|
||||
BOOL rc;
|
||||
PCLIENTIMC pClientImc;
|
||||
BOOL ret = FALSE, bWide;
|
||||
LPINPUTCONTEXT pIC;
|
||||
|
||||
TRACE("(%p, %p):\n", hIMC, lplf);
|
||||
TRACE("ImmGetCompositionFontA(%p, %p)\n", hIMC, lplf);
|
||||
|
||||
rc = ImmGetCompositionFontW(hIMC,&lfW);
|
||||
if (!rc || !lplf)
|
||||
pClientImc = ImmLockClientImc(hIMC);
|
||||
if (pClientImc == NULL)
|
||||
return FALSE;
|
||||
|
||||
memcpy(lplf,&lfW,sizeof(LOGFONTA));
|
||||
WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName,
|
||||
LF_FACESIZE, NULL, NULL);
|
||||
return TRUE;
|
||||
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
|
||||
ImmUnlockClientImc(pClientImc);
|
||||
|
||||
pIC = ImmLockIMC(hIMC);
|
||||
if (pIC == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (pIC->fdwInit & INIT_LOGFONT)
|
||||
{
|
||||
if (bWide)
|
||||
LogFontWideToAnsi(&pIC->lfFont.W, lplf);
|
||||
else
|
||||
*lplf = pIC->lfFont.A;
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
ImmUnlockIMC(hIMC);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -1482,16 +1522,36 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
|
|||
*/
|
||||
BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
|
||||
{
|
||||
InputContextData *data = get_imc_data(hIMC);
|
||||
PCLIENTIMC pClientImc;
|
||||
BOOL bWide;
|
||||
LPINPUTCONTEXT pIC;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
TRACE("(%p, %p):\n", hIMC, lplf);
|
||||
TRACE("ImmGetCompositionFontW(%p, %p)\n", hIMC, lplf);
|
||||
|
||||
if (!data || !lplf)
|
||||
pClientImc = ImmLockClientImc(hIMC);
|
||||
if (pClientImc == NULL)
|
||||
return FALSE;
|
||||
|
||||
*lplf = data->IMC.lfFont.W;
|
||||
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
|
||||
ImmUnlockClientImc(pClientImc);
|
||||
|
||||
return TRUE;
|
||||
pIC = ImmLockIMC(hIMC);
|
||||
if (pIC == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (pIC->fdwInit & INIT_LOGFONT)
|
||||
{
|
||||
if (bWide)
|
||||
*lplf = pIC->lfFont.W;
|
||||
else
|
||||
LogFontAnsiToWide(&pIC->lfFont.A, lplf);
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
ImmUnlockIMC(hIMC);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,6 +87,14 @@ C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x134);
|
|||
C_ASSERT(sizeof(INPUTCONTEXT) == 0x140);
|
||||
#endif
|
||||
|
||||
// bits of fdwInit of INPUTCONTEXT
|
||||
#define INIT_STATUSWNDPOS 0x00000001
|
||||
#define INIT_CONVERSION 0x00000002
|
||||
#define INIT_SENTENCE 0x00000004
|
||||
#define INIT_LOGFONT 0x00000008
|
||||
#define INIT_COMPFORM 0x00000010
|
||||
#define INIT_SOFTKBDPOS 0x00000020
|
||||
|
||||
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC);
|
||||
|
||||
#endif /* _WINE_IMM_H_ */
|
||||
|
|
Loading…
Reference in a new issue