Source code of Windows XP (NT5)
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.

267 lines
9.3 KiB

  1. /*
  2. *
  3. * @doc INTERNAL
  4. *
  5. * @module _CUIM.H CUIM declaration
  6. *
  7. * Purpose:
  8. *
  9. * Author: <nl>
  10. * 11/16/99 honwch
  11. *
  12. * Copyright (c) 1995-2001, Microsoft Corporation. All rights reserved.
  13. */
  14. #ifndef _CUIM_H
  15. #define _CUIM_H
  16. #include "_notmgr.h"
  17. class CUlColorArray : public CArray<COLORREF>
  18. {
  19. public:
  20. CUlColorArray() {};
  21. ~CUlColorArray() {};
  22. };
  23. class CITfEnumRange : public CArray<IEnumTfRanges *>
  24. {
  25. public:
  26. CITfEnumRange() {};
  27. ~CITfEnumRange() {};
  28. };
  29. typedef struct tagCTFMOUSETRAP
  30. {
  31. LONG cpMouseStart;
  32. LONG cchMosueComp;
  33. WPARAM wParamBefore;
  34. DWORD dwCookie;
  35. ITfMouseSink *pMouseSink;
  36. tagCTFMOUSETRAP *pNext;
  37. } CTFMOUSETRAP;
  38. typedef struct _EMBEDOBJECT
  39. {
  40. LONG cpOffset;
  41. IDataObject *pIDataObj;
  42. } EMBEDOBJECT;
  43. // Forward declarations
  44. class CTextMsgFilter;
  45. typedef HRESULT (*PTESCALLBACK)(ITfEditRecord *pEditRecord, void *pv);
  46. class CTextEditSink : public ITfTextEditSink
  47. {
  48. public:
  49. CTextEditSink(PTESCALLBACK pfnCallback, void *pv);
  50. //
  51. // IUnknown methods
  52. //
  53. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  54. STDMETHODIMP_(ULONG) AddRef(void);
  55. STDMETHODIMP_(ULONG) Release(void);
  56. //
  57. // ITfTextEditSink
  58. //
  59. STDMETHODIMP OnEndEdit(ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord);
  60. HRESULT _Advise(ITfContext *pic);
  61. HRESULT _Unadvise();
  62. private:
  63. long _cRef;
  64. ITfContext *_pic;
  65. DWORD _dwCookie;
  66. PTESCALLBACK _pfnCallback;
  67. void *_pv;
  68. };
  69. class CUIM : public ITextStoreACP, public ITfContextOwnerCompositionSink,
  70. public ITfMouseTrackerACP, public ITxNotify,
  71. public ITfEnableService, public IServiceProvider
  72. {
  73. public :
  74. CUIM(CTextMsgFilter *pTextMsgFilter);
  75. ~CUIM();
  76. //
  77. // IUnknown
  78. //
  79. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
  80. STDMETHODIMP_(ULONG) STDMETHODCALLTYPE AddRef(void);
  81. STDMETHODIMP_(ULONG) STDMETHODCALLTYPE Release(void);
  82. //
  83. // ITextStoreACP
  84. //
  85. STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD dwMask);
  86. STDMETHODIMP UnadviseSink(IUnknown *punk);
  87. STDMETHODIMP RequestLock(DWORD dwLockFlags, HRESULT *phrSession);
  88. STDMETHODIMP GetStatus(TS_STATUS *pdcs);
  89. STDMETHODIMP QueryInsert(LONG acpInsertStart, LONG acpInsertEnd, ULONG cch, LONG *pacpResultStart, LONG *pacpResultEnd);
  90. STDMETHODIMP GetSelection(ULONG ulIndex, ULONG ulCount, TS_SELECTION_ACP *pSelection, ULONG *pcFetched);
  91. STDMETHODIMP SetSelection(ULONG ulCount, const TS_SELECTION_ACP *pSelection);
  92. STDMETHODIMP GetText(LONG acpStart, LONG acpEnd, WCHAR *pchPlain, ULONG cchPlainReq, ULONG *pcchPlainOut, TS_RUNINFO *prgRunInfo,
  93. ULONG ulRunInfoReq, ULONG *pulRunInfoOut, LONG *pacpNext);
  94. STDMETHODIMP SetText(DWORD dwFlags, LONG acpStart, LONG acpEnd, const WCHAR *pchText, ULONG cch, TS_TEXTCHANGE *pChange);
  95. STDMETHODIMP GetFormattedText(LONG acpStart, LONG acpEnd, IDataObject **ppDataObject);
  96. STDMETHODIMP GetEmbedded(LONG acpPos, REFGUID rguidService, REFIID riid, IUnknown **ppunk);
  97. STDMETHODIMP InsertEmbedded(DWORD dwFlags, LONG acpStart, LONG acpEnd, IDataObject *pDataObject, TS_TEXTCHANGE *pChange);
  98. STDMETHODIMP RequestSupportedAttrs(DWORD dwFlags, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs);
  99. STDMETHODIMP RequestAttrsAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
  100. STDMETHODIMP RequestAttrsTransitioningAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
  101. STDMETHODIMP FindNextAttrTransition(LONG acpStart, LONG acpHalt, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs,
  102. DWORD dwFlags, LONG *pacpNext, BOOL *pfFound, LONG *plFoundOffset);
  103. STDMETHODIMP RetrieveRequestedAttrs(ULONG ulCount, TS_ATTRVAL *paAttrVals, ULONG *pcFetched);
  104. STDMETHODIMP GetEndACP(LONG *pacp);
  105. STDMETHODIMP GetActiveView(TsViewCookie *pvcView);
  106. STDMETHODIMP GetACPFromPoint(TsViewCookie vcView, const POINT *pt, DWORD dwFlags, LONG *pacp);
  107. STDMETHODIMP GetTextExt(TsViewCookie vcView, LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped);
  108. STDMETHODIMP GetScreenExt(TsViewCookie vcView, RECT *prc);
  109. STDMETHODIMP GetWnd(TsViewCookie vcView, HWND *phwnd);
  110. STDMETHODIMP QueryInsertEmbedded(const GUID *pguidService, const FORMATETC *pFormatEtc, BOOL *pfInsertable);
  111. STDMETHODIMP InsertTextAtSelection(DWORD dwFlags, const WCHAR *pchText, ULONG cch, LONG *pacpStart,
  112. LONG *pacpEnd, TS_TEXTCHANGE *pChange);
  113. STDMETHODIMP InsertEmbeddedAtSelection(DWORD dwFlags, IDataObject *pDataObject, LONG *pacpStart,
  114. LONG *pacpEnd, TS_TEXTCHANGE *pChange);
  115. //
  116. // ITxNotify
  117. //
  118. virtual void OnPreReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  119. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData );
  120. virtual void OnPostReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  121. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData );
  122. virtual void Zombie();
  123. //
  124. // ITfContextOwnerCompositionSink
  125. //
  126. STDMETHODIMP OnStartComposition(ITfCompositionView *pComposition, BOOL *pfOk);
  127. STDMETHODIMP OnUpdateComposition(ITfCompositionView *pComposition, ITfRange *pRangeNew);
  128. STDMETHODIMP OnEndComposition(ITfCompositionView *pComposition);
  129. //
  130. // ITfMouseTrackerACP
  131. //
  132. STDMETHODIMP AdviseMouseSink(ITfRangeACP *pRangeACP, ITfMouseSink *pSink, DWORD *pdwCookie);
  133. STDMETHODIMP UnadviseMouseSink(DWORD dwCookie);
  134. //
  135. // ITfEnableService
  136. //
  137. STDMETHODIMP IsEnabled(REFGUID rguidServiceCategory, CLSID clsidService, IUnknown *punkService, BOOL *pfOkToRun);
  138. STDMETHODIMP GetId(GUID *pguidId);
  139. //
  140. // IServiceProvider
  141. //
  142. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  143. // Public
  144. STDMETHODIMP Init();
  145. void Uninit();
  146. HRESULT GetAltDispAttrib(long lValue, ALTDISPLAYATTRIBUTE *pAltDispAttribute);
  147. void OnSetFocus(BOOL fEnable = TRUE);
  148. void CompleteUIMText();
  149. BOOL IsUIMTyping() { return _fUIMTyping; };
  150. STDMETHODIMP GetStoryLength(LONG *pacp);
  151. int Reconverse();
  152. HRESULT MouseCheck(UINT *pmsg, WPARAM *pwparam, LPARAM *plparam, LRESULT *plres);
  153. ITfContext *GetITfContext() { return _pic; };
  154. WORD _fUIMTyping : 1;
  155. WORD _fReadLockOn : 1;
  156. WORD _fWriteLockOn : 1;
  157. WORD _fReadLockPending : 1;
  158. WORD _fWriteLockPending : 1;
  159. WORD _fAllowUIMLock : 1;
  160. WORD _fAnyWriteOperation : 1;
  161. WORD _fSelChangeEventPending : 1;
  162. WORD _fLayoutEventPending : 1;
  163. WORD _fModeBiasPending : 1;
  164. WORD _fHoldCTFSelChangeNotify: 1;
  165. WORD _fEndTyping : 1;
  166. WORD _fInterimChar : 1;
  167. WORD _fInsertTextAtSel : 1;
  168. WORD _fShutDown : 1;
  169. WORD _fMosueSink : 1;
  170. short _cCallMgrLevels;
  171. short _ase;
  172. LONG _acpInterimStart;
  173. LONG _acpInterimEnd;
  174. LONG _cchComposition;
  175. BSTR _bstrComposition;
  176. LONG _acpBstrStart;
  177. long _cObjects;
  178. EMBEDOBJECT *_pObjects;
  179. LONG _acpFocusRange;
  180. LONG _cchFocusRange;
  181. LONG _acpPreFocusRangeLast;
  182. LONG _cchFocusRangeLast;
  183. LONG _cpEnd;
  184. ITextStoreACPSink *_ptss;
  185. BOOL CTFOpenStatus(BOOL fGetStatus, BOOL fOpen);
  186. CTFMOUSETRAP *_pSinkList; // Support for mouse trap operation
  187. void NotifyService(); // Notify Cicero about services changes
  188. private:
  189. ULONG _crefs;
  190. CTextMsgFilter *_pTextMsgFilter;
  191. ITfDocumentMgr *_pdim;
  192. ITfContext *_pic;
  193. ITextFont *_pTextFont;
  194. long _cpMin;
  195. TfEditCookie _editCookie;
  196. ITfDisplayAttributeMgr *_pDAM;
  197. ITfCategoryMgr *_pCategoryMgr;
  198. CTextEditSink *_pTextEditSink;
  199. CUlColorArray *_pacrUl;
  200. CITfEnumRange *_parITfEnumRange;
  201. ITfContextRenderingMarkup *_pContextRenderingMarkup;
  202. USHORT _uAttrsValCurrent;
  203. USHORT _uAttrsValTotal;
  204. TS_ATTRVAL *_parAttrsVal;
  205. void InitAttrVarArray(BOOL fAllocData = TRUE);
  206. BOOL GetExtentAcpPrange(ITfRange *ITfRangeIn, long &cpFirst, long &cpLim);
  207. static HRESULT EndEditCallback(ITfEditRecord *pEditRecord, void *pv);
  208. long GetUIMUnderline(TF_DISPLAYATTRIBUTE &da, long &idx, COLORREF &cr);
  209. BOOL GetUIMAttributeColor(TF_DA_COLOR *pdac, COLORREF *pcr);
  210. HRESULT HandlePropAttrib(IEnumTfRanges *pEnumRanges);
  211. HRESULT HandleFocusRange(IEnumTfRanges *pEnumRanges);
  212. HRESULT HandleLangID(IEnumTfRanges *pEnumRanges);
  213. void OnUIMTypingDone();
  214. BOOL GetGUIDATOMFromGUID(REFGUID rguid, TfGuidAtom *pguidatom);
  215. int FindGUID(REFGUID guid);
  216. BOOL PackAttrData(LONG idx, ITextFont *pITextFont, ITextPara *pITextPara, TS_ATTRVAL *pTSAttrVal);
  217. HRESULT GetAttrs(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, BOOL fGetDefault);
  218. void BuildHiddenTxtBlks(long &cpMin, long &cpMax, long **ppHiddenTxtBlk, long &cHiddenTxtBlk);
  219. HRESULT FindHiddenText(long cp, long cpEnd, long &cpRange);
  220. HRESULT FindUnhiddenText(long cp, long cpEnd, long &cpRange);
  221. void HandleFinalString(ITfRange *pPropRange, long cp=0, long cch=0, BOOL fEndComposition = FALSE);
  222. void HandleDispAttr(ITfRange *pITfRangeProp, VARIANT &var, long cp=0, long cch=0);
  223. int BuildObject(ITextRange *pTextRange, BSTR bstr, EMBEDOBJECT **ppEmbeddObjects, int cSize);
  224. void InsertTextandObject(ITextRange *pTextRange, BSTR bstr, EMBEDOBJECT *pEmbeddObjects, long cEmbeddedObjects);
  225. void CleanUpObjects(long cObjects, EMBEDOBJECT *pObjects);
  226. void HandleTempDispAttr(ITfEditRecord *pEditRecord);
  227. void CleanUpComposition();
  228. STDMETHODIMP InsertData(DWORD dwFlags, LONG acpStart, LONG acpEnd, const WCHAR *pchText, ULONG cch,
  229. IDataObject *pDataObject, TS_TEXTCHANGE *pChange);
  230. };
  231. BOOL CreateUIM(CTextMsgFilter *pTextMsgFilter);
  232. #endif // _CUIM_H