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.

441 lines
11 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992
  5. //
  6. // File: cdocfile.cxx
  7. //
  8. // Contents: Implementation of CDocFile methods for DocFiles
  9. //
  10. // History: 11-Dec-91 DrewB Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. #include <vectfunc.hxx>
  16. //+--------------------------------------------------------------
  17. //
  18. // Member: CDocFile::InitFromEntry, public
  19. //
  20. // Synopsis: Creation/Instantiation constructor for embeddings
  21. //
  22. // Arguments: [pstghParent] - Parent handle
  23. // [pdfn] - Name
  24. // [fCreate] - Create/Instantiate
  25. // [dwType] - Type of entry
  26. //
  27. // Returns: Appropriate status code
  28. //
  29. // History: 16-Dec-91 DrewB Created
  30. //
  31. // Algorithm: Create or get the entry from the multistream
  32. //
  33. //---------------------------------------------------------------
  34. SCODE CDocFile::InitFromEntry(CStgHandle *pstghParent,
  35. CDfName const *pdfn,
  36. BOOL const fCreate)
  37. {
  38. SCODE sc;
  39. olDebugOut((DEB_ITRACE, "In CDocFile::InitFromEntry(%p, %ws, %d)\n",
  40. pstghParent, pdfn, fCreate));
  41. if (fCreate)
  42. sc = pstghParent->CreateEntry(pdfn, STGTY_STORAGE, &_stgh);
  43. else
  44. sc = pstghParent->GetEntry(pdfn, STGTY_STORAGE, &_stgh);
  45. if (SUCCEEDED(sc))
  46. AddRef();
  47. olDebugOut((DEB_ITRACE, "Out CDocFile::InitFromEntry\n"));
  48. return sc;
  49. }
  50. //+--------------------------------------------------------------
  51. //
  52. // Member: CDocFile::CreateDocFile, public
  53. //
  54. // Synopsis: Creates a DocFile object in a parent
  55. //
  56. // Arguments: [pdfn] - Name of DocFile
  57. // [df] - Transactioning flags
  58. // [dlSet] - LUID to set or DF_NOLUID
  59. // [dwType] - Type of entry
  60. // [ppdfDocFile] - DocFile return
  61. //
  62. // Returns: Appropriate status code
  63. //
  64. // Modifies: [ppdfDocFile]
  65. //
  66. // History: 11-Dec-91 DrewB Created
  67. //
  68. // Algorithm: Allocate new docfile and init from given entry
  69. //
  70. //---------------------------------------------------------------
  71. SCODE CDocFile::CreateDocFile(CDfName const *pdfn,
  72. DFLAGS const df,
  73. DFLUID dlSet,
  74. PDocFile **ppdfDocFile)
  75. {
  76. CDocFile *pdf;
  77. SCODE sc;
  78. olDebugOut((DEB_ITRACE, "In CDocFile::CreateDocFile:%p("
  79. "%ws, %X, %lu, %p)\n", this, pdfn, df, dlSet,
  80. ppdfDocFile));
  81. UNREFERENCED_PARM(df);
  82. if (dlSet == DF_NOLUID)
  83. dlSet = CDocFile::GetNewLuid(_pdfb->GetMalloc());
  84. pdf = GetReservedDocfile(dlSet);
  85. olAssert(pdf != NULL && aMsg("Reserved Docfile not found"));
  86. if (pdf != NULL)
  87. olChkTo(EH_pdf, pdf->InitFromEntry(&_stgh, pdfn, TRUE));
  88. *ppdfDocFile = pdf;
  89. olDebugOut((DEB_ITRACE, "Out CDocFile::CreateDocFile => %p\n",
  90. *ppdfDocFile));
  91. return S_OK;
  92. EH_pdf:
  93. pdf->ReturnToReserve(BP_TO_P(CDFBasis *,_pdfb));
  94. return sc;
  95. }
  96. //+--------------------------------------------------------------
  97. //
  98. // Member: CDocFile::GetDocFile, public
  99. //
  100. // Synopsis: Instantiates an existing docfile
  101. //
  102. // Arguments: [pdfn] - Name of stream
  103. // [df] - Transactioning flags
  104. // [dwType] - Type of entry
  105. // [ppdfDocFile] - Docfile return
  106. //
  107. // Returns: Appropriate status code
  108. //
  109. // Modifies: [ppdfDocFile]
  110. //
  111. // History: 11-Dec-91 DrewB Created
  112. //
  113. // Algorithm: Allocate new docfile and init from given entry
  114. //
  115. //---------------------------------------------------------------
  116. SCODE CDocFile::GetDocFile(CDfName const *pdfn,
  117. DFLAGS const df,
  118. PDocFile **ppdfDocFile)
  119. {
  120. CDocFile *pdf;
  121. SCODE sc;
  122. olDebugOut((DEB_ITRACE, "In CDocFile::GetDocFile:%p("
  123. "%ws, %X, %p)\n", this, pdfn, df, ppdfDocFile));
  124. UNREFERENCED_PARM(df);
  125. DFLUID dl = CDocFile::GetNewLuid(_pdfb->GetMalloc());
  126. olMem(pdf = new (_pdfb->GetMalloc()) CDocFile(dl,
  127. BP_TO_P(CDFBasis *, _pdfb)));
  128. olChkTo(EH_pdf, pdf->InitFromEntry(&_stgh, pdfn, FALSE));
  129. *ppdfDocFile = pdf;
  130. olDebugOut((DEB_ITRACE, "Out CDocFile::GetDocFile => %p\n",
  131. *ppdfDocFile));
  132. return S_OK;
  133. EH_pdf:
  134. delete pdf;
  135. EH_Err:
  136. return sc;
  137. }
  138. //+--------------------------------------------------------------
  139. //
  140. // Member: CDocFile::RenameEntry, public
  141. //
  142. // Synopsis: Renames a child
  143. //
  144. // Arguments: [pdfnName] - Old name
  145. // [pdfnNewName] - New name
  146. //
  147. // Returns: Appropriate status code
  148. //
  149. // History: 12-Dec-91 DrewB Created
  150. //
  151. //---------------------------------------------------------------
  152. SCODE CDocFile::RenameEntry(CDfName const *pdfnName,
  153. CDfName const *pdfnNewName)
  154. {
  155. SCODE sc;
  156. olDebugOut((DEB_ITRACE, "In CDocFile::RenameEntry(%ws, %ws)\n",
  157. pdfnName, pdfnNewName));
  158. sc = _stgh.RenameEntry(pdfnName, pdfnNewName);
  159. olDebugOut((DEB_ITRACE, "Out CDocFile::RenameEntry\n"));
  160. return sc;
  161. }
  162. //+--------------------------------------------------------------
  163. //
  164. // Member: CDocFile::DestroyEntry, public
  165. //
  166. // Synopsis: Permanently destroys a child
  167. //
  168. // Arguments: [pdfnName] - Name of child
  169. // [fClean] - Ignored
  170. //
  171. // Returns: Appropriate status code
  172. //
  173. // History: 09-Jan-92 DrewB Created
  174. //
  175. //---------------------------------------------------------------
  176. SCODE CDocFile::DestroyEntry(CDfName const *pdfnName,
  177. BOOL fClean)
  178. {
  179. SCODE sc;
  180. olDebugOut((DEB_ITRACE, "In CDocFile::DestroyEntry:%p(%ws, %d)\n",
  181. this, pdfnName, fClean));
  182. UNREFERENCED_PARM(fClean);
  183. sc = _stgh.DestroyEntry(pdfnName);
  184. olDebugOut((DEB_ITRACE, "Out CDocFile::DestroyEntry\n"));
  185. return sc;
  186. }
  187. //+--------------------------------------------------------------
  188. //
  189. // Member: CDocFile::IsEntry, public
  190. //
  191. // Synopsis: Determines whether the given object is a member
  192. // of the DocFile
  193. //
  194. // Arguments: [pdfnName] - Name
  195. // [peb] - Entry buffer to fill in
  196. //
  197. // Returns: Appropriate status code
  198. //
  199. // Modifies: [peb]
  200. //
  201. // History: 07-Nov-91 DrewB Created
  202. //
  203. //---------------------------------------------------------------
  204. SCODE CDocFile::IsEntry(CDfName const *pdfnName,
  205. SEntryBuffer *peb)
  206. {
  207. SCODE sc;
  208. olDebugOut((DEB_ITRACE, "In CDocFile::IsEntry(%ws, %p)\n",
  209. pdfnName, peb));
  210. sc = _stgh.IsEntry(pdfnName, peb);
  211. olDebugOut((DEB_ITRACE, "Out CDocFile::IsEntry => %lu, %lu, %lu\n",
  212. sc, peb->luid, peb->dwType));
  213. return sc;
  214. }
  215. #ifdef INDINST
  216. //+--------------------------------------------------------------
  217. //
  218. // Member: CDocFile::Destroy, public
  219. //
  220. // Synopsis: Destroys the DocFile
  221. //
  222. // History: 12-Dec-91 DrewB Created
  223. //
  224. //---------------------------------------------------------------
  225. void CDocFile::Destroy(void)
  226. {
  227. olDebugOut((DEB_ITRACE, "In CDocFile::Destroy()\n"));
  228. olAssert(_cReferences == 1);
  229. olVerSucc(_stgh.DestroyEntry(NULL);
  230. CDocFile::Release();
  231. olDebugOut((DEB_ITRACE, "Out CDocFile::Destroy\n"));
  232. }
  233. #endif
  234. //+--------------------------------------------------------------
  235. //
  236. // Member: CDocFile::GetTime, public
  237. //
  238. // Synopsis: Gets a time
  239. //
  240. // Arguments: [wt] - Which time
  241. // [ptm] - Time return
  242. //
  243. // Returns: Appropriate status code
  244. //
  245. // Modifies: [ptm]
  246. //
  247. // History: 31-Jul-92 DrewB Created
  248. //
  249. //---------------------------------------------------------------
  250. SCODE CDocFile::GetTime(WHICHTIME wt, TIME_T *ptm)
  251. {
  252. return _stgh.GetTime(wt, ptm);
  253. }
  254. //+--------------------------------------------------------------
  255. //
  256. // Member: CDocFile::GetAllTimes, public
  257. //
  258. // Synopsis: Gets all time values
  259. //
  260. // Arguments: [patm] - Access Time
  261. // [pmtm] - Modification Time
  262. // [pctm] - Creation Time
  263. //
  264. // Returns: Appropriate status code
  265. //
  266. // Modifies: [patm]
  267. // [pmtm]
  268. // [pctm]
  269. //
  270. // History: 26-May-95 SusiA Created
  271. //
  272. //---------------------------------------------------------------
  273. SCODE CDocFile::GetAllTimes(TIME_T *patm, TIME_T *pmtm, TIME_T *pctm)
  274. {
  275. return _stgh.GetAllTimes(patm, pmtm, pctm);
  276. }
  277. //+--------------------------------------------------------------
  278. //
  279. // Member: CDocFile::SetAllTimes, public
  280. //
  281. // Synopsis: Sets all time values
  282. //
  283. // Arguments: [atm] - Access Time
  284. // [mtm] - Modification Time
  285. // [ctm] - Creation Time
  286. //
  287. // Returns: Appropriate status code
  288. //
  289. // Modifies:
  290. //
  291. // History: 22-Nov-95 SusiA Created
  292. //
  293. //---------------------------------------------------------------
  294. SCODE CDocFile::SetAllTimes(TIME_T atm, TIME_T mtm, TIME_T ctm)
  295. {
  296. return _stgh.SetAllTimes(atm, mtm, ctm);
  297. }
  298. //+--------------------------------------------------------------
  299. //
  300. // Member: CDocFile::SetTime, public
  301. //
  302. // Synopsis: Sets a time
  303. //
  304. // Arguments: [wt] - Which time
  305. // [tm] - New time
  306. //
  307. // Returns: Appropriate status code
  308. //
  309. // History: 31-Jul-92 DrewB Created
  310. //
  311. //---------------------------------------------------------------
  312. SCODE CDocFile::SetTime(WHICHTIME wt, TIME_T tm)
  313. {
  314. return _stgh.SetTime(wt, tm);
  315. }
  316. //+---------------------------------------------------------------------------
  317. //
  318. // Member: CDocFile::GetClass, public
  319. //
  320. // Synopsis: Gets the class ID
  321. //
  322. // Arguments: [pclsid] - Class ID return
  323. //
  324. // Returns: Appropriate status code
  325. //
  326. // Modifies: [pclsid]
  327. //
  328. // History: 11-Nov-92 DrewB Created
  329. //
  330. //----------------------------------------------------------------------------
  331. SCODE CDocFile::GetClass(CLSID *pclsid)
  332. {
  333. return _stgh.GetClass(pclsid);
  334. }
  335. //+---------------------------------------------------------------------------
  336. //
  337. // Member: CDocFile::SetClass, public
  338. //
  339. // Synopsis: Sets the class ID
  340. //
  341. // Arguments: [clsid] - New class ID
  342. //
  343. // Returns: Appropriate status code
  344. //
  345. // History: 11-Nov-92 DrewB Created
  346. //
  347. //----------------------------------------------------------------------------
  348. SCODE CDocFile::SetClass(REFCLSID clsid)
  349. {
  350. return _stgh.SetClass(clsid);
  351. }
  352. //+---------------------------------------------------------------------------
  353. //
  354. // Member: CDocFile::GetStateBits, public
  355. //
  356. // Synopsis: Gets the state bits
  357. //
  358. // Arguments: [pgrfStateBits] - State bits return
  359. //
  360. // Returns: Appropriate status code
  361. //
  362. // Modifies: [pgrfStateBits]
  363. //
  364. // History: 11-Nov-92 DrewB Created
  365. //
  366. //----------------------------------------------------------------------------
  367. SCODE CDocFile::GetStateBits(DWORD *pgrfStateBits)
  368. {
  369. return _stgh.GetStateBits(pgrfStateBits);
  370. }
  371. //+---------------------------------------------------------------------------
  372. //
  373. // Member: CDocFile::SetStateBits, public
  374. //
  375. // Synopsis: Sets the state bits
  376. //
  377. // Arguments: [grfStateBits] - Bits to set
  378. // [grfMask] - Mask
  379. //
  380. // Returns: Appropriate status code
  381. //
  382. // History: 11-Nov-92 DrewB Created
  383. //
  384. //----------------------------------------------------------------------------
  385. SCODE CDocFile::SetStateBits(DWORD grfStateBits, DWORD grfMask)
  386. {
  387. return _stgh.SetStateBits(grfStateBits, grfMask);
  388. }