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.

373 lines
8.3 KiB

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