git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68156
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#include "wx/sharedptr.h"
#include "wx/vector.h"
#include "wx/sharedptr.h"
#include "wx/vector.h"
class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView
{
public:
class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView
{
public:
//Generic helper functions for IHtmlDocument commands
bool CanExecCommand(wxString command);
void ExecCommand(wxString command);
//Generic helper functions for IHtmlDocument commands
bool CanExecCommand(wxString command);
void ExecCommand(wxString command);
+ IHTMLDocument2* GetDocument();
// FIXME: calling wxYield is not elegant nor very reliable probably
wxYield();
// FIXME: calling wxYield is not elegant nor very reliable probably
wxYield();
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
-
- wxASSERT (documentPtr != NULL);
-
// TODO: consider the "baseUrl" parameter if possible
// TODO: consider encoding
BSTR bstr = SysAllocString(html.wc_str());
// TODO: consider the "baseUrl" parameter if possible
// TODO: consider encoding
BSTR bstr = SysAllocString(html.wc_str());
param->bstrVal = bstr;
hr = SafeArrayUnaccessData(psaStrings);
param->bstrVal = bstr;
hr = SafeArrayUnaccessData(psaStrings);
-
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+ IHTMLDocument2* document = GetDocument();
document->write(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
document->write(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
wxString wxWebViewIE::GetPageSource()
{
wxString wxWebViewIE::GetPageSource()
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
-
- if (documentPtr == NULL)
- {
- return wxEmptyString;
- }
-
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
+ IHTMLDocument2* document = GetDocument();
IHTMLElement *bodyTag = NULL;
IHTMLElement *htmlTag = NULL;
document->get_body(&bodyTag);
IHTMLElement *bodyTag = NULL;
IHTMLElement *htmlTag = NULL;
document->get_body(&bodyTag);
wxString wxWebViewIE::GetCurrentTitle()
{
wxString wxWebViewIE::GetCurrentTitle()
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
- wxASSERT(documentPtr && document);
+ IHTMLDocument2* document = GetDocument();
BSTR title;
document->get_nameProp(&title);
BSTR title;
document->get_nameProp(&title);
bool wxWebViewIE::CanExecCommand(wxString command)
{
bool wxWebViewIE::CanExecCommand(wxString command)
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
- wxASSERT(documentPtr && document);
+ IHTMLDocument2* document = GetDocument();
VARIANT_BOOL enabled;
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
VARIANT_BOOL enabled;
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
void wxWebViewIE::ExecCommand(wxString command)
{
void wxWebViewIE::ExecCommand(wxString command)
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+ IHTMLDocument2* document = GetDocument();
+ document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+}
- wxASSERT(documentPtr && document);
+IHTMLDocument2* wxWebViewIE::GetDocument()
+{
+ wxVariant variant = m_ie.GetProperty("Document");
+ IHTMLDocument2* document = (IHTMLDocument2*)variant.GetVoidPtr();
- document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+ wxASSERT(document);
+
+ return document;
}
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
}
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)