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.

322 lines
9.4 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: expdf.hxx
  7. //
  8. // Contents: Exposed DocFile header
  9. //
  10. // Classes: CExposedDocFile
  11. //
  12. // History: 20-Jan-92 DrewB Created
  13. //
  14. //---------------------------------------------------------------
  15. #ifndef __EXPDF_HXX__
  16. #define __EXPDF_HXX__
  17. #include <except.hxx>
  18. #include <dfmsp.hxx>
  19. #include <dfbasis.hxx>
  20. #include <psstream.hxx>
  21. #include <debug.hxx>
  22. #include <stgprops.hxx>
  23. #include <safedecl.hxx>
  24. #include <psetstg.hxx>
  25. #include "dfmem.hxx"
  26. #include <mrshlist.hxx>
  27. #include <bag.hxx>
  28. #ifdef ASYNC
  29. #include "astgconn.hxx"
  30. #endif
  31. // CopyDocFileToIStorage flags
  32. #define COPY_STORAGES 1
  33. #define COPY_STREAMS 2
  34. #define COPY_ALL (COPY_STORAGES | COPY_STREAMS)
  35. class CPubDocFile;
  36. class PDocFile;
  37. class CPerContext;
  38. //+--------------------------------------------------------------
  39. //
  40. // Class: CExposedDocFile (df)
  41. //
  42. // Purpose: Exposed DocFile class
  43. //
  44. // Interface: See IStorage
  45. //
  46. // History: 20-Jan-92 DrewB Created
  47. //
  48. //---------------------------------------------------------------
  49. interface CExposedDocFile
  50. :
  51. public IStorage,
  52. #ifdef NEWPROPS
  53. public CPropertySetStorage,
  54. #endif
  55. public IRootStorage,
  56. public IMarshal,
  57. #if WIN32 >= 300
  58. public IAccessControl,
  59. #endif
  60. public CMallocBased
  61. #ifdef NEWPROPS
  62. , public IBlockingLock
  63. #endif
  64. #ifdef DIRECTWRITERLOCK
  65. , public IDirectWriterLock
  66. #endif
  67. #ifdef POINTER_IDENTITY
  68. , public CMarshalList
  69. #endif
  70. #ifdef ASYNC
  71. , public CAsyncConnectionContainer
  72. #endif
  73. {
  74. public:
  75. CExposedDocFile(CPubDocFile *pdf,
  76. CDFBasis *pdfb,
  77. CPerContext *ppc);
  78. #ifdef ASYNC
  79. SCODE InitMarshal(DWORD dwAsyncFlags,
  80. IDocfileAsyncConnectionPoint *pdacp);
  81. #endif
  82. ~CExposedDocFile(void);
  83. // From IUnknown
  84. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  85. STDMETHOD_(ULONG,AddRef)(void);
  86. STDMETHOD_(ULONG,Release)(void);
  87. // IMarshal
  88. STDMETHOD(GetUnmarshalClass)(REFIID riid,
  89. LPVOID pv,
  90. DWORD dwDestContext,
  91. LPVOID pvDestContext,
  92. DWORD mshlflags,
  93. LPCLSID pCid);
  94. STDMETHOD(GetMarshalSizeMax)(REFIID riid,
  95. LPVOID pv,
  96. DWORD dwDestContext,
  97. LPVOID pvDestContext,
  98. DWORD mshlflags,
  99. LPDWORD pSize);
  100. STDMETHOD(MarshalInterface)(IStream *pStm,
  101. REFIID riid,
  102. LPVOID pv,
  103. DWORD dwDestContext,
  104. LPVOID pvDestContext,
  105. DWORD mshlflags);
  106. STDMETHOD(UnmarshalInterface)(IStream *pStm,
  107. REFIID riid,
  108. LPVOID *ppv);
  109. static SCODE StaticReleaseMarshalData(IStream *pstStm,
  110. DWORD mshlflags);
  111. STDMETHOD(ReleaseMarshalData)(IStream *pStm);
  112. STDMETHOD(DisconnectObject)(DWORD dwReserved);
  113. // IStorage
  114. STDMETHOD(CreateStream)(OLECHAR const *pwcsName,
  115. DWORD grfMode,
  116. DWORD reserved1,
  117. DWORD reserved2,
  118. IStream **ppstm);
  119. STDMETHOD(OpenStream)(OLECHAR const *pwcsName,
  120. void *reserved1,
  121. DWORD grfMode,
  122. DWORD reserved2,
  123. IStream **ppstm);
  124. STDMETHOD(CreateStorage)(OLECHAR const *pwcsName,
  125. DWORD grfMode,
  126. DWORD reserved1,
  127. LPSTGSECURITY reserved2,
  128. IStorage **ppstg);
  129. STDMETHOD(OpenStorage)(OLECHAR const *pwcsName,
  130. IStorage *pstgPriority,
  131. DWORD grfMode,
  132. SNB snbExclude,
  133. DWORD reserved,
  134. IStorage **ppstg);
  135. STDMETHOD(CopyTo)(DWORD ciidExclude,
  136. IID const *rgiidExclude,
  137. SNB snbExclude,
  138. IStorage *pstgDest);
  139. STDMETHOD(MoveElementTo)(OLECHAR const *lpszName,
  140. IStorage *pstgDest,
  141. OLECHAR const *lpszNewName,
  142. DWORD grfFlags);
  143. STDMETHOD(Commit)(DWORD grfCommitFlags);
  144. STDMETHOD(Revert)(void);
  145. STDMETHOD(EnumElements)(DWORD reserved1,
  146. void *reserved2,
  147. DWORD reserved3,
  148. IEnumSTATSTG **ppenm);
  149. STDMETHOD(DestroyElement)(OLECHAR const *pwcsName);
  150. STDMETHOD(RenameElement)(OLECHAR const *pwcsOldName,
  151. OLECHAR const *pwcsNewName);
  152. STDMETHOD(SetElementTimes)(const OLECHAR *lpszName,
  153. FILETIME const *pctime,
  154. FILETIME const *patime,
  155. FILETIME const *pmtime);
  156. STDMETHOD(SetClass)(REFCLSID clsid);
  157. STDMETHOD(SetStateBits)(DWORD grfStateBits, DWORD grfMask);
  158. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  159. // IRootStorage
  160. STDMETHOD(SwitchToFile)(OLECHAR *ptcsFile);
  161. #ifdef NEWPROPS
  162. // IBlockingLock
  163. STDMETHOD(Lock)(DWORD dwTime);
  164. STDMETHOD(Unlock)(VOID);
  165. #endif
  166. #ifdef DIRECTWRITERLOCK
  167. // IDirectWriterLock
  168. STDMETHOD(WaitForWriteAccess)(DWORD dwTimeout);
  169. STDMETHOD(ReleaseWriteAccess)();
  170. STDMETHOD(HaveWriteAccess)();
  171. #endif
  172. // New methods
  173. inline SCODE Validate(void) const;
  174. inline CPubDocFile *GetPub(void) const;
  175. inline CPerContext *GetContext(void) const;
  176. static SCODE Unmarshal(IStream *pstm,
  177. void **ppv,
  178. DWORD mshlflags);
  179. #if WIN32 >= 300
  180. // IAccessControl
  181. STDMETHOD(GrantAccessRights)(ULONG cCount,
  182. ACCESS_REQUEST pAccessRequestList[]);
  183. STDMETHOD(SetAccessRights)(ULONG cCount,
  184. ACCESS_REQUEST pAccessRequestList[]);
  185. STDMETHOD(ReplaceAllAccessRights)(ULONG cCount,
  186. ACCESS_REQUEST pAccessRequestList[]);
  187. STDMETHOD(DenyAccessRights)(ULONG cCount,
  188. ACCESS_REQUEST pAccessRequestList[]);
  189. STDMETHOD(RevokeExplicitAccessRights)(ULONG cCount,
  190. TRUSTEE Trustee[]);
  191. STDMETHOD(IsAccessPermitted)(TRUSTEE *Trustee,
  192. DWORD grfAccessPermissions);
  193. STDMETHOD(GetEffectiveAccessRights)(TRUSTEE *Trustee,
  194. DWORD *pgrfAccessPermissions );
  195. STDMETHOD(GetExplicitAccessRights)(ULONG *pcCount,
  196. PEXPLICIT_ACCESS *pExplicitAccessList);
  197. STDMETHOD(CommitAccessRights)(DWORD grfCommitFlags);
  198. STDMETHOD(RevertAccessRights)();
  199. #endif // if WIN32 >= 300
  200. #ifdef COORD
  201. SCODE CommitPhase1(DWORD grfCommitFlags);
  202. SCODE CommitPhase2(DWORD grfCommitFlags, BOOL fCommit);
  203. #endif
  204. private:
  205. SCODE CreateEntry(CDfName const *pdfn,
  206. DWORD dwType,
  207. DWORD grfMode,
  208. void **ppv);
  209. SCODE OpenEntry(CDfName const *pdfn,
  210. DWORD dwType,
  211. DWORD grfMode,
  212. void **ppv);
  213. SCODE MoveElementWorker(WCHAR const *pwcsName,
  214. IStorage *pstgParent,
  215. OLECHAR const *ptcsNewName,
  216. DWORD grfFlags);
  217. static DWORD MakeCopyFlags(DWORD ciidExclude,
  218. IID const *rgiidExclude);
  219. SCODE CopyDocFileToIStorage(PDocFile *pdfFrom,
  220. IStorage *pstgTo,
  221. SNBW snbExclude,
  222. DWORD dwCopyFlags);
  223. SCODE CopySStreamToIStream(PSStream *psstFrom, IStream *pstTo);
  224. SCODE ConvertInternalStream(CExposedDocFile *pdfExp);
  225. inline SCODE CheckCopyTo(void);
  226. CBasedPubDocFilePtr _pdf;
  227. CBasedDFBasisPtr _pdfb;
  228. CPerContext *_ppc;
  229. ULONG _sig;
  230. LONG _cReferences;
  231. #if WIN32 >= 300
  232. IAccessControl *_pIAC;
  233. #endif // WIN32 >= 300
  234. #ifdef COORD
  235. //These are holder values for an exposed two-phase commit.
  236. ULONG _ulLock;
  237. DFSIGNATURE _sigMSF;
  238. ULONG _cbSizeBase;
  239. ULONG _cbSizeOrig;
  240. #endif
  241. #ifdef DIRECTWRITERLOCK
  242. HRESULT ValidateWriteAccess();
  243. #endif
  244. // IPropertyBagEx interface. This object forwards all IUnknown calls
  245. // to this object (actually, to the IPropertySetStorage base class).
  246. CPropertyBagEx _PropertyBagEx;
  247. };
  248. SAFE_INTERFACE_PTR(SafeCExposedDocFile, CExposedDocFile);
  249. #define CEXPOSEDDOCFILE_SIG LONGSIG('E', 'D', 'F', 'L')
  250. #define CEXPOSEDDOCFILE_SIGDEL LONGSIG('E', 'd', 'F', 'l')
  251. //+--------------------------------------------------------------
  252. //
  253. // Member: CExposedDocFile::Validate, public
  254. //
  255. // Synopsis: Validates the class signature
  256. //
  257. // Returns: Returns STG_E_INVALIDHANDLE for failure
  258. //
  259. // History: 20-Jan-92 DrewB Created
  260. //
  261. //---------------------------------------------------------------
  262. inline SCODE CExposedDocFile::Validate(void) const
  263. {
  264. olChkBlocks((DBG_FAST));
  265. return (this == NULL || _sig != CEXPOSEDDOCFILE_SIG) ?
  266. STG_E_INVALIDHANDLE : S_OK;
  267. }
  268. //+--------------------------------------------------------------
  269. //
  270. // Member: CExposedDocFile::GetPub, public
  271. //
  272. // Synopsis: Returns the public
  273. //
  274. // History: 26-Feb-92 DrewB Created
  275. //
  276. //---------------------------------------------------------------
  277. inline CPubDocFile *CExposedDocFile::GetPub(void) const
  278. {
  279. #ifdef MULTIHEAP
  280. // The tree mutex must be taken before calling this routine
  281. // CSafeMultiHeap smh(_ppc); // optimzation
  282. #endif
  283. return BP_TO_P(CPubDocFile *, _pdf);
  284. }
  285. inline CPerContext * CExposedDocFile::GetContext(void) const
  286. {
  287. return _ppc;
  288. }
  289. #endif