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.

98 lines
3.2 KiB

  1. #ifndef _CHTBRKR_H__
  2. #define _CHTBRKR_H__
  3. extern "C" TCHAR g_tszModuleFileName[MAX_PATH];
  4. extern "C" HINSTANCE g_hInstance;
  5. class CCHTWordBreaker;
  6. class CDefWordBreaker;
  7. // {1680E7C3-9430-4a51-9B82-1E7E7AEE5258}
  8. DEFINE_GUID(CLSID_CHTBRKR, 0x1680E7C3, 0x9430, 0x4A51, 0x9B, 0x82,
  9. 0x1E, 0x7E, 0x7A, 0xEE, 0x52, 0x58);
  10. // {954F1760-C1BC-11D0-9692-00A0C908146E}
  11. DEFINE_GUID(CLSID_WHISTLER_CHTBRKR, 0x954F1760, 0xC1BC, 0x11D0, 0x96, 0x92,
  12. 0x00, 0xA0, 0xC9, 0x08, 0x14, 0x6E);
  13. DEFINE_GUID(IID_IWordBreaker, 0xD53552C8, 0x77E3, 0x101A, 0xB5, 0x52,
  14. 0x08, 0x0, 0x2B ,0x33 ,0xB0, 0xE6);
  15. typedef SCODE ( __stdcall __RPC_FAR *PFNFILLTEXTBUFFER )(
  16. struct tagTEXT_SOURCE __RPC_FAR *pTextSource);
  17. typedef struct tagTEXT_SOURCE{
  18. PFNFILLTEXTBUFFER pfnFillTextBuffer;
  19. const WCHAR *awcBuffer;
  20. ULONG iEnd;
  21. ULONG iCur;
  22. }TEXT_SOURCE;
  23. typedef enum tagWORDREP_BREAK_TYPE{
  24. WORDREP_BREAK_EOW = 0,
  25. WORDREP_BREAK_EOS = 1,
  26. WORDREP_BREAK_EOP = 2,
  27. WORDREP_BREAK_EOC = 3
  28. } WORDREP_BREAK_TYPE;
  29. class IChtBrKrClassFactory: public IClassFactory
  30. {
  31. public:
  32. IChtBrKrClassFactory();
  33. ~IChtBrKrClassFactory();
  34. public:
  35. // IUnknown members
  36. STDMETHOD(QueryInterface) (THIS_ REFIID refiid, VOID **ppv);
  37. STDMETHOD_(ULONG,AddRef) (THIS);
  38. STDMETHOD_(ULONG,Release) (THIS);
  39. // IFEClassFactory members
  40. STDMETHOD(CreateInstance) (THIS_ LPUNKNOWN, REFIID, void **);
  41. STDMETHOD(LockServer) (THIS_ BOOL);
  42. private:
  43. LONG m_lRefCnt;
  44. };
  45. DECLARE_INTERFACE_(IWordSink, IUnknown)
  46. {
  47. public:
  48. STDMETHOD(PutWord) (THIS_ ULONG cwc, const WCHAR *pwcInBuf, ULONG cwcSrcLen, ULONG cwcSrcPos) PURE;
  49. STDMETHOD(PutAltWord) (THIS_ ULONG cwc, const WCHAR *pwcInBuf, ULONG cwcSrcLen, ULONG cwcSrcPos) PURE;
  50. STDMETHOD(StartAltPhrase) (THIS) PURE;
  51. STDMETHOD(EndAltPhrase) (THIS) PURE;
  52. STDMETHOD(PutBreak) (THIS_ WORDREP_BREAK_TYPE breakType) PURE;
  53. };
  54. DECLARE_INTERFACE_(IPhraseSink, IUnknown)
  55. {
  56. public:
  57. STDMETHOD(PutSmallPhrase) (THIS_ const WCHAR *pwcNoun, ULONG cwcNoun, const WCHAR *pwcModifier,
  58. ULONG cwcModifier, ULONG ulAttachmentType) PURE;
  59. STDMETHOD(PutPhrase) (THIS_ const WCHAR *pwcPhrase, ULONG cwcPhrase) PURE;
  60. };
  61. class IWordBreaker: public IUnknown
  62. {
  63. public:
  64. IWordBreaker();
  65. ~IWordBreaker();
  66. public:
  67. STDMETHOD(QueryInterface) (THIS_ REFIID refiid, VOID **ppv);
  68. STDMETHOD_(ULONG,AddRef) (THIS);
  69. STDMETHOD_(ULONG,Release) (THIS);
  70. public:
  71. STDMETHOD(Init) (THIS_ BOOL fQuery, ULONG ulMaxTokenSize, BOOL *pfLicense);
  72. STDMETHOD(BreakText) (THIS_ TEXT_SOURCE *pTextSource, IWordSink *pWordSink, IPhraseSink *pPhraseSink);
  73. STDMETHOD(ComposePhrase) (THIS_ const WCHAR *pwcNoun, ULONG cwcNoun, const WCHAR *pwcModifier,
  74. ULONG cwcModifier, ULONG ulAttachmentType, WCHAR *pwcPhrase, ULONG *pcwcPhrase);
  75. STDMETHOD(GetLicenseToUse) (THIS_ const WCHAR **ppwcsLicense);
  76. private:
  77. UINT m_uMaxCharNumberPerWord;
  78. LONG m_lRefCnt;
  79. CCHTWordBreaker* m_pcWordBreaker;
  80. TEXT_SOURCE* m_pNonChineseTextSource;
  81. IWordBreaker* m_pNonChineseWordBreaker;
  82. CDefWordBreaker* m_pcDefWordBreaker;
  83. BOOL m_fIsQueryTime;
  84. };
  85. #else
  86. #endif //_CHTBRKR_H__