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.

182 lines
4.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  5. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  6. // PARTICULAR PURPOSE.
  7. //
  8. // Copyright (c) 1998-1999 Microsoft Corporation. All Rights Reserved.
  9. //
  10. // File: smpfilt.hxx
  11. //
  12. // Contents: Sample filter declarations
  13. //
  14. // Platform: Windows 2000
  15. //
  16. //--------------------------------------------------------------------------
  17. #pragma once
  18. //+-------------------------------------------------------------------------
  19. //
  20. // Global definitions
  21. //
  22. //--------------------------------------------------------------------------
  23. const ULONG TEXT_FILTER_CHUNK_SIZE = 10000L; // size of character buffers
  24. long g_lInstances = 0; // Global count of CSmpFilt and CSmpFiltCF instances
  25. GUID const guidStorage = PSGUID_STORAGE; // GUID for storage property set
  26. //C-------------------------------------------------------------------------
  27. //
  28. // Class: CSmpFilter
  29. //
  30. // Purpose: Implements interfaces of sample filter
  31. //
  32. //--------------------------------------------------------------------------
  33. // SmpFilter Class ID
  34. // {8B0E5E70-3C30-11d1-8C0D-00AA00C26CD4}
  35. GUID const CLSID_CSmpFilter =
  36. {
  37. 0x8b0e5e70,
  38. 0x3c30,
  39. 0x11d1,
  40. { 0x8c, 0xd, 0x0, 0xaa, 0x0, 0xc2, 0x6c, 0xd4 }
  41. };
  42. class CSmpFilter : public IFilter, public IPersistFile
  43. {
  44. public:
  45. //
  46. // From IUnknown
  47. //
  48. virtual SCODE STDMETHODCALLTYPE QueryInterface(
  49. REFIID riid,
  50. void ** ppvObject
  51. );
  52. virtual ULONG STDMETHODCALLTYPE AddRef();
  53. virtual ULONG STDMETHODCALLTYPE Release();
  54. //
  55. // From IFilter
  56. //
  57. virtual SCODE STDMETHODCALLTYPE Init(
  58. ULONG grfFlags,
  59. ULONG cAttributes,
  60. FULLPROPSPEC const * aAttributes,
  61. ULONG * pFlags
  62. );
  63. virtual SCODE STDMETHODCALLTYPE GetChunk(
  64. STAT_CHUNK * pStat
  65. );
  66. virtual SCODE STDMETHODCALLTYPE GetText(
  67. ULONG * pcwcBuffer,
  68. WCHAR * awcBuffer
  69. );
  70. virtual SCODE STDMETHODCALLTYPE GetValue(
  71. PROPVARIANT ** ppPropValue
  72. );
  73. virtual SCODE STDMETHODCALLTYPE BindRegion(
  74. FILTERREGION origPos,
  75. REFIID riid,
  76. void ** ppunk
  77. );
  78. //
  79. // From IPersistFile
  80. //
  81. virtual SCODE STDMETHODCALLTYPE GetClassID(
  82. CLSID * pClassID
  83. );
  84. virtual SCODE STDMETHODCALLTYPE IsDirty();
  85. virtual SCODE STDMETHODCALLTYPE Load(
  86. LPCWSTR pszFileName,
  87. DWORD dwMode
  88. );
  89. virtual SCODE STDMETHODCALLTYPE Save(
  90. LPCWSTR pszFileName,
  91. BOOL fRemember
  92. );
  93. virtual SCODE STDMETHODCALLTYPE SaveCompleted(
  94. LPCWSTR pszFileName
  95. );
  96. virtual SCODE STDMETHODCALLTYPE GetCurFile(
  97. LPWSTR * ppszFileName
  98. );
  99. private:
  100. friend class CSmpFilterCF;
  101. CSmpFilter();
  102. ~CSmpFilter();
  103. HANDLE m_hFile; // Handle to the input file
  104. long m_lRefs; // Reference count
  105. WCHAR * m_pwszFileName; // Name of input file to filter
  106. ULONG m_ulBufferLen; // Characters read from file to buffer
  107. ULONG m_ulCharsRead; // Characters read from chunk buffer
  108. ULONG m_ulChunkID; // Current chunk id
  109. ULONG m_ulCodePage; // Current default codepage
  110. BOOL m_fContents; // TRUE if contents requested
  111. BOOL m_fEof; // TRUE if end of file reached
  112. WCHAR m_wcsBuffer[TEXT_FILTER_CHUNK_SIZE]; // Buffer for UNICODE
  113. };
  114. //C-------------------------------------------------------------------------
  115. //
  116. // Class: CSmpFilterCF
  117. //
  118. // Purpose: Implements class factory for sample filter
  119. //
  120. //--------------------------------------------------------------------------
  121. class CSmpFilterCF : public IClassFactory
  122. {
  123. public:
  124. //
  125. // From IUnknown
  126. //
  127. virtual SCODE STDMETHODCALLTYPE QueryInterface(
  128. REFIID riid,
  129. void ** ppvObject
  130. );
  131. virtual ULONG STDMETHODCALLTYPE AddRef();
  132. virtual ULONG STDMETHODCALLTYPE Release();
  133. //
  134. // From IClassFactory
  135. //
  136. virtual SCODE STDMETHODCALLTYPE CreateInstance(
  137. IUnknown * pUnkOuter,
  138. REFIID riid, void ** ppvObject
  139. );
  140. virtual SCODE STDMETHODCALLTYPE LockServer(
  141. BOOL fLock
  142. );
  143. private:
  144. friend SCODE STDMETHODCALLTYPE DllGetClassObject(
  145. REFCLSID cid,
  146. REFIID iid,
  147. void ** ppvObj
  148. );
  149. CSmpFilterCF();
  150. ~CSmpFilterCF();
  151. long m_lRefs; // Reference count
  152. };