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.

540 lines
16 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: laywrap.cxx
  7. //
  8. // Contents: IStorage wrapper for layout docfile
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 14-Feb-96 SusiA Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "layouthd.cxx"
  18. #pragma hdrstop
  19. #include "laywrap.hxx"
  20. #include "layouter.hxx"
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Member: CLayoutRootStorage::QueryInterface, public
  24. //
  25. // History: 14-Feb-96 SusiA Created
  26. //
  27. //----------------------------------------------------------------------------
  28. STDMETHODIMP CLayoutRootStorage::QueryInterface(REFIID iid, void **ppvObj)
  29. {
  30. SCODE sc = S_OK;
  31. *ppvObj = NULL;
  32. layDebugOut((DEB_ITRACE,
  33. "In CLayoutRootStorage::QueryInterface:%p()\n", this));
  34. if (IsEqualIID(iid, IID_IUnknown))
  35. {
  36. *ppvObj = (IStorage *)this;
  37. }
  38. else if (IsEqualIID(iid, IID_IStorage))
  39. {
  40. *ppvObj = (IStorage *)this;
  41. }
  42. else if (IsEqualIID(iid, IID_IRootStorage))
  43. {
  44. IRootStorage *prstg;
  45. if (FAILED(_pRealStg->QueryInterface(IID_IRootStorage,
  46. (void **) &prstg)))
  47. {
  48. return E_NOINTERFACE;
  49. }
  50. prstg->Release();
  51. *ppvObj = (IRootStorage *)this;
  52. }
  53. else if (IsEqualIID(iid, IID_ILayoutStorage))
  54. {
  55. *ppvObj = (ILayoutStorage *)this;
  56. }
  57. else
  58. {
  59. sc = E_NOINTERFACE;
  60. }
  61. if (SUCCEEDED(sc))
  62. {
  63. AddRef();
  64. }
  65. layDebugOut((DEB_ITRACE,
  66. "Out CLayoutRootStorage::QueryInterface:%p()\n", this));
  67. return sc;
  68. }
  69. //+---------------------------------------------------------------------------
  70. //
  71. // Member: CLayoutRootStorage::AddRef, public
  72. //
  73. // History: 01-Jan-96 SusiA Created
  74. //
  75. //----------------------------------------------------------------------------
  76. STDMETHODIMP_(ULONG) CLayoutRootStorage::AddRef(void)
  77. {
  78. ULONG ulRet;
  79. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::AddRef:%p()\n", this));
  80. InterlockedIncrement(&_cReferences);
  81. ulRet = _cReferences;
  82. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::AddRef\n"));
  83. return ulRet;
  84. }
  85. //+---------------------------------------------------------------------------
  86. //
  87. // Member: CLayoutRootStorage::Release, public
  88. //
  89. // History: 01-Jan-96 SusiA Created
  90. //
  91. //----------------------------------------------------------------------------
  92. STDMETHODIMP_(ULONG) CLayoutRootStorage::Release(void)
  93. {
  94. LONG lRet;
  95. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Release:%p()\n", this));
  96. lRet = InterlockedDecrement(&_cReferences);
  97. if (lRet == 0)
  98. {
  99. delete this;
  100. }
  101. else if (lRet < 0)
  102. lRet = 0;
  103. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Release\n"));
  104. return (ULONG)lRet;
  105. }
  106. //+---------------------------------------------------------------------------
  107. //
  108. // Member: CLayoutRootStorage::CreateStream, public
  109. //
  110. // History: 01-Jan-96 SusiA Created
  111. //
  112. //----------------------------------------------------------------------------
  113. STDMETHODIMP CLayoutRootStorage::CreateStream(OLECHAR const *pwcsName,
  114. DWORD grfMode,
  115. DWORD reserved1,
  116. DWORD reserved2,
  117. IStream **ppstm)
  118. {
  119. SCODE sc;
  120. layDebugOut((DEB_ITRACE,
  121. "In CLayoutRootStorage::CreateStream:%p()\n", this));
  122. sc = _pRealStg->CreateStream(pwcsName,
  123. grfMode,
  124. reserved1,
  125. reserved2,
  126. ppstm);
  127. layDebugOut((DEB_ITRACE,
  128. "Out CLayoutRootStorage::CreateStream:%p()\n", this));
  129. return ResultFromScode(sc);
  130. }
  131. //+---------------------------------------------------------------------------
  132. //
  133. // Member: CLayoutRootStorage::OpenStream, public
  134. //
  135. // History: 01-Jan-96 SusiA Created
  136. //
  137. //----------------------------------------------------------------------------
  138. STDMETHODIMP CLayoutRootStorage::OpenStream(OLECHAR const *pwcsName,
  139. void *reserved1,
  140. DWORD grfMode,
  141. DWORD reserved2,
  142. IStream **ppstm)
  143. {
  144. SCODE sc = S_OK;
  145. layDebugOut((DEB_ITRACE,
  146. "In CLayoutRootStorage::OpenStream:%p()\n", this));
  147. sc = _pRealStg->OpenStream(pwcsName,
  148. reserved1,
  149. grfMode,
  150. reserved2,
  151. ppstm);
  152. layDebugOut((DEB_ITRACE,
  153. "Out CLayoutRootStorage::OpenStream:%p()\n", this));
  154. return ResultFromScode(sc);
  155. }
  156. //+---------------------------------------------------------------------------
  157. //
  158. // Member: CLayoutRootStorage::CreateStorage, public
  159. //
  160. // History: 01-Jan-96 SusiA Created
  161. //
  162. //----------------------------------------------------------------------------
  163. STDMETHODIMP CLayoutRootStorage::CreateStorage(OLECHAR const *pwcsName,
  164. DWORD grfMode,
  165. DWORD reserved1,
  166. LPSTGSECURITY reserved2,
  167. IStorage **ppstg)
  168. {
  169. SCODE sc = S_OK;
  170. layDebugOut((DEB_ITRACE,
  171. "In CLayoutRootStorage::CreateStorage:%p()\n", this));
  172. sc = _pRealStg->CreateStorage( pwcsName,
  173. grfMode,
  174. reserved1,
  175. reserved2,
  176. ppstg);
  177. layDebugOut((DEB_ITRACE,
  178. "Out CLayoutRootStorage::CreateStorage:%p()\n", this));
  179. return ResultFromScode(sc);
  180. }
  181. //+---------------------------------------------------------------------------
  182. //
  183. // Member: CLayoutRootStorage::OpenStorage, public
  184. //
  185. // History: 01-Jan-96 SusiA Created
  186. //
  187. //----------------------------------------------------------------------------
  188. STDMETHODIMP CLayoutRootStorage::OpenStorage(OLECHAR const *pwcsName,
  189. IStorage *pstgPriority,
  190. DWORD grfMode,
  191. SNB snbExclude,
  192. DWORD reserved,
  193. IStorage **ppstg)
  194. {
  195. SCODE sc = S_OK;
  196. layDebugOut((DEB_ITRACE,
  197. "In CLayoutRootStorage::OpenStorage:%p()\n", this));
  198. sc = _pRealStg->OpenStorage(pwcsName,
  199. pstgPriority,
  200. grfMode,
  201. snbExclude,
  202. reserved,
  203. ppstg);
  204. layDebugOut((DEB_ITRACE,
  205. "Out CLayoutRootStorage::OpenStorage:%p()\n", this));
  206. return ResultFromScode(sc);
  207. }
  208. //+---------------------------------------------------------------------------
  209. //
  210. // Member: CLayoutRootStorage::CopyTo, public
  211. //
  212. // History: 01-Jan-96 SusiA Created
  213. //
  214. //----------------------------------------------------------------------------
  215. STDMETHODIMP CLayoutRootStorage::CopyTo(DWORD ciidExclude,
  216. IID const *rgiidExclude,
  217. SNB snbExclude,
  218. IStorage *pstgDest)
  219. {
  220. SCODE sc = S_OK;
  221. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::CopyTo%p()\n", this));
  222. sc = _pRealStg->CopyTo(ciidExclude,
  223. rgiidExclude,
  224. snbExclude,
  225. pstgDest);
  226. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::CopyTo\n"));
  227. return ResultFromScode(sc);
  228. }
  229. //+---------------------------------------------------------------------------
  230. //
  231. // Member: CLayoutRootStorage::MoveElementTo, public
  232. //
  233. // History: 01-Jan-96 SusiA Created
  234. //
  235. //----------------------------------------------------------------------------
  236. STDMETHODIMP CLayoutRootStorage::MoveElementTo(OLECHAR const *lpszName,
  237. IStorage *pstgDest,
  238. OLECHAR const *lpszNewName,
  239. DWORD grfFlags)
  240. {
  241. SCODE sc = S_OK;
  242. layDebugOut((DEB_ITRACE,
  243. "In CLayoutRootStorage::MoveElementTo%p()\n", this));
  244. sc = _pRealStg->MoveElementTo(lpszName,
  245. pstgDest,
  246. lpszNewName,
  247. grfFlags) ;
  248. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::MoveElementTo\n"));
  249. return ResultFromScode(sc);
  250. }
  251. //+---------------------------------------------------------------------------
  252. //
  253. // Member: CLayoutRootStorage::Commit, public
  254. //
  255. // History: 01-Jan-96 SusiA Created
  256. //
  257. //----------------------------------------------------------------------------
  258. STDMETHODIMP CLayoutRootStorage::Commit(DWORD grfCommitFlags)
  259. {
  260. SCODE sc = S_OK;
  261. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Commit%p()\n", this));
  262. sc = _pRealStg->Commit(grfCommitFlags);
  263. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Commit\n"));
  264. return ResultFromScode(sc);
  265. }
  266. //+---------------------------------------------------------------------------
  267. //
  268. // Member: CLayoutRootStorage::Revert, public
  269. //
  270. // History: 01-Jan-96 SusiA Created
  271. //
  272. //----------------------------------------------------------------------------
  273. STDMETHODIMP CLayoutRootStorage::Revert(void)
  274. {
  275. SCODE sc = S_OK;
  276. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Revert%p()\n", this));
  277. sc = _pRealStg->Revert();
  278. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Revert\n"));
  279. return ResultFromScode(sc);
  280. }
  281. //+---------------------------------------------------------------------------
  282. //
  283. // Member: CLayoutRootStorage::EnumElements, public
  284. //
  285. // History: 01-Jan-96 SusiA Created
  286. //
  287. //----------------------------------------------------------------------------
  288. STDMETHODIMP CLayoutRootStorage::EnumElements(DWORD reserved1,
  289. void *reserved2,
  290. DWORD reserved3,
  291. IEnumSTATSTG **ppenm)
  292. {
  293. SCODE sc = S_OK;
  294. layDebugOut((DEB_ITRACE,
  295. "In CLayoutRootStorage::EnumElements%p()\n", this));
  296. sc = _pRealStg->EnumElements(reserved1,
  297. reserved2,
  298. reserved3,
  299. ppenm);
  300. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::EnumElements\n"));
  301. return ResultFromScode(sc);
  302. }
  303. //+---------------------------------------------------------------------------
  304. //
  305. // Member: CLayoutRootStorage::DestroyElement, public
  306. //
  307. // History: 01-Jan-96 SusiA Created
  308. //
  309. //----------------------------------------------------------------------------
  310. STDMETHODIMP CLayoutRootStorage::DestroyElement(OLECHAR const *pwcsName)
  311. {
  312. SCODE sc = S_OK;
  313. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::DestroyElement\n"));
  314. sc = _pRealStg->DestroyElement(pwcsName);
  315. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::DestroyElement\n"));
  316. return ResultFromScode(sc);
  317. }
  318. //+---------------------------------------------------------------------------
  319. //
  320. // Member: CLayoutRootStorage::RenameElement, public
  321. //
  322. // History: 01-Jan-96 SusiA Created
  323. //
  324. //----------------------------------------------------------------------------
  325. STDMETHODIMP CLayoutRootStorage::RenameElement(OLECHAR const *pwcsOldName,
  326. OLECHAR const *pwcsNewName)
  327. {
  328. SCODE sc = S_OK;
  329. sc = _pRealStg->RenameElement(pwcsOldName, pwcsNewName);
  330. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::RenameElement\n"));
  331. return ResultFromScode(sc);
  332. }
  333. //+---------------------------------------------------------------------------
  334. //
  335. // Member: CLayoutRootStorage::SetElementTimes, public
  336. //
  337. // History: 01-Jan-96 SusiA Created
  338. //
  339. //----------------------------------------------------------------------------
  340. STDMETHODIMP CLayoutRootStorage::SetElementTimes(const OLECHAR *lpszName,
  341. FILETIME const *pctime,
  342. FILETIME const *patime,
  343. FILETIME const *pmtime)
  344. {
  345. SCODE sc = S_OK;
  346. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetElementTimes\n"));
  347. sc = _pRealStg->SetElementTimes(lpszName,
  348. pctime,
  349. patime,
  350. pmtime);
  351. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetElementTimes\n"));
  352. return ResultFromScode(sc);
  353. }
  354. //+---------------------------------------------------------------------------
  355. //
  356. // Member: CLayoutRootStorage::SetClass, public
  357. //
  358. // History: 01-Jan-96 SusiA Created
  359. //
  360. //----------------------------------------------------------------------------
  361. STDMETHODIMP CLayoutRootStorage::SetClass(REFCLSID clsid)
  362. {
  363. SCODE sc = S_OK;
  364. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetClass\n"));
  365. sc = _pRealStg->SetClass(clsid);
  366. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetClass\n"));
  367. return ResultFromScode(sc);
  368. }
  369. //+---------------------------------------------------------------------------
  370. //
  371. // Member: CLayoutRootStorage::SetStateBits, public
  372. //
  373. // History: 01-Jan-96 SusiA Created
  374. //
  375. //----------------------------------------------------------------------------
  376. STDMETHODIMP CLayoutRootStorage::SetStateBits(DWORD grfStateBits,
  377. DWORD grfMask)
  378. {
  379. SCODE sc = S_OK;
  380. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetStateBits\n"));
  381. sc = _pRealStg->SetStateBits(grfStateBits, grfMask);
  382. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetStateBits\n"));
  383. return ResultFromScode(sc);
  384. }
  385. //+---------------------------------------------------------------------------
  386. //
  387. // Member: CLayoutRootStorage::Stat, public
  388. //
  389. // History: 01-Jan-96 SusiA Created
  390. //
  391. //----------------------------------------------------------------------------
  392. STDMETHODIMP CLayoutRootStorage::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
  393. {
  394. SCODE sc = S_OK;
  395. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Stat%p()\n", this));
  396. sc = _pRealStg->Stat( pstatstg, grfStatFlag);
  397. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Stat\n"));
  398. return ResultFromScode(sc);
  399. }
  400. //+---------------------------------------------------------------------------
  401. //
  402. // Member: CLayoutRootStorage::SwitchToFile, public
  403. //
  404. // History: 01-Jan-96 SusiA Created
  405. //
  406. //----------------------------------------------------------------------------
  407. STDMETHODIMP CLayoutRootStorage::SwitchToFile(OLECHAR *ptcsFile)
  408. {
  409. SCODE sc = S_OK;
  410. IRootStorage *prstg;
  411. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::%p()\n", this));
  412. layVerify(SUCCEEDED(_pRealStg->QueryInterface(IID_IRootStorage,
  413. (void **) &prstg)));
  414. sc = prstg->SwitchToFile(ptcsFile);
  415. prstg->Release();
  416. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::\n"));
  417. return ResultFromScode(sc);
  418. }