@@ -3087,26 +3087,58 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
3087
3087
UINT WINAPI ImmGetRegisterWordStyleA (
3088
3088
HKL hKL , UINT nItem , LPSTYLEBUFA lpStyleBuf )
3089
3089
{
3090
- ImmHkl * immHkl = IMM_GetImmHkl (hKL );
3091
- TRACE ("(%p, %d, %p):\n" , hKL , nItem , lpStyleBuf );
3092
- if (immHkl -> hIME && immHkl -> pImeGetRegisterWordStyle )
3090
+ UINT iItem , ret = 0 ;
3091
+ PIMEDPI pImeDpi ;
3092
+ LPSTYLEBUFA pDestA ;
3093
+ LPSTYLEBUFW pSrcW , pNewStylesW = NULL ;
3094
+ size_t cchW ;
3095
+ INT cchA ;
3096
+
3097
+ TRACE ("(%p, %u, %p)\n" , hKL , nItem , lpStyleBuf );
3098
+
3099
+ pImeDpi = ImmLockOrLoadImeDpi (hKL );
3100
+ if (!pImeDpi )
3101
+ return 0 ;
3102
+
3103
+ if (!(pImeDpi -> ImeInfo .fdwProperty & IME_PROP_UNICODE ))
3093
3104
{
3094
- if (!is_kbd_ime_unicode (immHkl ))
3095
- return immHkl -> pImeGetRegisterWordStyle (nItem ,(LPSTYLEBUFW )lpStyleBuf );
3096
- else
3097
- {
3098
- STYLEBUFW sbw ;
3099
- UINT rc ;
3105
+ ret = pImeDpi -> ImeGetRegisterWordStyle (nItem , lpStyleBuf );
3106
+ goto Quit ;
3107
+ }
3100
3108
3101
- rc = immHkl -> pImeGetRegisterWordStyle (nItem ,& sbw );
3102
- WideCharToMultiByte (CP_ACP , 0 , sbw .szDescription , -1 ,
3103
- lpStyleBuf -> szDescription , 32 , NULL , NULL );
3104
- lpStyleBuf -> dwStyle = sbw .dwStyle ;
3105
- return rc ;
3109
+ if (nItem > 0 )
3110
+ {
3111
+ pNewStylesW = Imm32HeapAlloc (0 , nItem * sizeof (STYLEBUFW ));
3112
+ if (!pNewStylesW )
3113
+ goto Quit ;
3114
+ }
3115
+
3116
+ ret = pImeDpi -> ImeGetRegisterWordStyle (nItem , pNewStylesW );
3117
+
3118
+ if (nItem > 0 )
3119
+ {
3120
+ /* lpStyleBuf <-- pNewStylesW */
3121
+ for (iItem = 0 ; iItem < ret ; ++ iItem )
3122
+ {
3123
+ pSrcW = & pNewStylesW [iItem ];
3124
+ pDestA = & lpStyleBuf [iItem ];
3125
+ pDestA -> dwStyle = pSrcW -> dwStyle ;
3126
+ StringCchLengthW (pSrcW -> szDescription , _countof (pSrcW -> szDescription ), & cchW );
3127
+ cchA = WideCharToMultiByte (CP_ACP , MB_PRECOMPOSED ,
3128
+ pSrcW -> szDescription , (INT )cchW ,
3129
+ pDestA -> szDescription , _countof (pDestA -> szDescription ),
3130
+ NULL , NULL );
3131
+ if (cchA > _countof (pDestA -> szDescription ) - 1 )
3132
+ cchA = _countof (pDestA -> szDescription ) - 1 ;
3133
+ pDestA -> szDescription [cchA ] = 0 ;
3106
3134
}
3107
3135
}
3108
- else
3109
- return 0 ;
3136
+
3137
+ Quit :
3138
+ if (pNewStylesW )
3139
+ HeapFree (g_hImm32Heap , 0 , pNewStylesW );
3140
+ ImmUnlockImeDpi (pImeDpi );
3141
+ return ret ;
3110
3142
}
3111
3143
3112
3144
/***********************************************************************
@@ -3115,26 +3147,57 @@ UINT WINAPI ImmGetRegisterWordStyleA(
3115
3147
UINT WINAPI ImmGetRegisterWordStyleW (
3116
3148
HKL hKL , UINT nItem , LPSTYLEBUFW lpStyleBuf )
3117
3149
{
3118
- ImmHkl * immHkl = IMM_GetImmHkl (hKL );
3119
- TRACE ("(%p, %d, %p):\n" , hKL , nItem , lpStyleBuf );
3120
- if (immHkl -> hIME && immHkl -> pImeGetRegisterWordStyle )
3150
+ UINT iItem , ret = 0 ;
3151
+ PIMEDPI pImeDpi ;
3152
+ LPSTYLEBUFA pSrcA , pNewStylesA = NULL ;
3153
+ LPSTYLEBUFW pDestW ;
3154
+ size_t cchA ;
3155
+ INT cchW ;
3156
+
3157
+ TRACE ("(%p, %u, %p)\n" , hKL , nItem , lpStyleBuf );
3158
+
3159
+ pImeDpi = ImmLockOrLoadImeDpi (hKL );
3160
+ if (!pImeDpi )
3161
+ return 0 ;
3162
+
3163
+ if (pImeDpi -> ImeInfo .fdwProperty & IME_PROP_UNICODE )
3121
3164
{
3122
- if (is_kbd_ime_unicode (immHkl ))
3123
- return immHkl -> pImeGetRegisterWordStyle (nItem ,lpStyleBuf );
3124
- else
3125
- {
3126
- STYLEBUFA sba ;
3127
- UINT rc ;
3165
+ ret = pImeDpi -> ImeGetRegisterWordStyle (nItem , lpStyleBuf );
3166
+ goto Quit ;
3167
+ }
3128
3168
3129
- rc = immHkl -> pImeGetRegisterWordStyle (nItem ,(LPSTYLEBUFW )& sba );
3130
- MultiByteToWideChar (CP_ACP , 0 , sba .szDescription , -1 ,
3131
- lpStyleBuf -> szDescription , 32 );
3132
- lpStyleBuf -> dwStyle = sba .dwStyle ;
3133
- return rc ;
3169
+ if (nItem > 0 )
3170
+ {
3171
+ pNewStylesA = Imm32HeapAlloc (0 , nItem * sizeof (STYLEBUFA ));
3172
+ if (!pNewStylesA )
3173
+ goto Quit ;
3174
+ }
3175
+
3176
+ ret = pImeDpi -> ImeGetRegisterWordStyle (nItem , pNewStylesA );
3177
+
3178
+ if (nItem > 0 )
3179
+ {
3180
+ /* lpStyleBuf <-- pNewStylesA */
3181
+ for (iItem = 0 ; iItem < ret ; ++ iItem )
3182
+ {
3183
+ pSrcA = & pNewStylesA [iItem ];
3184
+ pDestW = & lpStyleBuf [iItem ];
3185
+ pDestW -> dwStyle = pSrcA -> dwStyle ;
3186
+ StringCchLengthA (pSrcA -> szDescription , _countof (pSrcA -> szDescription ), & cchA );
3187
+ cchW = MultiByteToWideChar (CP_ACP , MB_PRECOMPOSED ,
3188
+ pSrcA -> szDescription , (INT )cchA ,
3189
+ pDestW -> szDescription , _countof (pDestW -> szDescription ));
3190
+ if (cchW > _countof (pDestW -> szDescription ) - 1 )
3191
+ cchW = _countof (pDestW -> szDescription ) - 1 ;
3192
+ pDestW -> szDescription [cchW ] = 0 ;
3134
3193
}
3135
3194
}
3136
- else
3137
- return 0 ;
3195
+
3196
+ Quit :
3197
+ if (pNewStylesA )
3198
+ HeapFree (g_hImm32Heap , 0 , pNewStylesA );
3199
+ ImmUnlockImeDpi (pImeDpi );
3200
+ return ret ;
3138
3201
}
3139
3202
3140
3203
/***********************************************************************
0 commit comments