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);
	}
}
Example #2
0
void vmsFlashHelper::GetFlashMoviesList(IHTMLDocument2Ptr spDoc, std::vector <fsString> *pslURLs, std::vector <fsString> *pslHTMLs)
{
	USES_CONVERSION;

	FLASHLIST vf;
	GetFlashMoviesObjList (spDoc, &vf, TRUE);

	IHTMLLocationPtr spLoc;
	spDoc->get_location (&spLoc);
	BSTR bstrHref = NULL;
	spLoc->get_href (&bstrHref);
	fsString strParent = W2A (bstrHref);
	SysFreeString (bstrHref);

	for (int i = 0; i < vf.size (); i++)
	{
		IDispatch* pTag = vf [i];
		fsString strMovieURL;
		fsString strMovieHTML;
		
		
		IHTMLObjectElementPtr spObject (pTag);
		if (spObject != NULL)
		{
			IDispatchPtr spObj;
			spObject->get_object (&spObj);
			IShockwaveFlashPtr spFlash (spObj);
			if (spFlash != NULL)
			{
				BSTR bstr;
				spFlash->get_Movie (&bstr);
				strMovieURL = W2A (bstr);
				SysFreeString (bstr);
			}
		}
		else
		{
			
			IHTMLEmbedElementPtr spObject(pTag);
			BSTR bstrSrc = NULL;
			spObject->get_src(&bstrSrc);
			strMovieURL = W2A (bstrSrc);
			SysFreeString (bstrSrc);
		}

		
		if (pslHTMLs != NULL)
		{
			IHTMLElementPtr spElement (pTag);
			BSTR bstr = NULL;
			spElement->get_outerHTML (&bstr);
			strMovieHTML = W2A (bstr);
			SysFreeString (bstr);
		}

		pslURLs->push_back (strMovieURL);
		if (pslHTMLs)
			pslHTMLs->push_back (strMovieHTML);
	}
}
STDMETHODIMP CFDMFlashVideoDownloads::ProcessIeDocument(IDispatch *pDispatch)
{
	IHTMLDocument2Ptr spDoc (pDispatch);
	if (spDoc == NULL)
		return E_INVALIDARG;

	IPersistFilePtr spFile (pDispatch);
	if (spFile == NULL)
		return E_INVALIDARG;

	

	USES_CONVERSION;
	BSTR bstrHost = NULL;
	spDoc->get_URL (&bstrHost);
	fsURL url;
	if (url.Crack (W2A (bstrHost)) != IR_SUCCESS)
		return E_FAIL;
	SysFreeString (bstrHost);

	char szPath [MY_MAX_PATH];
	GetTempPath (sizeof (szPath), szPath);
	char szFile [MY_MAX_PATH];
	GetTempFileName (szPath, "fdm", 0, szFile);

	COleVariant vaFile (szFile);
	if (FAILED (spFile->Save (vaFile.bstrVal, FALSE)))
		return E_FAIL;

	HANDLE hFile = CreateFile (szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
		return E_FAIL;

	DWORD dw = GetFileSize (hFile, NULL);

	LPSTR pszHtml = new char [dw + 1];
	ReadFile (hFile, pszHtml, dw, &dw, NULL);
	pszHtml [dw] = 0;

	CloseHandle (hFile);
	DeleteFile (szFile);

	ProcessHtml (url.GetHostName (), pszHtml);
	delete [] pszHtml;

	return S_OK;
}
Example #4
0
void vmsFlashHelper::GetFlashInfo(IDispatchPtr spFlash, IHTMLDocument2Ptr spDoc, fsString *pstrMovieURL, fsString *pstrMovieHTML)
{
	USES_CONVERSION;

	IHTMLLocationPtr spLoc;
	spDoc->get_location (&spLoc);
	BSTR bstrHref = NULL;
	spLoc->get_href (&bstrHref);
	fsString strParent = W2A (bstrHref);
	SysFreeString (bstrHref);

	
	IHTMLObjectElementPtr spObject (spFlash);
	if (spObject != NULL)
	{
		IDispatchPtr spObj;
		spObject->get_object (&spObj);
		IShockwaveFlashPtr spFlash (spObj);
		if (spFlash != NULL)
		{
			BSTR bstr;
			spFlash->get_Movie (&bstr);
			*pstrMovieURL = W2A (bstr);
			SysFreeString (bstr);
		}
	}
	else
	{
		
		IHTMLEmbedElementPtr spObject (spFlash);
		BSTR bstrSrc = NULL;
		spObject->get_src(&bstrSrc);
		*pstrMovieURL = W2A (bstrSrc);
		SysFreeString (bstrSrc);
	}

	
	if (pstrMovieHTML != NULL)
	{
		IHTMLElementPtr spElement (spFlash);
		BSTR bstr = NULL;
		spElement->get_outerHTML (&bstr);
		*pstrMovieHTML = W2A (bstr);
		SysFreeString (bstr);
	}
}
Example #5
0
void vmsFlashHelper::GetFlashMoviesObjList(IHTMLDocument2Ptr spDoc, LPFLASHLIST pv, BOOL bIncludingFrames)
{
	
    GetFlashMoviesObjList_noframes (spDoc, pv);

	if (bIncludingFrames == FALSE)
		return;

    
    IHTMLFramesCollection2Ptr spFrames;
	spDoc->get_frames (&spFrames);
	if (spFrames == NULL)
		return;

	long lCount = 0;
	spFrames->get_length (&lCount);

	for (long i = 0; i < lCount; i++)
	{
		CComVariant va ((long)i);
		CComVariant vaR;

		spFrames->item (&va, &vaR);

		if (vaR.pdispVal != NULL)
		{
			IHTMLWindow2Ptr spWnd = vaR.pdispVal;
			if (spWnd != NULL)
			{
				IHTMLDocument2Ptr spFDoc;
				spWnd->get_document (&spFDoc);
				if (spFDoc != NULL)
					GetFlashMoviesObjList (spFDoc, pv, TRUE);
			}
		}
	}
}
Example #6
0
void vmsFlashHelper::SaveFlashMovies(IHTMLDocument2Ptr spDoc, LPCSTR pszFolder, BOOL bIncludingFrames)
{
    SaveFlashMovies_noframes(spDoc, pszFolder);

	if (bIncludingFrames == FALSE)
		return;

    
    IHTMLFramesCollection2Ptr spFrames;
	spDoc->get_frames (&spFrames);
	if (spFrames == NULL)
		return;

	long lCount = 0;
	spFrames->get_length (&lCount);

	for (long i = 0; i < lCount; i++)
	{
		CComVariant va ((long)i);
		CComVariant vaR;

		spFrames->item (&va, &vaR);

		if (vaR.pdispVal != NULL)
		{
			IHTMLWindow2Ptr spWnd = vaR.pdispVal;
			if (spWnd != NULL)
			{
				IHTMLDocument2Ptr spFDoc;
				spWnd->get_document (&spFDoc);
				if (spFDoc != NULL)
					SaveFlashMovies (spFDoc, pszFolder, TRUE);
			}
		}
	}
}
Example #7
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);
								}
							}
						}
					}
				}
            }
        }
	}
}
Example #8
0
File: WgBHO.cpp Project: 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;
}
Example #9
0
bool CPhotoManager::GetElements(IHTMLDocument2Ptr spDoc)
{
	m_ElementList.clear();

	if (spDoc == NULL)
		return false;

	CComPtr<IHTMLElementCollection> spAll;
	HRESULT hr = spDoc->get_all(&spAll);
	if (FAILED(hr) || !spAll)
		return false;
		
	// Find all the IMG tags in the document
    CComPtr<IDispatch> spTagsDisp;
	hr = spAll->tags(CComVariant(CComBSTR("img")), &spTagsDisp);
	if (FAILED(hr) || !spTagsDisp)
		return false;

	CComQIPtr<IHTMLElementCollection> spTags(spTagsDisp);
	if (!spTags)
		return false;

	long nTags = 0;
	hr = spTags->get_length(&nTags);
	if (FAILED(hr))
		return false;

	bool bSuccess = false;
	for (long i=0; i < nTags; i++)
	{
		CComPtr<IDispatch> spTagDisp;
		hr = spTags->item(CComVariant(i), CComVariant(i), &spTagDisp);
		if (FAILED(hr) || !spTagDisp)
			continue;
		
		CComQIPtr<IHTMLImgElement> spObject(spTagDisp);
		if (!spObject)
			continue;

		CComBSTR bstrFileName;
		hr = spObject->get_src(&bstrFileName);
		if (FAILED(hr))
			continue;

		CString strFileName = bstrFileName;
		if (strFileName.IsEmpty())
			continue;
			
		strFileName.MakeLower();
		bool bPhoto = (strFileName.Find("photo.gif") >= 0);
		bool bCid = (strFileName.Find("cid:") >= 0);
		if (!bPhoto && !bCid)
			continue;

		PMElementInfo ElemInfo;
		ElemInfo.pTagDisp= spTagDisp;
		m_ElementList.push_back(ElemInfo);
		bSuccess = true;
	}
	
	return bSuccess;
}
/******************************************************************************
*   Invoke -- Takes a dispid and uses it to call another of the methods of this 
*   class. Returns S_OK if the call was successful.
******************************************************************************/ 
STDMETHODIMP WebBrowserEventSinker::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
	WORD wFlags, DISPPARAMS* pDispParams,
	VARIANT* pVarResult,
	EXCEPINFO* pExcepInfo,
	UINT* puArgErr)
{
	//Validate arguments.
	if ((riid != IID_NULL))
		return E_INVALIDARG;

	//if (dispIdMember != DISPID_STATUSTEXTCHANGE)//过于频繁的不显示了
	//{
	//	TCHAR buf[128] = {0};
	//	_stprintf(buf, _T("WebBrowserEventSinker::Invoke dispId = %d\n"), dispIdMember);
	//	TRACE(buf);
	//}

	HRESULT hr = S_OK;  // Initialize.

	switch (dispIdMember)
	{
		//注意:pDispParams的参数和MFC的参数顺序是相反的,MFC的第一个参数是WebBrowser的this指针
		//The last of pDispParams is an object that evaluates to the top-level or frame WebBrowser object corresponding to the event.

// 	case DISPID_NEWWINDOW3:
// 		// (IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl)
// 		return E_NOTIMPL;
// 		break;
// 
// 	case DISPID_NEWWINDOW2:
// 		// pDispParams->rgvarg[0]: BOOL*   Cancel
// 		// pDispParams->rgvarg[1]: LPDISPATCH*   ppDisp, dest app
// 		{
// 			int nCount = pDispParams->cArgs;
// 			_variant_t vVal = pDispParams->rgvarg[1];
// 			IWebBrowser2Ptr pWB = vVal.pdispVal;
// 			AdviseWebBrowser(pWB);
// 		}
// 		break;

//	case DISPID_BEFORENAVIGATE2:
		// pDispParams->rgvarg[6]: WebBrowser object
		// pDispParams->rgvarg[5 - 0]: 
		// (LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel)
//		{
//			int nCount = pDispParams->cArgs;
//			_variant_t vVal = pDispParams->rgvarg[nCount - 2];
//		}
//		break;

	case DISPID_NAVIGATECOMPLETE2:
		//(LPCTSTR lpszURL)
		// pDispParams->rgvarg[0]: URL to navigate to - VT_BYREF|VT_VARIANT
		// pDispParams->rgvarg[1]: An object that evaluates to the top-level or frame WebBrowser object corresponding to the event.
		if (pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_DISPATCH)
			SetCustomDocUIHandler(pDispParams->rgvarg[1].pdispVal);
		break;


	case DISPID_DOCUMENTCOMPLETE:
		//(LPCTSTR lpszURL)
		// pDispParams->rgvarg[0]: URL to navigate to - VT_BYREF|VT_VARIANT
		// pDispParams->rgvarg[1]: An object that evaluates to the top-level or frame WebBrowser object corresponding to the event.
		if (pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_DISPATCH)
		{
			IWebBrowser2Ptr pBrowser;
			(pDispParams->rgvarg[1].pdispVal)->QueryInterface(IID_IWebBrowser2,(void**)&pBrowser);
			if (pBrowser)
			{
				IHTMLDocument2Ptr pDocument;
				IDispatchPtr spDisp;
				pBrowser->get_Document(&spDisp);
				pDocument = spDisp;
				if (pDocument)
				{
					IHTMLElementPtr pElement;
					IHTMLBodyElementPtr pBody; //IID_IHTMLBodyElement
					pDocument->get_body(&pElement);
					pBody = pElement;
					if (pBody != NULL)
					{
						pBody->put_scroll((BSTR)L"auto");

						IHTMLStylePtr pStyle;
						pElement->get_style(&pStyle);
						pStyle->put_border((BSTR)L"none");
						pStyle->put_overflow((BSTR)L"auto");
					}
				}
			}
		}
		break;

	default:
		break;
	}

	return hr;
}