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.

609 lines
15 KiB

  1. //**********************************************************************
  2. // File name: HLP_IOPS.cxx
  3. //
  4. // Implementation file for COleInPlaceSite
  5. //
  6. // Functions:
  7. //
  8. // See IOIPS.H for class Definition
  9. //
  10. // Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "hlp_pre.hxx"
  13. #include "hlp_iocs.hxx"
  14. #include "hlp_ias.hxx"
  15. #include "hlp_iopf.hxx"
  16. #include "hlp_iops.hxx"
  17. #include "hlp_app.hxx"
  18. #include "hlp_site.hxx"
  19. #include "hlp_doc.hxx"
  20. //**********************************************************************
  21. //
  22. // COleInPlaceSite::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. // S_FALSE - The interface is not supported
  40. //
  41. // Function Calls:
  42. // Function Location
  43. //
  44. // OutputDebugString Windows API
  45. // CSimpleSite::QueryInterface SITE.cxx
  46. //
  47. //
  48. //********************************************************************
  49. STDMETHODIMP COleInPlaceSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  50. {
  51. DEBUGOUT(TEXT("In IOIPS::QueryInterface\r\n"));
  52. // delegate to the container Site
  53. return m_pSite->QueryInterface(riid, ppvObj);
  54. }
  55. //**********************************************************************
  56. //
  57. // COleInPlaceSite::AddRef
  58. //
  59. // Purpose:
  60. //
  61. // Increments the reference count of the CSimpleSite. Since
  62. // COleInPlaceSite is a nested class of CSimpleSite, we don't need an
  63. // extra reference count for COleInPlaceSite. We can safely use the
  64. // reference count of CSimpleSite.
  65. //
  66. // Parameters:
  67. //
  68. // None
  69. //
  70. // Return Value:
  71. //
  72. // ULONG - The new reference count of CSimpleSite
  73. //
  74. // Function Calls:
  75. // Function Location
  76. //
  77. // OutputDebugString Windows API
  78. // CSimpleSite::QueryInterface SITE.cxx
  79. //
  80. //
  81. //********************************************************************
  82. STDMETHODIMP_(ULONG) COleInPlaceSite::AddRef()
  83. {
  84. DEBUGOUT(TEXT("In IOIPS::AddRef\r\n"));
  85. // delegate to the container Site
  86. return m_pSite->AddRef();
  87. }
  88. //**********************************************************************
  89. //
  90. // COleInPlaceSite::Release
  91. //
  92. // Purpose:
  93. //
  94. // Decrements the reference count of the CSimpleSite. Since
  95. // COleInPlaceSite is a nested class of CSimpleSite, we don't need an
  96. // extra reference count for COleInPlaceSite. We can safely use the
  97. // reference count of CSimpleSite.
  98. //
  99. // Parameters:
  100. //
  101. // None
  102. //
  103. // Return Value:
  104. //
  105. // ULONG - The new reference count of CSimpleSite
  106. //
  107. // Function Calls:
  108. // Function Location
  109. //
  110. // OutputDebugString Windows API
  111. // CSimpleSite::Release SITE.cxx
  112. //
  113. //
  114. //********************************************************************
  115. STDMETHODIMP_(ULONG) COleInPlaceSite::Release()
  116. {
  117. DEBUGOUT(TEXT("In IOIPS::Release\r\n"));
  118. // delegate to the container Site
  119. return m_pSite->Release();
  120. }
  121. //**********************************************************************
  122. //
  123. // COleInPlaceSite::GetWindow
  124. //
  125. // Purpose:
  126. //
  127. // Returns the Window Handle of the client site
  128. //
  129. // Parameters:
  130. //
  131. // HWND FAR* lphwnd - place to return the handle
  132. //
  133. // Return Value:
  134. //
  135. // S_OK
  136. //
  137. // Function Calls:
  138. // Function Location
  139. //
  140. // OutputDebugString Windows API
  141. // ResultFromScode OLE API
  142. //
  143. //
  144. //********************************************************************
  145. STDMETHODIMP COleInPlaceSite::GetWindow (HWND FAR* lphwnd)
  146. {
  147. DEBUGOUT(TEXT("In IOIPS::GetWindow\r\n"));
  148. // return the handle to our editing window.
  149. *lphwnd = m_pSite->m_lpDoc->m_hDocWnd;
  150. return ResultFromScode(S_OK);
  151. }
  152. //**********************************************************************
  153. //
  154. // COleInPlaceSite::ContextSensitiveHelp
  155. //
  156. // Purpose:
  157. // set/reset context sensitive help mode
  158. //
  159. // Parameters:
  160. //
  161. // BOOL fEnterMode - TRUE for entering Context Sensitive help mode
  162. //
  163. // Return Value:
  164. //
  165. // S_OK
  166. //
  167. // Function Calls:
  168. // Function Location
  169. //
  170. // OutputDebugString Windows API
  171. // ResultFromScode OLE API
  172. //
  173. // Comments:
  174. //
  175. // Be sure to read the technotes included with the OLE toolkit.
  176. //
  177. //********************************************************************
  178. STDMETHODIMP COleInPlaceSite::ContextSensitiveHelp (BOOL fEnterMode)
  179. {
  180. DEBUGOUT(TEXT("In IOIPS::ContextSensitiveHelp\r\n"));
  181. if (m_pSite->m_lpDoc->m_lpApp->m_fCSHMode != fEnterMode)
  182. m_pSite->m_lpDoc->m_lpApp->m_fCSHMode = fEnterMode;
  183. return ResultFromScode(S_OK);
  184. }
  185. //**********************************************************************
  186. //
  187. // COleInPlaceSite::CanInPlaceActivate
  188. //
  189. // Purpose:
  190. //
  191. // Object calls to find out if the container can InPlace activate
  192. //
  193. // Parameters:
  194. //
  195. // None
  196. //
  197. // Return Value:
  198. //
  199. // S_OK
  200. //
  201. // Function Calls:
  202. // Function Location
  203. //
  204. // OutputDebugString Windows API
  205. // ResultFromScode OLE API
  206. //
  207. //
  208. //********************************************************************
  209. STDMETHODIMP COleInPlaceSite::CanInPlaceActivate ()
  210. {
  211. DEBUGOUT(TEXT("In IOIPS::CanInPlaceActivate\r\n"));
  212. // return S_OK to indicate we can in-place activate
  213. return ResultFromScode(S_OK);
  214. }
  215. //**********************************************************************
  216. //
  217. // COleInPlaceSite::OnInPlaceActivate
  218. //
  219. // Purpose:
  220. //
  221. // Called by the object on InPlace Activation
  222. //
  223. // Parameters:
  224. //
  225. // None
  226. //
  227. // Return Value:
  228. //
  229. // S_OK - if the interface can be found
  230. // E_FAIL - otherwise
  231. //
  232. // Function Calls:
  233. // Function Location
  234. //
  235. // OutputDebugString Windows API
  236. // ResultFromScode OLE API
  237. // IOleObject::QueryInterface Object
  238. //
  239. //
  240. //********************************************************************
  241. STDMETHODIMP COleInPlaceSite::OnInPlaceActivate ()
  242. {
  243. HRESULT hrErr;
  244. DEBUGOUT(TEXT("In IOIPS::OnInPlaceActivate\r\n"));
  245. hrErr = m_pSite->m_lpOleObject->QueryInterface(
  246. IID_IOleInPlaceObject, (LPVOID FAR *)&m_pSite->m_lpInPlaceObject);
  247. if (hrErr != NOERROR)
  248. return ResultFromScode(E_FAIL);
  249. // return S_OK to indicate we can in-place activate.
  250. return ResultFromScode(S_OK);
  251. }
  252. //**********************************************************************
  253. //
  254. // COleInPlaceSite::OnUIActivate
  255. //
  256. // Purpose:
  257. //
  258. // Object calls this method when it displays it's UI.
  259. //
  260. // Parameters:
  261. //
  262. // None.
  263. //
  264. // Return Value:
  265. //
  266. // S_OK
  267. //
  268. // Function Calls:
  269. // Function Location
  270. //
  271. // OutputDebugString Windows API
  272. // ResultFromScode OLE API
  273. // IOleInPlaceObject::GetWindow Object
  274. //
  275. //
  276. //********************************************************************
  277. STDMETHODIMP COleInPlaceSite::OnUIActivate ()
  278. {
  279. DEBUGOUT(TEXT("In IOIPS::OnUIActivate\r\n"));
  280. m_pSite->m_lpDoc->m_fAddMyUI=FALSE;
  281. m_pSite->m_lpDoc->m_fInPlaceActive = TRUE;
  282. m_pSite->m_fInPlaceActive = TRUE;
  283. m_pSite->m_lpInPlaceObject->GetWindow((HWND FAR*)&m_pSite->m_hwndIPObj);
  284. // return S_OK to continue in-place activation
  285. return ResultFromScode(S_OK);
  286. }
  287. //**********************************************************************
  288. //
  289. // COleInPlaceSite::GetWindowContext
  290. //
  291. // Purpose:
  292. //
  293. // Called by the object to get information for InPlace Negotiation.
  294. //
  295. // Parameters:
  296. //
  297. // LPOLEINPLACEFRAME FAR* lplpFrame - Location to return a pointer
  298. // to IOleInPlaceFrame.
  299. //
  300. // LPOLEINPLACEUIWINDOW FAR* lplpDoc - Location to return a pointer
  301. // to IOleInPlaceUIWindow.
  302. //
  303. // LPRECT lprcPosRect - The rect that the object
  304. // occupies
  305. //
  306. // LPRECT lprcClipRect - The clipping rect
  307. //
  308. // LPOLEINPLACEFRAMEINFO lpFrameInfo - Pointer to FRAMEINFO
  309. //
  310. //
  311. // Return Value:
  312. //
  313. // S_OK
  314. //
  315. // Function Calls:
  316. // Function Location
  317. //
  318. // COleInPlaceFrame::AddRef IOIPF.cxx
  319. // CSimpleSite::GetObjRect SITE.cxx
  320. // OutputDebugString Windows API
  321. // CopyRect Windows API
  322. // GetClientRect Windows API
  323. // ResultFromScode OLE API
  324. //
  325. //
  326. //********************************************************************
  327. STDMETHODIMP COleInPlaceSite::GetWindowContext (
  328. LPOLEINPLACEFRAME FAR* lplpFrame,
  329. LPOLEINPLACEUIWINDOW FAR* lplpDoc,
  330. LPRECT lprcPosRect,
  331. LPRECT lprcClipRect,
  332. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  333. {
  334. RECT rect;
  335. DEBUGOUT(TEXT("In IOIPS::GetWindowContext\r\n"));
  336. // the frame is associated with the application object.
  337. // need to AddRef() it...
  338. m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame.AddRef();
  339. *lplpFrame = &m_pSite->m_lpDoc->m_lpApp->m_OleInPlaceFrame;
  340. *lplpDoc = NULL; // must be NULL, cause we're SDI.
  341. // get the size of the object in pixels
  342. m_pSite->GetObjRect(&rect);
  343. // Copy this to the passed buffer
  344. CopyRect(lprcPosRect, &rect);
  345. // fill the clipping region
  346. GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
  347. CopyRect(lprcClipRect, &rect);
  348. // fill the FRAMEINFO
  349. lpFrameInfo->fMDIApp = FALSE;
  350. lpFrameInfo->hwndFrame = m_pSite->m_lpDoc->m_lpApp->m_hAppWnd;
  351. lpFrameInfo->haccel = m_pSite->m_lpDoc->m_lpApp->m_hAccel;
  352. lpFrameInfo->cAccelEntries = SIMPCNTR_ACCEL_CNT;
  353. return ResultFromScode(S_OK);
  354. }
  355. //**********************************************************************
  356. //
  357. // COleInPlaceSite::Scroll
  358. //
  359. // Purpose:
  360. //
  361. // Not Implemented
  362. //
  363. // Parameters:
  364. //
  365. // SIZE scrollExtent - number of pixels scrolled in X and Y direction
  366. //
  367. // Return Value:
  368. //
  369. // E_FAIL
  370. //
  371. // Function Calls:
  372. // Function Location
  373. //
  374. // OutputDebugString Windows API
  375. //
  376. //
  377. //********************************************************************
  378. STDMETHODIMP COleInPlaceSite::Scroll (SIZE scrollExtent)
  379. {
  380. DEBUGOUT(TEXT("In IOIPS::Scroll\r\n"));
  381. return ResultFromScode(E_FAIL);
  382. }
  383. //**********************************************************************
  384. //
  385. // COleInPlaceSite::OnUIDeactivate
  386. //
  387. // Purpose:
  388. //
  389. // Called by the object when its UI goes away
  390. //
  391. // Parameters:
  392. //
  393. // BOOL fUndoable
  394. //
  395. // Return Value:
  396. //
  397. // S_OK
  398. //
  399. // Function Calls:
  400. // Function Location
  401. //
  402. // OutputDebugString Windows API
  403. // CSimpleAPP::QueryNewPalette APP.cxx
  404. // CSimpleAPP::AddFrameLevelUI APP.cxx
  405. // ResultFromScode OLE API
  406. //
  407. //
  408. //********************************************************************
  409. STDMETHODIMP COleInPlaceSite::OnUIDeactivate (BOOL fUndoable)
  410. {
  411. DEBUGOUT(TEXT("In IOIPS::OnUIDeactivate\r\n"));
  412. // need to clear this flag first
  413. m_pSite->m_lpDoc->m_fInPlaceActive = FALSE;
  414. m_pSite->m_fInPlaceActive = FALSE;
  415. m_pSite->m_lpDoc->m_lpApp->QueryNewPalette();
  416. m_pSite->m_lpDoc->m_lpApp->AddFrameLevelUI();
  417. return ResultFromScode(S_OK);
  418. }
  419. //**********************************************************************
  420. //
  421. // COleInPlaceSite::OnInPlaceDeactivate
  422. //
  423. // Purpose:
  424. //
  425. // Called when the inplace session is over
  426. //
  427. // Parameters:
  428. //
  429. // None
  430. //
  431. // Return Value:
  432. //
  433. // S_OK
  434. //
  435. // Function Calls:
  436. // Function Location
  437. //
  438. // OutputDebugString Windows API
  439. // ResultFromScode OLE API
  440. // IOleInPlaceObject::Release Object
  441. //
  442. //
  443. //********************************************************************
  444. STDMETHODIMP COleInPlaceSite::OnInPlaceDeactivate ()
  445. {
  446. DEBUGOUT(TEXT("In IOIPS::OnInPlaceDeactivate\r\n"));
  447. if (m_pSite->m_lpInPlaceObject)
  448. {
  449. m_pSite->m_lpInPlaceObject->Release();
  450. m_pSite->m_lpInPlaceObject = NULL;
  451. }
  452. return ResultFromScode(S_OK);
  453. }
  454. //**********************************************************************
  455. //
  456. // COleInPlaceSite::DiscardUndoState
  457. //
  458. // Purpose:
  459. //
  460. // Not Implemented
  461. //
  462. // Parameters:
  463. //
  464. // None
  465. //
  466. // Return Value:
  467. //
  468. // E_FAIL
  469. //
  470. // Function Calls:
  471. // Function Location
  472. //
  473. // OutputDebugString Windows API
  474. //
  475. //
  476. //********************************************************************
  477. STDMETHODIMP COleInPlaceSite::DiscardUndoState ()
  478. {
  479. DEBUGOUT(TEXT("In IOIPS::DiscardUndoState\r\n"));
  480. return ResultFromScode(E_FAIL);
  481. }
  482. //**********************************************************************
  483. //
  484. // COleInPlaceSite::DeactivateAndUndo
  485. //
  486. // Purpose:
  487. //
  488. // Not Implemented
  489. //
  490. // Parameters:
  491. //
  492. // None
  493. //
  494. // Return Value:
  495. //
  496. // E_FAIL
  497. //
  498. // Function Calls:
  499. // Function Location
  500. //
  501. // OutputDebugString Windows API
  502. //
  503. //
  504. //********************************************************************
  505. STDMETHODIMP COleInPlaceSite::DeactivateAndUndo ()
  506. {
  507. DEBUGOUT(TEXT("In IOIPS::DeactivateAndUndo\r\n"));
  508. return ResultFromScode(E_FAIL);
  509. }
  510. //**********************************************************************
  511. //
  512. // COleInPlaceSite::OnPosRectChange
  513. //
  514. // Purpose:
  515. //
  516. // The object calls this method when it's size changes during an
  517. // InPlace Session
  518. //
  519. // Parameters:
  520. //
  521. // LPCRECT lprcPosRect - The new object rect
  522. //
  523. // Return Value:
  524. //
  525. // S_OK
  526. //
  527. // Function Calls:
  528. // Function Location
  529. //
  530. // OutputDebugString Windows API
  531. // GetClientRect Windows API
  532. // IOleObject::GetExtent Object
  533. // IOleInPlaceObject::SetObjectRects Object
  534. // ResultFromScode OLE API
  535. //
  536. //
  537. //********************************************************************
  538. STDMETHODIMP COleInPlaceSite::OnPosRectChange (LPCRECT lprcPosRect)
  539. {
  540. DEBUGOUT(TEXT("In IOIPS::OnPosRectChange\r\n"));
  541. // update the size in the document object
  542. // NOTE: here we must call IOleObject::GetExtent to get actual extents
  543. // of the running object. IViewObject2::GetExtent returns the
  544. // last cached extents.
  545. m_pSite->m_lpOleObject->GetExtent(DVASPECT_CONTENT, &m_pSite->m_sizel);
  546. RECT rect;
  547. GetClientRect(m_pSite->m_lpDoc->m_hDocWnd, &rect);
  548. // tell the object its new size
  549. m_pSite->m_lpInPlaceObject->SetObjectRects(lprcPosRect, &rect);
  550. return ResultFromScode(S_OK);
  551. }
  552.