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.

128 lines
3.9 KiB

  1. /*
  2. * f r a m e s . c p p
  3. *
  4. * Purpose:
  5. * Frameset helper functions
  6. *
  7. * History
  8. *
  9. * Copyright (C) Microsoft Corp. 1995, 1996.
  10. */
  11. #include <pch.hxx>
  12. #include "frames.h"
  13. #include "htiframe.h" //ITargetFrame2
  14. #include "htiface.h" //ITargetFramePriv
  15. ASSERTDATA
  16. typedef enum _TARGET_TYPE {
  17. TARGET_FRAMENAME,
  18. TARGET_SELF,
  19. TARGET_PARENT,
  20. TARGET_BLANK,
  21. TARGET_TOP,
  22. TARGET_MAIN
  23. } TARGET_TYPE;
  24. typedef struct _TARGETENTRY
  25. {
  26. TARGET_TYPE targetType;
  27. const WCHAR *pTargetValue;
  28. } TARGETENTRY;
  29. static const TARGETENTRY targetTable[] =
  30. {
  31. {TARGET_SELF, L"_self"},
  32. {TARGET_PARENT, L"_parent"},
  33. {TARGET_BLANK, L"_blank"},
  34. {TARGET_TOP, L"_top"},
  35. {TARGET_MAIN, L"_main"},
  36. {TARGET_SELF, NULL}
  37. };
  38. /*******************************************************************
  39. NAME: ParseTargetType
  40. SYNOPSIS: Maps pszTarget into a target class.
  41. IMPLEMENTATION:
  42. Treats unknown MAGIC targets as _self
  43. ********************************************************************/
  44. TARGET_TYPE ParseTargetType(LPCOLESTR pszTarget)
  45. {
  46. const TARGETENTRY *pEntry = targetTable;
  47. if (pszTarget[0] != '_') return TARGET_FRAMENAME;
  48. while (pEntry->pTargetValue)
  49. {
  50. if (!StrCmpW(pszTarget, pEntry->pTargetValue)) return pEntry->targetType;
  51. pEntry++;
  52. }
  53. // Treat unknown MAGIC targets as regular frame name! <<for NETSCAPE compatibility>>
  54. return TARGET_FRAMENAME;
  55. }
  56. HRESULT DoFindFrameInContext(IUnknown *pUnkTrident, IUnknown *pUnkThis, LPCWSTR pszTargetName, IUnknown *punkContextFrame, DWORD dwFlags, IUnknown **ppunkTargetFrame)
  57. {
  58. IOleContainer *pOleContainer;
  59. LPENUMUNKNOWN penumUnknown;
  60. LPUNKNOWN punkChild,
  61. punkChildFrame;
  62. ITargetFramePriv *ptgfpChild;
  63. HRESULT hr = E_FAIL;
  64. TARGET_TYPE targetType;
  65. Assert (pUnkTrident && pUnkThis);
  66. targetType = ParseTargetType(pszTargetName);
  67. if (targetType != TARGET_FRAMENAME)
  68. {
  69. // blank frames need to open a new browser window
  70. if (targetType == TARGET_BLANK)
  71. {
  72. *ppunkTargetFrame = NULL;
  73. return S_OK;
  74. }
  75. // must be a margic target name if it's _self, _parent, _top or _main
  76. // let's just return our own target frame
  77. *ppunkTargetFrame = pUnkThis;
  78. pUnkThis->AddRef();
  79. return S_OK;
  80. }
  81. else
  82. {
  83. if (pUnkTrident &&
  84. pUnkTrident->QueryInterface(IID_IOleContainer, (LPVOID *)&pOleContainer)==S_OK)
  85. {
  86. if (pOleContainer->EnumObjects(OLECONTF_EMBEDDINGS, &penumUnknown)==S_OK)
  87. {
  88. while( hr!=S_OK &&
  89. penumUnknown->Next(1, &punkChild, NULL)==S_OK)
  90. {
  91. if (punkChild->QueryInterface(IID_ITargetFramePriv, (LPVOID *)&ptgfpChild)==S_OK)
  92. {
  93. if (ptgfpChild->QueryInterface(IID_IUnknown, (LPVOID *)&punkChildFrame)==S_OK)
  94. {
  95. // to avoid recursion - if this isn't the punkContextFrame, see if embedding supports ITargetFrame
  96. if (punkChildFrame != punkContextFrame)
  97. {
  98. hr = ptgfpChild->FindFrameDownwards(pszTargetName, dwFlags, ppunkTargetFrame);
  99. }
  100. punkChildFrame->Release();
  101. }
  102. ptgfpChild->Release();
  103. }
  104. punkChild->Release();
  105. }
  106. penumUnknown->Release();
  107. }
  108. pOleContainer->Release();
  109. }
  110. }
  111. return hr;
  112. }