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.

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