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.

972 lines
37 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. editses.h
  5. Abstract:
  6. This file defines the EditSession Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #ifndef _EDITSES_H_
  12. #define _EDITSES_H_
  13. #include "editcomp.h"
  14. #include "context.h"
  15. #include "globals.h"
  16. #include "imc.h"
  17. #include "uicomp.h"
  18. typedef enum {
  19. ESCB_HANDLETHISKEY = 1,
  20. ESCB_COMPCOMPLETE,
  21. ESCB_COMPCANCEL,
  22. ESCB_UPDATECOMPOSITIONSTRING,
  23. ESCB_REPLACEWHOLETEXT,
  24. ESCB_RECONVERTSTRING,
  25. ESCB_CLEARDOCFEEDBUFFER,
  26. ESCB_GETTEXTANDATTRIBUTE,
  27. ESCB_QUERYRECONVERTSTRING,
  28. ESCB_CALCRANGEPOS,
  29. ESCB_GETSELECTION,
  30. ESCB_GET_READONLY_PROP_MARGIN,
  31. ESCB_GET_CURSOR_POSITION,
  32. ESCB_GET_ALL_TEXT_RANGE,
  33. ESCB_REMOVE_PROPERTY
  34. } ESCB;
  35. /////////////////////////////////////////////////////////////////////////////
  36. // ImmIfEditSessionCallBack
  37. class ImmIfEditSession;
  38. class ImmIfEditSessionCallBack
  39. {
  40. public:
  41. ImmIfEditSessionCallBack(HIMC hIMC,
  42. TfClientId tid,
  43. Interface_Attach<ITfContext> pic,
  44. LIBTHREAD* pLibTLS)
  45. : m_hIMC(hIMC), m_tid(tid), m_ic(pic), m_pLibTLS(pLibTLS)
  46. {
  47. }
  48. virtual ~ImmIfEditSessionCallBack() { };
  49. virtual HRESULT CallBackRoutine(TfEditCookie ec,
  50. ImmIfEditSession* pes) = 0;
  51. static HRESULT GetAllTextRange(TfEditCookie ec,
  52. Interface_Attach<ITfContext>& ic,
  53. Interface<ITfRange>* range,
  54. LONG* lpTextLength,
  55. TF_HALTCOND* lpHaltCond=NULL);
  56. protected:
  57. HRESULT SetTextInRange(TfEditCookie ec,
  58. ITfRange* range,
  59. LPWSTR psz,
  60. DWORD len,
  61. CicInputContext& CicContext);
  62. HRESULT ClearTextInRange(TfEditCookie ec,
  63. ITfRange* range,
  64. CicInputContext& CicContext);
  65. HRESULT GetReadingString(TfEditCookie ec,
  66. Interface_Attach<ITfContext>& ic,
  67. CWCompString& reading_string,
  68. CWCompClause& reading_clause);
  69. HRESULT GetReadingString(TfEditCookie ec,
  70. Interface_Attach<ITfContext>& ic,
  71. ITfRange* range,
  72. CWCompString& reading_string,
  73. CWCompClause& reading_clause);
  74. HRESULT CompClauseToResultClause(IMCLock& imc,
  75. CWCompClause& result_clause, UINT cch);
  76. HRESULT CheckStrClauseAndReadClause(CWCompClause& str_clause, CWCompClause& reading_clause, LONG cch);
  77. HRESULT _GetTextAndAttribute(LIBTHREAD *pLibTLS,
  78. TfEditCookie ec,
  79. IMCLock& imc,
  80. CicInputContext& CicContext,
  81. Interface_Attach<ITfContext>& ic,
  82. Interface<ITfRange>& range,
  83. CWCompString& CompStr,
  84. CWCompAttribute& CompAttr,
  85. BOOL bInWriteSession)
  86. {
  87. CWCompClause CompClause;
  88. CWCompTfGuidAtom CompGuid;
  89. CWCompString CompReadStr;
  90. CWCompClause CompReadClause;
  91. CWCompString ResultStr;
  92. CWCompClause ResultClause;
  93. CWCompString ResultReadStr;
  94. CWCompClause ResultReadClause;
  95. return _GetTextAndAttribute(pLibTLS, ec, imc, CicContext, ic, range,
  96. CompStr, CompAttr, CompClause,
  97. CompGuid,
  98. CompReadStr, CompReadClause,
  99. ResultStr, ResultClause,
  100. ResultReadStr, ResultReadClause,
  101. bInWriteSession);
  102. }
  103. HRESULT _GetTextAndAttribute(LIBTHREAD *pLibTLS,
  104. TfEditCookie ec,
  105. IMCLock& imc,
  106. CicInputContext& CicContext,
  107. Interface_Attach<ITfContext>& ic,
  108. Interface<ITfRange>& range,
  109. CWCompString& CompStr,
  110. CWCompAttribute& CompAttr,
  111. CWCompClause& CompClause,
  112. CWCompTfGuidAtom& CompGuid,
  113. CWCompString& CompReadStr,
  114. CWCompClause& CompReadCls,
  115. CWCompString& ResultStr,
  116. CWCompClause& ResultClause,
  117. CWCompString& ResultReadStr,
  118. CWCompClause& ResultReadClause,
  119. BOOL bInWriteSession);
  120. HRESULT _GetTextAndAttributeGapRange(LIBTHREAD *pLibTLS,
  121. TfEditCookie ec,
  122. // IMCLock& imc,
  123. IME_UIWND_STATE uists,
  124. CicInputContext& CicContext,
  125. Interface<ITfRange>& gap_range,
  126. LONG result_comp,
  127. CWCompString& CompStr,
  128. CWCompAttribute& CompAttr,
  129. CWCompClause& CompClause,
  130. CWCompTfGuidAtom& CompGuid,
  131. CWCompString& ResultStr,
  132. CWCompClause& ResultClause);
  133. HRESULT _GetTextAndAttributePropertyRange(LIBTHREAD *pLibTLS,
  134. TfEditCookie ec,
  135. IMCLock& imc,
  136. IME_UIWND_STATE uists,
  137. CicInputContext& CicContext,
  138. ITfRange* pPropRange,
  139. BOOL fDispAttribute,
  140. LONG result_comp,
  141. BOOL bInWriteSession,
  142. TF_DISPLAYATTRIBUTE da,
  143. TfGuidAtom guidatom,
  144. CWCompString& CompStr,
  145. CWCompAttribute& CompAttr,
  146. CWCompClause& CompClause,
  147. CWCompTfGuidAtom& CompGuid,
  148. CWCompString& ResultStr,
  149. CWCompClause& ResultClause);
  150. HRESULT _GetNoDisplayAttributeRange(LIBTHREAD *pLibTLS,
  151. TfEditCookie ec,
  152. Interface_Attach<ITfContext>& ic,
  153. Interface<ITfRange>& range,
  154. const GUID** guids,
  155. const int guid_size,
  156. Interface<ITfRange>& no_display_attribute_range);
  157. HRESULT _GetCursorPosition(TfEditCookie ec,
  158. IMCLock& imc,
  159. CicInputContext& CicContext,
  160. Interface_Attach<ITfContext>& ic,
  161. CWCompCursorPos& CompCursorPos,
  162. CWCompAttribute& CompAttr);
  163. //
  164. // Edit session helper
  165. //
  166. protected:
  167. HRESULT EscbHandleThisKey(IMCLock& imc, UINT uVKey)
  168. {
  169. return ::EscbHandleThisKey(imc, m_tid, m_ic, m_pLibTLS, uVKey);
  170. }
  171. HRESULT EscbUpdateCompositionString(IMCLock& imc)
  172. {
  173. return ::EscbUpdateCompositionString(imc, m_tid, m_ic, m_pLibTLS, 0, 0);
  174. }
  175. HRESULT EscbUpdateCompositionStringSync(IMCLock& imc)
  176. {
  177. return ::EscbUpdateCompositionString(imc, m_tid, m_ic, m_pLibTLS, 0, TF_ES_SYNC);
  178. }
  179. HRESULT EscbCompCancel(IMCLock& imc)
  180. {
  181. return ::EscbCompCancel(imc, m_tid, m_ic, m_pLibTLS);
  182. }
  183. HRESULT EscbCompComplete(IMCLock& imc, BOOL fSync)
  184. {
  185. return ::EscbCompComplete(imc, m_tid, m_ic, m_pLibTLS, fSync);
  186. }
  187. HRESULT EscbClearDocFeedBuffer(IMCLock& imc, CicInputContext& CicContext, BOOL fSync)
  188. {
  189. return ::EscbClearDocFeedBuffer(imc, CicContext, m_tid, m_ic, m_pLibTLS, fSync);
  190. }
  191. HRESULT EscbRemoveProperty(IMCLock& imc, const GUID* guid)
  192. {
  193. return ::EscbRemoveProperty(imc, m_tid, m_ic, m_pLibTLS, guid);
  194. }
  195. //
  196. // Edit session friend
  197. //
  198. private:
  199. friend HRESULT EscbHandleThisKey(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* tls,
  200. UINT uVKey);
  201. friend HRESULT EscbCompComplete(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  202. BOOL fSync);
  203. friend HRESULT EscbCompCancel(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS);
  204. friend HRESULT EscbUpdateCompositionString(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  205. DWORD dwDeltaStart,
  206. DWORD dwFlags);
  207. friend HRESULT EscbReplaceWholeText(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  208. CWCompString* wCompString);
  209. friend HRESULT EscbReconvertString(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  210. CWReconvertString* wReconvertString,
  211. Interface<ITfRange>* selection,
  212. BOOL fDocFeedOnly);
  213. friend HRESULT EscbClearDocFeedBuffer(IMCLock& imc, CicInputContext& CicContext, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  214. BOOL fSync);
  215. friend HRESULT EscbGetTextAndAttribute(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  216. CWCompString* wCompString,
  217. CWCompAttribute* wCompAttribute);
  218. friend HRESULT EscbQueryReconvertString(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  219. CWReconvertString* wReconvertString,
  220. Interface<ITfRange>* selection);
  221. friend HRESULT EscbCalcRangePos(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  222. CWReconvertString* wReconvertString,
  223. Interface<ITfRange>* range);
  224. friend HRESULT EscbGetSelection(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  225. Interface<ITfRange>* selection);
  226. friend HRESULT EscbGetStartEndSelection(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  227. CWCompCursorPos& wStartSelection,
  228. CWCompCursorPos& wEndSelection);
  229. friend HRESULT EscbReadOnlyPropMargin(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  230. Interface<ITfRangeACP>* range_acp,
  231. LONG* pcch);
  232. friend HRESULT EscbGetCursorPosition(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  233. CWCompCursorPos* wCursorPosition);
  234. friend HRESULT EscbRemoveProperty(IMCLock& imc, TfClientId tid, Interface_Attach<ITfContext> pic, LIBTHREAD* pLibTLS,
  235. const GUID* guid);
  236. private:
  237. typedef struct _EnumReadingPropertyArgs
  238. {
  239. Interface<ITfProperty> Property;
  240. TfEditCookie ec;
  241. CWCompString* reading_string;
  242. CWCompClause* reading_clause;
  243. LONG ulClausePos;
  244. } EnumReadingPropertyArgs;
  245. //
  246. // Enumrate callbacks
  247. //
  248. static ENUM_RET EnumReadingPropertyCallback(ITfRange* pRange, EnumReadingPropertyArgs *pargs);
  249. BYTE _ConvertAttributeToImm32(IME_UIWND_STATE uists,
  250. TF_DA_ATTR_INFO attribute)
  251. {
  252. if (attribute == TF_ATTR_OTHER || attribute > TF_ATTR_FIXEDCONVERTED) {
  253. return ATTR_TARGET_CONVERTED;
  254. }
  255. else {
  256. if (attribute == ATTR_INPUT_ERROR)
  257. {
  258. if (uists != IME_UIWND_LEVEL1 && uists != IME_UIWND_LEVEL2)
  259. {
  260. return ATTR_CONVERTED;
  261. }
  262. }
  263. return (BYTE)attribute;
  264. }
  265. }
  266. HRESULT _FindCompAttr(CWCompAttribute& CompAttr, BYTE bAttr, INT_PTR* pich);
  267. Interface_Attach<ITfContext> m_ic;
  268. TfClientId m_tid;
  269. LIBTHREAD* m_pLibTLS;
  270. HIMC m_hIMC;
  271. };
  272. /////////////////////////////////////////////////////////////////////////////
  273. // ImmIfEditSession
  274. class ImmIfEditSession : public ITfEditSession
  275. {
  276. public:
  277. ImmIfEditSession(ESCB escb,
  278. IMCLock& imc,
  279. TfClientId tid,
  280. Interface_Attach<ITfContext> pic,
  281. LIBTHREAD* pLibTLS)
  282. : m_state((HIMC)imc), m_tid(tid), m_ic(pic), m_pLibTLS(pLibTLS)
  283. {
  284. _Init(escb);
  285. }
  286. private:
  287. void _Init(ESCB escb);
  288. public:
  289. virtual ~ImmIfEditSession();
  290. bool Valid();
  291. bool Invalid() { return ! Valid(); }
  292. //
  293. // IUnknown methods
  294. //
  295. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  296. STDMETHODIMP_(ULONG) AddRef(void);
  297. STDMETHODIMP_(ULONG) Release(void);
  298. //
  299. // ITfEditCallback method
  300. //
  301. STDMETHODIMP DoEditSession(TfEditCookie ec);
  302. //
  303. // ImmIfEditSession methods
  304. //
  305. static HRESULT EditSessionCallBack(TfEditCookie ec, ImmIfEditSession* pes)
  306. {
  307. if (pes->m_ImmIfCallBack)
  308. return pes->m_ImmIfCallBack->CallBackRoutine(ec, pes);
  309. else
  310. return E_FAIL;
  311. }
  312. //
  313. // EditSession methods.
  314. //
  315. HRESULT RequestEditSession(DWORD dwFlags,
  316. UINT uVKey=0)
  317. {
  318. HRESULT hr;
  319. m_state.uVKey = uVKey;
  320. m_ic->RequestEditSession(m_tid, this, dwFlags, &hr);
  321. return hr;
  322. }
  323. HRESULT RequestEditSession(DWORD dwFlags, CWCompString* pwCompStr,
  324. CWCompString* pwReadCompStr=NULL, Interface<ITfRange>* pRange=NULL)
  325. {
  326. m_state.lpwCompStr = pwCompStr;
  327. m_state.lpwReadCompStr = pwReadCompStr;
  328. m_pRange = pRange;
  329. return RequestEditSession(dwFlags);
  330. }
  331. HRESULT RequestEditSession(DWORD dwFlags, Interface<ITfRange>* pSelection)
  332. {
  333. m_pRange = pSelection;
  334. return RequestEditSession(dwFlags);
  335. }
  336. HRESULT RequestEditSession(DWORD dwFlags,
  337. CWReconvertString* pwReconvStr, Interface<ITfRange>* pSelection, BOOL fDocFeedOnly)
  338. {
  339. m_state.lpwReconvStr = pwReconvStr;
  340. m_pRange = pSelection;
  341. m_fDocFeedOnly = fDocFeedOnly;
  342. return RequestEditSession(dwFlags);
  343. }
  344. HRESULT RequestEditSession(DWORD dwFlags,
  345. Interface<ITfRangeACP>* pMouseRangeACP, LPMOUSE_RANGE_RECT pv)
  346. {
  347. m_pRangeACP = pMouseRangeACP;
  348. m_state.pv = (VOID*)pv;
  349. return RequestEditSession(dwFlags);
  350. }
  351. HRESULT RequestEditSession(DWORD dwFlags,
  352. CWCompString* pwCompStr, CWCompAttribute* pwCompAttr)
  353. {
  354. m_state.lpwCompStr = pwCompStr;
  355. m_state.lpwCompAttr = pwCompAttr;
  356. return RequestEditSession(dwFlags);
  357. }
  358. HRESULT RequestEditSession(DWORD dwFlags, BOOL fTerminateComp)
  359. {
  360. m_state.fTerminateComp = fTerminateComp;
  361. return RequestEditSession(dwFlags);
  362. }
  363. HRESULT RequestEditSession(DWORD dwFlags,
  364. Interface<ITfRangeACP>* pRange, LONG* cch)
  365. {
  366. m_pRangeACP = pRange;
  367. m_state.pv = (VOID*)cch;
  368. return RequestEditSession(dwFlags);
  369. }
  370. HRESULT RequestEditSession(DWORD dwFlags,
  371. CWCompCursorPos* pwCursorPosition)
  372. {
  373. m_state.lpwCursorPosition = pwCursorPosition;
  374. return RequestEditSession(dwFlags);
  375. }
  376. HRESULT RequestEditSession(DWORD dwFlags,
  377. const GUID* guid)
  378. {
  379. HRESULT hr;
  380. m_guid = guid;
  381. m_ic->RequestEditSession(m_tid, this, dwFlags, &hr);
  382. return hr;
  383. }
  384. public:
  385. ImmIfEditSessionCallBack* m_ImmIfCallBack;
  386. Interface_Attach<ITfContext> m_ic;
  387. Interface<ITfRange>* m_pRange;
  388. Interface<ITfRangeACP>* m_pRangeACP;
  389. const GUID* m_guid;
  390. BOOL m_fDocFeedOnly;
  391. struct state {
  392. state(HIMC hd) : hIMC(hd) { };
  393. UINT uVKey;
  394. HIMC hIMC;
  395. CWCompString* lpwCompStr;
  396. CWCompString* lpwReadCompStr;
  397. CWCompAttribute* lpwCompAttr;
  398. CWReconvertString* lpwReconvStr;
  399. CWCompCursorPos* lpwCursorPosition;
  400. VOID* pv;
  401. BOOL fTerminateComp;
  402. } m_state;
  403. TfClientId m_tid;
  404. LIBTHREAD* m_pLibTLS;
  405. HRESULT (*m_pfnCallback)(TfEditCookie ec, ImmIfEditSession*);
  406. int m_cRef;
  407. };
  408. /////////////////////////////////////////////////////////////////////////////
  409. // ImmIfHandleThisKey
  410. class ImmIfHandleThisKey : public ImmIfEditSessionCallBack
  411. {
  412. public:
  413. ImmIfHandleThisKey(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  414. HRESULT CallBackRoutine(TfEditCookie ec,
  415. ImmIfEditSession *pes)
  416. {
  417. return HandleThisKey(ec,
  418. pes->m_state.uVKey,
  419. pes->m_state.hIMC,
  420. pes->m_ic);
  421. }
  422. HRESULT HandleThisKey(TfEditCookie ec,
  423. UINT uVKey,
  424. HIMC hIMC,
  425. Interface_Attach<ITfContext> ic);
  426. private:
  427. HRESULT ShiftSelectionToLeft(TfEditCookie rc, ITfRange *range, int nShift, bool fShiftEnd);
  428. HRESULT ShiftSelectionToRight(TfEditCookie rc, ITfRange *range, int nShift, bool fShiftStart);
  429. };
  430. /////////////////////////////////////////////////////////////////////////////
  431. // ImmIfCompositionComplete
  432. class ImmIfCompositionComplete : public ImmIfEditSessionCallBack,
  433. private EditCompositionString
  434. {
  435. public:
  436. ImmIfCompositionComplete(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  437. HRESULT CallBackRoutine(TfEditCookie ec,
  438. ImmIfEditSession *pes)
  439. {
  440. return CompComplete(ec,
  441. pes->m_state.hIMC,
  442. pes->m_state.fTerminateComp,
  443. pes->m_ic);
  444. }
  445. HRESULT CompComplete(TfEditCookie ec,
  446. HIMC hIMC,
  447. BOOL fTerminateComp,
  448. Interface_Attach<ITfContext> ic);
  449. private:
  450. HRESULT _SetCompositionString(IMCLock& imc,
  451. CicInputContext& CicContext,
  452. CWCompString* ResultStr,
  453. CWCompClause* ResultClause,
  454. CWCompString* ResultReadStr,
  455. CWCompClause* ResultReadClause)
  456. {
  457. return SetString(imc,
  458. CicContext,
  459. NULL, NULL, NULL, // CompStr, CompAttr, CompCls
  460. NULL, NULL, // CompCursor, CompDeltaStart
  461. NULL, // CompGuid
  462. NULL, // lpbBufferOverflow
  463. NULL, NULL, NULL, // CompReadStr, CompReadAttr, CompReadCls
  464. ResultStr, ResultClause, // ResultStr, ResultCls
  465. ResultReadStr, ResultReadClause); // ResultReadStr, ResultReadCls
  466. }
  467. };
  468. /////////////////////////////////////////////////////////////////////////////
  469. // ImmIfCompositionCancel
  470. class ImmIfCompositionCancel : public ImmIfEditSessionCallBack,
  471. private EditCompositionString
  472. {
  473. public:
  474. ImmIfCompositionCancel(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  475. HRESULT CallBackRoutine(TfEditCookie ec,
  476. ImmIfEditSession *pes)
  477. {
  478. return CompCancel(ec,
  479. pes->m_state.hIMC,
  480. pes->m_ic);
  481. }
  482. HRESULT CompCancel(TfEditCookie ec,
  483. HIMC hIMC,
  484. Interface_Attach<ITfContext> ic);
  485. };
  486. /////////////////////////////////////////////////////////////////////////////
  487. // ImmIfUpdateCompositionString
  488. class ImmIfUpdateCompositionString : public ImmIfEditSessionCallBack,
  489. private EditCompositionString
  490. {
  491. public:
  492. ImmIfUpdateCompositionString(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  493. HRESULT CallBackRoutine(TfEditCookie ec,
  494. ImmIfEditSession *pes)
  495. {
  496. return UpdateCompositionString(ec,
  497. pes->m_state.hIMC,
  498. pes->m_ic,
  499. pes->m_state.uVKey,
  500. pes->m_tid,
  501. pes->m_pLibTLS);
  502. }
  503. HRESULT UpdateCompositionString(TfEditCookie ec,
  504. HIMC hIMC,
  505. Interface_Attach<ITfContext> ic,
  506. DWORD dwDeltaStart,
  507. TfClientId ClientId,
  508. LIBTHREAD* pLibTLS);
  509. private:
  510. HRESULT _IsInterimSelection(TfEditCookie ec,
  511. Interface_Attach<ITfContext>& ic,
  512. Interface<ITfRange>* pInterimRange,
  513. BOOL *pfInterim);
  514. HRESULT _MakeCompositionString(LIBTHREAD *pLibTLS,
  515. TfEditCookie ec,
  516. IMCLock& imc,
  517. CicInputContext& CicContext,
  518. Interface_Attach<ITfContext>& ic,
  519. Interface<ITfRange>& FullTextRange,
  520. DWORD dwDeltaStart,
  521. BOOL bInWriteSession);
  522. HRESULT _MakeInterimString(LIBTHREAD *pLibTLS,
  523. TfEditCookie ec,
  524. IMCLock& imc,
  525. CicInputContext& CicContext,
  526. Interface_Attach<ITfContext>& ic,
  527. Interface<ITfRange>& FullTextRange,
  528. Interface<ITfRange>& InterimRange,
  529. LONG lTextLength,
  530. BOOL bInWriteSession);
  531. HRESULT _GetDeltaStart(CWCompDeltaStart& CompDeltaStart,
  532. CWCompString& CompStr,
  533. DWORD dwDeltaStart);
  534. HRESULT _SetCompositionString(IMCLock& imc,
  535. CicInputContext& CicContext,
  536. CWCompString* CompStr,
  537. CWCompAttribute* CompAttr,
  538. CWCompClause* CompClause,
  539. CWCompCursorPos* CompCursorPos,
  540. CWCompDeltaStart* CompDeltaStart,
  541. CWCompTfGuidAtom* CompGuid,
  542. OUT BOOL* lpbBufferOverflow,
  543. CWCompString* CompReadStr)
  544. {
  545. return SetString(imc,
  546. CicContext,
  547. CompStr, CompAttr, CompClause,
  548. CompCursorPos, CompDeltaStart,
  549. CompGuid,
  550. lpbBufferOverflow,
  551. CompReadStr);
  552. }
  553. HRESULT _SetCompositionString(IMCLock& imc,
  554. CicInputContext& CicContext,
  555. CWCompString* CompStr,
  556. CWCompAttribute* CompAttr,
  557. CWCompClause* CompClause,
  558. CWCompCursorPos* CompCursorPos,
  559. CWCompDeltaStart* CompDeltaStart,
  560. CWCompTfGuidAtom* CompGuid,
  561. OUT BOOL* lpbBufferOverflow,
  562. CWCompString* CompReadStr,
  563. CWCompString* ResultStr,
  564. CWCompClause* ResultClause,
  565. CWCompString* ResultReadStr,
  566. CWCompClause* ResultReadClause)
  567. {
  568. return SetString(imc,
  569. CicContext,
  570. CompStr, CompAttr, CompClause,
  571. CompCursorPos, CompDeltaStart,
  572. CompGuid,
  573. lpbBufferOverflow,
  574. CompReadStr, NULL, NULL, // CompReadStr, CompReadAttr, CompReadCls
  575. ResultStr, ResultClause,
  576. ResultReadStr, ResultReadClause);
  577. }
  578. HRESULT _SetCompositionString(IMCLock& imc,
  579. CicInputContext& CicContext,
  580. CWInterimString* InterimStr)
  581. {
  582. return SetString(imc,
  583. CicContext,
  584. NULL, NULL, NULL, // CompStr, CompAttr, CompCls
  585. NULL, NULL, // CompCursor, CompDeltaStart
  586. NULL, // CompGuid
  587. NULL, // lpbBufferOverflow
  588. NULL, NULL, NULL, // CompReadStr, CompReadAttr, CompReadCls
  589. NULL, NULL, // ResultStr, ResultCls
  590. NULL, NULL, // ResultReadStr, ResultReadCls
  591. InterimStr);
  592. }
  593. };
  594. /////////////////////////////////////////////////////////////////////////////
  595. // ImmIfReplaceWholeText
  596. class ImmIfReplaceWholeText : public ImmIfEditSessionCallBack
  597. {
  598. public:
  599. ImmIfReplaceWholeText(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  600. HRESULT CallBackRoutine(TfEditCookie ec,
  601. ImmIfEditSession *pes)
  602. {
  603. return ReplaceWholeText(ec,
  604. pes->m_state.hIMC,
  605. pes->m_ic,
  606. pes->m_state.lpwCompStr);
  607. }
  608. HRESULT ReplaceWholeText(TfEditCookie ec,
  609. HIMC hIMC,
  610. Interface_Attach<ITfContext> ic,
  611. CWCompString* lpwCompStr);
  612. };
  613. /////////////////////////////////////////////////////////////////////////////
  614. // ImmIfReconvertString
  615. class ImmIfReconvertString : public ImmIfEditSessionCallBack
  616. {
  617. public:
  618. ImmIfReconvertString(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  619. HRESULT CallBackRoutine(TfEditCookie ec,
  620. ImmIfEditSession *pes)
  621. {
  622. return ReconvertString(ec,
  623. pes->m_state.hIMC,
  624. pes->m_ic,
  625. pes->m_pRange,
  626. pes->m_fDocFeedOnly,
  627. pes->m_state.lpwReconvStr);
  628. }
  629. HRESULT ReconvertString(TfEditCookie ec,
  630. HIMC hIMC,
  631. Interface_Attach<ITfContext> ic,
  632. Interface<ITfRange>* rangeSrc,
  633. BOOL fDocFeedOnly,
  634. CWReconvertString* lpwReconvStr);
  635. };
  636. /////////////////////////////////////////////////////////////////////////////
  637. // ImmIfClearDocFeedBuffer
  638. class ImmIfClearDocFeedBuffer : public ImmIfEditSessionCallBack
  639. {
  640. public:
  641. ImmIfClearDocFeedBuffer(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  642. HRESULT CallBackRoutine(TfEditCookie ec,
  643. ImmIfEditSession *pes)
  644. {
  645. return ClearDocFeedBuffer(ec,
  646. pes->m_state.hIMC,
  647. pes->m_ic);
  648. }
  649. HRESULT ClearDocFeedBuffer(TfEditCookie ec,
  650. HIMC hIMC,
  651. Interface_Attach<ITfContext> ic);
  652. };
  653. /////////////////////////////////////////////////////////////////////////////
  654. // ImmIfGetTextAndAttribute
  655. class ImmIfGetTextAndAttribute : public ImmIfEditSessionCallBack
  656. {
  657. public:
  658. ImmIfGetTextAndAttribute(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  659. HRESULT CallBackRoutine(TfEditCookie ec,
  660. ImmIfEditSession *pes)
  661. {
  662. return GetTextAndAttribute(ec,
  663. pes->m_state.hIMC,
  664. pes->m_ic,
  665. pes->m_state.lpwCompStr,
  666. pes->m_state.lpwCompAttr,
  667. pes->m_tid,
  668. pes->m_pLibTLS);
  669. }
  670. HRESULT GetTextAndAttribute(TfEditCookie ec,
  671. HIMC hIMC,
  672. Interface_Attach<ITfContext> ic,
  673. CWCompString* lpwCompString,
  674. CWCompAttribute* lpwCompAttribute,
  675. TfClientId ClientId,
  676. LIBTHREAD* pLibTLS);
  677. };
  678. /////////////////////////////////////////////////////////////////////////////
  679. // ImmIfQueryReconvertString
  680. class ImmIfQueryReconvertString : public ImmIfEditSessionCallBack
  681. {
  682. public:
  683. ImmIfQueryReconvertString(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  684. HRESULT CallBackRoutine(TfEditCookie ec,
  685. ImmIfEditSession *pes)
  686. {
  687. return QueryReconvertString(ec,
  688. pes->m_state.hIMC,
  689. pes->m_ic,
  690. pes->m_pRange,
  691. pes->m_state.lpwReconvStr);
  692. }
  693. HRESULT QueryReconvertString(TfEditCookie ec,
  694. HIMC hIMC,
  695. Interface_Attach<ITfContext> ic,
  696. Interface<ITfRange>* rangeQuery,
  697. CWReconvertString* lpwReconvStr);
  698. };
  699. /////////////////////////////////////////////////////////////////////////////
  700. // ImmIfCalcRangePos
  701. class ImmIfCalcRangePos : public ImmIfEditSessionCallBack
  702. {
  703. public:
  704. ImmIfCalcRangePos(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  705. HRESULT CallBackRoutine(TfEditCookie ec,
  706. ImmIfEditSession *pes)
  707. {
  708. return CalcRangePos(ec,
  709. pes->m_ic,
  710. pes->m_pRange,
  711. pes->m_state.lpwReconvStr);
  712. }
  713. HRESULT CalcRangePos(TfEditCookie ec,
  714. Interface_Attach<ITfContext> ic,
  715. Interface<ITfRange>* rangeSrc,
  716. CWReconvertString* lpwReconvStr);
  717. };
  718. /////////////////////////////////////////////////////////////////////////////
  719. // ImmIfGetSelection
  720. class ImmIfGetSelection : public ImmIfEditSessionCallBack
  721. {
  722. public:
  723. ImmIfGetSelection(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  724. HRESULT CallBackRoutine(TfEditCookie ec,
  725. ImmIfEditSession *pes)
  726. {
  727. return GetSelection(ec,
  728. pes->m_ic,
  729. pes->m_pRange);
  730. }
  731. HRESULT GetSelection(TfEditCookie ec,
  732. Interface_Attach<ITfContext> ic,
  733. Interface<ITfRange>* rangeSrc);
  734. };
  735. /////////////////////////////////////////////////////////////////////////////
  736. // ImmIfGetReadOnlyPropMargin
  737. class ImmIfGetReadOnlyPropMargin : public ImmIfEditSessionCallBack
  738. {
  739. public:
  740. ImmIfGetReadOnlyPropMargin(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  741. HRESULT CallBackRoutine(TfEditCookie ec,
  742. ImmIfEditSession *pes)
  743. {
  744. return GetReadOnlyPropMargin(ec,
  745. pes->m_ic,
  746. pes->m_pRangeACP,
  747. (LONG*)pes->m_state.pv);
  748. }
  749. HRESULT GetReadOnlyPropMargin(TfEditCookie ec,
  750. Interface_Attach<ITfContext> ic,
  751. Interface<ITfRangeACP>* rangeSrc,
  752. LONG* cch);
  753. };
  754. /////////////////////////////////////////////////////////////////////////////
  755. // ImmIfGetCursorPosition
  756. class ImmIfGetCursorPosition : public ImmIfEditSessionCallBack
  757. {
  758. public:
  759. ImmIfGetCursorPosition(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  760. HRESULT CallBackRoutine(TfEditCookie ec,
  761. ImmIfEditSession *pes)
  762. {
  763. return GetCursorPosition(ec,
  764. pes->m_state.hIMC,
  765. pes->m_ic,
  766. pes->m_state.lpwCursorPosition,
  767. pes->m_tid,
  768. pes->m_pLibTLS);
  769. }
  770. HRESULT GetCursorPosition(TfEditCookie ec,
  771. HIMC hIMC,
  772. Interface_Attach<ITfContext> ic,
  773. CWCompCursorPos* lpwCursorPosition,
  774. TfClientId ClientId,
  775. LIBTHREAD* pLibTLS);
  776. };
  777. /////////////////////////////////////////////////////////////////////////////
  778. // ImmIfGetCursorPosition
  779. class ImmIfGetAllTextRange : public ImmIfEditSessionCallBack
  780. {
  781. public:
  782. ImmIfGetAllTextRange(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  783. HRESULT CallBackRoutine(TfEditCookie ec,
  784. ImmIfEditSession *pes)
  785. {
  786. LONG cch;
  787. return GetAllTextRange(ec,
  788. pes->m_ic,
  789. pes->m_pRange,
  790. &cch);
  791. }
  792. };
  793. /////////////////////////////////////////////////////////////////////////////
  794. // ImmIfRemoveProperty
  795. class ImmIfRemoveProperty : public ImmIfEditSessionCallBack
  796. {
  797. public:
  798. ImmIfRemoveProperty(HIMC hIMC, TfClientId tid, Interface_Attach<ITfContext> ic, LIBTHREAD* pLibTLS) : ImmIfEditSessionCallBack(hIMC, tid, ic, pLibTLS) { }
  799. HRESULT CallBackRoutine(TfEditCookie ec,
  800. ImmIfEditSession *pes)
  801. {
  802. return RemoveProperty(ec,
  803. pes->m_ic,
  804. pes->m_guid);
  805. }
  806. HRESULT RemoveProperty(TfEditCookie ec,
  807. Interface_Attach<ITfContext> ic,
  808. const GUID* guid);
  809. };
  810. #endif // _EDITSES_H_