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.

400 lines
10 KiB

  1. //**********************************************************************
  2. // File name: IOIPO.CPP
  3. //
  4. // Implementation file for the CClassFactory Class
  5. //
  6. // Functions:
  7. //
  8. // See ioipo.h for a list of member functions.
  9. //
  10. // Copyright (c) 1993 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. #include "obj.h"
  14. #include "ioipo.h"
  15. #include "app.h"
  16. #include "doc.h"
  17. #include "math.h"
  18. //**********************************************************************
  19. //
  20. // COleInPlaceObject::QueryInterface
  21. //
  22. // Purpose:
  23. // Used for interface negotiation
  24. //
  25. // Parameters:
  26. //
  27. // REFIID riid - Interface being queried for.
  28. //
  29. // LPVOID FAR *ppvObj - Out pointer for the interface.
  30. //
  31. // Return Value:
  32. //
  33. // S_OK - Success
  34. // E_NOINTERFACE - Failure
  35. //
  36. // Function Calls:
  37. // Function Location
  38. //
  39. // CSimpSvrObj::QueryInterface OBJ.CPP
  40. //
  41. //
  42. //********************************************************************
  43. STDMETHODIMP COleInPlaceObject::QueryInterface ( REFIID riid, LPVOID FAR* ppvObj)
  44. {
  45. TestDebugOut(TEXT("In COleInPlaceObject::QueryInterface\r\n"));
  46. // need to NULL the out parameter
  47. *ppvObj = NULL;
  48. return m_lpObj->QueryInterface(riid, ppvObj);
  49. }
  50. //**********************************************************************
  51. //
  52. // COleInPlaceObject::AddRef
  53. //
  54. // Purpose:
  55. //
  56. // Increments the reference count of CSimpSvrObj. Since
  57. // COleInPlaceObject is a nested class of CSimpSvrObj, we don't need
  58. // to have a separate reference count for COleInPlaceObject. We can
  59. // use the reference count of CSimpSvrObj.
  60. //
  61. // Parameters:
  62. //
  63. // None
  64. //
  65. // Return Value:
  66. //
  67. // The new reference count of CSimpSvrObj
  68. //
  69. // Function Calls:
  70. // Function Location
  71. //
  72. // OuputDebugString Windows API
  73. // CSimpSvrObj::AddRef OBJ.CPP
  74. //
  75. //
  76. //********************************************************************
  77. STDMETHODIMP_(ULONG) COleInPlaceObject::AddRef ()
  78. {
  79. TestDebugOut(TEXT("In COleInPlaceObject::AddRef\r\n"));
  80. return m_lpObj->AddRef();
  81. }
  82. //**********************************************************************
  83. //
  84. // COleInPlaceObject::Release
  85. //
  86. // Purpose:
  87. //
  88. // Decrements the reference count of CSimpSvrObj. Since
  89. // COleInPlaceObject is a nested class of CSimpSvrObj, we don't need
  90. // to have a separate reference count for COleInPlaceObject. We can
  91. // use the reference count of CSimpSvrObj.
  92. //
  93. // Parameters:
  94. //
  95. // None
  96. //
  97. // Return Value:
  98. //
  99. // The new reference count of CSimpSvrObj
  100. //
  101. // Function Calls:
  102. // Function Location
  103. //
  104. // TestDebugOut Windows API
  105. // CSimpSvrObj::Release OBJ.CPP
  106. //
  107. //
  108. //********************************************************************
  109. STDMETHODIMP_(ULONG) COleInPlaceObject::Release ()
  110. {
  111. TestDebugOut(TEXT("In COleInPlaceObject::Release\r\n"));
  112. return m_lpObj->Release();
  113. }
  114. //**********************************************************************
  115. //
  116. // COleInPlaceObject::InPlaceDeactivate
  117. //
  118. // Purpose:
  119. //
  120. // Called to deactivat the object
  121. //
  122. // Parameters:
  123. //
  124. // None
  125. //
  126. // Return Value:
  127. // NOERROR
  128. //
  129. // Function Calls:
  130. // Function Location
  131. //
  132. // TestDebugOut Windows API
  133. // IOleInPlaceSite::OnInPlaceDeactivate Container
  134. // IOleInPlaceSite::Release Container
  135. // CSimpSvrObj::DeactivateUI OBJ.CPP
  136. // CSimpSvrObj::DoInPlaceHide OBJ.CPP
  137. //
  138. //********************************************************************
  139. STDMETHODIMP COleInPlaceObject::InPlaceDeactivate()
  140. {
  141. TestDebugOut(TEXT("In COleInPlaceObject::InPlaceDeactivate\r\n"));
  142. // if not inplace active, return NOERROR
  143. if (!m_lpObj->m_fInPlaceActive)
  144. return NOERROR;
  145. // clear inplace flag
  146. m_lpObj->m_fInPlaceActive = FALSE;
  147. // deactivate the UI
  148. m_lpObj->DeactivateUI();
  149. m_lpObj->DoInPlaceHide();
  150. // tell the container that we are deactivating.
  151. if (m_lpObj->m_lpIPSite)
  152. {
  153. HRESULT hRes;
  154. if ((hRes=m_lpObj->m_lpIPSite->OnInPlaceDeactivate()) != S_OK)
  155. {
  156. TestDebugOut(TEXT("COleInPlaceObject::InPlaceDeactivate \
  157. OnInPlaceDeactivate fails\n"));
  158. }
  159. m_lpObj->m_lpIPSite->Release();
  160. m_lpObj->m_lpIPSite =NULL;
  161. }
  162. return ResultFromScode(S_OK);
  163. }
  164. //**********************************************************************
  165. //
  166. // COleInPlaceObject::UIDeactivate
  167. //
  168. // Purpose:
  169. //
  170. // Instructs us to remove our UI.
  171. //
  172. // Parameters:
  173. //
  174. // None
  175. //
  176. // Return Value:
  177. //
  178. // S_OK
  179. //
  180. // Function Calls:
  181. // Function Location
  182. //
  183. // TestDebugOut Windows API
  184. // CSimpSvrObj::DeactivateUI OBJ.CPP
  185. //
  186. //
  187. //********************************************************************
  188. STDMETHODIMP COleInPlaceObject::UIDeactivate()
  189. {
  190. TestDebugOut(TEXT("In COleInPlaceObject::UIDeactivate\r\n"));
  191. m_lpObj->DeactivateUI();
  192. return ResultFromScode (S_OK);
  193. }
  194. //**********************************************************************
  195. //
  196. // COleInPlaceObject::SetObjectRects
  197. //
  198. // Purpose:
  199. //
  200. // Called when the container clipping region or the object position
  201. // changes.
  202. //
  203. // Parameters:
  204. //
  205. // LPCRECT lprcPosRect - New Position Rect.
  206. //
  207. // LPCRECT lprcClipRect - New Clipping Rect.
  208. //
  209. // Return Value:
  210. //
  211. // S_OK
  212. //
  213. // Function Calls:
  214. // Function Location
  215. //
  216. // TestDebugOut Windows API
  217. // IntersectRect Windows API
  218. // OffsetRect Windows API
  219. // CopyRect Windows API
  220. // MoveWindow Windows API
  221. // CSimpSvrDoc::GethHatchWnd DOC.H
  222. // CSimpSvrDoc::gethDocWnd DOC.h
  223. // SetHatchWindowSize OLE2UI
  224. //
  225. //
  226. //********************************************************************
  227. STDMETHODIMP COleInPlaceObject::SetObjectRects ( LPCRECT lprcPosRect, LPCRECT lprcClipRect)
  228. {
  229. TestDebugOut(TEXT("In COleInPlaceObject::SetObjectRects\r\n"));
  230. RECT resRect;
  231. POINT pt;
  232. // Get the intersection of the clipping rect and the position rect.
  233. IntersectRect(&resRect, lprcPosRect, lprcClipRect);
  234. m_lpObj->m_xOffset = abs (resRect.left - lprcPosRect->left);
  235. m_lpObj->m_yOffset = abs (resRect.top - lprcPosRect->top);
  236. m_lpObj->m_scale = (float)(lprcPosRect->right - lprcPosRect->left)/m_lpObj->m_size.x;
  237. if (m_lpObj->m_scale == 0)
  238. m_lpObj->m_scale = 1.0F;
  239. TCHAR szBuffer[255];
  240. wsprintf(szBuffer, TEXT("New Scale %3d\r\n"), m_lpObj->m_scale);
  241. TestDebugOut(szBuffer);
  242. // Adjust the size of the Hatch Window.
  243. SetHatchWindowSize(m_lpObj->m_lpDoc->GethHatchWnd(),(LPRECT) lprcPosRect, (LPRECT) lprcClipRect, &pt);
  244. // offset the rect
  245. OffsetRect(&resRect, pt.x, pt.y);
  246. CopyRect(&m_lpObj->m_posRect, lprcPosRect);
  247. // Move the actual object window
  248. MoveWindow(m_lpObj->m_lpDoc->GethDocWnd(),
  249. resRect.left,
  250. resRect.top,
  251. resRect.right - resRect.left,
  252. resRect.bottom - resRect.top,
  253. TRUE);
  254. return ResultFromScode( S_OK );
  255. }
  256. //**********************************************************************
  257. //
  258. // COleInPlaceObject::GetWindow
  259. //
  260. // Purpose:
  261. //
  262. // Returns the Window handle of the inplace object
  263. //
  264. // Parameters:
  265. //
  266. // HWND FAR* lphwnd - Out pointer in which to return the window
  267. // Handle.
  268. //
  269. // Return Value:
  270. //
  271. // S_OK
  272. //
  273. // Function Calls:
  274. // Function Location
  275. //
  276. // TestDebugOut Windows API
  277. // CSimpleDoc::GethDocWnd DOC.H
  278. //
  279. //
  280. //********************************************************************
  281. STDMETHODIMP COleInPlaceObject::GetWindow ( HWND FAR* lphwnd)
  282. {
  283. TestDebugOut(TEXT("In COleInPlaceObject::GetWindow\r\n"));
  284. *lphwnd = m_lpObj->m_lpDoc->GethDocWnd();
  285. return ResultFromScode( S_OK );
  286. }
  287. //**********************************************************************
  288. //
  289. // COleInPlaceObject::ContextSensitiveHelp
  290. //
  291. // Purpose:
  292. //
  293. // Used in performing Context Sensitive Help
  294. //
  295. // Parameters:
  296. //
  297. // BOOL fEnterMode - Flag to determine if enter or exiting
  298. // Context Sensitive Help.
  299. //
  300. // Return Value:
  301. //
  302. // E_NOTIMPL
  303. //
  304. // Function Calls:
  305. // Function Location
  306. //
  307. // TestDebugOut Windows API
  308. //
  309. // Comments:
  310. //
  311. // This function is not implemented due to the fact that it is
  312. // beyond the scope of a simple object. All *real* applications
  313. // are going to want to implement this function, otherwise any
  314. // container that supports context sensitive help will not work
  315. // properly while the object is in place.
  316. //
  317. // See TECHNOTES.WRI include with the OLE SDK for details on
  318. // Implementing this method.
  319. //
  320. //********************************************************************
  321. STDMETHODIMP COleInPlaceObject::ContextSensitiveHelp ( BOOL fEnterMode)
  322. {
  323. TestDebugOut(TEXT("In COleInPlaceObject::ContextSensitiveHelp\r\n"));
  324. return ResultFromScode( E_NOTIMPL);
  325. }
  326. //**********************************************************************
  327. //
  328. // COleInPlaceObject::ReactivateAndUndo
  329. //
  330. // Purpose:
  331. //
  332. // Called when the container wants to undo the last edit made in
  333. // the object.
  334. //
  335. // Parameters:
  336. //
  337. // None
  338. //
  339. // Return Value:
  340. //
  341. // INPLACE_E_NOTUNDOABLE
  342. //
  343. // Function Calls:
  344. // Function Location
  345. //
  346. // TestDebugOut Windows API
  347. //
  348. // Comments:
  349. //
  350. // Since this server does not support undo, the value
  351. // INPLACE_E_NOTUNDOABLE is always returned.
  352. //
  353. //********************************************************************
  354. STDMETHODIMP COleInPlaceObject::ReactivateAndUndo ()
  355. {
  356. TestDebugOut(TEXT("In COleInPlaceObject::ReactivateAndUndo\r\n"));
  357. return ResultFromScode( INPLACE_E_NOTUNDOABLE );
  358. }
  359.