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.

212 lines
4.4 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. //
  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. // Comments:
  41. //
  42. //
  43. //********************************************************************
  44. STDMETHODIMP CExternalConnection::QueryInterface (REFIID riid, LPVOID FAR* ppvObj)
  45. {
  46. TestDebugOut("In CExternalConnection::QueryInterface\r\n");
  47. return m_lpObj->QueryInterface(riid, ppvObj);
  48. }
  49. //**********************************************************************
  50. //
  51. // CExternalConnection::AddRef
  52. //
  53. // Purpose:
  54. //
  55. // Increments the reference count on CExternalConnection and the "object"
  56. // object.
  57. //
  58. // Parameters:
  59. //
  60. // None
  61. //
  62. // Return Value:
  63. //
  64. // The Reference count on the Object.
  65. //
  66. // Function Calls:
  67. // Function Location
  68. //
  69. // OuputDebugString Windows API
  70. // CSimpSvrObj::AddRef OBJ.CPP
  71. //
  72. // Comments:
  73. //
  74. //
  75. //********************************************************************
  76. STDMETHODIMP_(ULONG) CExternalConnection::AddRef ()
  77. {
  78. TestDebugOut("In CExternalConnection::AddRef\r\n");
  79. ++m_nCount;
  80. return m_lpObj->AddRef();
  81. };
  82. //**********************************************************************
  83. //
  84. // CExternalConnection::Release
  85. //
  86. // Purpose:
  87. //
  88. // Decrements the reference count of COleObject and the
  89. // "object" object.
  90. //
  91. // Parameters:
  92. //
  93. // None
  94. //
  95. // Return Value:
  96. //
  97. // The new reference count
  98. //
  99. // Function Calls:
  100. // Function Location
  101. //
  102. // TestDebugOut Windows API
  103. // CSimpSvrObj::Release OBJ.CPP
  104. //
  105. // Comments:
  106. //
  107. //
  108. //********************************************************************
  109. STDMETHODIMP_(ULONG) CExternalConnection::Release ()
  110. {
  111. TestDebugOut("In CExternalConnection::Release\r\n");
  112. --m_nCount;
  113. return m_lpObj->Release();
  114. };
  115. //**********************************************************************
  116. //
  117. // CExternalConnection::AddConnection
  118. //
  119. // Purpose:
  120. //
  121. // Called when another connection is made to the object.
  122. //
  123. // Parameters:
  124. //
  125. // DWORD extconn - Type of connection
  126. //
  127. // DWORD reserved - Reserved
  128. //
  129. // Return Value:
  130. //
  131. // Strong connection count
  132. //
  133. // Function Calls:
  134. // Function Location
  135. //
  136. // TestDebugOut Windows API
  137. //
  138. // Comments:
  139. //
  140. //
  141. //********************************************************************
  142. STDMETHODIMP_(DWORD) CExternalConnection::AddConnection (DWORD extconn, DWORD reserved)
  143. {
  144. TestDebugOut("In CExternalConnection::AddConnection\r\n");
  145. if (extconn & EXTCONN_STRONG)
  146. return ++m_dwStrong;
  147. return 0;
  148. }
  149. //**********************************************************************
  150. //
  151. // CExternalConnection::ReleaseConnection
  152. //
  153. // Purpose:
  154. //
  155. // Called when a connection to the object is released.
  156. //
  157. // Parameters:
  158. //
  159. // DWORD extconn - Type of Connection
  160. //
  161. // DWORD reserved - Reserved
  162. //
  163. // BOOL fLastReleaseCloses - Close flag
  164. //
  165. // Return Value:
  166. //
  167. // The new reference count
  168. //
  169. // Function Calls:
  170. // Function Location
  171. //
  172. // TestDebugOut Windows API
  173. // COleObject::Close IOO.CPP
  174. //
  175. // Comments:
  176. //
  177. //
  178. //********************************************************************
  179. STDMETHODIMP_(DWORD) CExternalConnection::ReleaseConnection (DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses)
  180. {
  181. TestDebugOut("In CExternalConnection::ReleaseConnection\r\n");
  182. if (extconn & EXTCONN_STRONG)
  183. {
  184. DWORD dwSave = --m_dwStrong;
  185. if (!m_dwStrong && fLastReleaseCloses)
  186. m_lpObj->m_OleObject.Close(OLECLOSE_SAVEIFDIRTY);
  187. return dwSave;
  188. }
  189. return 0;
  190. }