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.

208 lines
5.5 KiB

  1. // editsess.h
  2. //
  3. // Edit Session classes declaration
  4. //
  5. #ifndef EDITSESS_H
  6. #define EDITSESS_H
  7. #include "private.h"
  8. #include "sapilayr.h"
  9. #include "playback.h"
  10. #include "fnrecon.h"
  11. #include "propstor.h"
  12. #include "selword.h"
  13. class CSapiIMX;
  14. class CPlayBack;
  15. class CFnReconversion;
  16. class CPropStoreRecoResultObject;
  17. class CPropStoreLMLattice;
  18. class CSelectWord;
  19. //
  20. // Caller puts all the Edit Session in-paramaters to this structure and pass to _RequestEditSession( ).
  21. //
  22. typedef struct _ESData
  23. {
  24. void *pData; // pData pointer to memory. its size is uByte of bytes.
  25. UINT uByte; //
  26. LONG_PTR lData1; // m_lData1 and m_lData2 contain constant data.
  27. LONG_PTR lData2;
  28. BOOL fBool;
  29. ITfRange *pRange;
  30. IUnknown *pUnk;
  31. } ESDATA;
  32. //
  33. // This is a base class for Sptip edit sessions.
  34. // We don't want to inherit the class from CEditSession in inc\editcb.h which doesn't correctly handle some COM pointer
  35. // and /or allocated memeory pointer.
  36. // We don't change the code in lib\editcb.cpp, since it is used by other TIPs.
  37. //
  38. class CEditSessionBase : public ITfEditSession
  39. {
  40. public:
  41. CEditSessionBase(ITfContext *pContext);
  42. virtual ~CEditSessionBase();
  43. // IUnknown
  44. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  45. STDMETHODIMP_(ULONG) AddRef(void);
  46. STDMETHODIMP_(ULONG) Release(void);
  47. // ITfEditSession
  48. virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0;
  49. HRESULT _SetEditSessionData(UINT m_idEditSession, void *pData, UINT uBytes, LONG_PTR lData1 = 0, LONG_PTR lData2=0, BOOL fBool = FALSE);
  50. void _SetRange(ITfRange *pRange) { m_cpRange = pRange; }
  51. void _SetUnk(IUnknown *punk) { m_cpunk = punk; }
  52. ITfRange *_GetRange( ) { return m_cpRange; }
  53. IUnknown *_GetUnk( ) { return m_cpunk; }
  54. void *_GetPtrData( ) { return m_pData; }
  55. LONG_PTR _GetData1( ) { return m_lData1; }
  56. LONG_PTR _GetData2( ) { return m_lData2; }
  57. BOOL _GetBool( ) { return m_fBool; }
  58. LONG_PTR _GetRetData( ) { return m_lRetData; }
  59. IUnknown *_GetRetUnknown( )
  60. {
  61. IUnknown *pUnk = NULL;
  62. pUnk = m_cpRetUnk;
  63. if ( pUnk )
  64. pUnk->AddRef( );
  65. return pUnk;
  66. }
  67. UINT m_idEditSession;
  68. CComPtr<ITfContext> m_cpic;
  69. // Keep the return data for this edit session.
  70. LONG_PTR m_lRetData;
  71. CComPtr<IUnknown> m_cpRetUnk;
  72. private:
  73. // Data passed by caller to request a edit session.
  74. void *m_pData; // pData pointer to memory. its size is uByte of bytes.
  75. LONG_PTR m_lData1; // m_lData1 and m_lData2 contain constant data.
  76. LONG_PTR m_lData2;
  77. BOOL m_fBool;
  78. CComPtr<ITfRange> m_cpRange;
  79. CComPtr<IUnknown> m_cpunk; // keep any COM pointer.
  80. LONG _cRef; // COM ref count
  81. };
  82. //
  83. // Edit Session for CSapiIMX.
  84. //
  85. class CSapiEditSession : public CEditSessionBase
  86. {
  87. public:
  88. CSapiEditSession(CSapiIMX *pimx, ITfContext *pContext);
  89. virtual ~CSapiEditSession( );
  90. STDMETHODIMP DoEditSession(TfEditCookie ec);
  91. private:
  92. CSapiIMX *m_pimx;
  93. };
  94. //
  95. // Edit Session for CSelectWord: Selection related commands
  96. //
  97. class CSelWordEditSession : public CSapiEditSession
  98. {
  99. public:
  100. CSelWordEditSession(CSapiIMX *pimx, CSelectWord *pSelWord, ITfContext *pContext);
  101. virtual ~CSelWordEditSession( );
  102. STDMETHODIMP DoEditSession(TfEditCookie ec);
  103. void _SetUnk2(IUnknown *cpunk) { m_cpunk2 = cpunk; };
  104. IUnknown *_GetUnk2( ) { return m_cpunk2; };
  105. LONG_PTR _GetLenXXX( ) { return m_ulLenXXX; }
  106. void _SetLenXXX( LONG_PTR ulLenXXX ) { m_ulLenXXX = ulLenXXX; }
  107. private:
  108. CComPtr<IUnknown> m_cpunk2;
  109. LONG_PTR m_ulLenXXX; // the charnum of XXX part for "Select XXX through YYY" command.
  110. CSelectWord *m_pSelWord;
  111. };
  112. //
  113. // Edit Session for PlayBack
  114. //
  115. class CPlayBackEditSession : public CEditSessionBase
  116. {
  117. public:
  118. CPlayBackEditSession(CSapiPlayBack *pPlayBack, ITfContext *pContext);
  119. virtual ~CPlayBackEditSession( );
  120. STDMETHODIMP DoEditSession(TfEditCookie ec);
  121. private:
  122. CSapiPlayBack *m_pPlayBack;
  123. };
  124. //
  125. // Edit Session for Reconversion
  126. //
  127. class CFnRecvEditSession : public CEditSessionBase
  128. {
  129. public:
  130. CFnRecvEditSession(CFnReconversion *pFnRecv, ITfRange *pRange, ITfContext *pContext);
  131. virtual ~CFnRecvEditSession( );
  132. STDMETHODIMP DoEditSession(TfEditCookie ec);
  133. private:
  134. CFnReconversion *m_pFnRecv;
  135. };
  136. //
  137. // Edit Session for CPropStoreRecoResultObject
  138. //
  139. class CPSRecoEditSession : public CEditSessionBase
  140. {
  141. public:
  142. CPSRecoEditSession(CPropStoreRecoResultObject *pPropStoreReco, ITfRange *pRange, ITfContext *pContext);
  143. virtual ~CPSRecoEditSession( );
  144. STDMETHODIMP DoEditSession(TfEditCookie ec);
  145. private:
  146. CPropStoreRecoResultObject *m_pPropStoreReco;
  147. };
  148. //
  149. // Edit Session for CPropStoreLMLattice
  150. //
  151. class CPSLMEditSession : public CEditSessionBase
  152. {
  153. public:
  154. CPSLMEditSession(CPropStoreLMLattice *pPropStoreLM, ITfRange *pRange, ITfContext *pContext);
  155. virtual ~CPSLMEditSession( );
  156. STDMETHODIMP DoEditSession(TfEditCookie ec);
  157. private:
  158. CPropStoreLMLattice *m_pPropStoreLM;
  159. };
  160. #endif // EDITSESS_H