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.

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