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.

147 lines
4.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: DefBreak.hxx
  7. //
  8. // Contents: 'Default' Word Breaker
  9. //
  10. // Classes: CDefWordBreaker
  11. //
  12. // History: 08-May-91 t-WadeR Created
  13. // 06-Jun-91 t-WadeR changed for input-based pipeline
  14. // 11-Apr-94 KyleP Sync with spec
  15. //
  16. //----------------------------------------------------------------------------
  17. #pragma once
  18. const WCHAR ZERO_WIDTH_SPACE = 0x200B; // Unicode zero width space
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CDefWordBreaker
  22. //
  23. // Purpose: Break text into phrases and words (default wordbreaker)
  24. //
  25. // History: 02-May-91 BartoszM Created.
  26. // 13-May-91 t-WadeR Changed to use CWordItr.
  27. // 06-June-91 t-WadeR changed for input-based pipeline
  28. // 12-Oct-92 AmyA Added Unicode support
  29. // 18-Nov-92 AmyA Overloaded BreakText
  30. // 11-Apr-94 KyleP Sync with spec
  31. //
  32. //----------------------------------------------------------------------------
  33. class CDefWordBreaker : public IWordBreaker
  34. {
  35. public:
  36. //
  37. // From IUnknown
  38. //
  39. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid,
  40. void **ppvObject );
  41. virtual ULONG STDMETHODCALLTYPE AddRef();
  42. virtual ULONG STDMETHODCALLTYPE Release();
  43. //
  44. // From IWordBreaker
  45. //
  46. virtual SCODE STDMETHODCALLTYPE Init( BOOL fQuery,
  47. ULONG ulMaxTokenSize,
  48. BOOL *pfLicense );
  49. virtual SCODE STDMETHODCALLTYPE BreakText( TEXT_SOURCE *pTextSource,
  50. IWordSink *pWordSink,
  51. IPhraseSink *pPhraseSink );
  52. virtual SCODE STDMETHODCALLTYPE ComposePhrase( WCHAR const *pwcNoun,
  53. ULONG cwcNoun,
  54. WCHAR const *pwcModifier,
  55. ULONG cwcModifier,
  56. ULONG ulAttachmentType,
  57. WCHAR *pwcPhrase,
  58. ULONG *pcwcPhrase );
  59. virtual SCODE STDMETHODCALLTYPE GetLicenseToUse( const WCHAR **ppwcsLicense );
  60. //
  61. // Local methods
  62. //
  63. CDefWordBreaker();
  64. private:
  65. BOOL IsWordChar (int i) const;
  66. BOOL ScanChunk ();
  67. void Tokenize( TEXT_SOURCE *pTextSource, ULONG cwc, IWordSink *pWordSink, ULONG& cwcProcd );
  68. ~CDefWordBreaker();
  69. enum _EBufSize
  70. {
  71. ccCompare = 500
  72. };
  73. // These variables describe current chunk
  74. ULONG _cMapped;
  75. const WCHAR* _pwcChunk;
  76. // Leave space for one (dummy) lookahead
  77. WORD _aCharInfo1[CDefWordBreaker::ccCompare+1];
  78. WORD _aCharInfo3[CDefWordBreaker::ccCompare+1];
  79. WCHAR _awcBufZWS[CDefWordBreaker::ccCompare]; // temp buffer for a word having zero-width space
  80. long _cRefs;
  81. };
  82. //+---------------------------------------------------------------------------
  83. //
  84. // Class: CDefWordBreakerCF
  85. //
  86. // Purpose: Class factory for default word breaker
  87. //
  88. // History: 07-Feb-95 SitaramR Created
  89. //
  90. //----------------------------------------------------------------------------
  91. class CDefWordBreakerCF : public IClassFactory
  92. {
  93. public:
  94. CDefWordBreakerCF();
  95. //
  96. // From IUnknown
  97. //
  98. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid,
  99. void ** ppvObject);
  100. virtual ULONG STDMETHODCALLTYPE AddRef();
  101. virtual ULONG STDMETHODCALLTYPE Release();
  102. //
  103. // From IClassFactory
  104. //
  105. virtual SCODE STDMETHODCALLTYPE CreateInstance( IUnknown * pUnkOuter,
  106. REFIID riid, void * * ppvObject );
  107. virtual SCODE STDMETHODCALLTYPE LockServer( BOOL fLock );
  108. protected:
  109. virtual ~CDefWordBreakerCF();
  110. long _cRefs;
  111. };