Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

regword.c

Go to the documentation of this file.
00001 /**************************************************************************\ 00002 * Module Name: regword.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * Word registration into IME dictionary 00007 * 00008 * History: 00009 * 03-Jan-1996 wkwok Created 00010 \**************************************************************************/ 00011 00012 #include "precomp.h" 00013 #pragma hdrstop 00014 00015 00016 /***************************************************************************\ 00017 * ImmRegisterWordA 00018 * 00019 * Registers a string into the dictionary of the IME with the specified hKL. 00020 * 00021 * History: 00022 * 01-Mar-1996 wkwok Created 00023 \***************************************************************************/ 00024 00025 BOOL WINAPI ImmRegisterWordA( 00026 HKL hKL, 00027 LPCSTR lpszReading, 00028 DWORD dwStyle, 00029 LPCSTR lpszString) 00030 { 00031 PIMEDPI pImeDpi; 00032 LPWSTR lpwszReading; 00033 LPWSTR lpwszString; 00034 INT cchReading; 00035 INT cchString; 00036 INT i; 00037 BOOL fRet; 00038 00039 pImeDpi = FindOrLoadImeDpi(hKL); 00040 if (pImeDpi == NULL) { 00041 RIPMSG0(RIP_WARNING, "ImmRegisterWordA: no pImeDpi entry."); 00042 return FALSE; 00043 } 00044 00045 if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)) { 00046 /* 00047 * Doesn't need A/W conversion. Calls directly to IME to 00048 * register the string. 00049 */ 00050 fRet = (*pImeDpi->pfn.ImeRegisterWord.a)(lpszReading, dwStyle, lpszString); 00051 ImmUnlockImeDpi(pImeDpi); 00052 return fRet; 00053 } 00054 00055 /* 00056 * ANSI caller, Unicode IME. Needs A/W conversion on 00057 * lpszReading and lpszString. 00058 */ 00059 if (lpszReading != NULL) { 00060 cchReading = strlen(lpszReading) + sizeof(CHAR); 00061 lpwszReading = ImmLocalAlloc(0, cchReading * sizeof(WCHAR)); 00062 if (lpwszReading == NULL) { 00063 RIPMSG0(RIP_WARNING, "ImmRegisterWordA: memory failure."); 00064 ImmUnlockImeDpi(pImeDpi); 00065 return FALSE; 00066 } 00067 00068 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00069 (DWORD)MB_PRECOMPOSED, 00070 (LPSTR)lpszReading, // src 00071 (INT)strlen(lpszReading), 00072 (LPWSTR)lpwszReading, // dest 00073 cchReading); 00074 lpwszReading[i] = L'\0'; 00075 } 00076 else { 00077 lpwszReading = NULL; 00078 } 00079 00080 if (lpszString != NULL) { 00081 cchString = strlen(lpszString) + sizeof(CHAR); 00082 lpwszString = ImmLocalAlloc(0, cchString * sizeof(WCHAR)); 00083 if (lpwszString == NULL) { 00084 RIPMSG0(RIP_WARNING, "ImmRegisterWordA: memory failure."); 00085 if (lpwszReading != NULL) 00086 ImmLocalFree(lpwszReading); 00087 ImmUnlockImeDpi(pImeDpi); 00088 return FALSE; 00089 } 00090 00091 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00092 (DWORD)MB_PRECOMPOSED, 00093 (LPSTR)lpszString, // src 00094 (INT)strlen(lpszString), 00095 (LPWSTR)lpwszString, // dest 00096 cchString); 00097 lpwszString[i] = L'\0'; 00098 } 00099 else { 00100 lpwszString = NULL; 00101 } 00102 00103 fRet = ImmRegisterWordW(hKL, lpwszReading, dwStyle, lpwszString); 00104 00105 if (lpwszReading != NULL) 00106 ImmLocalFree(lpwszReading); 00107 00108 if (lpwszString != NULL) 00109 ImmLocalFree(lpwszString); 00110 00111 ImmUnlockImeDpi(pImeDpi); 00112 return fRet; 00113 } 00114 00115 00116 BOOL WINAPI ImmRegisterWordW( 00117 HKL hKL, 00118 LPCWSTR lpwszReading, 00119 DWORD dwStyle, 00120 LPCWSTR lpwszString) 00121 { 00122 PIMEDPI pImeDpi; 00123 LPSTR lpszReading; 00124 LPSTR lpszString; 00125 INT cchReading; 00126 INT cchString; 00127 INT i; 00128 BOOL fRet; 00129 00130 pImeDpi = FindOrLoadImeDpi(hKL); 00131 if (pImeDpi == NULL) { 00132 RIPMSG0(RIP_WARNING, "ImmRegisterWordW: no pImeDpi entry."); 00133 return FALSE; 00134 } 00135 00136 if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE) { 00137 /* 00138 * Doesn't need W/A conversion. Calls directly to IME to 00139 * register the string. 00140 */ 00141 fRet = (*pImeDpi->pfn.ImeRegisterWord.w)(lpwszReading, dwStyle, lpwszString); 00142 ImmUnlockImeDpi(pImeDpi); 00143 return fRet; 00144 } 00145 00146 /* 00147 * Unicode caller, ANSI IME. Needs W/A conversion on 00148 * lpwszReading and lpwszString. 00149 */ 00150 if (lpwszReading != NULL) { 00151 cchReading = (wcslen(lpwszReading) + 1) * sizeof(WCHAR); 00152 lpszReading = ImmLocalAlloc(0, cchReading); 00153 if (lpszReading == NULL) { 00154 RIPMSG0(RIP_WARNING, "ImmRegisterWordW: memory failure."); 00155 ImmUnlockImeDpi(pImeDpi); 00156 return FALSE; 00157 } 00158 00159 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00160 (DWORD)0, 00161 (LPWSTR)lpwszReading, // src 00162 (INT)wcslen(lpwszReading), 00163 (LPSTR)lpszReading, // dest 00164 cchReading, 00165 (LPSTR)NULL, 00166 (LPBOOL)NULL); 00167 lpszReading[i] = '\0'; 00168 } 00169 else { 00170 lpszReading = NULL; 00171 } 00172 00173 if (lpwszString != NULL) { 00174 cchString = (wcslen(lpwszString) + 1) * sizeof(WCHAR); 00175 lpszString = ImmLocalAlloc(0, cchString); 00176 if (lpszString == NULL) { 00177 RIPMSG0(RIP_WARNING, "ImmRegisterWordW: memory failure."); 00178 if (lpszReading != NULL) 00179 ImmLocalFree(lpszReading); 00180 ImmUnlockImeDpi(pImeDpi); 00181 return FALSE; 00182 } 00183 00184 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00185 (DWORD)0, 00186 (LPWSTR)lpwszString, // src 00187 (INT)wcslen(lpwszString), 00188 (LPSTR)lpszString, // dest 00189 cchString, 00190 (LPSTR)NULL, 00191 (LPBOOL)NULL); 00192 lpszString[i] = '\0'; 00193 } 00194 else { 00195 lpszString = NULL; 00196 } 00197 00198 fRet = ImmRegisterWordA(hKL, lpszReading, dwStyle, lpszString); 00199 00200 if (lpszReading != NULL) 00201 ImmLocalFree(lpszReading); 00202 00203 if (lpszString != NULL) 00204 ImmLocalFree(lpszString); 00205 00206 ImmUnlockImeDpi(pImeDpi); 00207 return fRet; 00208 } 00209 00210 00211 BOOL WINAPI ImmUnregisterWordA( 00212 HKL hKL, 00213 LPCSTR lpszReading, 00214 DWORD dwStyle, 00215 LPCSTR lpszString) 00216 { 00217 PIMEDPI pImeDpi; 00218 LPWSTR lpwszReading; 00219 LPWSTR lpwszString; 00220 INT cchReading; 00221 INT cchString; 00222 INT i; 00223 BOOL fRet; 00224 00225 pImeDpi = FindOrLoadImeDpi(hKL); 00226 if (pImeDpi == NULL) { 00227 RIPMSG0(RIP_WARNING, "ImmUnregisterWordA: no pImeDpi entry."); 00228 return FALSE; 00229 } 00230 00231 if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)) { 00232 /* 00233 * Doesn't need A/W conversion. Calls directly to IME to 00234 * un-register the string. 00235 */ 00236 fRet = (*pImeDpi->pfn.ImeUnregisterWord.a)(lpszReading, dwStyle, lpszString); 00237 ImmUnlockImeDpi(pImeDpi); 00238 return fRet; 00239 } 00240 00241 /* 00242 * ANSI caller, Unicode IME. Needs A/W conversion on 00243 * lpszReading and lpszString. 00244 */ 00245 if (lpszReading != NULL) { 00246 cchReading = strlen(lpszReading) + sizeof(CHAR); 00247 lpwszReading = ImmLocalAlloc(0, cchReading * sizeof(WCHAR)); 00248 if (lpwszReading == NULL) { 00249 RIPMSG0(RIP_WARNING, "ImmUnregisterWordA: memory failure."); 00250 ImmUnlockImeDpi(pImeDpi); 00251 return FALSE; 00252 } 00253 00254 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00255 (DWORD)MB_PRECOMPOSED, 00256 (LPSTR)lpszReading, // src 00257 (INT)strlen(lpszReading), 00258 (LPWSTR)lpwszReading, // dest 00259 cchReading); 00260 lpwszReading[i] = L'\0'; 00261 } 00262 else { 00263 lpwszReading = NULL; 00264 } 00265 00266 if (lpszString != NULL) { 00267 cchString = strlen(lpszString) + sizeof(CHAR); 00268 lpwszString = ImmLocalAlloc(0, cchString * sizeof(WCHAR)); 00269 if (lpwszString == NULL) { 00270 RIPMSG0(RIP_WARNING, "ImmUnregisterWordA: memory failure."); 00271 if (lpwszReading != NULL) 00272 ImmLocalFree(lpwszReading); 00273 ImmUnlockImeDpi(pImeDpi); 00274 return FALSE; 00275 } 00276 00277 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00278 (DWORD)MB_PRECOMPOSED, 00279 (LPSTR)lpszString, // src 00280 (INT)strlen(lpszString), 00281 (LPWSTR)lpwszString, // dest 00282 cchString); 00283 lpwszString[i] = L'\0'; 00284 } 00285 else { 00286 lpwszString = NULL; 00287 } 00288 00289 fRet = ImmUnregisterWordW(hKL, lpwszReading, dwStyle, lpwszString); 00290 00291 if (lpwszReading != NULL) 00292 ImmLocalFree(lpwszReading); 00293 00294 if (lpwszString != NULL) 00295 ImmLocalFree(lpwszString); 00296 00297 ImmUnlockImeDpi(pImeDpi); 00298 return fRet; 00299 } 00300 00301 00302 BOOL WINAPI ImmUnregisterWordW( 00303 HKL hKL, 00304 LPCWSTR lpwszReading, 00305 DWORD dwStyle, 00306 LPCWSTR lpwszString) 00307 { 00308 PIMEDPI pImeDpi; 00309 LPSTR lpszReading; 00310 LPSTR lpszString; 00311 INT cchReading; 00312 INT cchString; 00313 INT i; 00314 BOOL fRet; 00315 00316 pImeDpi = FindOrLoadImeDpi(hKL); 00317 if (pImeDpi == NULL) { 00318 RIPMSG0(RIP_WARNING, "ImmUnregisterWordW: no pImeDpi entry."); 00319 return FALSE; 00320 } 00321 00322 if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE) { 00323 /* 00324 * Doesn't need W/A conversion. Calls directly to IME to 00325 * register the string. 00326 */ 00327 fRet = (*pImeDpi->pfn.ImeUnregisterWord.w)(lpwszReading, dwStyle, lpwszString); 00328 ImmUnlockImeDpi(pImeDpi); 00329 return fRet; 00330 } 00331 00332 /* 00333 * Unicode caller, ANSI IME. Needs W/A conversion on 00334 * lpwszReading and lpwszString. 00335 */ 00336 if (lpwszReading != NULL) { 00337 cchReading = (wcslen(lpwszReading) + 1) * sizeof(WCHAR); 00338 lpszReading = ImmLocalAlloc(0, cchReading); 00339 if (lpszReading == NULL) { 00340 RIPMSG0(RIP_WARNING, "ImmUnregisterWordW: memory failure."); 00341 ImmUnlockImeDpi(pImeDpi); 00342 return FALSE; 00343 } 00344 00345 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00346 (DWORD)0, 00347 (LPWSTR)lpwszReading, // src 00348 (INT)wcslen(lpwszReading), 00349 (LPSTR)lpszReading, // dest 00350 cchReading, 00351 (LPSTR)NULL, 00352 (LPBOOL)NULL); 00353 lpszReading[i] = '\0'; 00354 } 00355 else { 00356 lpszReading = NULL; 00357 } 00358 00359 if (lpwszString != NULL) { 00360 cchString = (wcslen(lpwszString) + 1) * sizeof(WCHAR); 00361 lpszString = ImmLocalAlloc(0, cchString); 00362 if (lpszString == NULL) { 00363 RIPMSG0(RIP_WARNING, "ImmUnregisterWordW: memory failure."); 00364 if (lpszReading != NULL) 00365 ImmLocalFree(lpszReading); 00366 ImmUnlockImeDpi(pImeDpi); 00367 return FALSE; 00368 } 00369 00370 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00371 (DWORD)0, 00372 (LPWSTR)lpwszString, // src 00373 (INT)wcslen(lpwszString), 00374 (LPSTR)lpszString, // dest 00375 cchString, 00376 (LPSTR)NULL, 00377 (LPBOOL)NULL); 00378 lpszString[i] = '\0'; 00379 } 00380 else { 00381 lpszString = NULL; 00382 } 00383 00384 fRet = ImmUnregisterWordA(hKL, lpszReading, dwStyle, lpszString); 00385 00386 if (lpszReading != NULL) 00387 ImmLocalFree(lpszReading); 00388 00389 if (lpszString != NULL) 00390 ImmLocalFree(lpszString); 00391 00392 ImmUnlockImeDpi(pImeDpi); 00393 return fRet; 00394 } 00395 00396 00397 UINT WINAPI ImmGetRegisterWordStyleA( 00398 HKL hKL, 00399 UINT nItem, 00400 LPSTYLEBUFA lpStyleBufA) 00401 { 00402 PIMEDPI pImeDpi; 00403 LPSTYLEBUFW lpStyleBufW; 00404 UINT uRet; 00405 00406 pImeDpi = FindOrLoadImeDpi(hKL); 00407 if (pImeDpi == NULL) { 00408 RIPMSG0(RIP_WARNING, "ImmGetRegisterWordStyleA: no pImeDpi entry."); 00409 return 0; 00410 } 00411 00412 if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)) { 00413 /* 00414 * Doesn't need A/W conversion. Calls directly to IME to 00415 * get the available style. 00416 */ 00417 uRet = (*pImeDpi->pfn.ImeGetRegisterWordStyle.a)(nItem, lpStyleBufA); 00418 ImmUnlockImeDpi(pImeDpi); 00419 return uRet; 00420 } 00421 00422 /* 00423 * ANSI caller, Unicode IME. Needs A/W conversion on 00424 * lpStyleBufA. 00425 */ 00426 lpStyleBufW = NULL; 00427 00428 if (nItem != 0) { 00429 lpStyleBufW = ImmLocalAlloc(0, nItem * sizeof(STYLEBUFW)); 00430 if (lpStyleBufW == NULL) { 00431 RIPMSG0(RIP_WARNING, "ImmGetRegisterWordStyleA: memory failure."); 00432 ImmUnlockImeDpi(pImeDpi); 00433 return 0; 00434 } 00435 } 00436 00437 uRet = ImmGetRegisterWordStyleW(hKL, nItem, lpStyleBufW); 00438 00439 if (nItem != 0) { 00440 LPSTYLEBUFW lpsbw; 00441 INT i, j; 00442 00443 for (i = 0, lpsbw = lpStyleBufW; i < (INT)uRet; i++, lpsbw++) { 00444 00445 lpStyleBufA->dwStyle = lpsbw->dwStyle; 00446 00447 j = WideCharToMultiByte(IMECodePage(pImeDpi), 00448 (DWORD)0, 00449 (LPWSTR)lpsbw->szDescription, // src 00450 (INT)wcslen(lpsbw->szDescription), 00451 (LPSTR)lpStyleBufA->szDescription, // dest 00452 (INT)sizeof(lpStyleBufA->szDescription), 00453 (LPSTR)NULL, 00454 (LPBOOL)NULL); 00455 lpStyleBufA->szDescription[j] = '\0'; 00456 lpStyleBufA++; 00457 } 00458 } 00459 00460 if (lpStyleBufW != NULL) 00461 ImmLocalFree(lpStyleBufW); 00462 00463 ImmUnlockImeDpi(pImeDpi); 00464 00465 return uRet; 00466 } 00467 00468 00469 UINT WINAPI ImmGetRegisterWordStyleW( 00470 HKL hKL, 00471 UINT nItem, 00472 LPSTYLEBUFW lpStyleBufW) 00473 { 00474 PIMEDPI pImeDpi; 00475 LPSTYLEBUFA lpStyleBufA; 00476 UINT uRet; 00477 00478 pImeDpi = FindOrLoadImeDpi(hKL); 00479 if (pImeDpi == NULL) { 00480 RIPMSG0(RIP_WARNING, "ImmGetRegisterWordStyleA: no pImeDpi entry."); 00481 return 0; 00482 } 00483 00484 if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE) { 00485 /* 00486 * Doesn't need W/A conversion. Calls directly to IME to 00487 * get the available style. 00488 */ 00489 uRet = (*pImeDpi->pfn.ImeGetRegisterWordStyle.w)(nItem, lpStyleBufW); 00490 ImmUnlockImeDpi(pImeDpi); 00491 return uRet; 00492 } 00493 00494 /* 00495 * Unicode caller, ANSI IME. Needs W/A conversion on 00496 * lpStyleBufW. 00497 */ 00498 lpStyleBufA = NULL; 00499 00500 if (nItem != 0) { 00501 lpStyleBufA = ImmLocalAlloc(0, nItem * sizeof(STYLEBUFA)); 00502 if (lpStyleBufA == NULL) { 00503 RIPMSG0(RIP_WARNING, "ImmGetRegisterWordStyleW: memory failure."); 00504 ImmUnlockImeDpi(pImeDpi); 00505 return 0; 00506 } 00507 } 00508 00509 uRet = ImmGetRegisterWordStyleA(hKL, nItem, lpStyleBufA); 00510 00511 if (nItem != 0) { 00512 LPSTYLEBUFA lpsba; 00513 INT i, j; 00514 00515 for (i = 0, lpsba = lpStyleBufA; i < (INT)uRet; i++, lpsba++) { 00516 00517 lpStyleBufW->dwStyle = lpsba->dwStyle; 00518 00519 j = MultiByteToWideChar(IMECodePage(pImeDpi), 00520 (DWORD)MB_PRECOMPOSED, 00521 (LPSTR)lpsba->szDescription, // src 00522 (INT)strlen(lpsba->szDescription), 00523 (LPWSTR)lpStyleBufW->szDescription, // dest 00524 (INT)(sizeof(lpStyleBufW->szDescription)/sizeof(WCHAR))); 00525 lpStyleBufW->szDescription[j] = L'\0'; 00526 lpStyleBufW++; 00527 } 00528 } 00529 00530 if (lpStyleBufA != NULL) 00531 ImmLocalFree(lpStyleBufA); 00532 00533 ImmUnlockImeDpi(pImeDpi); 00534 00535 return uRet; 00536 } 00537 00538 00539 UINT WINAPI ImmEnumRegisterWordA( 00540 HKL hKL, 00541 REGISTERWORDENUMPROCA lpfnRegisterWordEnumProcA, 00542 LPCSTR lpszReading, 00543 DWORD dwStyle, 00544 LPCSTR lpszString, 00545 LPVOID lpData) 00546 { 00547 PIMEDPI pImeDpi; 00548 LPWSTR lpwszReading; 00549 LPWSTR lpwszString; 00550 INT cchReading; 00551 INT cchString; 00552 INT i; 00553 ENUMREGWORDDATA erwData; 00554 UINT uRet; 00555 00556 pImeDpi = FindOrLoadImeDpi(hKL); 00557 if (pImeDpi == NULL) { 00558 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordA: no pImeDpi entry."); 00559 return 0; 00560 } 00561 00562 if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE)) { 00563 /* 00564 * Doesn't need A/W conversion. Calls directly to IME to 00565 * enumerate registered strings. 00566 */ 00567 uRet = (*pImeDpi->pfn.ImeEnumRegisterWord.a)(lpfnRegisterWordEnumProcA, 00568 lpszReading, 00569 dwStyle, 00570 lpszString, 00571 lpData); 00572 ImmUnlockImeDpi(pImeDpi); 00573 return uRet; 00574 } 00575 00576 /* 00577 * ANSI caller, Unicode IME. Needs A/W conversion on 00578 * lpszReading and lpszString. 00579 */ 00580 if (lpszReading != NULL) { 00581 cchReading = strlen(lpszReading) + sizeof(CHAR); 00582 lpwszReading = ImmLocalAlloc(0, cchReading * sizeof(WCHAR)); 00583 if (lpwszReading == NULL) { 00584 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordA: memory failure."); 00585 ImmUnlockImeDpi(pImeDpi); 00586 return 0; 00587 } 00588 00589 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00590 (DWORD)MB_PRECOMPOSED, 00591 (LPSTR)lpszReading, // src 00592 (INT)strlen(lpszReading), 00593 (LPWSTR)lpwszReading, // dest 00594 cchReading); 00595 lpwszReading[i] = L'\0'; 00596 } 00597 else { 00598 lpwszReading = NULL; 00599 } 00600 00601 if (lpszString != NULL) { 00602 cchString = strlen(lpszString) + sizeof(CHAR); 00603 lpwszString = ImmLocalAlloc(0, cchString * sizeof(WCHAR)); 00604 if (lpwszString == NULL) { 00605 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordA: memory failure."); 00606 if (lpwszReading != NULL) 00607 ImmLocalFree(lpwszReading); 00608 ImmUnlockImeDpi(pImeDpi); 00609 return 0; 00610 } 00611 00612 i = MultiByteToWideChar(IMECodePage(pImeDpi), 00613 (DWORD)MB_PRECOMPOSED, 00614 (LPSTR)lpszString, // src 00615 (INT)strlen(lpszString), 00616 (LPWSTR)lpwszString, // dest 00617 cchString); 00618 lpwszString[i] = L'\0'; 00619 } 00620 else { 00621 lpwszString = NULL; 00622 } 00623 00624 erwData.lpfn.a = lpfnRegisterWordEnumProcA; 00625 erwData.lpData = lpData; 00626 erwData.dwCodePage = IMECodePage(pImeDpi); 00627 00628 uRet = ImmEnumRegisterWordW(hKL, EnumRegisterWordProcW, 00629 lpwszReading, dwStyle, lpwszString, (LPVOID)&erwData); 00630 00631 if (lpwszReading != NULL) 00632 ImmLocalFree(lpwszReading); 00633 00634 if (lpwszString != NULL) 00635 ImmLocalFree(lpwszString); 00636 00637 ImmUnlockImeDpi(pImeDpi); 00638 return uRet; 00639 } 00640 00641 00642 UINT WINAPI ImmEnumRegisterWordW( 00643 HKL hKL, 00644 REGISTERWORDENUMPROCW lpfnRegisterWordEnumProcW, 00645 LPCWSTR lpwszReading, 00646 DWORD dwStyle, 00647 LPCWSTR lpwszString, 00648 LPVOID lpData) 00649 { 00650 PIMEDPI pImeDpi; 00651 LPSTR lpszReading; 00652 LPSTR lpszString; 00653 INT cchReading; 00654 INT cchString; 00655 INT i; 00656 ENUMREGWORDDATA erwData; 00657 UINT uRet; 00658 00659 pImeDpi = FindOrLoadImeDpi(hKL); 00660 if (pImeDpi == NULL) { 00661 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordW: no pImeDpi entry."); 00662 return FALSE; 00663 } 00664 00665 if (pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE) { 00666 /* 00667 * Doesn't need W/A conversion. Calls directly to IME to 00668 * enumerate registered strings. 00669 */ 00670 uRet = (*pImeDpi->pfn.ImeEnumRegisterWord.w)(lpfnRegisterWordEnumProcW, 00671 lpwszReading, 00672 dwStyle, 00673 lpwszString, 00674 lpData); 00675 ImmUnlockImeDpi(pImeDpi); 00676 return uRet; 00677 } 00678 00679 /* 00680 * Unicode caller, ANSI IME. Needs W/A conversion on 00681 * lpwszReading and lpwszString. 00682 */ 00683 if (lpwszReading != NULL) { 00684 cchReading = (wcslen(lpwszReading) + 1) * sizeof(WCHAR); 00685 lpszReading = ImmLocalAlloc(0, cchReading); 00686 if (lpszReading == NULL) { 00687 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordW: memory failure."); 00688 ImmUnlockImeDpi(pImeDpi); 00689 return 0; 00690 } 00691 00692 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00693 (DWORD)0, 00694 (LPWSTR)lpwszReading, // src 00695 (INT)wcslen(lpwszReading), 00696 (LPSTR)lpszReading, // dest 00697 cchReading, 00698 (LPSTR)NULL, 00699 (LPBOOL)NULL); 00700 lpszReading[i] = '\0'; 00701 } 00702 else { 00703 lpszReading = NULL; 00704 } 00705 00706 if (lpwszString != NULL) { 00707 cchString = (wcslen(lpwszString) + 1) * sizeof(WCHAR); 00708 lpszString = ImmLocalAlloc(0, cchString); 00709 if (lpszString == NULL) { 00710 RIPMSG0(RIP_WARNING, "ImmEnumRegisterWordW: memory failure."); 00711 if (lpszReading != NULL) 00712 ImmLocalFree(lpszReading); 00713 ImmUnlockImeDpi(pImeDpi); 00714 return 0; 00715 } 00716 00717 i = WideCharToMultiByte(IMECodePage(pImeDpi), 00718 (DWORD)0, 00719 (LPWSTR)lpwszString, // src 00720 (INT)wcslen(lpwszString), 00721 (LPSTR)lpszString, // dest 00722 cchString, 00723 (LPSTR)NULL, 00724 (LPBOOL)NULL); 00725 lpszString[i] = '\0'; 00726 } 00727 else { 00728 lpszString = NULL; 00729 } 00730 00731 erwData.lpfn.w = lpfnRegisterWordEnumProcW; 00732 erwData.lpData = lpData; 00733 erwData.dwCodePage = IMECodePage(pImeDpi); 00734 00735 uRet = ImmEnumRegisterWordA(hKL, EnumRegisterWordProcA, 00736 lpszReading, dwStyle, lpszString, (LPVOID)&erwData); 00737 00738 if (lpszReading != NULL) 00739 ImmLocalFree(lpszReading); 00740 00741 if (lpszString != NULL) 00742 ImmLocalFree(lpszString); 00743 00744 ImmUnlockImeDpi(pImeDpi); 00745 return uRet; 00746 } 00747 00748 00749 UINT CALLBACK EnumRegisterWordProcA( 00750 LPCSTR lpszReading, 00751 DWORD dwStyle, 00752 LPCSTR lpszString, 00753 PENUMREGWORDDATA pEnumRegWordData) 00754 { 00755 LPWSTR lpwszReading; 00756 LPWSTR lpwszString; 00757 INT cchReading; 00758 INT cchString; 00759 INT i; 00760 UINT uRet; 00761 00762 ImmAssert(pEnumRegWordData != NULL); 00763 00764 if (lpszReading != NULL) { 00765 cchReading = strlen(lpszReading) + sizeof(CHAR); 00766 lpwszReading = ImmLocalAlloc(0, cchReading * sizeof(WCHAR)); 00767 if (lpwszReading == NULL) { 00768 RIPMSG0(RIP_WARNING, "EnumRegisterWordProcA: memory failure."); 00769 return 0; 00770 } 00771 00772 i = MultiByteToWideChar(pEnumRegWordData->dwCodePage, 00773 (DWORD)MB_PRECOMPOSED, 00774 (LPSTR)lpszReading, // src 00775 (INT)strlen(lpszReading), 00776 (LPWSTR)lpwszReading, // dest 00777 cchReading); 00778 lpwszReading[i] = L'\0'; 00779 } 00780 else { 00781 lpwszReading = NULL; 00782 } 00783 00784 if (lpszString != NULL) { 00785 cchString = strlen(lpszString) + sizeof(CHAR); 00786 lpwszString = ImmLocalAlloc(0, cchString * sizeof(WCHAR)); 00787 if (lpwszString == NULL) { 00788 RIPMSG0(RIP_WARNING, "EnumRegisterWordProcA: memory failure."); 00789 if (lpwszReading != NULL) 00790 ImmLocalFree(lpwszReading); 00791 return 0; 00792 } 00793 00794 i = MultiByteToWideChar(pEnumRegWordData->dwCodePage, 00795 (DWORD)MB_PRECOMPOSED, 00796 (LPSTR)lpszString, // src 00797 (INT)strlen(lpszString), 00798 (LPWSTR)lpwszString, // dest 00799 cchString); 00800 lpwszString[i] = L'\0'; 00801 } 00802 else { 00803 lpwszString = NULL; 00804 } 00805 00806 uRet = (*pEnumRegWordData->lpfn.w)(lpwszReading, dwStyle, 00807 lpwszString, pEnumRegWordData->lpData); 00808 00809 if (lpwszReading != NULL) 00810 ImmLocalFree(lpwszReading); 00811 00812 if (lpwszString != NULL) 00813 ImmLocalFree(lpwszString); 00814 00815 return uRet; 00816 } 00817 00818 00819 UINT CALLBACK EnumRegisterWordProcW( 00820 LPCWSTR lpwszReading, 00821 DWORD dwStyle, 00822 LPCWSTR lpwszString, 00823 PENUMREGWORDDATA pEnumRegWordData) 00824 { 00825 LPSTR lpszReading; 00826 LPSTR lpszString; 00827 INT cchReading; 00828 INT cchString; 00829 INT i; 00830 UINT uRet; 00831 00832 ImmAssert(pEnumRegWordData != NULL); 00833 00834 if (lpwszReading != NULL) { 00835 cchReading = (wcslen(lpwszReading) + 1) * sizeof(WCHAR); 00836 lpszReading = ImmLocalAlloc(0, cchReading); 00837 if (lpszReading == NULL) { 00838 RIPMSG0(RIP_WARNING, "ImmRegisterWordW: memory failure."); 00839 return 0; 00840 } 00841 00842 i = WideCharToMultiByte(pEnumRegWordData->dwCodePage, 00843 (DWORD)0, 00844 (LPWSTR)lpwszReading, // src 00845 (INT)wcslen(lpwszReading), 00846 (LPSTR)lpszReading, // dest 00847 cchReading, 00848 (LPSTR)NULL, 00849 (LPBOOL)NULL); 00850 lpszReading[i] = '\0'; 00851 } 00852 else { 00853 lpszReading = NULL; 00854 } 00855 00856 if (lpwszString != NULL) { 00857 cchString = (wcslen(lpwszString) + 1) * sizeof(WCHAR); 00858 lpszString = ImmLocalAlloc(0, cchString); 00859 if (lpszString == NULL) { 00860 RIPMSG0(RIP_WARNING, "ImmRegisterWordW: memory failure."); 00861 if (lpszReading != NULL) 00862 ImmLocalFree(lpszReading); 00863 return 0; 00864 } 00865 00866 i = WideCharToMultiByte(pEnumRegWordData->dwCodePage, 00867 (DWORD)0, 00868 (LPWSTR)lpwszString, // src 00869 (INT)wcslen(lpwszString), 00870 (LPSTR)lpszString, // dest 00871 cchString, 00872 (LPSTR)NULL, 00873 (LPBOOL)NULL); 00874 lpszString[i] = '\0'; 00875 } 00876 else { 00877 lpszString = NULL; 00878 } 00879 00880 uRet = (*pEnumRegWordData->lpfn.a)(lpszReading, dwStyle, 00881 lpszString, pEnumRegWordData->lpData); 00882 00883 if (lpszReading != NULL) 00884 ImmLocalFree(lpszReading); 00885 00886 if (lpszString != NULL) 00887 ImmLocalFree(lpszString); 00888 00889 return uRet; 00890 }

Generated on Sat May 15 19:41:38 2004 for test by doxygen 1.3.7