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.

197 lines
4.8 KiB

  1. //**********************************************************************
  2. // File name: IEC.CPP
  3. //
  4. // Implementation file for the CExternalConnection Class
  5. //
  6. // Functions:
  7. //
  8. // See iec.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 "iec.h"
  15. #include "app.h"
  16. #include "doc.h"
  17. //**********************************************************************
  18. //
  19. // CExternalConnection::QueryInterface
  20. //
  21. // Purpose:
  22. // Used for interface negotiation
  23. //
  24. // Parameters:
  25. //
  26. // REFIID riid - Interface being queried for.
  27. //
  28. // LPVOID FAR *ppvObj - Out pointer for the interface.
  29. //
  30. // Return Value:
  31. //
  32. // S_OK - Success
  33. // E_NOINTERFACE - Failure
  34. //
  35. // Function Calls:
  36. // Function Location
  37. //
  38. // CSimpSvrObj::QueryInterface OBJ.CPP
  39. //
  40. //********************************************************************
  41. STDMETHODIMP CExternalConnection::QueryInterface (REFIID riid, LPVOID FAR* ppvObj)
  42. {
  43. TestDebugOut(TEXT("In CExternalConnection::QueryInterface\r\n"));
  44. return m_lpObj->QueryInterface(riid, ppvObj);
  45. }
  46. //**********************************************************************
  47. //
  48. // CExternalConnection::AddRef
  49. //
  50. // Purpose:
  51. //
  52. // Increments the reference count on CSimpSvrObj object. Since
  53. // CExternalConnection is a nested class of CSimpSvrObj, we don't
  54. // need a separate reference count for CExternalConnection. We
  55. // can just use the reference count of CSimpSvrObj.
  56. //
  57. // Parameters:
  58. //
  59. // None
  60. //
  61. // Return Value:
  62. //
  63. // The new reference count of the CSimpSvrObj
  64. //
  65. // Function Calls:
  66. // Function Location
  67. //
  68. // OuputDebugString Windows API
  69. // CSimpSvrObj::AddRef OBJ.CPP
  70. //
  71. //********************************************************************
  72. STDMETHODIMP_(ULONG) CExternalConnection::AddRef ()
  73. {
  74. TestDebugOut(TEXT("In CExternalConnection::AddRef\r\n"));
  75. return( m_lpObj->AddRef() );
  76. }
  77. //**********************************************************************
  78. //
  79. // CExternalConnection::Release
  80. //
  81. // Purpose:
  82. //
  83. // Decrements the reference count on CSimpSvrObj object. Since
  84. // CExternalConnection is a nested class of CSimpSvrObj, we don't
  85. // need a separate reference count for CExternalConnection. We
  86. // can just use the reference count of CSimpSvrObj.
  87. //
  88. // Parameters:
  89. //
  90. // None
  91. //
  92. // Return Value:
  93. //
  94. // The new reference count of CSimpSvrObj
  95. //
  96. // Function Calls:
  97. // Function Location
  98. //
  99. // TestDebugOut Windows API
  100. // CSimpSvrObj::Release OBJ.CPP
  101. //
  102. //********************************************************************
  103. STDMETHODIMP_(ULONG) CExternalConnection::Release ()
  104. {
  105. TestDebugOut(TEXT("In CExternalConnection::Release\r\n"));
  106. return m_lpObj->Release();
  107. }
  108. //**********************************************************************
  109. //
  110. // CExternalConnection::AddConnection
  111. //
  112. // Purpose:
  113. //
  114. // Called when another connection is made to the object.
  115. //
  116. // Parameters:
  117. //
  118. // DWORD extconn - Type of connection
  119. //
  120. // DWORD reserved - Reserved
  121. //
  122. // Return Value:
  123. //
  124. // Strong connection count
  125. //
  126. // Function Calls:
  127. // Function Location
  128. //
  129. // TestDebugOut Windows API
  130. //
  131. //********************************************************************
  132. STDMETHODIMP_(DWORD) CExternalConnection::AddConnection (DWORD extconn, DWORD reserved)
  133. {
  134. TestDebugOut(TEXT("In CExternalConnection::AddConnection\r\n"));
  135. if (extconn & EXTCONN_STRONG)
  136. return ++m_dwStrong;
  137. return 0;
  138. }
  139. //**********************************************************************
  140. //
  141. // CExternalConnection::ReleaseConnection
  142. //
  143. // Purpose:
  144. //
  145. // Called when a connection to the object is released.
  146. //
  147. // Parameters:
  148. //
  149. // DWORD extconn - Type of Connection
  150. //
  151. // DWORD reserved - Reserved
  152. //
  153. // BOOL fLastReleaseCloses - Close flag
  154. //
  155. // Return Value:
  156. //
  157. // The new reference count
  158. //
  159. // Function Calls:
  160. // Function Location
  161. //
  162. // TestDebugOut Windows API
  163. // COleObject::Close IOO.CPP
  164. //
  165. //
  166. //********************************************************************
  167. STDMETHODIMP_(DWORD) CExternalConnection::ReleaseConnection (DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses)
  168. {
  169. TestDebugOut(TEXT("In CExternalConnection::ReleaseConnection\r\n"));
  170. if (extconn & EXTCONN_STRONG)
  171. {
  172. DWORD dwSave = --m_dwStrong;
  173. if (!m_dwStrong && fLastReleaseCloses)
  174. m_lpObj->m_OleObject.Close(OLECLOSE_SAVEIFDIRTY);
  175. return dwSave;
  176. }
  177. return 0;
  178. }