git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71639
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Define a helper for the macro below: we just need a function taking a
// pointer and not returning anything to avoid warnings about unused return
// value of the cast in the macro itself.
// Define a helper for the macro below: we just need a function taking a
// pointer and not returning anything to avoid warnings about unused return
// value of the cast in the macro itself.
-namespace wxPrivate { void PPV_ARGS_CHECK(void*) { } }
+namespace wxPrivate { inline void PPV_ARGS_CHECK(void*) { } }
// Takes the interface name and a pointer to a pointer of the interface type
// and expands into the IID of this interface and the same pointer but after a
// Takes the interface name and a pointer to a pointer of the interface type
// and expands into the IID of this interface and the same pointer but after a
#include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h"
#include "wx/msw/ole/oleutils.h"
#include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h"
#include "wx/msw/ole/oleutils.h"
+#include "wx/msw/private/comptr.h"
#include "wx/msw/wrapwin.h"
#include "wx/msw/missing.h"
#include "wx/sharedptr.h"
#include "wx/msw/wrapwin.h"
#include "wx/msw/missing.h"
#include "wx/sharedptr.h"
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
DWORD m_dwCookie;
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
DWORD m_dwCookie;
- DocHostUIHandler* m_uiHandler;
+ wxCOMPtr<DocHostUIHandler> m_uiHandler;
//We store the current zoom type;
wxWebViewZoomType m_zoomType;
//We store the current zoom type;
wxWebViewZoomType m_zoomType;
//Generic helper functions for IHtmlDocument commands
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
//Generic helper functions for IHtmlDocument commands
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
- IHTMLDocument2* GetDocument() const;
+ wxCOMPtr<IHTMLDocument2> GetDocument() const;
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
m_uiHandler = new DocHostUIHandler;
m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
m_uiHandler = new DocHostUIHandler;
m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
{
m_factories[i]->Release();
}
{
m_factories[i]->Release();
}
-
- m_uiHandler->Release();
}
void wxWebViewIE::LoadURL(const wxString& url)
}
void wxWebViewIE::LoadURL(const wxString& url)
hr = SafeArrayUnaccessData(psaStrings);
hr = SafeArrayUnaccessData(psaStrings);
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(!document)
return;
document->write(psaStrings);
document->close();
if(!document)
return;
document->write(psaStrings);
document->close();
SafeArrayDestroy(psaStrings);
SafeArrayDestroy(psaStrings);
return;
document->write(psaStrings);
return;
document->write(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
SafeArrayDestroy(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
SafeArrayDestroy(psaStrings);
wxString wxWebViewIE::GetPageSource() const
{
wxString wxWebViewIE::GetPageSource() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
- IHTMLElement *bodyTag = NULL;
- IHTMLElement *htmlTag = NULL;
+ wxCOMPtr<IHTMLElement> bodyTag;
+ wxCOMPtr<IHTMLElement> htmlTag;
wxString source;
HRESULT hr = document->get_body(&bodyTag);
if(SUCCEEDED(hr))
wxString source;
HRESULT hr = document->get_body(&bodyTag);
if(SUCCEEDED(hr))
BSTR bstr;
htmlTag->get_outerHTML(&bstr);
source = wxString(bstr);
BSTR bstr;
htmlTag->get_outerHTML(&bstr);
source = wxString(bstr);
wxString wxWebViewIE::GetCurrentTitle() const
{
wxString wxWebViewIE::GetCurrentTitle() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(document)
{
BSTR title;
document->get_nameProp(&title);
if(document)
{
BSTR title;
document->get_nameProp(&title);
return wxString(title);
}
else
return wxString(title);
}
else
void wxWebViewIE::SetEditable(bool enable)
{
void wxWebViewIE::SetEditable(bool enable)
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
else
document->put_designMode(SysAllocString(L"Off"));
else
document->put_designMode(SysAllocString(L"Off"));
}
}
bool wxWebViewIE::IsEditable() const
{
}
}
bool wxWebViewIE::IsEditable() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(document)
{
BSTR mode;
document->get_designMode(&mode);
if(document)
{
BSTR mode;
document->get_designMode(&mode);
if(wxString(mode) == "On")
return true;
else
if(wxString(mode) == "On")
return true;
else
bool wxWebViewIE::HasSelection() const
{
bool wxWebViewIE::HasSelection() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
- IHTMLSelectionObject* selection;
+ wxCOMPtr<IHTMLSelectionObject> selection;
wxString sel;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
wxString sel;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
BSTR type;
selection->get_type(&type);
sel = wxString(type);
BSTR type;
selection->get_type(&type);
sel = wxString(type);
return sel != "None";
}
else
return sel != "None";
}
else
wxString wxWebViewIE::GetSelectedText() const
{
wxString wxWebViewIE::GetSelectedText() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
- IHTMLSelectionObject* selection;
+ wxCOMPtr<IHTMLSelectionObject> selection;
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
+ wxCOMPtr<IDispatch> disrange;
hr = selection->createRange(&disrange);
if(SUCCEEDED(hr))
{
hr = selection->createRange(&disrange);
if(SUCCEEDED(hr))
{
+ wxCOMPtr<IHTMLTxtRange> range;
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
if(SUCCEEDED(hr))
{
BSTR text;
range->get_text(&text);
selected = wxString(text);
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
if(SUCCEEDED(hr))
{
BSTR text;
range->get_text(&text);
selected = wxString(text);
wxString wxWebViewIE::GetSelectedSource() const
{
wxString wxWebViewIE::GetSelectedSource() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
- IHTMLSelectionObject* selection;
+ wxCOMPtr<IHTMLSelectionObject> selection;
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
+ wxCOMPtr<IDispatch> disrange;
hr = selection->createRange(&disrange);
if(SUCCEEDED(hr))
{
hr = selection->createRange(&disrange);
if(SUCCEEDED(hr))
{
+ wxCOMPtr<IHTMLTxtRange> range;
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
if(SUCCEEDED(hr))
{
BSTR text;
range->get_htmlText(&text);
selected = wxString(text);
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
if(SUCCEEDED(hr))
{
BSTR text;
range->get_htmlText(&text);
selected = wxString(text);
void wxWebViewIE::ClearSelection()
{
void wxWebViewIE::ClearSelection()
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
- IHTMLSelectionObject* selection;
+ wxCOMPtr<IHTMLSelectionObject> selection;
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
selection->empty();
wxString selected;
HRESULT hr = document->get_selection(&selection);
if(SUCCEEDED(hr))
{
selection->empty();
}
}
wxString wxWebViewIE::GetPageText() const
{
}
}
wxString wxWebViewIE::GetPageText() const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(document)
{
wxString text;
if(document)
{
wxString text;
+ wxCOMPtr<IHTMLElement> body;
HRESULT hr = document->get_body(&body);
if(SUCCEEDED(hr))
{
BSTR out;
body->get_innerText(&out);
text = wxString(out);
HRESULT hr = document->get_body(&body);
if(SUCCEEDED(hr))
{
BSTR out;
body->get_innerText(&out);
text = wxString(out);
void wxWebViewIE::RunScript(const wxString& javascript)
{
void wxWebViewIE::RunScript(const wxString& javascript)
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
+ wxCOMPtr<IHTMLWindow2> window;
wxString language = "javascript";
HRESULT hr = document->get_parentWindow(&window);
if(SUCCEEDED(hr))
wxString language = "javascript";
HRESULT hr = document->get_parentWindow(&window);
if(SUCCEEDED(hr))
SysAllocString(language.wc_str()),
&level);
}
SysAllocString(language.wc_str()),
&level);
}
bool wxWebViewIE::CanExecCommand(wxString command) const
{
bool wxWebViewIE::CanExecCommand(wxString command) const
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(document)
{
VARIANT_BOOL enabled;
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
if(document)
{
VARIANT_BOOL enabled;
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
return (enabled == VARIANT_TRUE);
}
return (enabled == VARIANT_TRUE);
}
void wxWebViewIE::ExecCommand(wxString command)
{
void wxWebViewIE::ExecCommand(wxString command)
{
- IHTMLDocument2* document = GetDocument();
+ wxCOMPtr<IHTMLDocument2> document(GetDocument());
if(document)
{
document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
if(document)
{
document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
-IHTMLDocument2* wxWebViewIE::GetDocument() const
+wxCOMPtr<IHTMLDocument2> wxWebViewIE::GetDocument() const
- IDispatch* dispatch = NULL;
+ wxCOMPtr<IDispatch> dispatch;
+ wxCOMPtr<IHTMLDocument2> document;
HRESULT result = m_webBrowser->get_Document(&dispatch);
if(dispatch && SUCCEEDED(result))
{
HRESULT result = m_webBrowser->get_Document(&dispatch);
if(dispatch && SUCCEEDED(result))
{
- IHTMLDocument2* document;
- dispatch->QueryInterface(IID_IHTMLDocument2, (void**)&document);
- dispatch->Release();
//document is set to null automatically if the interface isn't supported
//document is set to null automatically if the interface isn't supported
- return document;
- }
- else
- {
- return NULL;
+ dispatch->QueryInterface(IID_IHTMLDocument2, (void**)&document);
}
bool wxWebViewIE::EnableControlFeature(long flag, bool enable)
}
bool wxWebViewIE::EnableControlFeature(long flag, bool enable)