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.

1969 lines
48 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: clnthndlr.cpp
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 10-10-95 JohannP (Johann Posch) Created
  15. // 12-03-96 rogerg Changed to New Embed ServerHandler Model.
  16. //
  17. //----------------------------------------------------------------------------
  18. #include <le2int.h>
  19. #include <ole2int.h>
  20. #include <stdid.hxx> // CStdIdentity
  21. #include "srvhdl.h"
  22. #include "clthndlr.h"
  23. ASSERTDATA
  24. //+---------------------------------------------------------------------------
  25. //
  26. // Function: CreateClientSiteHandler
  27. //
  28. // Synopsis:
  29. //
  30. // Arguments: [pOCS] --
  31. // [ppClntHdlr] --
  32. //
  33. // Returns:
  34. //
  35. // History: 11-10-95 JohannP (Johann Posch) Created
  36. //
  37. // Notes:
  38. //
  39. //----------------------------------------------------------------------------
  40. HRESULT CreateClientSiteHandler(IOleClientSite *pOCS, CClientSiteHandler **ppClntHdlr, BOOL *pfHasIPSite)
  41. {
  42. HRESULT hr = NOERROR;
  43. LEDebugOut((DEB_TRACE, "IN CreateClientSiteHandler(pOCS:%p)\n",pOCS));
  44. *ppClntHdlr = new CClientSiteHandler(pOCS);
  45. if (*ppClntHdlr)
  46. {
  47. *pfHasIPSite = (*ppClntHdlr)->m_pOIPS ? TRUE: FALSE;
  48. }
  49. else
  50. {
  51. hr = E_OUTOFMEMORY;
  52. }
  53. LEDebugOut((DEB_TRACE, "OUT CreateClientSiteHandler(ppSrvHdlr:%p) return %lx\n",*ppClntHdlr,hr));
  54. return hr;
  55. }
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Method: CClientSiteHandler::CClientSiteHandler
  59. //
  60. // Synopsis:
  61. //
  62. // Arguments: (none)
  63. //
  64. // Returns:
  65. //
  66. // History: 9-22-95 JohannP (Johann Posch) Created
  67. //
  68. // Notes:
  69. //
  70. //----------------------------------------------------------------------------
  71. CClientSiteHandler::CClientSiteHandler(IOleClientSite *pOCS)
  72. {
  73. Win4Assert(pOCS);
  74. m_cRefs = 1;
  75. m_pOIPS = NULL;
  76. m_pOCS = pOCS;
  77. if (m_pOCS)
  78. {
  79. m_pOCS->AddRef();
  80. // see if Supports InPlaceSite and if so hold onto it.
  81. if (FAILED(m_pOCS->QueryInterface(IID_IOleInPlaceSite,(void **) &m_pOIPS)))
  82. {
  83. m_pOIPS = NULL;
  84. }
  85. }
  86. }
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Method: CClientSiteHandler::~CClientSiteHandler
  90. //
  91. // Synopsis:
  92. //
  93. // Arguments: (none)
  94. //
  95. // Returns:
  96. //
  97. // History: 9-22-95 JohannP (Johann Posch) Created
  98. //
  99. // Notes:
  100. //
  101. //----------------------------------------------------------------------------
  102. CClientSiteHandler::~CClientSiteHandler()
  103. {
  104. Win4Assert(m_pOIPS == NULL);
  105. Win4Assert(m_pOCS == NULL);
  106. }
  107. //+---------------------------------------------------------------------------
  108. //
  109. // Method: CClientSiteHandler::QueryInterface
  110. //
  111. // Synopsis:
  112. //
  113. // Arguments: [riid] --
  114. // [ppv] --
  115. //
  116. // Returns:
  117. //
  118. // History: 8-18-95 JohannP (Johann Posch) Created
  119. //
  120. // Notes:
  121. //
  122. //----------------------------------------------------------------------------
  123. STDMETHODIMP CClientSiteHandler::QueryInterface( REFIID riid, void **ppv)
  124. {
  125. HRESULT hresult = NOERROR;
  126. VDATEHEAP();
  127. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::QueryInterface (%lx, %p)\n", this, riid, ppv));
  128. if (IsEqualIID(riid, IID_IUnknown)
  129. || IsEqualIID(riid, IID_IClientSiteHandler) )
  130. {
  131. *ppv = (void FAR *)(IClientSiteHandler *)this;
  132. InterlockedIncrement((long *)&m_cRefs);
  133. }
  134. else
  135. {
  136. hresult = m_pOCS->QueryInterface(riid,ppv);
  137. }
  138. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::QueryInterface (%lx)[%p]\n", this, hresult, *ppv));
  139. return hresult;
  140. }
  141. //+---------------------------------------------------------------------------
  142. //
  143. // Method: CClientSiteHandler::AddRef
  144. //
  145. // Synopsis:
  146. //
  147. // Arguments: [void] --
  148. //
  149. // Returns:
  150. //
  151. // History: 8-18-95 JohannP (Johann Posch) Created
  152. //
  153. // Notes:
  154. //
  155. //----------------------------------------------------------------------------
  156. STDMETHODIMP_(ULONG) CClientSiteHandler::AddRef( void )
  157. {
  158. VDATEHEAP();
  159. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::AddRef\n", this));
  160. InterlockedIncrement((long *)&m_cRefs);
  161. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::AddRef (%ld)\n", this, m_cRefs));
  162. return m_cRefs;
  163. }
  164. //+---------------------------------------------------------------------------
  165. //
  166. // Method: CClientSiteHandler::Release
  167. //
  168. // Synopsis:
  169. //
  170. // Arguments: [void] --
  171. //
  172. // Returns:
  173. //
  174. // History: 8-18-95 JohannP (Johann Posch) Created
  175. //
  176. // Notes:
  177. //
  178. //----------------------------------------------------------------------------
  179. STDMETHODIMP_(ULONG) CClientSiteHandler::Release( void )
  180. {
  181. ULONG cRefs = 0;
  182. VDATEHEAP();
  183. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::Release\n", this));
  184. cRefs = InterlockedDecrement((long *)&m_cRefs);
  185. if (cRefs == 0)
  186. {
  187. LPUNKNOWN punk; // local var for safe release
  188. if (m_pOIPS)
  189. {
  190. punk = (LPUNKNOWN) m_pOIPS;
  191. m_pOIPS = NULL;
  192. punk->Release();
  193. }
  194. if (m_pOCS)
  195. {
  196. punk = (LPUNKNOWN) m_pOCS;
  197. m_pOCS = NULL;
  198. punk->Release();
  199. }
  200. delete this;
  201. }
  202. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::Release (%ld)\n", this, cRefs));
  203. return cRefs;
  204. }
  205. //+---------------------------------------------------------------------------
  206. //
  207. // Method: CClientSiteHandler::GetContainer
  208. //
  209. // Synopsis: delegates call on to appropriate OleClientSite
  210. //
  211. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  212. // [ppContainer] --
  213. //
  214. // Returns:
  215. //
  216. // History: 11-17-95 JohannP (Johann Posch) Created
  217. //
  218. // Notes:
  219. //
  220. //----------------------------------------------------------------------------
  221. STDMETHODIMP CClientSiteHandler::GetContainer(IOleContainer * *ppContainer)
  222. {
  223. HRESULT hresult = E_FAIL;
  224. VDATEHEAP();
  225. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::GetContainer\n", this));
  226. Win4Assert(m_pOCS);
  227. if (m_pOCS)
  228. {
  229. hresult = m_pOCS->GetContainer(ppContainer);
  230. }
  231. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::GetContainer hr=%lx\n", this, hresult));
  232. return hresult;
  233. }
  234. //+---------------------------------------------------------------------------
  235. //
  236. // Method: CClientSiteHandler::OnShowWindow
  237. //
  238. // Synopsis: delegates call on to appropriate OleClientSite
  239. //
  240. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  241. // [fShow] --
  242. //
  243. // Returns:
  244. //
  245. // History: 11-17-95 JohannP (Johann Posch) Created
  246. //
  247. // Notes:
  248. //
  249. //----------------------------------------------------------------------------
  250. STDMETHODIMP CClientSiteHandler::OnShowWindow(BOOL fShow)
  251. {
  252. HRESULT hresult = E_FAIL;
  253. VDATEHEAP();
  254. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnShowWindow\n", this));
  255. Win4Assert(m_pOCS);
  256. if (m_pOCS)
  257. {
  258. hresult = m_pOCS->OnShowWindow(fShow);
  259. }
  260. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnShowWindow hr=%lx\n", this, hresult));
  261. return hresult;
  262. }
  263. //+---------------------------------------------------------------------------
  264. //
  265. // Method: CClientSiteHandler::RequestNewObjectLayout
  266. //
  267. // Synopsis: delegates call on to appropriate OleClientSite
  268. //
  269. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  270. //
  271. // Returns:
  272. //
  273. // History: 11-17-95 JohannP (Johann Posch) Created
  274. //
  275. // Notes:
  276. //
  277. //----------------------------------------------------------------------------
  278. STDMETHODIMP CClientSiteHandler::RequestNewObjectLayout()
  279. {
  280. HRESULT hresult = E_FAIL;
  281. VDATEHEAP();
  282. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::RequestNewObjectLayout\n", this));
  283. Win4Assert(m_pOCS);
  284. if (m_pOCS)
  285. {
  286. hresult = m_pOCS->RequestNewObjectLayout();
  287. }
  288. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::RequestNewObjectLayout hr=%lx\n", this, hresult));
  289. return hresult;
  290. }
  291. //+---------------------------------------------------------------------------
  292. //
  293. // Method: CClientSiteHandler::GetMoniker
  294. //
  295. // Synopsis: delegates call on to appropriate OleClientSite
  296. //
  297. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  298. // [DWORD] --
  299. // [IMoniker] --
  300. // [ppmk] --
  301. //
  302. // Returns:
  303. //
  304. // History: 11-17-95 JohannP (Johann Posch) Created
  305. //
  306. // Notes:
  307. //
  308. //----------------------------------------------------------------------------
  309. STDMETHODIMP CClientSiteHandler::GetMoniker(DWORD dwAssign,DWORD dwWhichMoniker,IMoniker * *ppmk)
  310. {
  311. HRESULT hresult = E_FAIL;
  312. VDATEHEAP();
  313. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::GetMoniker\n", this));
  314. Win4Assert(m_pOCS);
  315. if (m_pOCS)
  316. {
  317. hresult = m_pOCS->GetMoniker(dwAssign, dwWhichMoniker,ppmk);
  318. }
  319. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::GetMoniker hr=%lx\n", this, hresult));
  320. return hresult;
  321. }
  322. //+---------------------------------------------------------------------------
  323. //
  324. // Method: CClientSiteHandler::SaveObject
  325. //
  326. // Synopsis: delegates call on to appropriate OleClientSite
  327. //
  328. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  329. //
  330. // Returns:
  331. //
  332. // History: 11-17-95 JohannP (Johann Posch) Created
  333. //
  334. // Notes:
  335. //
  336. //----------------------------------------------------------------------------
  337. STDMETHODIMP CClientSiteHandler::SaveObject( )
  338. {
  339. HRESULT hresult = E_FAIL;
  340. VDATEHEAP();
  341. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::SaveObject\n", this));
  342. Win4Assert(m_pOCS);
  343. if (m_pOCS)
  344. {
  345. hresult = m_pOCS->SaveObject();
  346. }
  347. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::SaveObject hr=%lx\n", this, hresult));
  348. return hresult;
  349. }
  350. //+---------------------------------------------------------------------------
  351. //
  352. // Method: CClientSiteHandler::ShowObject
  353. //
  354. // Synopsis: delegates call on to appropriate OleClientSite
  355. //
  356. // Arguments: [dwId] -- id of the OleClientSite the call should be delegate too
  357. //
  358. // Returns:
  359. //
  360. // History: 11-17-95 JohannP (Johann Posch) Created
  361. //
  362. // Notes:
  363. //
  364. //----------------------------------------------------------------------------
  365. STDMETHODIMP CClientSiteHandler::ShowObject()
  366. {
  367. HRESULT hresult = E_FAIL;
  368. VDATEHEAP();
  369. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::ShowObject\n", this));
  370. Win4Assert(m_pOCS);
  371. if (m_pOCS)
  372. {
  373. hresult = m_pOCS->ShowObject();
  374. }
  375. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::ShowObject hr=%lx\n", this, hresult));
  376. return hresult;
  377. }
  378. //
  379. // IOleInPlaceSite methods
  380. //
  381. //+---------------------------------------------------------------------------
  382. //
  383. // Method: CClientSiteHandler::GetWindow
  384. //
  385. // Synopsis: delegates call on to OleInPlaceSite
  386. //
  387. // Arguments: [phwnd] --
  388. //
  389. // Returns:
  390. //
  391. // History: 11-17-95 JohannP (Johann Posch) Created
  392. //
  393. // Notes:
  394. //
  395. //----------------------------------------------------------------------------
  396. STDMETHODIMP CClientSiteHandler::GetWindow( HWND *phwnd)
  397. {
  398. HRESULT hresult = E_FAIL;
  399. VDATEHEAP();
  400. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::GetWindow\n", this));
  401. Win4Assert(m_pOIPS);
  402. if (m_pOIPS)
  403. {
  404. hresult = m_pOIPS->GetWindow(phwnd);
  405. }
  406. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::GetWindow hr=%lx\n", this, hresult));
  407. return hresult;
  408. }
  409. //+---------------------------------------------------------------------------
  410. //
  411. // Method: CClientSiteHandler::ContextSensitiveHelp
  412. //
  413. // Synopsis: delegates call on to OleInPlaceSite
  414. //
  415. // Arguments: [fEnterMode] --
  416. //
  417. // Returns:
  418. //
  419. // History: 11-17-95 JohannP (Johann Posch) Created
  420. //
  421. // Notes:
  422. //
  423. //----------------------------------------------------------------------------
  424. STDMETHODIMP CClientSiteHandler::ContextSensitiveHelp(BOOL fEnterMode)
  425. {
  426. HRESULT hresult = E_FAIL;
  427. VDATEHEAP();
  428. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::ContextSensitiveHelp\n", this));
  429. Win4Assert(m_pOIPS);
  430. if (m_pOIPS)
  431. {
  432. hresult = m_pOIPS->ContextSensitiveHelp(fEnterMode);
  433. }
  434. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::ContextSensitiveHelp hr=%lx\n", this, hresult));
  435. return hresult;
  436. }
  437. //+---------------------------------------------------------------------------
  438. //
  439. // Method: CClientSiteHandler::CanInPlaceActivate
  440. //
  441. // Synopsis: delegates call on to OleInPlaceSite
  442. //
  443. // Arguments: [void] --
  444. //
  445. // Returns:
  446. //
  447. // History: 11-17-95 JohannP (Johann Posch) Created
  448. //
  449. // Notes:
  450. //
  451. //----------------------------------------------------------------------------
  452. STDMETHODIMP CClientSiteHandler::CanInPlaceActivate(void)
  453. {
  454. HRESULT hresult = E_FAIL;
  455. VDATEHEAP();
  456. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::CanInPlaceActivate\n", this));
  457. Win4Assert(m_pOIPS);
  458. if (m_pOIPS)
  459. {
  460. hresult = m_pOIPS->CanInPlaceActivate();
  461. }
  462. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::CanInPlaceActivate hr=%lx\n", this, hresult));
  463. return hresult;
  464. }
  465. //+---------------------------------------------------------------------------
  466. //
  467. // Method: CClientSiteHandler::OnInPlaceActivate
  468. //
  469. // Synopsis: delegates call on to OleInPlaceSite
  470. //
  471. // Arguments: [void] --
  472. //
  473. // Returns:
  474. //
  475. // History: 11-17-95 JohannP (Johann Posch) Created
  476. //
  477. // Notes:
  478. //
  479. //----------------------------------------------------------------------------
  480. STDMETHODIMP CClientSiteHandler::OnInPlaceActivate(void)
  481. {
  482. HRESULT hresult = E_FAIL;
  483. VDATEHEAP();
  484. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnInPlaceActivate\n", this));
  485. Win4Assert(m_pOIPS);
  486. if (m_pOIPS)
  487. {
  488. hresult = m_pOIPS->OnInPlaceActivate();
  489. }
  490. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnInPlaceActivate hr=%lx\n", this, hresult));
  491. return hresult;
  492. }
  493. //+---------------------------------------------------------------------------
  494. //
  495. // Method: CClientSiteHandler::OnUIActivate
  496. //
  497. // Synopsis: delegates call on to OleInPlaceSite
  498. //
  499. // Arguments: [void] --
  500. //
  501. // Returns:
  502. //
  503. // History: 11-17-95 JohannP (Johann Posch) Created
  504. //
  505. // Notes:
  506. //
  507. //----------------------------------------------------------------------------
  508. STDMETHODIMP CClientSiteHandler::OnUIActivate(void)
  509. {
  510. HRESULT hresult = E_FAIL;
  511. VDATEHEAP();
  512. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnUIActivate\n", this));
  513. Win4Assert(m_pOIPS);
  514. if (m_pOIPS)
  515. {
  516. hresult = m_pOIPS->OnUIActivate();
  517. }
  518. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnUIActivate hr=%lx\n", this, hresult));
  519. return hresult;
  520. }
  521. //+---------------------------------------------------------------------------
  522. //
  523. // Method: CClientSiteHandler::GetWindowContext
  524. //
  525. // Synopsis: delegates call on to OleInPlaceSite
  526. //
  527. // Arguments: [ppFrame] --
  528. // [ppDoc] --
  529. // [lprcPosRect] --
  530. // [lprcClipRect] --
  531. // [lpFrameInfo] --
  532. //
  533. // Returns:
  534. //
  535. // History: 11-17-95 JohannP (Johann Posch) Created
  536. //
  537. // Notes:
  538. //
  539. //----------------------------------------------------------------------------
  540. STDMETHODIMP CClientSiteHandler::GetWindowContext(IOleInPlaceFrame **ppFrame,
  541. IOleInPlaceUIWindow * *ppDoc, LPRECT lprcPosRect,
  542. LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
  543. {
  544. HRESULT hresult = E_FAIL;
  545. VDATEHEAP();
  546. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::GetWindowContext\n", this));
  547. Win4Assert(m_pOIPS);
  548. if (m_pOIPS)
  549. {
  550. hresult = m_pOIPS->GetWindowContext(ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
  551. }
  552. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::GetWindowContext hr=%lx\n", this, hresult));
  553. return hresult;
  554. }
  555. //+---------------------------------------------------------------------------
  556. //
  557. // Method: CClientSiteHandler::Scroll
  558. //
  559. // Synopsis: delegates call on to OleInPlaceSite
  560. //
  561. // Arguments: [scrollExtant] --
  562. //
  563. // Returns:
  564. //
  565. // History: 11-17-95 JohannP (Johann Posch) Created
  566. //
  567. // Notes:
  568. //
  569. //----------------------------------------------------------------------------
  570. STDMETHODIMP CClientSiteHandler::Scroll(SIZE scrollExtant)
  571. {
  572. HRESULT hresult = E_FAIL;
  573. VDATEHEAP();
  574. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::Scroll\n", this));
  575. Win4Assert(m_pOIPS);
  576. if (m_pOIPS)
  577. {
  578. hresult = m_pOIPS->Scroll(scrollExtant);
  579. }
  580. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::Scroll hr=%lx\n", this, hresult));
  581. return hresult;
  582. }
  583. //+---------------------------------------------------------------------------
  584. //
  585. // Method: CClientSiteHandler::OnUIDeactivate
  586. //
  587. // Synopsis: delegates call on to OleInPlaceSite
  588. //
  589. // Arguments: [fUndoable] --
  590. //
  591. // Returns:
  592. //
  593. // History: 11-17-95 JohannP (Johann Posch) Created
  594. //
  595. // Notes:
  596. //
  597. //----------------------------------------------------------------------------
  598. STDMETHODIMP CClientSiteHandler::OnUIDeactivate(BOOL fUndoable)
  599. {
  600. HRESULT hresult = E_FAIL;
  601. VDATEHEAP();
  602. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnUIDeactivate\n", this));
  603. Win4Assert(m_pOIPS);
  604. if (m_pOIPS)
  605. {
  606. hresult = m_pOIPS->OnUIDeactivate(fUndoable);
  607. }
  608. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnUIDeactivate hr=%lx\n", this, hresult));
  609. return hresult;
  610. }
  611. //+---------------------------------------------------------------------------
  612. //
  613. // Method: CClientSiteHandler::OnInPlaceDeactivate
  614. //
  615. // Synopsis: delegates call on to OleInPlaceSite
  616. //
  617. // Arguments: [void] --
  618. //
  619. // Returns:
  620. //
  621. // History: 11-17-95 JohannP (Johann Posch) Created
  622. //
  623. // Notes:
  624. //
  625. //----------------------------------------------------------------------------
  626. STDMETHODIMP CClientSiteHandler::OnInPlaceDeactivate( void)
  627. {
  628. HRESULT hresult = E_FAIL;
  629. VDATEHEAP();
  630. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnInPlaceDeactivate\n", this));
  631. Win4Assert(m_pOIPS);
  632. if (m_pOIPS)
  633. {
  634. hresult = m_pOIPS->OnInPlaceDeactivate();
  635. }
  636. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnInPlaceDeactivate hr=%lx\n", this, hresult));
  637. return hresult;
  638. }
  639. //+---------------------------------------------------------------------------
  640. //
  641. // Method: CClientSiteHandler::DiscardUndoState
  642. //
  643. // Synopsis: delegates call on to OleInPlaceSite
  644. //
  645. // Arguments: [void] --
  646. //
  647. // Returns:
  648. //
  649. // History: 11-17-95 JohannP (Johann Posch) Created
  650. //
  651. // Notes:
  652. //
  653. //----------------------------------------------------------------------------
  654. STDMETHODIMP CClientSiteHandler::DiscardUndoState(void)
  655. {
  656. HRESULT hresult = E_FAIL;
  657. VDATEHEAP();
  658. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::DiscardUndoState\n", this));
  659. Win4Assert(m_pOIPS);
  660. if (m_pOIPS)
  661. {
  662. hresult = m_pOIPS->DiscardUndoState();
  663. }
  664. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::DiscardUndoState hr=%lx\n", this, hresult));
  665. return hresult;
  666. }
  667. //+---------------------------------------------------------------------------
  668. //
  669. // Method: CClientSiteHandler::DeactivateAndUndo
  670. //
  671. // Synopsis: delegates call on to OleInPlaceSite
  672. //
  673. // Arguments: [void] --
  674. //
  675. // Returns:
  676. //
  677. // History: 11-17-95 JohannP (Johann Posch) Created
  678. //
  679. // Notes:
  680. //
  681. //----------------------------------------------------------------------------
  682. STDMETHODIMP CClientSiteHandler::DeactivateAndUndo(void)
  683. {
  684. HRESULT hresult = E_FAIL;
  685. VDATEHEAP();
  686. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::DeactivateAndUndo\n", this));
  687. Win4Assert(m_pOIPS);
  688. if (m_pOIPS)
  689. {
  690. hresult = m_pOIPS->DeactivateAndUndo();
  691. }
  692. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::DeactivateAndUndo hr=%lx\n", this, hresult));
  693. return hresult;
  694. }
  695. //+---------------------------------------------------------------------------
  696. //
  697. // Method: CClientSiteHandler::OnPosRectChange
  698. //
  699. // Synopsis: delegates call on to OleInPlaceSite
  700. //
  701. // Arguments: [lprcPosRect] --
  702. //
  703. // Returns:
  704. //
  705. // History: 11-17-95 JohannP (Johann Posch) Created
  706. //
  707. // Notes:
  708. //
  709. //----------------------------------------------------------------------------
  710. STDMETHODIMP CClientSiteHandler::OnPosRectChange(LPCRECT lprcPosRect)
  711. {
  712. HRESULT hresult = E_FAIL;
  713. VDATEHEAP();
  714. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::OnPosRectChange\n", this));
  715. Win4Assert(m_pOIPS);
  716. if (m_pOIPS)
  717. {
  718. hresult = m_pOIPS->OnPosRectChange(lprcPosRect);
  719. }
  720. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::OnPosRectChange hr=%lx\n", this, hresult));
  721. return hresult;
  722. }
  723. //
  724. // ClientSiteHandler methods
  725. //
  726. //+---------------------------------------------------------------------------
  727. //
  728. // Method: CClientSiteHandler::GoInPlaceActivate
  729. //
  730. // Synopsis: called by the serverhandler when going inplace
  731. //
  732. // Arguments: [phwndOIPS] --
  733. //
  734. // Returns:
  735. //
  736. // History: 11-17-95 JohannP (Johann Posch) Created
  737. //
  738. // Notes:
  739. //
  740. //----------------------------------------------------------------------------
  741. STDMETHODIMP CClientSiteHandler::GoInPlaceActivate(HWND *phwndOIPS)
  742. {
  743. HRESULT hresult = E_FAIL;
  744. VDATEHEAP();
  745. LEDebugOut((DEB_TRACE, "%p _IN CClientSiteHandler::GoInPlaceActivate\n", this));
  746. Win4Assert(m_pOIPS);
  747. *phwndOIPS = NULL;
  748. if (m_pOIPS)
  749. {
  750. // 1. OnInPlaceActivate
  751. hresult = m_pOIPS->OnInPlaceActivate();
  752. // 2. Get the Site Window, not an error if this fails
  753. if (SUCCEEDED(hresult))
  754. {
  755. if (NOERROR != m_pOIPS->GetWindow(phwndOIPS))
  756. {
  757. *phwndOIPS = NULL;
  758. }
  759. }
  760. }
  761. LEDebugOut((DEB_TRACE, "%p OUT CClientSiteHandler::GoInPlaceActivate\n", this));
  762. return hresult;
  763. }
  764. // ClientSiteHandler on ServerSide
  765. //+---------------------------------------------------------------------------
  766. //
  767. // Method: CEmbServerClientSite::CEmbServerClientSite
  768. //
  769. // Synopsis: Constructor
  770. //
  771. // Arguments:
  772. // pStdId - Pointer to StandardIdentity for Object
  773. //
  774. // Returns:
  775. //
  776. // History: 10-30-96 rogerg Created
  777. //
  778. // Notes:
  779. //
  780. //----------------------------------------------------------------------------
  781. CEmbServerClientSite::CEmbServerClientSite (IUnknown *pUnkOuter)
  782. {
  783. VDATEHEAP();
  784. if (!pUnkOuter)
  785. {
  786. pUnkOuter = &m_Unknown;
  787. }
  788. m_pUnkOuter = pUnkOuter;
  789. m_pClientSiteHandler = NULL;
  790. m_cRefs = 1;
  791. m_pUnkInternal = NULL;
  792. m_hwndOIPS = NULL;
  793. m_Unknown.m_EmbServerClientSite = this;
  794. m_fInDelete = FALSE;
  795. }
  796. //+---------------------------------------------------------------------------
  797. //
  798. // Method: CEmbServerClientSite::Initialize
  799. //
  800. // Synopsis: Initialize the ClientSiteHandler
  801. //
  802. // Arguments:
  803. // objref - objref to be unmarshaled
  804. // fHasIPSite - Indicates if ClientSite should support IOleInPlaceSite
  805. //
  806. // Returns:
  807. //
  808. // History: 10-30-96 rogerg Created
  809. //
  810. // Notes:
  811. //
  812. //----------------------------------------------------------------------------
  813. STDMETHODIMP CEmbServerClientSite::Initialize(OBJREF objref,BOOL fHasIPSite)
  814. {
  815. HRESULT hr = E_OUTOFMEMORY;
  816. CStdIdentity *pStdId;
  817. BOOL fSuccess = FALSE;
  818. // Need to create a Standard Identity Handler
  819. // as the controlling Unknown, then unmarshal pIRDClientsite
  820. // into it.
  821. // This code relies on the premise that this is the first time the
  822. // interface has been unmarshaled which is checked for on the Container Side
  823. m_fHasIPSite = fHasIPSite;
  824. pStdId = new CStdIdentity(STDID_CLIENT,
  825. GetCurrentApartmentId(),
  826. m_pUnkOuter,
  827. NULL, &m_pUnkInternal, &fSuccess);
  828. if (pStdId && fSuccess == FALSE)
  829. {
  830. delete pStdId;
  831. pStdId = NULL;
  832. }
  833. if (pStdId)
  834. {
  835. LPUNKNOWN pObjRefInterface = NULL;
  836. Win4Assert(IsEqualIID(objref.iid, IID_IClientSiteHandler));
  837. hr = pStdId->UnmarshalObjRef(objref, (void **)&m_pClientSiteHandler);
  838. if (NOERROR == hr)
  839. {
  840. m_pUnkOuter->Release(); // Release ref from UnMarshal
  841. }
  842. }
  843. return hr;
  844. }
  845. //+---------------------------------------------------------------------------
  846. //
  847. // Method: CEmbServerClientSite::SetDoVerbState
  848. //
  849. // Synopsis: Informs ClientSiteHandler if a DoVerb is in progress
  850. //
  851. // Arguments:
  852. //
  853. // Returns:
  854. //
  855. // History: 10-30-96 rogerg Created
  856. //
  857. // Notes:
  858. //
  859. //----------------------------------------------------------------------------
  860. STDMETHODIMP CEmbServerClientSite::SetDoVerbState(BOOL fDoVerbState)
  861. {
  862. m_fInDoVerb = fDoVerbState ? TRUE: FALSE;
  863. if (!m_fInDoVerb)
  864. {
  865. // reset any data the is Cached while in a DoVerb.
  866. m_hwndOIPS = NULL;
  867. }
  868. return NOERROR;
  869. }
  870. //+---------------------------------------------------------------------------
  871. //
  872. // Method: CEmbServerClientSite::~CEmbServerClientSite
  873. //
  874. // Synopsis: Destructor
  875. //
  876. // Arguments: (none)
  877. //
  878. // Returns:
  879. //
  880. // History: 10-30-96 rogerg Created
  881. //
  882. // Notes:
  883. //
  884. //----------------------------------------------------------------------------
  885. CEmbServerClientSite::~CEmbServerClientSite()
  886. {
  887. Win4Assert(NULL == m_pClientSiteHandler);
  888. Win4Assert(NULL == m_pUnkInternal);
  889. Win4Assert(TRUE == m_fInDelete);
  890. }
  891. //
  892. // Controlling Uknown
  893. //
  894. //
  895. //+-------------------------------------------------------------------------
  896. //
  897. // Member: CEmbServerClientSite::CPrivUnknown::QueryInterface
  898. //
  899. // Synopsis: Returns a pointer to one of the supported interfaces.
  900. //
  901. // Effects:
  902. //
  903. // Arguments: [iid] -- the requested interface ID
  904. // [ppv] -- where to put the iface pointer
  905. //
  906. // Requires:
  907. //
  908. // Returns: HRESULT
  909. //
  910. // History: 10-30-96 rogerg Created
  911. //
  912. // Notes:
  913. //
  914. //--------------------------------------------------------------------------
  915. STDMETHODIMP CEmbServerClientSite::CPrivUnknown::QueryInterface(REFIID iid,
  916. LPLPVOID ppv)
  917. {
  918. HRESULT hresult;
  919. VDATEHEAP();
  920. Win4Assert(m_EmbServerClientSite);
  921. LEDebugOut((DEB_TRACE,
  922. "%p _IN CDefObject::CUnknownImpl::QueryInterface "
  923. "( %p , %p )\n", m_EmbServerClientSite, iid, ppv));
  924. if (IsEqualIID(iid, IID_IUnknown))
  925. {
  926. *ppv = (void FAR *)this;
  927. }
  928. else if (IsEqualIID(iid, IID_IOleClientSite))
  929. {
  930. *ppv = (void FAR *)(IOleClientSite *) m_EmbServerClientSite;
  931. }
  932. else if (IsEqualIID(iid, IID_IOleInPlaceSite) && (m_EmbServerClientSite->m_fHasIPSite))
  933. {
  934. *ppv = (void FAR *)(IOleInPlaceSite *) m_EmbServerClientSite;
  935. }
  936. else if(m_EmbServerClientSite->m_pUnkInternal)
  937. {
  938. hresult = m_EmbServerClientSite->m_pUnkInternal->QueryInterface(iid,(void **) ppv);
  939. LEDebugOut((DEB_TRACE,
  940. "%p OUT CDefObject::CUnknownImpl::QueryInterface "
  941. "( %lx ) [ %p ]\n", m_EmbServerClientSite, hresult,
  942. (ppv) ? *ppv : 0 ));
  943. return hresult;
  944. }
  945. else
  946. {
  947. // Don't have a ClientSite.
  948. *ppv = NULL;
  949. LEDebugOut((DEB_TRACE,
  950. "%p OUT CDefObject::CUnkownImpl::QueryInterface "
  951. "( %lx ) [ %p ]\n", m_EmbServerClientSite, CO_E_OBJNOTCONNECTED,
  952. 0 ));
  953. return E_NOINTERFACE;
  954. }
  955. // this indirection is important since there are different
  956. // implementationsof AddRef (this unk and the others).
  957. ((IUnknown FAR*) *ppv)->AddRef();
  958. LEDebugOut((DEB_TRACE,
  959. "%p OUT CDefObject::CUnknownImpl::QueryInterface "
  960. "( %lx ) [ %p ]\n", m_EmbServerClientSite, NOERROR, *ppv));
  961. return NOERROR;
  962. }
  963. //+-------------------------------------------------------------------------
  964. //
  965. // Member: CEmbServerClientSite::CPrivUnknown::AddRef
  966. //
  967. // Synopsis: Increments the reference count.
  968. //
  969. // Effects:
  970. //
  971. // Arguments: void
  972. //
  973. // Requires:
  974. //
  975. // Returns: ULONG (the new reference count)
  976. //
  977. // History: 10-30-96 rogerg Created
  978. //
  979. // Notes:
  980. //
  981. //--------------------------------------------------------------------------
  982. STDMETHODIMP_(ULONG) CEmbServerClientSite::CPrivUnknown::AddRef( void )
  983. {
  984. ULONG cRefs;
  985. VDATEHEAP();
  986. LEDebugOut((DEB_TRACE, "%p _IN CDefObject::CPrivUnknown::AddRef "
  987. "( )\n", m_EmbServerClientSite));
  988. Win4Assert(m_EmbServerClientSite);
  989. cRefs = InterlockedIncrement((long *) &(m_EmbServerClientSite->m_cRefs));
  990. LEDebugOut((DEB_TRACE, "%p OUT CDefObject::CPrivUnknown::AddRef "
  991. "( %lu )\n", m_EmbServerClientSite, m_EmbServerClientSite->m_cRefs));
  992. return cRefs;
  993. }
  994. //+-------------------------------------------------------------------------
  995. //
  996. // Member: CEmbServerClientSite::CPrivUnknown::Release
  997. //
  998. // Synopsis: Decrements the ref count, cleaning up and deleting the
  999. // object if necessary
  1000. //
  1001. // Effects: May delete the object (and potentially objects to which the
  1002. // handler has pointer)
  1003. //
  1004. // Arguments: void
  1005. //
  1006. // Requires:
  1007. //
  1008. // Returns: ULONG--the new ref count
  1009. //
  1010. // History: 10-30-96 rogerg Created
  1011. //
  1012. // Notes:
  1013. //
  1014. //--------------------------------------------------------------------------
  1015. STDMETHODIMP_(ULONG) CEmbServerClientSite::CPrivUnknown::Release(void)
  1016. {
  1017. ULONG refcount;
  1018. VDATEHEAP();
  1019. LEDebugOut((DEB_TRACE, "%p _IN CDefObject::CPrivUnknown::Release "
  1020. "( )\n", m_EmbServerClientSite));
  1021. Win4Assert(m_EmbServerClientSite);
  1022. refcount = InterlockedDecrement((long *) &(m_EmbServerClientSite->m_cRefs));
  1023. // TODO: not thread safe.
  1024. if (0 == refcount && !(m_EmbServerClientSite->m_fInDelete))
  1025. {
  1026. m_EmbServerClientSite->m_fInDelete = TRUE;
  1027. if (m_EmbServerClientSite->m_pClientSiteHandler)
  1028. {
  1029. LPUNKNOWN lpUnkForSafeRelease = m_EmbServerClientSite->m_pClientSiteHandler;
  1030. m_EmbServerClientSite->m_pClientSiteHandler = NULL;
  1031. m_EmbServerClientSite->m_pUnkOuter->AddRef();
  1032. lpUnkForSafeRelease->Release();
  1033. }
  1034. if (m_EmbServerClientSite->m_pUnkInternal)
  1035. {
  1036. LPUNKNOWN pUnkSafeRelease;
  1037. pUnkSafeRelease = m_EmbServerClientSite->m_pUnkInternal;
  1038. m_EmbServerClientSite->m_pUnkInternal = NULL;
  1039. pUnkSafeRelease->Release();
  1040. }
  1041. delete m_EmbServerClientSite;
  1042. }
  1043. LEDebugOut((DEB_TRACE, "%p OUT CDefObject::CPrivUnknown::Release "
  1044. "( %lu )\n", m_EmbServerClientSite, refcount));
  1045. return refcount;
  1046. }
  1047. //+---------------------------------------------------------------------------
  1048. //
  1049. // Method: CEmbServerClientSite::QueryInterface
  1050. //
  1051. // Synopsis:
  1052. //
  1053. // Arguments: [riid] --
  1054. // [ppv] --
  1055. //
  1056. // Returns:
  1057. //
  1058. // History: 9-18-95 JohannP (Johann Posch) Created
  1059. //
  1060. // Notes:
  1061. //
  1062. //----------------------------------------------------------------------------
  1063. STDMETHODIMP CEmbServerClientSite::QueryInterface( REFIID riid, void **ppv )
  1064. {
  1065. HRESULT hresult = E_NOINTERFACE;
  1066. VDATEHEAP();
  1067. LEDebugOut((DEB_TRACE, "%p _IN CDefObject::QueryInterface ( %lx , "
  1068. "%p )\n", this, riid, ppv));
  1069. Win4Assert(m_pUnkOuter);
  1070. hresult = m_pUnkOuter->QueryInterface(riid, ppv);
  1071. LEDebugOut((DEB_TRACE, "%p OUT CDefObject::QueryInterface ( %lx ) "
  1072. "[ %p ]\n", this, hresult, *ppv));
  1073. return hresult;
  1074. }
  1075. //+---------------------------------------------------------------------------
  1076. //
  1077. // Method: CEmbServerClientSite::AddRef
  1078. //
  1079. // Synopsis:
  1080. //
  1081. // Arguments: [void] --
  1082. //
  1083. // Returns:
  1084. //
  1085. // History: 9-18-95 JohannP (Johann Posch) Created
  1086. //
  1087. // Notes:
  1088. //
  1089. //----------------------------------------------------------------------------
  1090. STDMETHODIMP_(ULONG) CEmbServerClientSite::AddRef( void )
  1091. {
  1092. ULONG crefs;;
  1093. VDATEHEAP();
  1094. LEDebugOut((DEB_TRACE, "%p _IN CDefObject::AddRef ( )\n", this));
  1095. Assert(m_pUnkOuter);
  1096. crefs = m_pUnkOuter->AddRef();
  1097. LEDebugOut((DEB_TRACE, "%p OUT CDefObject::AddRef ( %ld ) ", this,
  1098. crefs));
  1099. return crefs;
  1100. }
  1101. //+---------------------------------------------------------------------------
  1102. //
  1103. // Method: CEmbServerClientSite::Release
  1104. //
  1105. // Synopsis:
  1106. //
  1107. // Arguments: [void] --
  1108. //
  1109. // Returns:
  1110. //
  1111. // History: 9-18-95 JohannP (Johann Posch) Created
  1112. //
  1113. // Notes:
  1114. //
  1115. //----------------------------------------------------------------------------
  1116. STDMETHODIMP_(ULONG) CEmbServerClientSite::Release( void )
  1117. {
  1118. ULONG crefs;;
  1119. VDATEHEAP();
  1120. LEDebugOut((DEB_TRACE, "%p _IN CDefObject::Release ( )\n", this));
  1121. Assert(m_pUnkOuter);
  1122. crefs = m_pUnkOuter->Release();
  1123. LEDebugOut((DEB_TRACE, "%p OUT CDefObject::Release ( %ld ) ", this,
  1124. crefs));
  1125. return crefs;
  1126. }
  1127. //+---------------------------------------------------------------------------
  1128. //
  1129. // Method: CEmbServerClientSite::GetContainer
  1130. //
  1131. // Synopsis:
  1132. //
  1133. // Arguments: [ppContainer] --
  1134. //
  1135. // Returns:
  1136. //
  1137. // History: 11-17-95 JohannP (Johann Posch) Created
  1138. //
  1139. // Notes:
  1140. //
  1141. //----------------------------------------------------------------------------
  1142. STDMETHODIMP CEmbServerClientSite::GetContainer(IOleContainer **ppContainer)
  1143. {
  1144. HRESULT hresult = E_FAIL;
  1145. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplGetContainer\n", this));
  1146. Win4Assert(m_pClientSiteHandler);
  1147. if (m_pClientSiteHandler)
  1148. {
  1149. hresult = m_pClientSiteHandler->GetContainer(ppContainer);
  1150. }
  1151. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplGetContainer return %lx\n", this, hresult));
  1152. return hresult;
  1153. }
  1154. //+---------------------------------------------------------------------------
  1155. //
  1156. // Method: CEmbServerClientSite::ShowObject
  1157. //
  1158. // Synopsis:
  1159. //
  1160. // Arguments: [void] --
  1161. //
  1162. // Returns:
  1163. //
  1164. // History: 11-17-95 JohannP (Johann Posch) Created
  1165. //
  1166. // Notes:
  1167. //
  1168. //----------------------------------------------------------------------------
  1169. STDMETHODIMP CEmbServerClientSite::ShowObject( void)
  1170. {
  1171. HRESULT hresult = E_FAIL;
  1172. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplShowObject\n", this));
  1173. Win4Assert(m_pClientSiteHandler);
  1174. if (m_pClientSiteHandler)
  1175. {
  1176. hresult = m_pClientSiteHandler->ShowObject();
  1177. }
  1178. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplShowObject return %lx\n", this, hresult));
  1179. return hresult;
  1180. }
  1181. //+---------------------------------------------------------------------------
  1182. //
  1183. // Method: CEmbServerClientSite::COleClientSiteImplOnShowWindow
  1184. //
  1185. // Synopsis:
  1186. //
  1187. // Arguments: [fShow] --
  1188. //
  1189. // Returns:
  1190. //
  1191. // History: 11-17-95 JohannP (Johann Posch) Created
  1192. //
  1193. // Notes:
  1194. //
  1195. //----------------------------------------------------------------------------
  1196. STDMETHODIMP CEmbServerClientSite::OnShowWindow(BOOL fShow)
  1197. {
  1198. HRESULT hresult = E_FAIL;
  1199. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplOnShowWindow\n", this));
  1200. Win4Assert(m_pClientSiteHandler);
  1201. if (m_pClientSiteHandler)
  1202. {
  1203. hresult = m_pClientSiteHandler->OnShowWindow(fShow);
  1204. }
  1205. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplOnShowWindow return %lx\n", this, hresult));
  1206. return hresult;
  1207. }
  1208. //+---------------------------------------------------------------------------
  1209. //
  1210. // Method: CEmbServerClientSite::COleClientSiteImplRequestNewObjectLayout
  1211. //
  1212. // Synopsis:
  1213. //
  1214. // Arguments: [void] --
  1215. //
  1216. // Returns:
  1217. //
  1218. // History: 11-17-95 JohannP (Johann Posch) Created
  1219. //
  1220. // Notes:
  1221. //
  1222. //----------------------------------------------------------------------------
  1223. STDMETHODIMP CEmbServerClientSite::RequestNewObjectLayout(void)
  1224. {
  1225. HRESULT hresult = E_FAIL;
  1226. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplRequestNewObjectLayout\n", this));
  1227. Win4Assert(m_pClientSiteHandler);
  1228. if (m_pClientSiteHandler)
  1229. {
  1230. hresult = m_pClientSiteHandler->RequestNewObjectLayout();
  1231. }
  1232. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplRequestNewObjectLayout return %lx\n", this, hresult));
  1233. return hresult;
  1234. }
  1235. //+---------------------------------------------------------------------------
  1236. //
  1237. // Method: CEmbServerClientSite::COleClientSiteImplSaveObject
  1238. //
  1239. // Synopsis:
  1240. //
  1241. // Arguments: [void] --
  1242. //
  1243. // Returns:
  1244. //
  1245. // History: 11-17-95 JohannP (Johann Posch) Created
  1246. //
  1247. // Notes:
  1248. //
  1249. //----------------------------------------------------------------------------
  1250. STDMETHODIMP CEmbServerClientSite::SaveObject(void)
  1251. {
  1252. HRESULT hresult = E_FAIL;
  1253. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplSaveObject\n", this));
  1254. Win4Assert(m_pClientSiteHandler);
  1255. if (m_pClientSiteHandler)
  1256. {
  1257. hresult = m_pClientSiteHandler->SaveObject();
  1258. }
  1259. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplSaveObject return %lx\n", this, hresult));
  1260. return hresult;
  1261. }
  1262. //+---------------------------------------------------------------------------
  1263. //
  1264. // Method: CEmbServerClientSite::COleClientSiteImplGetMoniker
  1265. //
  1266. // Synopsis:
  1267. //
  1268. // Arguments: [dwAssign] --
  1269. // [dwWhichMoniker] --
  1270. // [ppmk] --
  1271. //
  1272. // Returns:
  1273. //
  1274. // History: 11-17-95 JohannP (Johann Posch) Created
  1275. //
  1276. // Notes:
  1277. //
  1278. //----------------------------------------------------------------------------
  1279. STDMETHODIMP CEmbServerClientSite::GetMoniker(DWORD dwAssign,DWORD dwWhichMoniker,IMoniker **ppmk)
  1280. {
  1281. HRESULT hresult = E_FAIL;
  1282. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleClientSiteImplGetMoniker\n", this));
  1283. Win4Assert(m_pClientSiteHandler);
  1284. if (m_pClientSiteHandler)
  1285. {
  1286. hresult = m_pClientSiteHandler->GetMoniker(dwAssign, dwWhichMoniker, ppmk);
  1287. }
  1288. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleClientSiteImplGetMoniker return %lx\n", this, hresult));
  1289. return hresult;
  1290. }
  1291. // IOleWindow Methods
  1292. //+---------------------------------------------------------------------------
  1293. //
  1294. // Method: CEmbServerClientSite::GetWindow
  1295. //
  1296. // Synopsis:
  1297. //
  1298. // Arguments: [phwnd] --
  1299. //
  1300. // Returns:
  1301. //
  1302. // History: 11-17-95 JohannP (Johann Posch) Created
  1303. //
  1304. // Notes:
  1305. //
  1306. //----------------------------------------------------------------------------
  1307. STDMETHODIMP CEmbServerClientSite::GetWindow(HWND *phwnd)
  1308. {
  1309. HRESULT hresult = NOERROR;
  1310. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::GetWindow\n", this));
  1311. *phwnd = NULL;
  1312. if ( m_fInDoVerb && m_hwndOIPS )
  1313. {
  1314. *phwnd = m_hwndOIPS;
  1315. }
  1316. else
  1317. {
  1318. Win4Assert(m_pClientSiteHandler);
  1319. if (m_pClientSiteHandler)
  1320. {
  1321. hresult = m_pClientSiteHandler->GetWindow(phwnd);
  1322. }
  1323. else
  1324. {
  1325. hresult = E_FAIL;
  1326. }
  1327. if (NOERROR == hresult)
  1328. {
  1329. m_hwndOIPS = *phwnd;
  1330. }
  1331. }
  1332. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleCInPlaceSiteImpl::GetWindow return %lx\n", this, hresult));
  1333. return hresult;
  1334. }
  1335. //
  1336. // IOleInPlaceSite Methods
  1337. //
  1338. //+---------------------------------------------------------------------------
  1339. //
  1340. // Method: CEmbServerClientSite::ContextSensitiveHelp
  1341. //
  1342. // Synopsis:
  1343. //
  1344. // Arguments: [fEnterMode] --
  1345. //
  1346. // Returns:
  1347. //
  1348. // History: 11-17-95 JohannP (Johann Posch) Created
  1349. //
  1350. // Notes:
  1351. //
  1352. //----------------------------------------------------------------------------
  1353. STDMETHODIMP CEmbServerClientSite::ContextSensitiveHelp(BOOL fEnterMode)
  1354. {
  1355. HRESULT hresult = E_FAIL;
  1356. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::COleCInPlaceSiteImpl::ContextSensitiveHelp\n", this));
  1357. Win4Assert(m_pClientSiteHandler);
  1358. if (m_pClientSiteHandler)
  1359. {
  1360. hresult = m_pClientSiteHandler->ContextSensitiveHelp(fEnterMode);
  1361. }
  1362. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::COleCInPlaceSiteImpl::ContextSensitiveHelp return %lx\n", this, hresult));
  1363. return hresult;
  1364. }
  1365. //+---------------------------------------------------------------------------
  1366. //
  1367. // Method: CEmbServerClientSite::CanInPlaceActivate
  1368. //
  1369. // Synopsis:
  1370. //
  1371. // Arguments: [] --
  1372. //
  1373. // Returns:
  1374. //
  1375. // History: 11-17-95 JohannP (Johann Posch) Created
  1376. //
  1377. // Notes:
  1378. //
  1379. //----------------------------------------------------------------------------
  1380. STDMETHODIMP CEmbServerClientSite::CanInPlaceActivate( void)
  1381. {
  1382. HRESULT hresult = E_FAIL;
  1383. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::CanInPlaceActivate\n", this));
  1384. Win4Assert(m_pClientSiteHandler);
  1385. if (m_pClientSiteHandler)
  1386. {
  1387. hresult = m_pClientSiteHandler->CanInPlaceActivate();
  1388. }
  1389. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::CanInPlaceActivate return %lx\n", this, hresult));
  1390. return hresult;
  1391. }
  1392. //+---------------------------------------------------------------------------
  1393. //
  1394. // Method: CEmbServerClientSite::OnInPlaceActivate
  1395. //
  1396. // Synopsis:
  1397. //
  1398. // Arguments: [void] --
  1399. //
  1400. // Returns:
  1401. //
  1402. // History: 11-17-95 JohannP (Johann Posch) Created
  1403. //
  1404. // Notes:
  1405. //
  1406. //----------------------------------------------------------------------------
  1407. STDMETHODIMP CEmbServerClientSite::OnInPlaceActivate( void)
  1408. {
  1409. HRESULT hresult = E_FAIL;
  1410. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::OnInPlaceActivate\n", this));
  1411. Win4Assert(m_pClientSiteHandler);
  1412. if (m_pClientSiteHandler)
  1413. {
  1414. if (m_fInDoVerb )
  1415. {
  1416. // call back to client site
  1417. hresult = m_pClientSiteHandler->GoInPlaceActivate(&m_hwndOIPS);
  1418. if (FAILED(hresult))
  1419. {
  1420. // on failure make sure out params for caching are NULL;
  1421. m_hwndOIPS = NULL;
  1422. }
  1423. }
  1424. else
  1425. {
  1426. hresult = m_pClientSiteHandler->OnInPlaceActivate();
  1427. }
  1428. }
  1429. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::OnInPlaceActivate return %lx\n", this, hresult));
  1430. return hresult;
  1431. }
  1432. //+---------------------------------------------------------------------------
  1433. //
  1434. // Method: CEmbServerClientSite::OnUIActivate
  1435. //
  1436. // Synopsis:
  1437. //
  1438. // Arguments: [void] --
  1439. //
  1440. // Returns:
  1441. //
  1442. // History: 11-17-95 JohannP (Johann Posch) Created
  1443. //
  1444. // Notes:
  1445. //
  1446. //----------------------------------------------------------------------------
  1447. STDMETHODIMP CEmbServerClientSite::OnUIActivate( void)
  1448. {
  1449. HRESULT hresult = E_FAIL;
  1450. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::OnUIActivate\n", this));
  1451. Win4Assert(m_pClientSiteHandler);
  1452. if (m_pClientSiteHandler)
  1453. {
  1454. hresult = m_pClientSiteHandler->OnUIActivate();
  1455. }
  1456. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::OnUIActivate return %lx\n", this, hresult));
  1457. return hresult;
  1458. }
  1459. //+---------------------------------------------------------------------------
  1460. //
  1461. // Method: CEmbServerClientSite::GetWindowContext
  1462. //
  1463. // Synopsis:
  1464. //
  1465. // Arguments: [ppFrame] --
  1466. // [ppDoc] --
  1467. // [lprcPosRect] --
  1468. // [lprcClipRect] --
  1469. // [lpFrameInfo] --
  1470. //
  1471. // Returns:
  1472. //
  1473. // History: 11-17-95 JohannP (Johann Posch) Created
  1474. //
  1475. // Notes:
  1476. //
  1477. //----------------------------------------------------------------------------
  1478. STDMETHODIMP CEmbServerClientSite::GetWindowContext(IOleInPlaceFrame **ppFrame,
  1479. IOleInPlaceUIWindow **ppDoc,LPRECT lprcPosRect,LPRECT lprcClipRect,
  1480. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  1481. {
  1482. HRESULT hresult = E_FAIL;
  1483. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::GetWindowContext\n", this));
  1484. Win4Assert(m_pClientSiteHandler);
  1485. if (m_pClientSiteHandler)
  1486. {
  1487. hresult = m_pClientSiteHandler->GetWindowContext(ppFrame, ppDoc,lprcPosRect, lprcClipRect, lpFrameInfo);
  1488. }
  1489. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::GetWindowContext return %lx\n", this, hresult));
  1490. return hresult;
  1491. }
  1492. //+---------------------------------------------------------------------------
  1493. //
  1494. // Method: CEmbServerClientSite::Scroll
  1495. //
  1496. // Synopsis:
  1497. //
  1498. // Arguments: [scrollExtant] --
  1499. //
  1500. // Returns:
  1501. //
  1502. // History: 11-17-95 JohannP (Johann Posch) Created
  1503. //
  1504. // Notes:
  1505. //
  1506. //----------------------------------------------------------------------------
  1507. STDMETHODIMP CEmbServerClientSite::Scroll(SIZE scrollExtant)
  1508. {
  1509. HRESULT hresult = E_FAIL;
  1510. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::Scroll\n", this));
  1511. Win4Assert(m_pClientSiteHandler);
  1512. if (m_pClientSiteHandler)
  1513. {
  1514. hresult = m_pClientSiteHandler->Scroll(scrollExtant);
  1515. }
  1516. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::Scroll return %lx\n", this, hresult));
  1517. return hresult;
  1518. }
  1519. //+---------------------------------------------------------------------------
  1520. //
  1521. // Method: CEmbServerClientSite::OnUIDeactivate
  1522. //
  1523. // Synopsis:
  1524. //
  1525. // Arguments: [fUndoable] --
  1526. //
  1527. // Returns:
  1528. //
  1529. // History: 11-17-95 JohannP (Johann Posch) Created
  1530. //
  1531. // Notes:
  1532. //
  1533. //----------------------------------------------------------------------------
  1534. STDMETHODIMP CEmbServerClientSite::OnUIDeactivate(BOOL fUndoable)
  1535. {
  1536. HRESULT hresult = E_FAIL;
  1537. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::OnUIDeactivate\n", this));
  1538. Win4Assert(m_pClientSiteHandler);
  1539. if (m_pClientSiteHandler)
  1540. {
  1541. hresult = m_pClientSiteHandler->OnUIDeactivate(fUndoable);
  1542. }
  1543. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::OnUIDeactivate return %lx\n", this, hresult));
  1544. return hresult;
  1545. }
  1546. //+---------------------------------------------------------------------------
  1547. //
  1548. // Method: CEmbServerClientSite::OnInPlaceDeactivate
  1549. //
  1550. // Synopsis:
  1551. //
  1552. // Arguments: [void] --
  1553. //
  1554. // Returns:
  1555. //
  1556. // History: 11-17-95 JohannP (Johann Posch) Created
  1557. //
  1558. // Notes:
  1559. //
  1560. //----------------------------------------------------------------------------
  1561. STDMETHODIMP CEmbServerClientSite::OnInPlaceDeactivate(void)
  1562. {
  1563. HRESULT hresult = E_FAIL;
  1564. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::OnInPlaceDeactivate\n", this));
  1565. Win4Assert(m_pClientSiteHandler);
  1566. if (m_pClientSiteHandler)
  1567. {
  1568. hresult = m_pClientSiteHandler->OnInPlaceDeactivate();
  1569. }
  1570. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::OnInPlaceDeactivate return %lx\n", this, hresult));
  1571. return hresult;
  1572. }
  1573. //+---------------------------------------------------------------------------
  1574. //
  1575. // Method: CEmbServerClientSite::DiscardUndoState
  1576. //
  1577. // Synopsis:
  1578. //
  1579. // Arguments: [void] --
  1580. //
  1581. // Returns:
  1582. //
  1583. // History: 11-17-95 JohannP (Johann Posch) Created
  1584. //
  1585. // Notes:
  1586. //
  1587. //----------------------------------------------------------------------------
  1588. STDMETHODIMP CEmbServerClientSite::DiscardUndoState(void)
  1589. {
  1590. HRESULT hresult = E_FAIL;
  1591. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::DiscardUndoState\n", this));
  1592. Win4Assert(m_pClientSiteHandler);
  1593. if (m_pClientSiteHandler)
  1594. {
  1595. hresult = m_pClientSiteHandler->DiscardUndoState();
  1596. }
  1597. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::DiscardUndoState return %lx\n", this, hresult));
  1598. return hresult;
  1599. }
  1600. //+---------------------------------------------------------------------------
  1601. //
  1602. // Method: CEmbServerClientSite::DeactivateAndUndo
  1603. //
  1604. // Synopsis:
  1605. //
  1606. // Arguments: [void] --
  1607. //
  1608. // Returns:
  1609. //
  1610. // History: 11-17-95 JohannP (Johann Posch) Created
  1611. //
  1612. // Notes:
  1613. //
  1614. //----------------------------------------------------------------------------
  1615. STDMETHODIMP CEmbServerClientSite::DeactivateAndUndo(void)
  1616. {
  1617. HRESULT hresult = E_FAIL;
  1618. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::DeactivateAndUndo\n", this));
  1619. Win4Assert(m_pClientSiteHandler);
  1620. if (m_pClientSiteHandler)
  1621. {
  1622. hresult = m_pClientSiteHandler->DeactivateAndUndo();
  1623. }
  1624. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::DeactivateAndUndo return %lx\n", this, hresult));
  1625. return hresult;
  1626. }
  1627. //+---------------------------------------------------------------------------
  1628. //
  1629. // Method: CEmbServerClientSite::OnPosRectChange
  1630. //
  1631. // Synopsis:
  1632. //
  1633. // Arguments: [lprcPosRect] --
  1634. //
  1635. // Returns:
  1636. //
  1637. // History: 11-17-95 JohannP (Johann Posch) Created
  1638. //
  1639. // Notes:
  1640. //
  1641. //----------------------------------------------------------------------------
  1642. STDMETHODIMP CEmbServerClientSite::OnPosRectChange(LPCRECT lprcPosRect)
  1643. {
  1644. HRESULT hresult = E_FAIL;
  1645. LEDebugOut((DEB_TRACE, "%p _IN CEmbServerClientSite::OnPosRectChange\n", this));
  1646. Win4Assert(m_pClientSiteHandler);
  1647. if (m_pClientSiteHandler)
  1648. {
  1649. hresult = m_pClientSiteHandler->OnPosRectChange(lprcPosRect);
  1650. }
  1651. LEDebugOut((DEB_TRACE, "%p OUT CEmbServerClientSite::OnPosRectChange return %lx\n", this, hresult));
  1652. return hresult;
  1653. }