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.

194 lines
4.6 KiB

  1. /*
  2. * AMBIENTS.CPP
  3. * Implementation of the ambient properties IDispatch on a
  4. * control site.
  5. *
  6. * Copyright (c)1995-1996 Microsoft Corporation, All Rights Reserved
  7. */
  8. #include "stdafx.h"
  9. #include <docobj.h>
  10. #include "site.h"
  11. #include "proxyframe.h"
  12. #include "mshtmdid.h"
  13. /*
  14. * CImpAmbientIDispatch::CImpAmbientIDispatch
  15. * CImpAmbientIDispatch::~CImpAmbientIDispatch
  16. *
  17. * Parameters (Constructor):
  18. * pSite PCSite of the site we're in.
  19. * pUnkOuter LPUNKNOWN to which we delegate.
  20. */
  21. CImpAmbientIDispatch::CImpAmbientIDispatch( PCSite pSite, LPUNKNOWN pUnkOuter)
  22. {
  23. m_cRef = 0;
  24. m_pSite = pSite;
  25. m_pUnkOuter = pUnkOuter;
  26. return;
  27. }
  28. CImpAmbientIDispatch::~CImpAmbientIDispatch(void)
  29. {
  30. return;
  31. }
  32. /*
  33. * CImpAmbientIDispatch::QueryInterface
  34. * CImpAmbientIDispatch::AddRef
  35. * CImpAmbientIDispatch::Release
  36. */
  37. STDMETHODIMP CImpAmbientIDispatch::QueryInterface(REFIID riid, void** ppv)
  38. {
  39. return m_pUnkOuter->QueryInterface(riid, ppv);
  40. }
  41. STDMETHODIMP_(ULONG) CImpAmbientIDispatch::AddRef(void)
  42. {
  43. ++m_cRef;
  44. return m_pUnkOuter->AddRef();
  45. }
  46. STDMETHODIMP_(ULONG) CImpAmbientIDispatch::Release(void)
  47. {
  48. m_cRef--;
  49. return m_pUnkOuter->Release();
  50. }
  51. /*
  52. * CImpAmbientIDispatch::GetTypeInfoCount
  53. * CImpAmbientIDispatch::GetTypeInfo
  54. * CImpAmbientIDispatch::GetIDsOfNames
  55. *
  56. * Unimplemented members, not needed for ambient properties.
  57. */
  58. STDMETHODIMP CImpAmbientIDispatch::GetTypeInfoCount(UINT *pctInfo)
  59. {
  60. *pctInfo=0;
  61. return E_NOTIMPL;
  62. }
  63. STDMETHODIMP CImpAmbientIDispatch::GetTypeInfo(
  64. UINT /*itinfo*/,
  65. LCID /*lcid*/,
  66. ITypeInfo** pptInfo
  67. )
  68. {
  69. *pptInfo=NULL;
  70. return ResultFromScode(E_NOTIMPL);
  71. }
  72. STDMETHODIMP CImpAmbientIDispatch::GetIDsOfNames(
  73. REFIID /*riid*/,
  74. OLECHAR** rgszNames,
  75. UINT /*cNames*/,
  76. LCID /*lcid*/,
  77. DISPID* rgDispID)
  78. {
  79. *rgszNames = NULL;
  80. *rgDispID = NULL;
  81. return ResultFromScode(E_NOTIMPL);
  82. }
  83. /*
  84. * CImpAmbientIDispatch::Invoke
  85. *
  86. * Purpose:
  87. * Calls a method in the dispatch interface or manipulates a
  88. * property.
  89. *
  90. * Parameters:
  91. * dispIDMember DISPID of the method or property of interest.
  92. * riid REFIID reserved, must be NULL.
  93. * lcid LCID of the locale.
  94. * wFlags USHORT describing the context of the invocation.
  95. * pDispParams DISPPARAMS * to the array of arguments.
  96. * pVarResult VARIANT * in which to store the result. Is
  97. * NULL if the caller is not interested.
  98. * pExcepInfo EXCEPINFO * to exception information.
  99. * puArgErr UINT * in which to store the index of an
  100. * invalid parameter if DISP_E_TYPEMISMATCH
  101. * is returned.
  102. *
  103. * Return Value:
  104. * HRESULT NOERROR or a general error code.
  105. */
  106. STDMETHODIMP CImpAmbientIDispatch::Invoke(
  107. DISPID dispIDMember,
  108. REFIID riid,
  109. LCID /*lcid*/,
  110. unsigned short wFlags,
  111. DISPPARAMS* /*pDispParams*/,
  112. VARIANT* pVarResult,
  113. EXCEPINFO* /*pExcepInfo*/,
  114. UINT* /*puArgErr*/
  115. )
  116. {
  117. HRESULT hr;
  118. VARIANT varResult;
  119. VARIANT_BOOL vbBool = VARIANT_FALSE;
  120. if (IID_NULL!=riid)
  121. return ResultFromScode(E_INVALIDARG);
  122. if(NULL==pVarResult)
  123. pVarResult=&varResult;
  124. VariantInit(pVarResult);
  125. //The most common case is boolean, use as an initial type
  126. V_VT(pVarResult)=VT_BOOL;
  127. /*
  128. * Process the requested ambient property. Anything but a
  129. * request for a property is invalid, so we can check that
  130. * before looking at the specific ID. We can only get away
  131. * with this because all properties are read-only.
  132. */
  133. if (!(DISPATCH_PROPERTYGET & wFlags))
  134. return ResultFromScode(DISP_E_MEMBERNOTFOUND);
  135. hr = NOERROR;
  136. switch (dispIDMember)
  137. {
  138. case DISPID_AMBIENT_USERMODE:
  139. hr = m_pSite->GetFrame()->GetBrowseMode( &vbBool );
  140. if ( SUCCEEDED ( hr ) )
  141. {
  142. V_BOOL(pVarResult) = vbBool;
  143. }
  144. break;
  145. // BUG 542694: Disalbe the loading of frames.
  146. case DISPID_AMBIENT_DLCONTROL:
  147. if ( m_pSite->GetFrame() &&
  148. m_pSite->GetFrame()->GetControl() &&
  149. m_pSite->GetFrame()->GetControl()->IsSafeForScripting() )
  150. {
  151. V_VT(pVarResult)=VT_I4;
  152. V_I4(pVarResult) =
  153. DLCTL_DLIMAGES |
  154. DLCTL_NO_SCRIPTS |
  155. DLCTL_NO_DLACTIVEXCTLS |
  156. DLCTL_NO_FRAMEDOWNLOAD |
  157. DLCTL_NO_CLIENTPULL |
  158. DLCTL_NOFRAMES;
  159. }
  160. break;
  161. default:
  162. hr=ResultFromScode(DISP_E_MEMBERNOTFOUND);
  163. break;
  164. }
  165. return hr;
  166. }