void CDownloads_Opinions_WBEvents::RetrieveLinkToUsText(IDispatch *pdDoc)
{
	IHTMLDocument2Ptr spDoc (pdDoc);
	ASSERT (spDoc != NULL);
	IHTMLElementCollectionPtr spelForms;
	spDoc->get_forms (&spelForms);
	if (spelForms == NULL)
		return;	

	long cForms = 0;
	spelForms->get_length (&cForms);
	for (long i = 0; i < cForms; i++)
	{
		IDispatchPtr spdel;
		spelForms->item (COleVariant (i), COleVariant (i), &spdel);
		ASSERT (spdel != NULL);
		IHTMLFormElementPtr spForm (spdel);
		ASSERT (spForm != NULL);

		

		bool bFound;
		
		CString str = GetFormInputElementText (spForm, "LINKTOUSTEXT", bFound);
		if (bFound)
			_App.View_SpreadHelpDialog_LinkToUsText (str); 
		
		str = GetFormInputElementText (spForm, "RADIOBUTTON1TEXT", bFound);
		if (bFound)
			_App.View_SpreadHelpDialog_RadioButton1Text (str);
		str = GetFormInputElementText (spForm, "RADIOBUTTON2TEXT", bFound);
		if (bFound)
			_App.View_SpreadHelpDialog_RadioButton2Text (str);
	}
}
Esempio n. 2
0
File: WgBHO.cpp Progetto: naroya/fdm
void CWgBHO::WalkThroughForm(IHTMLElement *pElement, fsString &str)
{
	USES_CONVERSION;

	IDispatchPtr spd;
	pElement->get_children (&spd);
	IHTMLElementCollectionPtr spels (spd);

	long cElements = 0;
	if (spels != NULL)
		spels->get_length (&cElements);

	for (int j = 0; j < cElements; j++)
	{
		spd = NULL;
		spels->item (CComVariant (j), CComVariant (j), &spd);

		IHTMLInputElementPtr spInp (spd);
		if (spInp != NULL)
		{
			BSTR bstr = NULL, bstr2 = NULL;
			spInp->get_name (&bstr);				
			spInp->get_value (&bstr2);
			if (bstr)
			{
				str += W2A (bstr);
				str += "=";
				SysFreeString (bstr);
			}
			if (bstr2)
			{
				str += W2A (bstr2);
				SysFreeString (bstr2);
			}

			if (bstr || bstr2)
				str += "&";
		}
		
		IHTMLElementPtr spel (spd);
		if (spel != NULL)
			WalkThroughForm (spel, str);
	}
}
void vmsDomHelper::GetElementParam(IHTMLElement *pElem, LPCWSTR pwszName, wstring &wstrResult)
{
	getElementAttribute (pElem, pwszName, wstrResult);
	if (!wstrResult.empty ())
		return;

	IDispatchPtr spDisp;
	pElem->get_children (&spDisp);

	IHTMLElementCollectionPtr spElems (spDisp);

	if (spElems != NULL)
	{
		long cElems = 0;
		spElems->get_length (&cElems);

		for (long i = 0; i < cElems; i++)
		{
			IDispatchPtr spDisp;
			spElems->item (CComVariant (i), CComVariant (i), &spDisp);
			IHTMLElementPtr spChildElem (spDisp);
			if (spChildElem == NULL)
				continue;
			wstring wstrName;
			getElementAttribute (spChildElem, L"name", wstrName);
			if (wcsicmp (wstrName.c_str (), pwszName) == 0)
			{
				getElementAttribute (spChildElem, L"value", wstrResult);
				break;
			}
		}
	}

	if (!wstrResult.empty ())
		return;

	IHTMLElementPtr spParentElem;
	pElem->get_parentElement (&spParentElem);

	if (spParentElem != NULL)
		GetElementParam (spParentElem, pwszName, wstrResult);
}
Esempio n. 4
0
void vmsFlashHelper::SaveFlashMovies_noframes(IHTMLDocument2Ptr spDoc, LPCSTR pszFolder)
{
	USES_CONVERSION;

	if (spDoc == NULL)
		return;

	IHTMLElementCollectionPtr spAll;
	HRESULT hr = spDoc->get_all(&spAll);
	if (SUCCEEDED(hr) && spAll != NULL)
	{
		
		CComVariant vTagName ("OBJECT");
        IDispatchPtr spTagsDisp;
		hr = spAll->tags (vTagName, &spTagsDisp);
		if (SUCCEEDED(hr) && spTagsDisp != NULL)
		{
			IHTMLElementCollectionPtr spTags (spTagsDisp);
			if (spTags)
			{
				long nCnt;
				hr = spTags->get_length(&nCnt);
				if (SUCCEEDED(hr))
				{
					for (long i = 0; i < nCnt; i++)
					{
						CComVariant varIdx;
						V_VT(&varIdx) = VT_I4;
						V_I4(&varIdx) = i;

						IDispatchPtr spTagDisp;
						hr = spTags->item(varIdx, varIdx, &spTagDisp);
						if (SUCCEEDED(hr) && spTagDisp != NULL)
						{
							IHTMLObjectElementPtr spObject(spTagDisp);
							if (spObject != NULL)
							{
								BSTR bstrClassID = NULL;
								hr = spObject->get_classid(&bstrClassID);
								if (SUCCEEDED(hr) && bstrClassID)
								{
									fsString strClassID = W2A (bstrClassID);
									SysFreeString (bstrClassID);
									if (lstrcmpi (strClassID, "CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000") == 0)
									{
										IDispatchPtr spObj;
										spObject->get_object (&spObj);
										IShockwaveFlashPtr spFlash (spObj);
										if (spFlash != NULL)
										{
											BSTR bstr;
											spFlash->get_Movie (&bstr);
											SysFreeString (bstr);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	
    CComVariant vTagName ("EMBED");
	IDispatchPtr spTagsDisp;
    hr = spAll->tags(vTagName, &spTagsDisp);
    if (SUCCEEDED(hr) && spTagsDisp != NULL)
    {
        IHTMLElementCollectionPtr spTags(spTagsDisp);
        if (spTags != NULL)
        {
            long nCnt;
            hr = spTags->get_length(&nCnt);
            if (SUCCEEDED(hr))
            {
                for (long i = 0; i < nCnt; i++)
				{
					CComVariant varIdx;
					V_VT(&varIdx) = VT_I4;
					V_I4(&varIdx) = i;

					IDispatchPtr spTagDisp;
					hr = spTags->item(varIdx, varIdx, &spTagDisp);
					if (SUCCEEDED(hr) && spTagDisp != NULL)
					{
						IHTMLEmbedElementPtr spObject(spTagDisp);
						if (spObject != NULL)
						{
							IShockwaveFlashPtr spFlash (spObject);
							if (spFlash != NULL)
							{
								BSTR bstrSrc = NULL;
								hr = spObject->get_src(&bstrSrc);
								if (SUCCEEDED(hr) && bstrSrc)
								{
									SysFreeString (bstrSrc);
								}
							}
						}
					}
				}
            }
        }
	}
}
Esempio n. 5
0
File: WgBHO.cpp Progetto: naroya/fdm
STDMETHODIMP CWgBHO::BeforeNavigate2(IDispatch *, VARIANT *url, VARIANT *flags, VARIANT *tfn, VARIANT *pd, VARIANT *headers, VARIANT_BOOL *bCancel)
{
	USES_CONVERSION;

	if (fsIsMonitoringTurnedOn () == FALSE)
		return S_OK;
	
	_bstr_t bstrUrl = url->bstrVal;

	LPCSTR pszUrl = W2A (bstrUrl);

	if (fsIsOKUrl (pszUrl) == FALSE)
		return S_OK;

	*bCancel = VARIANT_FALSE;

	

	if (FALSE == fsOnNavigateUrl (pszUrl))
		return S_OK;

	fsString strCookies, strPostData, strReferer;
	IDispatchPtr spdDoc;
	m_spWebBrowser2->get_Document (&spdDoc);
	IHTMLDocument2Ptr spDoc;
	if (spdDoc)
		spDoc = spdDoc;
	if (spDoc)
	{		
		BSTR bstr = NULL;
		spDoc->get_cookie (&bstr);
		if (bstr)
		{
			strCookies = W2A (bstr);
			SysFreeString (bstr);
		}

		bstr = NULL;
		spDoc->get_URL (&bstr);
		if (bstr)
		{
			strReferer = W2A (bstr);
			SysFreeString (bstr);
		}

		IHTMLElementCollectionPtr spForms;
		spDoc->get_forms (&spForms);

		long cForms = 0;
		if (spForms)
			spForms->get_length (&cForms);

		bool bFound = false;

		for (long i = 0; bFound == false && i < cForms; i++)
		{
			IDispatchPtr spd;
			spForms->item (CComVariant (i), CComVariant (i), &spd);

			IHTMLFormElementPtr spForm (spd);
			if (spForm == NULL)
				continue;

			BSTR bstr = NULL;
			spForm->get_action (&bstr);
			bFound = bstr != NULL && wcscmp (url->bstrVal, bstr) == 0;
			SysFreeString (bstr);
			if (bFound == false)
				continue;

			bstr = NULL;
			spForm->get_method (&bstr);
			if (bstr == NULL || wcsicmp (bstr, L"post"))
				break;
			SysFreeString (bstr);

			IHTMLElementPtr spFormElem (spForm);
			if (spFormElem == NULL)
			{
				bFound = false;
				continue;
			}

			WalkThroughForm (spFormElem, strPostData);

			if (strPostData != "" && 
					strPostData [strPostData.GetLength ()-1] == '&')
				strPostData [strPostData.GetLength ()-1] = 0;
		}

	}

	if (fsUrlToFdm (pszUrl, strReferer, strCookies != "" ? strCookies : NULL,
			strPostData != "" ? strPostData : NULL, FALSE))
		*bCancel = VARIANT_TRUE;

	return S_OK;
}