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.

95 lines
2.5 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. iextconn.cpp
  5. Abstract:
  6. Implementation of IExternalConnection as required for an
  7. in-process object that supports linking to embedding.
  8. Specifically, this will call IOleObject::Close when there
  9. are no more strong locks on the object.
  10. --*/
  11. #include "polyline.h"
  12. #include "unkhlpr.h"
  13. // CImpIExternalConnection interface implementation
  14. CImpIExternalConnection::CImpIExternalConnection(PCPolyline pObj
  15. , LPUNKNOWN pUnkOuter)
  16. {
  17. m_cRef=0;
  18. m_pObj=pObj;
  19. m_pUnkOuter=pUnkOuter;
  20. m_cLockStrong=0L;
  21. return;
  22. }
  23. IMPLEMENT_CONTAINED_DESTRUCTOR(CImpIExternalConnection)
  24. IMPLEMENT_CONTAINED_IUNKNOWN(CImpIExternalConnection)
  25. /*
  26. * CImpIExternalConnection::AddConnection
  27. *
  28. * Purpose:
  29. * Informs the object that a strong connection has been made to it.
  30. *
  31. * Parameters:
  32. * dwConn DWORD identifying the type of connection, taken
  33. * from the EXTCONN enumeration.
  34. * dwReserved DWORD reserved. This is used inside OLE and
  35. * should not be validated.
  36. *
  37. * Return Value:
  38. * DWORD The number of connection counts on the
  39. * object, used for debugging purposes only.
  40. */
  41. STDMETHODIMP_(DWORD) CImpIExternalConnection::AddConnection
  42. (DWORD dwConn, DWORD /* dwReserved */)
  43. {
  44. if (EXTCONN_STRONG & dwConn)
  45. return ++m_cLockStrong;
  46. return 0;
  47. }
  48. /*
  49. * CImpIExternalConnection::ReleaseConnection
  50. *
  51. * Purpose:
  52. * Informs an object that a connection has been taken away from
  53. * it in which case the object may need to shut down.
  54. *
  55. * Parameters:
  56. * dwConn DWORD identifying the type of connection,
  57. * taken from the EXTCONN enumeration.
  58. * dwReserved DWORD reserved. This is used inside OLE and
  59. * should not be validated.
  60. * dwRerved DWORD reserved
  61. * fLastReleaseCloses BOOL indicating if the last call to this
  62. * function should close the object.
  63. *
  64. * Return Value:
  65. * DWORD The number of remaining connection counts on
  66. * the object, used for debugging purposes only.
  67. */
  68. STDMETHODIMP_(DWORD) CImpIExternalConnection::ReleaseConnection
  69. (DWORD dwConn, DWORD /* dwReserved */, BOOL fLastReleaseCloses)
  70. {
  71. if (EXTCONN_STRONG==dwConn)
  72. {
  73. if (0==--m_cLockStrong && fLastReleaseCloses)
  74. m_pObj->m_pImpIOleObject->Close(OLECLOSE_SAVEIFDIRTY);
  75. return m_cLockStrong;
  76. }
  77. return 0L;
  78. }