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.

365 lines
8.4 KiB

  1. //**********************************************************************
  2. // File name: IOCS.CPP
  3. //
  4. // Implementation file for COleClientSite
  5. //
  6. // Functions:
  7. //
  8. // See IOCS.H for class definition
  9. //
  10. // Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. #include "iocs.h"
  14. #include "ias.h"
  15. #include "app.h"
  16. #include "site.h"
  17. #include "doc.h"
  18. //**********************************************************************
  19. //
  20. // COleClientSite::QueryInterface
  21. //
  22. // Purpose:
  23. //
  24. // Used for interface negotiation
  25. //
  26. // Parameters:
  27. //
  28. // REFIID riid - A reference to the interface that is
  29. // being queried.
  30. //
  31. // LPVOID FAR* ppvObj - An out parameter to return a pointer to
  32. // the interface.
  33. //
  34. // Return Value:
  35. //
  36. // S_OK - The interface is supported.
  37. // E_NOINTERFACE - The interface is not supported
  38. //
  39. // Function Calls:
  40. // Function Location
  41. //
  42. // TestDebugOut Windows API
  43. // CSimpleSite::QueryInterface SITE.CPP
  44. //
  45. //
  46. //********************************************************************
  47. STDMETHODIMP COleClientSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  48. {
  49. TestDebugOut("In IOCS::QueryInterface\r\n");
  50. // delegate to the container Site
  51. return m_pSite->QueryInterface(riid, ppvObj);
  52. }
  53. //**********************************************************************
  54. //
  55. // COleClientSite::AddRef
  56. //
  57. // Purpose:
  58. //
  59. // Increments the reference count to CSimpleSite. Since COleClientSite
  60. // is a nested class of CSimpleSite, we don't need an extra reference
  61. // count for COleClientSite. We can safely use the reference count of
  62. // CSimpleSite.
  63. //
  64. // Parameters:
  65. //
  66. // None
  67. //
  68. // Return Value:
  69. //
  70. // ULONG - The new reference count of CSimpleSite
  71. //
  72. // Function Calls:
  73. // Function Location
  74. //
  75. // TestDebugOut Windows API
  76. // CSimpleSite::AddRef SITE.CPP
  77. //
  78. //
  79. //********************************************************************
  80. STDMETHODIMP_(ULONG) COleClientSite::AddRef()
  81. {
  82. TestDebugOut("In IOCS::AddRef\r\n");
  83. // delegate to the container Site
  84. return m_pSite->AddRef();
  85. }
  86. //**********************************************************************
  87. //
  88. // COleClientSite::Release
  89. //
  90. // Purpose:
  91. //
  92. // Decrements the reference count to CSimpleSite. Since COleClientSite
  93. // is a nested class of CSimpleSite, we don't need an extra reference
  94. // count for COleClientSite. We can safely use the reference count of
  95. // CSimpleSite.
  96. //
  97. // Parameters:
  98. //
  99. // None
  100. //
  101. // Return Value:
  102. //
  103. // ULONG - The new reference count of the CSimpleSite
  104. //
  105. // Function Calls:
  106. // Function Location
  107. //
  108. // TestDebugOut Windows API
  109. // CSimpleSite::Release SITE.CPP
  110. //
  111. //
  112. //********************************************************************
  113. STDMETHODIMP_(ULONG) COleClientSite::Release()
  114. {
  115. TestDebugOut("In IOCS::Release\r\n");
  116. // delegate to the container Site
  117. return m_pSite->Release();
  118. }
  119. //**********************************************************************
  120. //
  121. // COleClientSite::SaveObject
  122. //
  123. // Purpose:
  124. //
  125. // Called by the object when it wants to be saved to persistant
  126. // storage
  127. //
  128. // Parameters:
  129. //
  130. // None
  131. //
  132. // Return Value:
  133. //
  134. // S_OK
  135. //
  136. // Function Calls:
  137. // Function Location
  138. //
  139. // TestDebugOut Windows API
  140. // IOleObject::QueryInterface Object
  141. // IPersistStorage::SaveCompleted Object
  142. // IPersistStorage::Release Object
  143. // ResultFromScode OLE API
  144. //
  145. //
  146. //********************************************************************
  147. STDMETHODIMP COleClientSite::SaveObject()
  148. {
  149. LPPERSISTSTORAGE lpPS;
  150. SCODE sc = E_FAIL;
  151. TestDebugOut("In IOCS::SaveObject\r\n");
  152. // get a pointer to IPersistStorage
  153. HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(
  154. IID_IPersistStorage,(LPVOID FAR *)&lpPS);
  155. // save the object
  156. if (hErr == NOERROR)
  157. {
  158. sc = GetScode( OleSave(lpPS, m_pSite->m_lpObjStorage, TRUE) );
  159. lpPS->SaveCompleted(NULL);
  160. lpPS->Release();
  161. }
  162. return ResultFromScode(sc);
  163. }
  164. //**********************************************************************
  165. //
  166. // COleClientSite::GetMoniker
  167. //
  168. // Purpose:
  169. //
  170. // Not Implemented
  171. //
  172. // Parameters:
  173. //
  174. // DWORD dwAssign - the type of Moniker to be returned
  175. // DWORD dwWhichMoniker - which Moniker to be returned in ppmk
  176. // LPMONIKER ppmk - point to where to return the Moniker
  177. //
  178. // Return Value:
  179. //
  180. // E_NOTIMPL
  181. //
  182. // Function Calls:
  183. // Function Location
  184. //
  185. // TestDebugOut Windows API
  186. //
  187. // Comments:
  188. //
  189. // This function is not implemented because we don't support
  190. // linking.
  191. //
  192. //********************************************************************
  193. STDMETHODIMP COleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
  194. LPMONIKER FAR* ppmk)
  195. {
  196. TestDebugOut("In IOCS::GetMoniker\r\n");
  197. // need to null the out pointer
  198. *ppmk = NULL;
  199. return ResultFromScode(E_NOTIMPL);
  200. }
  201. //**********************************************************************
  202. //
  203. // COleClientSite::GetContainer
  204. //
  205. // Purpose:
  206. //
  207. // Not Implemented
  208. //
  209. // Parameters:
  210. //
  211. // LPOLECONTAINER ppContainer - point to where the interface to be
  212. // returned
  213. //
  214. // Return Value:
  215. //
  216. // E_NOTIMPL
  217. //
  218. // Function Calls:
  219. // Function Location
  220. //
  221. // TestDebugOut Windows API
  222. //
  223. //
  224. //********************************************************************
  225. STDMETHODIMP COleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
  226. {
  227. TestDebugOut("In IOCS::GetContainer\r\n");
  228. // NULL the out pointer
  229. *ppContainer = NULL;
  230. return ResultFromScode(E_NOTIMPL);
  231. }
  232. //**********************************************************************
  233. //
  234. // COleClientSite::ShowObject
  235. //
  236. // Purpose:
  237. //
  238. // Not Implemented
  239. //
  240. // Parameters:
  241. //
  242. // None
  243. //
  244. // Return Value:
  245. //
  246. // NOERROR
  247. //
  248. // Function Calls:
  249. // Function Location
  250. //
  251. // TestDebugOut Windows API
  252. //
  253. // Comments:
  254. //
  255. // This function is not implemented because we don't support
  256. // linking.
  257. //
  258. //********************************************************************
  259. STDMETHODIMP COleClientSite::ShowObject()
  260. {
  261. TestDebugOut("In IOCS::ShowObject\r\n");
  262. return NOERROR;
  263. }
  264. //**********************************************************************
  265. //
  266. // COleClientSite::OnShowWindow
  267. //
  268. // Purpose:
  269. //
  270. // Object calls this method when it is opening/closing non-InPlace
  271. // Window
  272. //
  273. // Parameters:
  274. //
  275. // BOOL fShow - TRUE if Window is opening, FALSE if closing
  276. //
  277. // Return Value:
  278. //
  279. // S_OK
  280. //
  281. // Function Calls:
  282. // Function Location
  283. //
  284. // TestDebugOut Windows API
  285. // InvalidateRect Windows API
  286. // BringWindowToTop Windows API
  287. // SetFocus Windows API
  288. // ResultFromScode OLE API
  289. //
  290. //
  291. //********************************************************************
  292. STDMETHODIMP COleClientSite::OnShowWindow(BOOL fShow)
  293. {
  294. TestDebugOut("In IOCS::OnShowWindow\r\n");
  295. m_pSite->m_fObjectOpen = fShow;
  296. InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
  297. // if object window is closing, then bring container window to top
  298. if (! fShow)
  299. {
  300. BringWindowToTop(m_pSite->m_lpDoc->m_hDocWnd);
  301. SetFocus(m_pSite->m_lpDoc->m_hDocWnd);
  302. }
  303. return ResultFromScode(S_OK);
  304. }
  305. //**********************************************************************
  306. //
  307. // COleClientSite::RequestNewObjectLayout
  308. //
  309. // Purpose:
  310. //
  311. // Not Implemented
  312. //
  313. // Parameters:
  314. //
  315. // None
  316. //
  317. // Return Value:
  318. //
  319. // E_NOTIMPL
  320. //
  321. // Function Calls:
  322. // Function Location
  323. //
  324. // TestDebugOut Windows API
  325. //
  326. //
  327. //********************************************************************
  328. STDMETHODIMP COleClientSite::RequestNewObjectLayout()
  329. {
  330. TestDebugOut("In IOCS::RequestNewObjectLayout\r\n");
  331. return ResultFromScode(E_NOTIMPL);
  332. }