Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
6.4 KiB

  1. /*
  2. *
  3. * @doc INTERNAL
  4. *
  5. * @module _CMSGFLT.H CTextMsgFilter declaration |
  6. *
  7. * Purpose: CTextMsgFilter is used in handling IME as well as Cicero Input.
  8. *
  9. * Author: <nl>
  10. * 2/6/98 v-honwch
  11. *
  12. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  13. */
  14. // Forward declarations
  15. #ifndef NOPRIVATEMESSAGE
  16. #include "_MSREMSG.H"
  17. #endif
  18. class CIme;
  19. class CUIM;
  20. class CTextMsgFilter;
  21. class CLangProfileSink;
  22. // CheckIMEType dwFlags
  23. #define CHECK_IME_SERVICE 0x0001
  24. #ifndef __ITfThreadMgr_INTERFACE_DEFINED__
  25. class ITfThreadMgr;
  26. #endif
  27. class CLangProfileSink : public ITfLanguageProfileNotifySink
  28. {
  29. public:
  30. CLangProfileSink();
  31. //
  32. // IUnknown methods
  33. //
  34. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  35. STDMETHODIMP_(ULONG) AddRef(void);
  36. STDMETHODIMP_(ULONG) Release(void);
  37. //
  38. // ITfLanguageProfilesNotifySink
  39. //
  40. STDMETHODIMP OnLanguageChange(LANGID langid, BOOL *pfAccept);
  41. STDMETHODIMP OnLanguageChanged();
  42. HRESULT _Advise(CTextMsgFilter *, ITfInputProcessorProfiles *pipp);
  43. HRESULT _Unadvise();
  44. private:
  45. long _cRef;
  46. CTextMsgFilter *_pTextMsgFilter;
  47. ITfInputProcessorProfiles *_pITFIPP;
  48. DWORD _dwCookie;
  49. };
  50. class CTextMsgFilter : public ITextMsgFilter
  51. {
  52. public :
  53. friend class CUIM;
  54. friend class CLangProfileSink;
  55. HRESULT STDMETHODCALLTYPE QueryInterface(
  56. REFIID riid,
  57. void **ppvObject);
  58. ULONG STDMETHODCALLTYPE AddRef(void);
  59. ULONG STDMETHODCALLTYPE Release(void);
  60. HRESULT STDMETHODCALLTYPE AttachDocument( HWND hwnd, ITextDocument2 *pTextDoc, IUnknown *punk);
  61. HRESULT STDMETHODCALLTYPE HandleMessage(
  62. UINT *pmsg,
  63. WPARAM *pwparam,
  64. LPARAM *plparam,
  65. LRESULT *plres);
  66. HRESULT STDMETHODCALLTYPE AttachMsgFilter( ITextMsgFilter *pMsgFilter);
  67. COMPCOLOR* GetIMECompAttributes();
  68. void OnSetUIMMode(WORD wUIMModeBias);
  69. LRESULT OnGetUIMMode() { return _wUIMModeBias; };
  70. ~CTextMsgFilter();
  71. BOOL IsIMEComposition() { return (_ime != NULL);};
  72. BOOL GetTxSelection();
  73. BOOL NoIMEProcess();
  74. BOOL MouseOperation(UINT msg, long ichStart, long cchComp, WPARAM wParam, WPARAM *pwParamBefore,
  75. BOOL *pfTerminateIME, HWND hwndIME, long *pCpCursor=NULL, ITfMouseSink *pMouseSink=NULL);
  76. CIme *_ime; // non-NULL when IME composition active
  77. HWND _hwnd;
  78. UINT _uKeyBoardCodePage; // current keyboard codepage
  79. UINT _uSystemCodePage; // system codepage
  80. DWORD _fIMECancelComplete :1; // If aborting IME, cancel comp string, else complete
  81. DWORD _fUnicodeIME :1; // TRUE if Unicode IME
  82. DWORD _fIMEAlwaysNotify :1; // Send Notification during IME undetermined string
  83. DWORD _fHangulToHanja :1; // TRUE during Hangul to Hanja conversion
  84. DWORD _fOvertypeMode :1; // TRUE if overtype mode is on.
  85. DWORD _fMSIME :1; // TRUE if MSIME98 or later
  86. DWORD _fUsingAIMM :1; // TRUE if AIMM is activated
  87. DWORD _fUnicodeWindow :1; // TRUE if Unicode Window
  88. DWORD _fForceEnable :1; // TRUE if Force Enable on Focus
  89. DWORD _fForceActivate :1; // TRUE if Force Activate on Focus
  90. DWORD _fForceRemember :1; // TRUE if Force Remember
  91. DWORD _fIMEEnable :1; // TRUE if IME was enable before
  92. DWORD _fRE10Mode :1; // TRUE if running in RE1.0 Mode
  93. DWORD _fUsingUIM :1; // TRUE if Cicero is activated
  94. DWORD _fTurnOffUIM :1; // TRUE if Client doesn't want UIM
  95. DWORD _fTurnOffAIMM :1; // TRUE if Client doesn't want AIIM
  96. DWORD _nIMEMode :2; // 1 = IME_SMODE_PLAURALCLAUSE
  97. // 2 = IME_SMODE_NONE
  98. DWORD _fNoIme :1; // TRUE if Client has turn off IME processing
  99. DWORD _fRestoreOLDIME :1; // TRUE if _wOldIMESentence is setup before
  100. DWORD _fSendTransaction :1; // TRUE if we need to send EndEditTransaction
  101. DWORD _fReceivedKeyDown :1; // TRUE if we have received key down message
  102. DWORD _fAllowEmbedded :1; // TRUE if we allow Cicero insert embedded
  103. DWORD _fAllowSmartTag :1; // TRUE if we allow Cicero SmartTag tips
  104. DWORD _fAllowProofing :1; // TRUE if we allow Cicero Proofing tips
  105. WORD _wOldIMESentence; // for IME_SMODE_PHRASEPREDICT use
  106. WORD _wUIMModeBias; // for UIM Mode bias
  107. // Support for SETIMEOPTIONS:
  108. DWORD _fIMEConversion; // for Force Remember use
  109. DWORD _fIMESentence; // for Force Remember use
  110. HKL _fIMEHKL; // for Force Remember use
  111. long _cpReconvertStart; // use during reconversion
  112. long _cpReconvertEnd; // use during reconversion
  113. long _lFEFlags; // For FE setting (ES_NOIME, ES_SELFIME)
  114. COMPCOLOR* _pcrComp; // Support 1.0 mode composition color
  115. ITextDocument2 *_pTextDoc;
  116. ITextServices *_pTextService;
  117. ITextSelection *_pTextSel;
  118. ITfThreadMgr *_pTim;
  119. CUIM *_pCUIM;
  120. TfClientId _tid;
  121. #ifndef NOPRIVATEMESSAGE
  122. CMsgCallBack *_pMsgCallBack;
  123. #endif
  124. ITfInputProcessorProfiles *_pITfIPP;
  125. CLangProfileSink *_pCLangProfileSink;
  126. private:
  127. ULONG _crefs;
  128. ITextMsgFilter * _pFilter;
  129. HIMC _hIMCContext;
  130. // private methods
  131. HRESULT OnWMChar(
  132. UINT *pmsg,
  133. WPARAM *pwparam,
  134. LPARAM *plparam,
  135. LRESULT *plres);
  136. HRESULT OnWMIMEChar(
  137. UINT *pmsg,
  138. WPARAM *pwparam,
  139. LPARAM *plparam,
  140. LRESULT *plres);
  141. HRESULT OnIMEReconvert(
  142. UINT *pmsg,
  143. WPARAM *pwparam,
  144. LPARAM *plparam,
  145. LRESULT *plres,
  146. BOOL fUnicode);
  147. BOOL CheckIMEChange(
  148. LPRECONVERTSTRING lpRCS,
  149. long cpParaStart,
  150. long cpParaEnd,
  151. long cpMin,
  152. long cpMax,
  153. BOOL fUnicode);
  154. HRESULT OnIMEQueryPos(
  155. UINT *pmsg,
  156. WPARAM *pwparam,
  157. LPARAM *plparam,
  158. LRESULT *plres,
  159. BOOL fUnicode);
  160. BOOL CheckIMEType( HKL hKL, DWORD dwFlags = CHECK_IME_SERVICE);
  161. HRESULT InputFEChar( WCHAR wchFEChar );
  162. void OnSetFocus();
  163. void OnKillFocus();
  164. LRESULT OnSetIMEOptions(WPARAM wparam, LPARAM lparam);
  165. LRESULT OnGetIMEOptions();
  166. void SetupIMEOptions();
  167. void SetupCallback();
  168. void SetupLangSink();
  169. void ReleaseLangSink();
  170. void CompleteUIMTyping(LONG mode, BOOL fTransaction = TRUE);
  171. void StartUIM();
  172. void StartAimm(BOOL fUseAimm12);
  173. void TurnOffUIM(BOOL fSafeToSendMessage);
  174. void TurnOffAimm(BOOL fSafeToSendMessage);
  175. int OnGetIMECompText(WPARAM wparam, LPARAM lparam);
  176. void OnSetIMEMode(WPARAM wparam, LPARAM lparam);
  177. LRESULT OnGetIMEMode()
  178. {
  179. if (!_nIMEMode)
  180. return 0;
  181. return _nIMEMode == 1 ? IMF_SMODE_PLAURALCLAUSE : IMF_SMODE_NONE;
  182. };
  183. void SetIMESentenseMode(BOOL fSetup, HKL hKL = NULL);
  184. void HandleCTFService(WPARAM wparam, LPARAM lparam);
  185. };