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.

243 lines
6.0 KiB

  1. // WrdBrk.h : Declaration of the CWrdBrk
  2. #ifndef __WRDBRK_H_
  3. #define __WRDBRK_H_
  4. #include "resource.h"
  5. #include "Query.h"
  6. #include "autoptr.h"
  7. #include "excption.h"
  8. #include "tokenizer.h"
  9. #include "FrenchTokenizer.h"
  10. #include "SpanishTokenizer.h"
  11. DECLARE_TAG(s_tagWordBreaker, "Word Breaker");
  12. template <class T, const CLSID* pclsid, const long IDR, class Tokenizer>
  13. class CBaseWrdBrk :
  14. public CComObjectRootEx<CComMultiThreadModel>,
  15. public CComCoClass<T, pclsid>,
  16. public IWordBreaker
  17. {
  18. public:
  19. CBaseWrdBrk(LCID lcid) :
  20. m_fInitialize(FALSE),
  21. m_lcid(lcid)
  22. {
  23. Trace(
  24. elVerbose,
  25. s_tagWordBreaker,
  26. ("WordBreaker constructed"));
  27. m_pUnkMarshaler = NULL;
  28. }
  29. // IWordBreaker
  30. public:
  31. DECLARE_REGISTRY_RESOURCEID(IDR)
  32. DECLARE_NOT_AGGREGATABLE(T)
  33. DECLARE_GET_CONTROLLING_UNKNOWN()
  34. BEGIN_COM_MAP(T)
  35. COM_INTERFACE_ENTRY(IWordBreaker)
  36. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  37. END_COM_MAP()
  38. HRESULT FinalConstruct()
  39. {
  40. return CoCreateFreeThreadedMarshaler(
  41. GetControllingUnknown(), &m_pUnkMarshaler.p);
  42. }
  43. void FinalRelease()
  44. {
  45. m_pUnkMarshaler.Release();
  46. }
  47. STDMETHOD(Init)(
  48. BOOL fQuery,
  49. ULONG ulMaxTokenSize,
  50. BOOL * pfLicense )
  51. {
  52. BEGIN_STDMETHOD(CWrdBrk::Init, s_tagWordBreaker);
  53. Trace(
  54. elVerbose,
  55. s_tagWordBreaker,
  56. ("WordBreaker Init"));
  57. if (NULL == pfLicense)
  58. {
  59. return E_INVALIDARG;
  60. }
  61. m_fInitialize = TRUE;
  62. m_fQueryTime = fQuery;
  63. m_ulMaxTokenSize = ulMaxTokenSize;
  64. return S_OK;
  65. END_STDMETHOD(CWrdBrk::Init, s_tagWordBreaker);
  66. }
  67. STDMETHOD(BreakText)(
  68. TEXT_SOURCE * pTextSource,
  69. IWordSink * pWordSink,
  70. IPhraseSink * pPhraseSink )
  71. {
  72. BEGIN_STDMETHOD(CWrdBrk::BreakText, s_tagWordBreaker);
  73. Trace(
  74. elVerbose,
  75. s_tagWordBreaker,
  76. ("WordBreaker Break Text, lcid - %x",
  77. m_lcid));
  78. if (NULL == pTextSource)
  79. {
  80. return E_INVALIDARG;
  81. }
  82. Tokenizer t(pTextSource,
  83. pWordSink,
  84. pPhraseSink,
  85. m_lcid,
  86. m_fQueryTime,
  87. m_ulMaxTokenSize);
  88. t.BreakText();
  89. return S_OK;
  90. END_STDMETHOD(CWrdBrk::BreakText, s_tagWordBreaker);
  91. }
  92. STDMETHOD(ComposePhrase)(
  93. WCHAR const * pwcNoun,
  94. ULONG cwcNoun,
  95. WCHAR const * pwcModifier,
  96. ULONG cwcModifier,
  97. ULONG ulAttachmentType,
  98. WCHAR * pwcPhrase,
  99. ULONG * pcwcPhrase )
  100. {
  101. BEGIN_STDMETHOD(CWrdBrk::ComposePhrase, s_tagWordBreaker);
  102. return E_NOTIMPL;
  103. END_STDMETHOD(CWrdBrk::ComposePhrase, s_tagWordBreaker);
  104. }
  105. STDMETHOD(GetLicenseToUse)(
  106. WCHAR const ** ppwcsLicense )
  107. {
  108. BEGIN_STDMETHOD(CWrdBrk::GetLicenseToUse, s_tagWordBreaker);
  109. if ( NULL == ppwcsLicense )
  110. return E_INVALIDARG;
  111. static WCHAR const * wcsCopyright = L"Copyright Microsoft Inc.";
  112. *ppwcsLicense = wcsCopyright;
  113. return( S_OK );
  114. END_STDMETHOD(CWrdBrk::GetLicenseToUse, s_tagWordBreaker);
  115. }
  116. protected:
  117. BOOL m_fInitialize;
  118. BOOL m_fQueryTime;
  119. ULONG m_ulMaxTokenSize;
  120. LCID m_lcid;
  121. public:
  122. CComPtr<IUnknown> m_pUnkMarshaler;
  123. };
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CEngUSWrdBrk
  126. class ATL_NO_VTABLE CEngUSWrdBrk :
  127. public CBaseWrdBrk<CEngUSWrdBrk, &CLSID_EngUSWrdBrk, IDR_ENGUSWRDBRK, CTokenizer>
  128. {
  129. public:
  130. CEngUSWrdBrk() :
  131. CBaseWrdBrk<CEngUSWrdBrk, &CLSID_EngUSWrdBrk, IDR_ENGUSWRDBRK, CTokenizer>
  132. (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
  133. SORT_DEFAULT ))
  134. {
  135. }
  136. };
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CEngUKWrdBrk
  139. class ATL_NO_VTABLE CEngUKWrdBrk :
  140. public CBaseWrdBrk<CEngUKWrdBrk, &CLSID_EngUKWrdBrk, IDR_ENGUKWRDBRK, CTokenizer>
  141. {
  142. public:
  143. CEngUKWrdBrk() :
  144. CBaseWrdBrk<CEngUKWrdBrk, &CLSID_EngUKWrdBrk, IDR_ENGUKWRDBRK, CTokenizer>
  145. (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK),
  146. SORT_DEFAULT ))
  147. {
  148. }
  149. };
  150. /////////////////////////////////////////////////////////////////////////////
  151. // CFrnFrnWrdBrk
  152. class ATL_NO_VTABLE CFrnFrnWrdBrk :
  153. public CBaseWrdBrk<CFrnFrnWrdBrk, &CLSID_FrnFrnWrdBrk, IDR_FRNFRNWRDBRK, CFrenchTokenizer>
  154. {
  155. public:
  156. CFrnFrnWrdBrk() :
  157. CBaseWrdBrk<CFrnFrnWrdBrk, &CLSID_FrnFrnWrdBrk, IDR_FRNFRNWRDBRK, CFrenchTokenizer>
  158. (MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH),
  159. SORT_DEFAULT ))
  160. {
  161. }
  162. };
  163. /////////////////////////////////////////////////////////////////////////////
  164. // CItlItlWrdBrk
  165. class ATL_NO_VTABLE CItlItlWrdBrk :
  166. public CBaseWrdBrk<CItlItlWrdBrk, &CLSID_ItlItlWrdBrk, IDR_ITLITLWRDBRK, CTokenizer>
  167. {
  168. public:
  169. CItlItlWrdBrk() :
  170. CBaseWrdBrk<CItlItlWrdBrk, &CLSID_ItlItlWrdBrk, IDR_ITLITLWRDBRK, CTokenizer>
  171. (MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_ITALIAN),
  172. SORT_DEFAULT ))
  173. {
  174. }
  175. };
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CSpnMdrWrdBrk
  178. class ATL_NO_VTABLE CSpnMdrWrdBrk :
  179. public CBaseWrdBrk<CSpnMdrWrdBrk, &CLSID_SpnMdrWrdBrk, IDR_SPNMDRWRDBRK, CSpanishTokenizer>
  180. {
  181. public:
  182. CSpnMdrWrdBrk() :
  183. CBaseWrdBrk<CSpnMdrWrdBrk, &CLSID_SpnMdrWrdBrk, IDR_SPNMDRWRDBRK, CSpanishTokenizer>
  184. (MAKELCID(MAKELANGID(LANG_SPANISH , SUBLANG_SPANISH_MODERN),
  185. SORT_DEFAULT ))
  186. {
  187. }
  188. };
  189. #endif //__WRDBRK_H_