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.

537 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. LONG lRet;
  79. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::AddRef:%p()\n", this));
  80. lRet = InterlockedIncrement(&_cReferences);
  81. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::AddRef\n"));
  82. return lRet;
  83. }
  84. //+---------------------------------------------------------------------------
  85. //
  86. // Member: CLayoutRootStorage::Release, public
  87. //
  88. // History: 01-Jan-96 SusiA Created
  89. //
  90. //----------------------------------------------------------------------------
  91. STDMETHODIMP_(ULONG) CLayoutRootStorage::Release(void)
  92. {
  93. LONG lRet;
  94. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Release:%p()\n", this));
  95. lRet = InterlockedDecrement(&_cReferences);
  96. if (lRet == 0)
  97. {
  98. delete this;
  99. }
  100. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Release\n"));
  101. return (ULONG)lRet;
  102. }
  103. //+---------------------------------------------------------------------------
  104. //
  105. // Member: CLayoutRootStorage::CreateStream, public
  106. //
  107. // History: 01-Jan-96 SusiA Created
  108. //
  109. //----------------------------------------------------------------------------
  110. STDMETHODIMP CLayoutRootStorage::CreateStream(OLECHAR const *pwcsName,
  111. DWORD grfMode,
  112. DWORD reserved1,
  113. DWORD reserved2,
  114. IStream **ppstm)
  115. {
  116. SCODE sc;
  117. layDebugOut((DEB_ITRACE,
  118. "In CLayoutRootStorage::CreateStream:%p()\n", this));
  119. sc = _pRealStg->CreateStream(pwcsName,
  120. grfMode,
  121. reserved1,
  122. reserved2,
  123. ppstm);
  124. layDebugOut((DEB_ITRACE,
  125. "Out CLayoutRootStorage::CreateStream:%p()\n", this));
  126. return ResultFromScode(sc);
  127. }
  128. //+---------------------------------------------------------------------------
  129. //
  130. // Member: CLayoutRootStorage::OpenStream, public
  131. //
  132. // History: 01-Jan-96 SusiA Created
  133. //
  134. //----------------------------------------------------------------------------
  135. STDMETHODIMP CLayoutRootStorage::OpenStream(OLECHAR const *pwcsName,
  136. void *reserved1,
  137. DWORD grfMode,
  138. DWORD reserved2,
  139. IStream **ppstm)
  140. {
  141. SCODE sc = S_OK;
  142. layDebugOut((DEB_ITRACE,
  143. "In CLayoutRootStorage::OpenStream:%p()\n", this));
  144. sc = _pRealStg->OpenStream(pwcsName,
  145. reserved1,
  146. grfMode,
  147. reserved2,
  148. ppstm);
  149. layDebugOut((DEB_ITRACE,
  150. "Out CLayoutRootStorage::OpenStream:%p()\n", this));
  151. return ResultFromScode(sc);
  152. }
  153. //+---------------------------------------------------------------------------
  154. //
  155. // Member: CLayoutRootStorage::CreateStorage, public
  156. //
  157. // History: 01-Jan-96 SusiA Created
  158. //
  159. //----------------------------------------------------------------------------
  160. STDMETHODIMP CLayoutRootStorage::CreateStorage(OLECHAR const *pwcsName,
  161. DWORD grfMode,
  162. DWORD reserved1,
  163. LPSTGSECURITY reserved2,
  164. IStorage **ppstg)
  165. {
  166. SCODE sc = S_OK;
  167. layDebugOut((DEB_ITRACE,
  168. "In CLayoutRootStorage::CreateStorage:%p()\n", this));
  169. sc = _pRealStg->CreateStorage( pwcsName,
  170. grfMode,
  171. reserved1,
  172. reserved2,
  173. ppstg);
  174. layDebugOut((DEB_ITRACE,
  175. "Out CLayoutRootStorage::CreateStorage:%p()\n", this));
  176. return ResultFromScode(sc);
  177. }
  178. //+---------------------------------------------------------------------------
  179. //
  180. // Member: CLayoutRootStorage::OpenStorage, public
  181. //
  182. // History: 01-Jan-96 SusiA Created
  183. //
  184. //----------------------------------------------------------------------------
  185. STDMETHODIMP CLayoutRootStorage::OpenStorage(OLECHAR const *pwcsName,
  186. IStorage *pstgPriority,
  187. DWORD grfMode,
  188. SNB snbExclude,
  189. DWORD reserved,
  190. IStorage **ppstg)
  191. {
  192. SCODE sc = S_OK;
  193. layDebugOut((DEB_ITRACE,
  194. "In CLayoutRootStorage::OpenStorage:%p()\n", this));
  195. sc = _pRealStg->OpenStorage(pwcsName,
  196. pstgPriority,
  197. grfMode,
  198. snbExclude,
  199. reserved,
  200. ppstg);
  201. layDebugOut((DEB_ITRACE,
  202. "Out CLayoutRootStorage::OpenStorage:%p()\n", this));
  203. return ResultFromScode(sc);
  204. }
  205. //+---------------------------------------------------------------------------
  206. //
  207. // Member: CLayoutRootStorage::CopyTo, public
  208. //
  209. // History: 01-Jan-96 SusiA Created
  210. //
  211. //----------------------------------------------------------------------------
  212. STDMETHODIMP CLayoutRootStorage::CopyTo(DWORD ciidExclude,
  213. IID const *rgiidExclude,
  214. SNB snbExclude,
  215. IStorage *pstgDest)
  216. {
  217. SCODE sc = S_OK;
  218. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::CopyTo%p()\n", this));
  219. sc = _pRealStg->CopyTo(ciidExclude,
  220. rgiidExclude,
  221. snbExclude,
  222. pstgDest);
  223. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::CopyTo\n"));
  224. return ResultFromScode(sc);
  225. }
  226. //+---------------------------------------------------------------------------
  227. //
  228. // Member: CLayoutRootStorage::MoveElementTo, public
  229. //
  230. // History: 01-Jan-96 SusiA Created
  231. //
  232. //----------------------------------------------------------------------------
  233. STDMETHODIMP CLayoutRootStorage::MoveElementTo(OLECHAR const *lpszName,
  234. IStorage *pstgDest,
  235. OLECHAR const *lpszNewName,
  236. DWORD grfFlags)
  237. {
  238. SCODE sc = S_OK;
  239. layDebugOut((DEB_ITRACE,
  240. "In CLayoutRootStorage::MoveElementTo%p()\n", this));
  241. sc = _pRealStg->MoveElementTo(lpszName,
  242. pstgDest,
  243. lpszNewName,
  244. grfFlags) ;
  245. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::MoveElementTo\n"));
  246. return ResultFromScode(sc);
  247. }
  248. //+---------------------------------------------------------------------------
  249. //
  250. // Member: CLayoutRootStorage::Commit, public
  251. //
  252. // History: 01-Jan-96 SusiA Created
  253. //
  254. //----------------------------------------------------------------------------
  255. STDMETHODIMP CLayoutRootStorage::Commit(DWORD grfCommitFlags)
  256. {
  257. SCODE sc = S_OK;
  258. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Commit%p()\n", this));
  259. sc = _pRealStg->Commit(grfCommitFlags);
  260. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Commit\n"));
  261. return ResultFromScode(sc);
  262. }
  263. //+---------------------------------------------------------------------------
  264. //
  265. // Member: CLayoutRootStorage::Revert, public
  266. //
  267. // History: 01-Jan-96 SusiA Created
  268. //
  269. //----------------------------------------------------------------------------
  270. STDMETHODIMP CLayoutRootStorage::Revert(void)
  271. {
  272. SCODE sc = S_OK;
  273. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Revert%p()\n", this));
  274. sc = _pRealStg->Revert();
  275. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Revert\n"));
  276. return ResultFromScode(sc);
  277. }
  278. //+---------------------------------------------------------------------------
  279. //
  280. // Member: CLayoutRootStorage::EnumElements, public
  281. //
  282. // History: 01-Jan-96 SusiA Created
  283. //
  284. //----------------------------------------------------------------------------
  285. STDMETHODIMP CLayoutRootStorage::EnumElements(DWORD reserved1,
  286. void *reserved2,
  287. DWORD reserved3,
  288. IEnumSTATSTG **ppenm)
  289. {
  290. SCODE sc = S_OK;
  291. layDebugOut((DEB_ITRACE,
  292. "In CLayoutRootStorage::EnumElements%p()\n", this));
  293. sc = _pRealStg->EnumElements(reserved1,
  294. reserved2,
  295. reserved3,
  296. ppenm);
  297. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::EnumElements\n"));
  298. return ResultFromScode(sc);
  299. }
  300. //+---------------------------------------------------------------------------
  301. //
  302. // Member: CLayoutRootStorage::DestroyElement, public
  303. //
  304. // History: 01-Jan-96 SusiA Created
  305. //
  306. //----------------------------------------------------------------------------
  307. STDMETHODIMP CLayoutRootStorage::DestroyElement(OLECHAR const *pwcsName)
  308. {
  309. SCODE sc = S_OK;
  310. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::DestroyElement\n"));
  311. sc = _pRealStg->DestroyElement(pwcsName);
  312. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::DestroyElement\n"));
  313. return ResultFromScode(sc);
  314. }
  315. //+---------------------------------------------------------------------------
  316. //
  317. // Member: CLayoutRootStorage::RenameElement, public
  318. //
  319. // History: 01-Jan-96 SusiA Created
  320. //
  321. //----------------------------------------------------------------------------
  322. STDMETHODIMP CLayoutRootStorage::RenameElement(OLECHAR const *pwcsOldName,
  323. OLECHAR const *pwcsNewName)
  324. {
  325. SCODE sc = S_OK;
  326. sc = _pRealStg->RenameElement(pwcsOldName, pwcsNewName);
  327. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::RenameElement\n"));
  328. return ResultFromScode(sc);
  329. }
  330. //+---------------------------------------------------------------------------
  331. //
  332. // Member: CLayoutRootStorage::SetElementTimes, public
  333. //
  334. // History: 01-Jan-96 SusiA Created
  335. //
  336. //----------------------------------------------------------------------------
  337. STDMETHODIMP CLayoutRootStorage::SetElementTimes(const OLECHAR *lpszName,
  338. FILETIME const *pctime,
  339. FILETIME const *patime,
  340. FILETIME const *pmtime)
  341. {
  342. SCODE sc = S_OK;
  343. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetElementTimes\n"));
  344. sc = _pRealStg->SetElementTimes(lpszName,
  345. pctime,
  346. patime,
  347. pmtime);
  348. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetElementTimes\n"));
  349. return ResultFromScode(sc);
  350. }
  351. //+---------------------------------------------------------------------------
  352. //
  353. // Member: CLayoutRootStorage::SetClass, public
  354. //
  355. // History: 01-Jan-96 SusiA Created
  356. //
  357. //----------------------------------------------------------------------------
  358. STDMETHODIMP CLayoutRootStorage::SetClass(REFCLSID clsid)
  359. {
  360. SCODE sc = S_OK;
  361. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetClass\n"));
  362. sc = _pRealStg->SetClass(clsid);
  363. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetClass\n"));
  364. return ResultFromScode(sc);
  365. }
  366. //+---------------------------------------------------------------------------
  367. //
  368. // Member: CLayoutRootStorage::SetStateBits, public
  369. //
  370. // History: 01-Jan-96 SusiA Created
  371. //
  372. //----------------------------------------------------------------------------
  373. STDMETHODIMP CLayoutRootStorage::SetStateBits(DWORD grfStateBits,
  374. DWORD grfMask)
  375. {
  376. SCODE sc = S_OK;
  377. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::SetStateBits\n"));
  378. sc = _pRealStg->SetStateBits(grfStateBits, grfMask);
  379. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::SetStateBits\n"));
  380. return ResultFromScode(sc);
  381. }
  382. //+---------------------------------------------------------------------------
  383. //
  384. // Member: CLayoutRootStorage::Stat, public
  385. //
  386. // History: 01-Jan-96 SusiA Created
  387. //
  388. //----------------------------------------------------------------------------
  389. STDMETHODIMP CLayoutRootStorage::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
  390. {
  391. SCODE sc = S_OK;
  392. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::Stat%p()\n", this));
  393. sc = _pRealStg->Stat( pstatstg, grfStatFlag);
  394. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::Stat\n"));
  395. return ResultFromScode(sc);
  396. }
  397. //+---------------------------------------------------------------------------
  398. //
  399. // Member: CLayoutRootStorage::SwitchToFile, public
  400. //
  401. // History: 01-Jan-96 SusiA Created
  402. //
  403. //----------------------------------------------------------------------------
  404. STDMETHODIMP CLayoutRootStorage::SwitchToFile(OLECHAR *ptcsFile)
  405. {
  406. SCODE sc = S_OK;
  407. IRootStorage *prstg;
  408. layDebugOut((DEB_ITRACE, "In CLayoutRootStorage::%p()\n", this));
  409. layVerify(SUCCEEDED(_pRealStg->QueryInterface(IID_IRootStorage,
  410. (void **) &prstg)));
  411. sc = prstg->SwitchToFile(ptcsFile);
  412. prstg->Release();
  413. layDebugOut((DEB_ITRACE, "Out CLayoutRootStorage::\n"));
  414. return ResultFromScode(sc);
  415. }