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
7.7 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 at this interface
  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. // Comments:
  46. //
  47. //********************************************************************
  48. STDMETHODIMP COleClientSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  49. {
  50. TestDebugOut("In IOCS::QueryInterface\r\n");
  51. // delegate to the container Site
  52. return m_pSite->QueryInterface(riid, ppvObj);
  53. }
  54. //**********************************************************************
  55. //
  56. // CSimpleApp::AddRef
  57. //
  58. // Purpose:
  59. //
  60. // Adds to the reference count at the interface level.
  61. //
  62. // Parameters:
  63. //
  64. // None
  65. //
  66. // Return Value:
  67. //
  68. // ULONG - The new reference count of the interface
  69. //
  70. // Function Calls:
  71. // Function Location
  72. //
  73. // TestDebugOut Windows API
  74. //
  75. // Comments:
  76. //
  77. //********************************************************************
  78. STDMETHODIMP_(ULONG) COleClientSite::AddRef()
  79. {
  80. TestDebugOut("In IOCS::AddRef\r\n");
  81. // increment the interface reference count (for debugging only)
  82. ++m_nCount;
  83. // delegate to the container Site
  84. return m_pSite->AddRef();
  85. }
  86. //**********************************************************************
  87. //
  88. // CSimpleApp::Release
  89. //
  90. // Purpose:
  91. //
  92. // Decrements the reference count at this level
  93. //
  94. // Parameters:
  95. //
  96. // None
  97. //
  98. // Return Value:
  99. //
  100. // ULONG - The new reference count of the interface.
  101. //
  102. // Function Calls:
  103. // Function Location
  104. //
  105. // TestDebugOut Windows API
  106. //
  107. // Comments:
  108. //
  109. //********************************************************************
  110. STDMETHODIMP_(ULONG) COleClientSite::Release()
  111. {
  112. TestDebugOut("In IOCS::Release\r\n");
  113. // decrement the interface reference count (for debugging only)
  114. --m_nCount;
  115. // delegate to the container Site
  116. return m_pSite->Release();
  117. }
  118. //**********************************************************************
  119. //
  120. // COleClientSite::SaveObject
  121. //
  122. // Purpose:
  123. //
  124. // Called by the object when it wants to be saved to persistant
  125. // storage
  126. //
  127. // Parameters:
  128. //
  129. // None
  130. //
  131. // Return Value:
  132. //
  133. // S_OK
  134. //
  135. // Function Calls:
  136. // Function Location
  137. //
  138. // TestDebugOut Windows API
  139. // IOleObject::QueryInterface Object
  140. // IPersistStorage::SaveCompleted Object
  141. // IPersistStorage::Release Object
  142. // OleSave OLE API
  143. // ResultFromScode OLE API
  144. //
  145. // Comments:
  146. //
  147. //********************************************************************
  148. STDMETHODIMP COleClientSite::SaveObject()
  149. {
  150. LPPERSISTSTORAGE lpPS;
  151. SCODE sc = E_FAIL;
  152. TestDebugOut("In IOCS::SaveObject\r\n");
  153. // get a pointer to IPersistStorage
  154. HRESULT hErr = m_pSite->m_lpOleObject->QueryInterface(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. // Not Implemented
  175. //
  176. // Return Value:
  177. //
  178. // Function Calls:
  179. // Function Location
  180. //
  181. // TestDebugOut Windows API
  182. //
  183. // Comments:
  184. //
  185. // This function is not implemented because we don't support
  186. // linking.
  187. //
  188. //********************************************************************
  189. STDMETHODIMP COleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER FAR* ppmk)
  190. {
  191. TestDebugOut("In IOCS::GetMoniker\r\n");
  192. // need to null the out pointer
  193. *ppmk = NULL;
  194. return ResultFromScode(E_NOTIMPL);
  195. }
  196. //**********************************************************************
  197. //
  198. // COleClientSite::GetContainer
  199. //
  200. // Purpose:
  201. //
  202. // Not Implemented
  203. //
  204. // Parameters:
  205. //
  206. // Not Implemented
  207. //
  208. // Return Value:
  209. //
  210. // Not Implemented
  211. //
  212. // Function Calls:
  213. // Function Location
  214. //
  215. // TestDebugOut Windows API
  216. //
  217. // Comments:
  218. //
  219. // Not Implemented
  220. //
  221. //********************************************************************
  222. STDMETHODIMP COleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
  223. {
  224. TestDebugOut("In IOCS::GetContainer\r\n");
  225. // NULL the out pointer
  226. *ppContainer = NULL;
  227. return ResultFromScode(E_NOTIMPL);
  228. }
  229. //**********************************************************************
  230. //
  231. // COleClientSite::ShowObject
  232. //
  233. // Purpose:
  234. //
  235. // Not Implemented
  236. //
  237. // Parameters:
  238. //
  239. // Not Implemented
  240. //
  241. // Return Value:
  242. //
  243. // Not Implemented
  244. //
  245. // Function Calls:
  246. // Function Location
  247. //
  248. // TestDebugOut Windows API
  249. //
  250. // Comments:
  251. //
  252. // This function is not implemented because we don't support
  253. // linking.
  254. //
  255. //********************************************************************
  256. STDMETHODIMP COleClientSite::ShowObject()
  257. {
  258. TestDebugOut("In IOCS::ShowObject\r\n");
  259. return NOERROR;
  260. }
  261. //**********************************************************************
  262. //
  263. // COleClientSite::OnShowWindow
  264. //
  265. // Purpose:
  266. //
  267. // Object calls this method when it is opening/closing non-InPlace
  268. // Window
  269. //
  270. // Parameters:
  271. //
  272. // BOOL fShow - TRUE if Window is opening, FALSE if closing
  273. //
  274. // Return Value:
  275. //
  276. // S_OK
  277. //
  278. // Function Calls:
  279. // Function Location
  280. //
  281. // TestDebugOut Windows API
  282. // InvalidateRect Windows API
  283. // ResultFromScode OLE API
  284. //
  285. // Comments:
  286. //
  287. //********************************************************************
  288. STDMETHODIMP COleClientSite::OnShowWindow(BOOL fShow)
  289. {
  290. TestDebugOut("In IOCS::OnShowWindow\r\n");
  291. m_pSite->m_fObjectOpen = fShow;
  292. InvalidateRect(m_pSite->m_lpDoc->m_hDocWnd, NULL, TRUE);
  293. // if object window is closing, then bring container window to top
  294. if (! fShow) {
  295. BringWindowToTop(m_pSite->m_lpDoc->m_hDocWnd);
  296. SetFocus(m_pSite->m_lpDoc->m_hDocWnd);
  297. }
  298. return ResultFromScode(S_OK);
  299. }
  300. //**********************************************************************
  301. //
  302. // COleClientSite::RequestNewObjectLayout
  303. //
  304. // Purpose:
  305. //
  306. // Not Implemented
  307. //
  308. // Parameters:
  309. //
  310. // Not Implemented
  311. //
  312. // Return Value:
  313. //
  314. // Not Implemented
  315. //
  316. // Function Calls:
  317. // Function Location
  318. //
  319. // TestDebugOut Windows API
  320. //
  321. // Comments:
  322. //
  323. // Not Implemented
  324. //
  325. //********************************************************************
  326. STDMETHODIMP COleClientSite::RequestNewObjectLayout()
  327. {
  328. TestDebugOut("In IOCS::RequestNewObjectLayout\r\n");
  329. return ResultFromScode(E_NOTIMPL);
  330. }