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.

307 lines
8.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: stgwrap.hxx
  7. //
  8. // Contents: IStorage and IStream wrappers for async docfile
  9. //
  10. // Classes: CAsyncStorage
  11. // CAsyncRootStorage
  12. // CAsyncStream
  13. // CConnectionPoint
  14. //
  15. // Functions:
  16. //
  17. // History: 27-Dec-95 SusiA Created
  18. //
  19. //----------------------------------------------------------------------------
  20. #ifndef __ASYNCEXPDF_HXX__
  21. #define __ASYNCEXPDF_HXX__
  22. #include "sinklist.hxx"
  23. #include "filllkb.hxx"
  24. //BUGBUG: defined in dfmsp.hxx.
  25. typedef DWORD LPSTGSECURITY;
  26. //+---------------------------------------------------------------------------
  27. //
  28. // Class: CAsyncStorage
  29. //
  30. // Purpose: Wrap storage objects for Async Docfiles
  31. //
  32. // Interface:
  33. //
  34. // History: 28-Dec-95 SusiA Created
  35. //
  36. // Notes:
  37. //
  38. //----------------------------------------------------------------------------
  39. class CAsyncStorage:
  40. public IStorage,
  41. public IConnectionPointContainer
  42. {
  43. public:
  44. inline CAsyncStorage(IStorage *pstg, CFillLockBytes *pflb);
  45. inline ~CAsyncStorage(void);
  46. // IUnknown
  47. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  48. STDMETHOD_(ULONG, AddRef)(void);
  49. STDMETHOD_(ULONG, Release)(void);
  50. // IStorage
  51. STDMETHOD(CreateStream)(OLECHAR const *pwcsName,
  52. DWORD grfMode,
  53. DWORD reserved1,
  54. DWORD reserved2,
  55. IStream **ppstm);
  56. STDMETHOD(OpenStream)(OLECHAR const *pwcsName,
  57. void *reserved1,
  58. DWORD grfMode,
  59. DWORD reserved2,
  60. IStream **ppstm);
  61. STDMETHOD(CreateStorage)(OLECHAR const *pwcsName,
  62. DWORD grfMode,
  63. DWORD reserved1,
  64. LPSTGSECURITY reserved2,
  65. IStorage **ppstg);
  66. STDMETHOD(OpenStorage)(OLECHAR const *pwcsName,
  67. IStorage *pstgPriority,
  68. DWORD grfMode,
  69. SNB snbExclude,
  70. DWORD reserved,
  71. IStorage **ppstg);
  72. STDMETHOD(CopyTo)(DWORD ciidExclude,
  73. IID const *rgiidExclude,
  74. SNB snbExclude,
  75. IStorage *pstgDest);
  76. STDMETHOD(MoveElementTo)(OLECHAR const *lpszName,
  77. IStorage *pstgDest,
  78. OLECHAR const *lpszNewName,
  79. DWORD grfFlags);
  80. STDMETHOD(Commit)(DWORD grfCommitFlags);
  81. STDMETHOD(Revert)(void);
  82. STDMETHOD(EnumElements)(DWORD reserved1,
  83. void *reserved2,
  84. DWORD reserved3,
  85. IEnumSTATSTG **ppenm);
  86. STDMETHOD(DestroyElement)(OLECHAR const *pwcsName);
  87. STDMETHOD(RenameElement)(OLECHAR const *pwcsOldName,
  88. OLECHAR const *pwcsNewName);
  89. STDMETHOD(SetElementTimes)(const OLECHAR *lpszName,
  90. FILETIME const *pctime,
  91. FILETIME const *patime,
  92. FILETIME const *pmtime);
  93. STDMETHOD(SetClass)(REFCLSID clsid);
  94. STDMETHOD(SetStateBits)(DWORD grfStateBits, DWORD grfMask);
  95. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  96. //From IConnectionPointContainer
  97. STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints **ppEnum);
  98. STDMETHOD(FindConnectionPoint)(REFIID iid, IConnectionPoint **ppCP);
  99. SCODE Notify(void);
  100. protected:
  101. LONG _cReferences;
  102. IStorage *_pRealStg;
  103. CFillLockBytes *_pflb;
  104. CConnectionPoint _cpoint;
  105. };
  106. inline CAsyncStorage::CAsyncStorage(IStorage *pstg, CFillLockBytes *pflb)
  107. {
  108. _cReferences = 1;
  109. _pRealStg = pstg;
  110. _pflb = pflb;
  111. }
  112. inline CAsyncStorage::~CAsyncStorage(void)
  113. {
  114. if (_pRealStg != NULL)
  115. _pRealStg->Release;
  116. }
  117. //+---------------------------------------------------------------------------
  118. //
  119. // Class: CAsyncRootStorage
  120. //
  121. // Purpose: Wrap Root Storage objects for Async Docfiles
  122. //
  123. // Interface:
  124. //
  125. // History: 28-Dec-95 SusiA Created
  126. //
  127. // Notes:
  128. //
  129. //----------------------------------------------------------------------------
  130. class CAsyncRootStorage:
  131. public IRootStorage,
  132. public CAsyncStorage
  133. {
  134. public:
  135. inline CAsyncRootStorage(IStorage *pstg, CFillLockBytes *pflb);
  136. // IUnknown
  137. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  138. STDMETHOD_(ULONG, AddRef)(void);
  139. STDMETHOD_(ULONG, Release)(void);
  140. // IRootStorage
  141. STDMETHOD(SwitchToFile)(OLECHAR *ptcsFile);
  142. };
  143. inline CAsyncRootStorage::CAsyncRootStorage(IStorage *pstg, CFillLockBytes *pflb)
  144. :CAsyncStorage(pstg, pflb)
  145. {
  146. }
  147. //+---------------------------------------------------------------------------
  148. //
  149. // Class: CAsyncStream
  150. //
  151. // Purpose: Wrap Stream objects for Async Docfiles
  152. //
  153. // Interface:
  154. //
  155. // History: 28-Dec-95 SusiA Created
  156. //
  157. // Notes:
  158. //
  159. //----------------------------------------------------------------------------
  160. class CAsyncStream:
  161. public IStream,
  162. public IConnectionPointContainer
  163. {
  164. public:
  165. inline CAsyncStream(IStream *pstm, CFillLockBytes *pflb);
  166. inline ~CAsyncStream(void);
  167. // From IUnknown
  168. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  169. STDMETHOD_(ULONG,AddRef)(void);
  170. STDMETHOD_(ULONG,Release)(void);
  171. // From IStream
  172. STDMETHOD(Read)(VOID HUGEP *pv,
  173. ULONG cb,
  174. ULONG *pcbRead);
  175. STDMETHOD(Write)(VOID const HUGEP *pv,
  176. ULONG cb,
  177. ULONG *pcbWritten);
  178. STDMETHOD(Seek)(LARGE_INTEGER dlibMove,
  179. DWORD dwOrigin,
  180. ULARGE_INTEGER *plibNewPosition);
  181. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  182. STDMETHOD(CopyTo)(IStream *pstm,
  183. ULARGE_INTEGER cb,
  184. ULARGE_INTEGER *pcbRead,
  185. ULARGE_INTEGER *pcbWritten);
  186. STDMETHOD(Commit)(DWORD grfCommitFlags);
  187. STDMETHOD(Revert)(void);
  188. STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset,
  189. ULARGE_INTEGER cb,
  190. DWORD dwLockType);
  191. STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset,
  192. ULARGE_INTEGER cb,
  193. DWORD dwLockType);
  194. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  195. STDMETHOD(Clone)(IStream **ppstm);
  196. //From IConnectionPointContainer
  197. STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints **ppEnum);
  198. STDMETHOD(FindConnectionPoint)(REFIID iid, IConnectionPoint **ppCP);
  199. SCODE Notify(void);
  200. private:
  201. LONG _cReferences;
  202. IStream *_pRealStm;
  203. CFillLockBytes *_pflb;
  204. CConnectionPoint _cpoint;
  205. };
  206. inline CAsyncStream::CAsyncStream(IStream *pstm, CFillLockBytes *pflb)
  207. {
  208. _cReferences = 1;
  209. _pRealStm = pstm;
  210. _pflb = pflb;
  211. }
  212. inline CAsyncStream::~CAsyncStream(void)
  213. {
  214. if (_pRealStm != NULL)
  215. _pRealStm->Release;
  216. }
  217. //+---------------------------------------------------------------------------
  218. //
  219. // Class: CAsyncEnumSTATSTG
  220. //
  221. // Purpose: Wrap EnumSTATSTG objects for Async Docfiles
  222. //
  223. // Interface:
  224. //
  225. // History: 28-Dec-95 SusiA Created
  226. //
  227. // Notes:
  228. //
  229. //----------------------------------------------------------------------------
  230. class CAsyncEnum
  231. : public IEnumSTATSTG,
  232. public IConnectionPointContainer
  233. {
  234. public:
  235. inline CAsyncEnum(IEnumSTATSTG *penum, CFillLockBytes *pflb);
  236. inline ~CAsyncEnum(void);
  237. // From IUnknown
  238. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  239. STDMETHOD_(ULONG,AddRef)(void);
  240. STDMETHOD_(ULONG,Release)(void);
  241. // IEnumSTATSTG
  242. STDMETHOD(Next)(ULONG celt, STATSTG FAR *rgelt, ULONG *pceltFetched);
  243. STDMETHOD(Skip)(ULONG celt);
  244. STDMETHOD(Reset)(void);
  245. STDMETHOD(Clone)(IEnumSTATSTG **ppenm);
  246. //From IConnectionPointContainer
  247. STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints **ppEnum);
  248. STDMETHOD(FindConnectionPoint)(REFIID iid, IConnectionPoint **ppCP);
  249. SCODE Notify(void);
  250. private:
  251. LONG _cReferences;
  252. IEnumSTATSTG *_pRealEnum;
  253. CFillLockBytes *_pflb;
  254. CConnectionPoint _cpoint;
  255. };
  256. inline CAsyncEnum::CAsyncEnum(IEnumSTATSTG *penum, CFillLockBytes *pflb)
  257. {
  258. _cReferences = 1;
  259. _pRealEnum = penum;
  260. _pflb = pflb;
  261. }
  262. inline CAsyncEnum::~CAsyncEnum(void)
  263. {
  264. if (_pRealEnum != NULL)
  265. _pRealEnum->Release;
  266. }
  267. #endif // #ifndef __ASYNCEXPDF_HXX__