]> git.saurik.com Git - wxWidgets.git/blame - src/msw/webview_ie.cpp
Fix wxButtonToolBar compilation after adding new wxFont ctor overload.
[wxWidgets.git] / src / msw / webview_ie.cpp
CommitLineData
61b98a2d 1/////////////////////////////////////////////////////////////////////////////
8290e3cd 2// Name: src/msw/webview_ie.cpp
61b98a2d
SL
3// Purpose: wxMSW wxWebViewIE class implementation for web view component
4// Author: Marianne Gagnon
5// Id: $Id$
153530af 6// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
61b98a2d
SL
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
384b8d9f
SL
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#if defined(__BORLANDC__)
14 #pragma hdrstop
15#endif
16
8290e3cd 17#include "wx/msw/webview_ie.h"
61b98a2d 18
9d2f31db 19#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
61b98a2d
SL
20
21#include <olectl.h>
22#include <oleidl.h>
23#include <exdispid.h>
24#include <exdisp.h>
25#include <mshtml.h>
cd4e4673 26#include "wx/msw/registry.h"
1d7d04d7 27#include "wx/msw/missing.h"
7d3f6b4d 28#include "wx/filesys.h"
e924e848 29#include "wx/dynlib.h"
f559d1a2
VZ
30#include <initguid.h>
31
32/* These GUID definitions are our own implementation to support interfaces
33 * normally in urlmon.h. See include/wx/msw/webview_ie.h
34 */
35
36namespace {
37
38DEFINE_GUID(wxIID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
39DEFINE_GUID(wxIID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
accc94d5 40DEFINE_GUID(wxIID_IDocHostUIHandler, 0xbd3f23c0, 0xd43e, 0x11cf, 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a);
f559d1a2
VZ
41
42}
7d3f6b4d 43
cddf4541
SL
44wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewIE, wxWebView);
45
61b98a2d 46BEGIN_EVENT_TABLE(wxWebViewIE, wxControl)
97ad1425
SL
47 EVT_ACTIVEX(wxID_ANY, wxWebViewIE::onActiveXEvent)
48 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg)
61b98a2d
SL
49END_EVENT_TABLE()
50
51bool wxWebViewIE::Create(wxWindow* parent,
52 wxWindowID id,
53 const wxString& url,
54 const wxPoint& pos,
55 const wxSize& size,
56 long style,
57 const wxString& name)
58{
59 if (!wxControl::Create(parent, id, pos, size, style,
60 wxDefaultValidator, name))
61 {
62 return false;
63 }
64
65 m_webBrowser = NULL;
61b98a2d 66 m_isBusy = false;
74af0b13
SL
67 m_historyLoadingFromList = false;
68 m_historyEnabled = true;
69 m_historyPosition = -1;
c5f417cb 70 m_zoomType = wxWEB_VIEW_ZOOM_TYPE_TEXT;
61b98a2d
SL
71
72 if (::CoCreateInstance(CLSID_WebBrowser, NULL,
73 CLSCTX_INPROC_SERVER, // CLSCTX_INPROC,
74 IID_IWebBrowser2 , (void**)&m_webBrowser) != 0)
75 {
76 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
77 return false;
78 }
79
80 m_ie.SetDispatchPtr(m_webBrowser); // wxAutomationObject will release itself
81
82 m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
83 m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
61b98a2d 84
accc94d5
SL
85 m_uiHandler = new DocHostUIHandler;
86 m_uiHandler->AddRef();
87
88 m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
61b98a2d 89
4d0dddc7 90 LoadURL(url);
61b98a2d
SL
91 return true;
92}
93
39498710
SL
94wxWebViewIE::~wxWebViewIE()
95{
96 for(unsigned int i = 0; i < m_factories.size(); i++)
97 {
98 m_factories[i]->Release();
99 }
accc94d5
SL
100
101 m_uiHandler->Release();
39498710 102}
61b98a2d 103
4d0dddc7 104void wxWebViewIE::LoadURL(const wxString& url)
61b98a2d 105{
e8d243a9 106 m_ie.CallMethod("Navigate", wxConvertStringToOle(url));
61b98a2d
SL
107}
108
442262d4 109void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
61b98a2d 110{
7f98bdd6 111 BSTR bstr = SysAllocString(OLESTR(""));
61b98a2d
SL
112 SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
113 if (psaStrings != NULL)
114 {
115 VARIANT *param;
116 HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
117 param->vt = VT_BSTR;
118 param->bstrVal = bstr;
442262d4 119
7f98bdd6 120 hr = SafeArrayUnaccessData(psaStrings);
accc94d5 121
617227c3 122 IHTMLDocument2* document = GetDocument();
61b98a2d 123 document->write(psaStrings);
7f98bdd6 124 document->close();
442262d4 125 document->Release();
61b98a2d 126
61b98a2d 127 SafeArrayDestroy(psaStrings);
442262d4 128
7f98bdd6
SL
129 bstr = SysAllocString(html.wc_str());
130
131 // Creates a new one-dimensional array
132 psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
133 if (psaStrings != NULL)
134 {
135 hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
136 param->vt = VT_BSTR;
137 param->bstrVal = bstr;
138 hr = SafeArrayUnaccessData(psaStrings);
139
140 document = GetDocument();
141 document->write(psaStrings);
142 document->Release();
143
144 // SafeArrayDestroy calls SysFreeString for each BSTR
145 SafeArrayDestroy(psaStrings);
146
147 //We send the events when we are done to mimic webkit
148 //Navigated event
149 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
150 GetId(), baseUrl, "");
151 event.SetEventObject(this);
152 HandleWindowEvent(event);
153
154 //Document complete event
155 event.SetEventType(wxEVT_COMMAND_WEB_VIEW_LOADED);
156 event.SetEventObject(this);
157 HandleWindowEvent(event);
158 }
159 else
160 {
161 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
162 }
61b98a2d
SL
163 }
164 else
165 {
7f98bdd6 166 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL during clear");
61b98a2d 167 }
61b98a2d
SL
168}
169
e669ddde 170wxString wxWebViewIE::GetPageSource() const
61b98a2d 171{
617227c3 172 IHTMLDocument2* document = GetDocument();
61b98a2d
SL
173 IHTMLElement *bodyTag = NULL;
174 IHTMLElement *htmlTag = NULL;
423adfde 175 wxString source;
7fbc727b
SL
176 HRESULT hr = document->get_body(&bodyTag);
177 if(SUCCEEDED(hr))
178 {
179 hr = bodyTag->get_parentElement(&htmlTag);
180 if(SUCCEEDED(hr))
181 {
423adfde 182 BSTR bstr;
7fbc727b 183 htmlTag->get_outerHTML(&bstr);
423adfde 184 source = wxString(bstr);
7fbc727b
SL
185 htmlTag->Release();
186 }
187 bodyTag->Release();
188 }
61b98a2d
SL
189
190 document->Release();
423adfde 191 return source;
61b98a2d
SL
192}
193
e669ddde 194wxWebViewZoom wxWebViewIE::GetZoom() const
61b98a2d 195{
8acbf08b
SL
196 switch( m_zoomType )
197 {
198 case wxWEB_VIEW_ZOOM_TYPE_LAYOUT:
199 return GetIEOpticalZoom();
200 case wxWEB_VIEW_ZOOM_TYPE_TEXT:
201 return GetIETextZoom();
202 default:
203 wxFAIL;
204 }
423adfde
SL
205
206 //Dummy return to stop compiler warnings
207 return wxWEB_VIEW_ZOOM_MEDIUM;
1d7d04d7 208
61b98a2d 209}
c5f417cb 210
61b98a2d
SL
211void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
212{
8acbf08b
SL
213 switch( m_zoomType )
214 {
215 case wxWEB_VIEW_ZOOM_TYPE_LAYOUT:
216 SetIEOpticalZoom(zoom);
217 break;
218 case wxWEB_VIEW_ZOOM_TYPE_TEXT:
219 SetIETextZoom(zoom);
220 break;
221 default:
222 wxFAIL;
223 }
61b98a2d
SL
224}
225
c5f417cb 226void wxWebViewIE::SetIETextZoom(wxWebViewZoom level)
61b98a2d 227{
1d7d04d7 228 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
c5f417cb
SL
229 //is 0 to 4 so the check is unnecessary, these match exactly with the
230 //enum values
61b98a2d
SL
231 VARIANT zoomVariant;
232 VariantInit (&zoomVariant);
233 V_VT(&zoomVariant) = VT_I4;
234 V_I4(&zoomVariant) = level;
235
8acbf08b
SL
236#if wxDEBUG_LEVEL
237 HRESULT result =
238#endif
239 m_webBrowser->ExecWB(OLECMDID_ZOOM,
240 OLECMDEXECOPT_DONTPROMPTUSER,
241 &zoomVariant, NULL);
c5f417cb 242 wxASSERT(result == S_OK);
61b98a2d
SL
243}
244
e669ddde 245wxWebViewZoom wxWebViewIE::GetIETextZoom() const
61b98a2d
SL
246{
247 VARIANT zoomVariant;
248 VariantInit (&zoomVariant);
249 V_VT(&zoomVariant) = VT_I4;
61b98a2d 250
8acbf08b
SL
251#if wxDEBUG_LEVEL
252 HRESULT result =
253#endif
254 m_webBrowser->ExecWB(OLECMDID_ZOOM,
255 OLECMDEXECOPT_DONTPROMPTUSER,
256 NULL, &zoomVariant);
c5f417cb 257 wxASSERT(result == S_OK);
61b98a2d 258
c5f417cb
SL
259 //We can safely cast here as we know that the range matches our enum
260 return static_cast<wxWebViewZoom>(V_I4(&zoomVariant));
61b98a2d
SL
261}
262
c5f417cb 263void wxWebViewIE::SetIEOpticalZoom(wxWebViewZoom level)
61b98a2d 264{
1d7d04d7 265 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
c5f417cb 266 //is 10 to 1000 so the check is unnecessary
61b98a2d
SL
267 VARIANT zoomVariant;
268 VariantInit (&zoomVariant);
269 V_VT(&zoomVariant) = VT_I4;
c5f417cb
SL
270
271 //We make a somewhat arbitray map here, taken from values used by webkit
272 switch(level)
273 {
274 case wxWEB_VIEW_ZOOM_TINY:
275 V_I4(&zoomVariant) = 60;
276 break;
277 case wxWEB_VIEW_ZOOM_SMALL:
278 V_I4(&zoomVariant) = 80;
279 break;
280 case wxWEB_VIEW_ZOOM_MEDIUM:
281 V_I4(&zoomVariant) = 100;
282 break;
283 case wxWEB_VIEW_ZOOM_LARGE:
284 V_I4(&zoomVariant) = 130;
285 break;
286 case wxWEB_VIEW_ZOOM_LARGEST:
287 V_I4(&zoomVariant) = 160;
288 break;
289 default:
290 wxFAIL;
291 }
61b98a2d 292
8acbf08b
SL
293#if wxDEBUG_LEVEL
294 HRESULT result =
295#endif
296 m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
297 OLECMDEXECOPT_DODEFAULT,
298 &zoomVariant,
299 NULL);
c5f417cb 300 wxASSERT(result == S_OK);
61b98a2d
SL
301}
302
e669ddde 303wxWebViewZoom wxWebViewIE::GetIEOpticalZoom() const
61b98a2d 304{
61b98a2d
SL
305 VARIANT zoomVariant;
306 VariantInit (&zoomVariant);
307 V_VT(&zoomVariant) = VT_I4;
61b98a2d 308
8acbf08b
SL
309#if wxDEBUG_LEVEL
310 HRESULT result =
311#endif
312 m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
313 OLECMDEXECOPT_DODEFAULT, NULL,
314 &zoomVariant);
c5f417cb 315 wxASSERT(result == S_OK);
61b98a2d
SL
316
317 const int zoom = V_I4(&zoomVariant);
61b98a2d 318
c5f417cb
SL
319 //We make a somewhat arbitray map here, taken from values used by webkit
320 if (zoom <= 65)
321 {
322 return wxWEB_VIEW_ZOOM_TINY;
323 }
324 else if (zoom > 65 && zoom <= 90)
325 {
326 return wxWEB_VIEW_ZOOM_SMALL;
327 }
328 else if (zoom > 90 && zoom <= 115)
329 {
330 return wxWEB_VIEW_ZOOM_MEDIUM;
331 }
332 else if (zoom > 115 && zoom <= 145)
333 {
334 return wxWEB_VIEW_ZOOM_LARGE;
335 }
423adfde 336 else /*if (zoom > 145) */ //Using else removes a compiler warning
c5f417cb
SL
337 {
338 return wxWEB_VIEW_ZOOM_LARGEST;
339 }
61b98a2d
SL
340}
341
c5f417cb 342void wxWebViewIE::SetZoomType(wxWebViewZoomType type)
61b98a2d 343{
c5f417cb 344 m_zoomType = type;
61b98a2d
SL
345}
346
347wxWebViewZoomType wxWebViewIE::GetZoomType() const
348{
c5f417cb 349 return m_zoomType;
61b98a2d
SL
350}
351
cd4e4673 352bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type) const
61b98a2d 353{
cd4e4673
SL
354 //IE 6 and below only support text zoom, so check the registry to see what
355 //version we actually have
356 wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer");
357 wxString value;
358 key.QueryValue("Version", value);
359
360 long version = wxAtoi(value.Left(1));
361 if(version <= 6 && type == wxWEB_VIEW_ZOOM_TYPE_LAYOUT)
362 return false;
363 else
364 return true;
61b98a2d
SL
365}
366
367void wxWebViewIE::Print()
368{
369 m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW,
370 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
371}
372
e669ddde 373bool wxWebViewIE::CanGoBack() const
61b98a2d 374{
74af0b13
SL
375 if(m_historyEnabled)
376 return m_historyPosition > 0;
377 else
378 return false;
379}
61b98a2d 380
e669ddde 381bool wxWebViewIE::CanGoForward() const
74af0b13
SL
382{
383 if(m_historyEnabled)
22ca10fa 384 return m_historyPosition != static_cast<int>(m_historyList.size()) - 1;
74af0b13
SL
385 else
386 return false;
61b98a2d
SL
387}
388
c13d6ac1 389void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
61b98a2d 390{
74af0b13
SL
391 int pos = -1;
392 for(unsigned int i = 0; i < m_historyList.size(); i++)
393 {
3e7968c2
SL
394 //We compare the actual pointers to find the correct item
395 if(m_historyList[i].get() == item.get())
74af0b13
SL
396 pos = i;
397 }
1d7d04d7 398 wxASSERT_MSG(pos != static_cast<int>(m_historyList.size()),
22ca10fa 399 "invalid history item");
74af0b13 400 m_historyLoadingFromList = true;
4d0dddc7 401 LoadURL(item->GetUrl());
74af0b13
SL
402 m_historyPosition = pos;
403}
61b98a2d 404
c13d6ac1 405wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetBackwardHistory()
5cbda74b 406{
c13d6ac1 407 wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
5cbda74b
SL
408 //As we don't have std::copy or an iterator constructor in the wxwidgets
409 //native vector we construct it by hand
410 for(int i = 0; i < m_historyPosition; i++)
411 {
412 backhist.push_back(m_historyList[i]);
413 }
414 return backhist;
415}
416
c13d6ac1 417wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewIE::GetForwardHistory()
5cbda74b 418{
c13d6ac1 419 wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
5cbda74b
SL
420 //As we don't have std::copy or an iterator constructor in the wxwidgets
421 //native vector we construct it by hand
22ca10fa 422 for(int i = m_historyPosition + 1; i < static_cast<int>(m_historyList.size()); i++)
5cbda74b
SL
423 {
424 forwardhist.push_back(m_historyList[i]);
425 }
426 return forwardhist;
427}
428
74af0b13
SL
429void wxWebViewIE::GoBack()
430{
3e7968c2 431 LoadHistoryItem(m_historyList[m_historyPosition - 1]);
74af0b13
SL
432}
433
434void wxWebViewIE::GoForward()
435{
3e7968c2 436 LoadHistoryItem(m_historyList[m_historyPosition + 1]);
61b98a2d
SL
437}
438
439void wxWebViewIE::Stop()
440{
7fbc727b 441 m_ie.CallMethod("Stop");
61b98a2d
SL
442}
443
74af0b13
SL
444void wxWebViewIE::ClearHistory()
445{
446 m_historyList.clear();
447 m_historyPosition = -1;
448}
449
450void wxWebViewIE::EnableHistory(bool enable)
451{
452 m_historyEnabled = enable;
453 m_historyList.clear();
454 m_historyPosition = -1;
455}
61b98a2d
SL
456
457void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
458{
7aa18fc7
SL
459 VARIANTARG level;
460 VariantInit(&level);
461 V_VT(&level) = VT_I2;
61b98a2d 462
7aa18fc7 463 switch(flags)
61b98a2d 464 {
7aa18fc7
SL
465 case wxWEB_VIEW_RELOAD_DEFAULT:
466 V_I2(&level) = REFRESH_NORMAL;
467 break;
468 case wxWEB_VIEW_RELOAD_NO_CACHE:
469 V_I2(&level) = REFRESH_COMPLETELY;
470 break;
471 default:
472 wxFAIL_MSG("Unexpected reload type");
61b98a2d
SL
473 }
474
7aa18fc7 475 m_webBrowser->Refresh2(&level);
61b98a2d
SL
476}
477
478bool wxWebViewIE::IsOfflineMode()
479{
480 wxVariant out = m_ie.GetProperty("Offline");
481
482 wxASSERT(out.GetType() == "bool");
483
484 return out.GetBool();
485}
486
487void wxWebViewIE::SetOfflineMode(bool offline)
488{
489 // FIXME: the wxWidgets docs do not really document what the return
490 // parameter of PutProperty is
8acbf08b
SL
491#if wxDEBUG_LEVEL
492 const bool success =
493#endif
494 m_ie.PutProperty("Offline", (offline ?
495 VARIANT_TRUE :
496 VARIANT_FALSE));
61b98a2d
SL
497 wxASSERT(success);
498}
499
e669ddde 500bool wxWebViewIE::IsBusy() const
60eabdbe 501{
61b98a2d
SL
502 if (m_isBusy) return true;
503
504 wxVariant out = m_ie.GetProperty("Busy");
505
506 wxASSERT(out.GetType() == "bool");
507
508 return out.GetBool();
509}
510
e669ddde 511wxString wxWebViewIE::GetCurrentURL() const
61b98a2d
SL
512{
513 wxVariant out = m_ie.GetProperty("LocationURL");
514
515 wxASSERT(out.GetType() == "string");
516 return out.GetString();
517}
518
e669ddde 519wxString wxWebViewIE::GetCurrentTitle() const
61b98a2d 520{
617227c3 521 IHTMLDocument2* document = GetDocument();
977c5320 522 BSTR title;
7fbc727b 523
977c5320 524 document->get_nameProp(&title);
7fbc727b 525 document->Release();
977c5320 526 return wxString(title);
61b98a2d
SL
527}
528
e669ddde 529bool wxWebViewIE::CanCut() const
4681a3ea
SL
530{
531 return CanExecCommand("Cut");
532}
533
e669ddde 534bool wxWebViewIE::CanCopy() const
4681a3ea
SL
535{
536 return CanExecCommand("Copy");
537}
e669ddde 538bool wxWebViewIE::CanPaste() const
4681a3ea
SL
539{
540 return CanExecCommand("Paste");
541}
542
543void wxWebViewIE::Cut()
544{
545 ExecCommand("Cut");
546}
547
548void wxWebViewIE::Copy()
549{
550 ExecCommand("Copy");
551}
552
553void wxWebViewIE::Paste()
554{
555 ExecCommand("Paste");
556}
557
e669ddde 558bool wxWebViewIE::CanUndo() const
97e49559
SL
559{
560 return CanExecCommand("Undo");
561}
e669ddde 562bool wxWebViewIE::CanRedo() const
97e49559
SL
563{
564 return CanExecCommand("Redo");
565}
566
567void wxWebViewIE::Undo()
568{
569 ExecCommand("Undo");
570}
571
572void wxWebViewIE::Redo()
573{
574 ExecCommand("Redo");
575}
576
c7cbe308
SL
577void wxWebViewIE::SetEditable(bool enable)
578{
579 IHTMLDocument2* document = GetDocument();
580 if( enable )
581 document->put_designMode(SysAllocString(L"On"));
582 else
583 document->put_designMode(SysAllocString(L"Off"));
7fbc727b
SL
584
585 document->Release();
c7cbe308
SL
586}
587
e669ddde 588bool wxWebViewIE::IsEditable() const
c7cbe308
SL
589{
590 IHTMLDocument2* document = GetDocument();
591 BSTR mode;
592 document->get_designMode(&mode);
423adfde 593 document->Release();
c7cbe308
SL
594 if(wxString(mode) == "On")
595 return true;
596 else
597 return false;
598}
599
63a65070
SL
600void wxWebViewIE::SelectAll()
601{
602 ExecCommand("SelectAll");
603}
604
e669ddde 605bool wxWebViewIE::HasSelection() const
63a65070
SL
606{
607 IHTMLDocument2* document = GetDocument();
608 IHTMLSelectionObject* selection;
423adfde 609 wxString sel;
7fbc727b
SL
610 HRESULT hr = document->get_selection(&selection);
611 if(SUCCEEDED(hr))
612 {
423adfde 613 BSTR type;
7fbc727b 614 selection->get_type(&type);
423adfde 615 sel = wxString(type);
7fbc727b
SL
616 selection->Release();
617 }
618 document->Release();
423adfde 619 return sel != "None";
63a65070
SL
620}
621
622void wxWebViewIE::DeleteSelection()
623{
624 ExecCommand("Delete");
625}
626
e669ddde 627wxString wxWebViewIE::GetSelectedText() const
c9355a3d
SL
628{
629 IHTMLDocument2* document = GetDocument();
630 IHTMLSelectionObject* selection;
631 wxString selected;
632 HRESULT hr = document->get_selection(&selection);
633 if(SUCCEEDED(hr))
634 {
635 IDispatch* disrange;
636 hr = selection->createRange(&disrange);
637 if(SUCCEEDED(hr))
638 {
639 IHTMLTxtRange* range;
640 hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
641 if(SUCCEEDED(hr))
642 {
643 BSTR text;
644 range->get_text(&text);
645 selected = wxString(text);
646 range->Release();
647 }
648 disrange->Release();
649 }
650 selection->Release();
651 }
652 document->Release();
653 return selected;
654}
655
e669ddde 656wxString wxWebViewIE::GetSelectedSource() const
0fe8a1b6
SL
657{
658 IHTMLDocument2* document = GetDocument();
659 IHTMLSelectionObject* selection;
660 wxString selected;
661 HRESULT hr = document->get_selection(&selection);
662 if(SUCCEEDED(hr))
663 {
664 IDispatch* disrange;
665 hr = selection->createRange(&disrange);
666 if(SUCCEEDED(hr))
667 {
668 IHTMLTxtRange* range;
669 hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
670 if(SUCCEEDED(hr))
671 {
672 BSTR text;
673 range->get_htmlText(&text);
674 selected = wxString(text);
675 range->Release();
676 }
677 disrange->Release();
678 }
679 selection->Release();
680 }
681 document->Release();
682 return selected;
683}
684
41933aa5
SL
685void wxWebViewIE::ClearSelection()
686{
687 IHTMLDocument2* document = GetDocument();
688 IHTMLSelectionObject* selection;
689 wxString selected;
690 HRESULT hr = document->get_selection(&selection);
691 if(SUCCEEDED(hr))
692 {
693 selection->empty();
694 selection->Release();
695 }
696 document->Release();
697}
698
e669ddde 699wxString wxWebViewIE::GetPageText() const
241b769f
SL
700{
701 IHTMLDocument2* document = GetDocument();
423adfde 702 wxString text;
241b769f
SL
703 IHTMLElement* body;
704 HRESULT hr = document->get_body(&body);
705 if(SUCCEEDED(hr))
706 {
423adfde 707 BSTR out;
241b769f 708 body->get_innerText(&out);
423adfde 709 text = wxString(out);
241b769f
SL
710 body->Release();
711 }
712 document->Release();
423adfde 713 return text;
241b769f
SL
714}
715
c9ccc09c
SL
716void wxWebViewIE::RunScript(const wxString& javascript)
717{
718 IHTMLDocument2* document = GetDocument();
719 IHTMLWindow2* window;
720 wxString language = "javascript";
721 HRESULT hr = document->get_parentWindow(&window);
722 if(SUCCEEDED(hr))
723 {
724 VARIANT level;
725 VariantInit(&level);
726 V_VT(&level) = VT_EMPTY;
c9a828e7 727 window->execScript(SysAllocString(javascript.wc_str()),
ee8bc1a8 728 SysAllocString(language.wc_str()),
c9a828e7 729 &level);
c9ccc09c
SL
730 }
731 document->Release();
732}
733
7d8d6163 734void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
29365629 735{
e924e848
SL
736 wxDynamicLibrary urlMon(wxT("urlmon.dll"));
737 if(urlMon.HasSymbol(wxT("CoInternetGetSession")))
29365629 738 {
f559d1a2 739 typedef HRESULT (WINAPI *CoInternetGetSession_t)(DWORD, wxIInternetSession**, DWORD);
e924e848
SL
740 wxDYNLIB_FUNCTION(CoInternetGetSession_t, CoInternetGetSession, urlMon);
741
742 ClassFactory* cf = new ClassFactory(handler);
f559d1a2 743 wxIInternetSession* session;
e924e848
SL
744 HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
745 if(FAILED(res))
746 {
747 wxFAIL_MSG("Could not retrive internet session");
748 }
29365629 749
c9a828e7
VZ
750 HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol,
751 handler->GetName().wc_str(),
752 0, NULL, 0);
e924e848
SL
753 if(FAILED(hr))
754 {
755 wxFAIL_MSG("Could not register protocol");
756 }
39498710 757 m_factories.push_back(cf);
e924e848
SL
758 }
759 else
29365629 760 {
e924e848 761 wxFAIL_MSG("urlmon does not contain CoInternetGetSession");
29365629
SL
762 }
763}
764
e669ddde 765bool wxWebViewIE::CanExecCommand(wxString command) const
4681a3ea 766{
617227c3 767 IHTMLDocument2* document = GetDocument();
4681a3ea 768 VARIANT_BOOL enabled;
7fbc727b 769
4681a3ea 770 document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
7fbc727b 771 document->Release();
4681a3ea
SL
772
773 return (enabled == VARIANT_TRUE);
774}
775
776void wxWebViewIE::ExecCommand(wxString command)
777{
617227c3
SL
778 IHTMLDocument2* document = GetDocument();
779 document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
7fbc727b 780 document->Release();
617227c3 781}
4681a3ea 782
e669ddde 783IHTMLDocument2* wxWebViewIE::GetDocument() const
617227c3
SL
784{
785 wxVariant variant = m_ie.GetProperty("Document");
786 IHTMLDocument2* document = (IHTMLDocument2*)variant.GetVoidPtr();
4681a3ea 787
617227c3
SL
788 wxASSERT(document);
789
790 return document;
4681a3ea
SL
791}
792
61b98a2d
SL
793void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
794{
795 if (m_webBrowser == NULL) return;
796
797 switch (evt.GetDispatchId())
798 {
799 case DISPID_BEFORENAVIGATE2:
800 {
801 m_isBusy = true;
802
803 wxString url = evt[1].GetString();
804 wxString target = evt[3].GetString();
805
04fa04d8 806 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
3225a4b8 807 GetId(), url, target);
e11b9a6b
SL
808
809 //skip empty javascript events.
810 if(url == "javascript:\"\"" && target.IsEmpty())
811 {
812 event.Veto();
813 }
814 else
815 {
816 event.SetEventObject(this);
817 HandleWindowEvent(event);
818 }
61b98a2d 819
3225a4b8 820 if (!event.IsAllowed())
61b98a2d
SL
821 {
822 wxActiveXEventNativeMSW* nativeParams =
823 evt.GetNativeParameters();
824 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
825 }
826
827 // at this point, either the navigation event has been cancelled
828 // and we're not busy, either it was accepted and IWebBrowser2's
829 // Busy property will be true; so we don't need our override
830 // flag anymore.
831 m_isBusy = false;
832
833 break;
834 }
835
836 case DISPID_NAVIGATECOMPLETE2:
837 {
838 wxString url = evt[1].GetString();
839 // TODO: set target parameter if possible
840 wxString target = wxEmptyString;
04fa04d8 841 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
3225a4b8 842 GetId(), url, target);
61b98a2d
SL
843 event.SetEventObject(this);
844 HandleWindowEvent(event);
845 break;
846 }
847
848 case DISPID_PROGRESSCHANGE:
849 {
850 // download progress
851 break;
852 }
853
854 case DISPID_DOCUMENTCOMPLETE:
855 {
3ee442ff
SL
856 //Only send a complete even if we are actually finished, this brings
857 //the event in to line with webkit
858 READYSTATE rs;
859 m_webBrowser->get_ReadyState( &rs );
860 if(rs != READYSTATE_COMPLETE)
861 break;
862
61b98a2d 863 wxString url = evt[1].GetString();
113e0a92
SL
864
865 //As we are complete we also add to the history list, but not if the
866 //page is not the main page, ie it is a subframe
60eabdbe 867 //We also have to check if we are loading a file:// url, if so we
f239a200
SL
868 //need to change the comparison as ie passes back a different style
869 //of url
60eabdbe
VZ
870 if(m_historyEnabled && !m_historyLoadingFromList &&
871 (url == GetCurrentURL() ||
872 (GetCurrentURL().substr(0, 4) == "file" &&
f239a200 873 wxFileSystem::URLToFileName(GetCurrentURL()).GetFullPath() == url)))
74af0b13
SL
874 {
875 //If we are not at the end of the list, then erase everything
876 //between us and the end before adding the new page
22ca10fa 877 if(m_historyPosition != static_cast<int>(m_historyList.size()) - 1)
74af0b13
SL
878 {
879 m_historyList.erase(m_historyList.begin() + m_historyPosition + 1,
880 m_historyList.end());
881 }
c13d6ac1 882 wxSharedPtr<wxWebViewHistoryItem> item(new wxWebViewHistoryItem(url, GetCurrentTitle()));
74af0b13
SL
883 m_historyList.push_back(item);
884 m_historyPosition++;
885 }
886 //Reset as we are done now
887 m_historyLoadingFromList = false;
61b98a2d
SL
888 // TODO: set target parameter if possible
889 wxString target = wxEmptyString;
04fa04d8 890 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
3225a4b8 891 url, target);
61b98a2d
SL
892 event.SetEventObject(this);
893 HandleWindowEvent(event);
894 break;
895 }
896
897 case DISPID_STATUSTEXTCHANGE:
898 {
899 break;
900 }
901
902 case DISPID_TITLECHANGE:
903 {
153530af
SL
904 wxString title = evt[0].GetString();
905
04fa04d8 906 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
3225a4b8 907 GetId(), GetCurrentURL(), "");
153530af
SL
908 event.SetString(title);
909 event.SetEventObject(this);
910 HandleWindowEvent(event);
61b98a2d
SL
911 break;
912 }
913
914 case DISPID_NAVIGATEERROR:
915 {
04fa04d8 916 wxWebViewNavigationError errorType = wxWEB_NAV_ERR_OTHER;
61b98a2d
SL
917 wxString errorCode = "?";
918 switch (evt[3].GetLong())
919 {
920 case INET_E_INVALID_URL: // (0x800C0002L or -2146697214)
921 errorCode = "INET_E_INVALID_URL";
922 errorType = wxWEB_NAV_ERR_REQUEST;
923 break;
924 case INET_E_NO_SESSION: // (0x800C0003L or -2146697213)
925 errorCode = "INET_E_NO_SESSION";
926 errorType = wxWEB_NAV_ERR_CONNECTION;
927 break;
928 case INET_E_CANNOT_CONNECT: // (0x800C0004L or -2146697212)
929 errorCode = "INET_E_CANNOT_CONNECT";
930 errorType = wxWEB_NAV_ERR_CONNECTION;
931 break;
932 case INET_E_RESOURCE_NOT_FOUND: // (0x800C0005L or -2146697211)
933 errorCode = "INET_E_RESOURCE_NOT_FOUND";
934 errorType = wxWEB_NAV_ERR_NOT_FOUND;
935 break;
936 case INET_E_OBJECT_NOT_FOUND: // (0x800C0006L or -2146697210)
937 errorCode = "INET_E_OBJECT_NOT_FOUND";
938 errorType = wxWEB_NAV_ERR_NOT_FOUND;
939 break;
940 case INET_E_DATA_NOT_AVAILABLE: // (0x800C0007L or -2146697209)
941 errorCode = "INET_E_DATA_NOT_AVAILABLE";
942 errorType = wxWEB_NAV_ERR_NOT_FOUND;
943 break;
944 case INET_E_DOWNLOAD_FAILURE: // (0x800C0008L or -2146697208)
945 errorCode = "INET_E_DOWNLOAD_FAILURE";
946 errorType = wxWEB_NAV_ERR_CONNECTION;
947 break;
948 case INET_E_AUTHENTICATION_REQUIRED: // (0x800C0009L or -2146697207)
949 errorCode = "INET_E_AUTHENTICATION_REQUIRED";
950 errorType = wxWEB_NAV_ERR_AUTH;
951 break;
952 case INET_E_NO_VALID_MEDIA: // (0x800C000AL or -2146697206)
953 errorCode = "INET_E_NO_VALID_MEDIA";
954 errorType = wxWEB_NAV_ERR_REQUEST;
955 break;
956 case INET_E_CONNECTION_TIMEOUT: // (0x800C000BL or -2146697205)
957 errorCode = "INET_E_CONNECTION_TIMEOUT";
958 errorType = wxWEB_NAV_ERR_CONNECTION;
959 break;
960 case INET_E_INVALID_REQUEST: // (0x800C000CL or -2146697204)
961 errorCode = "INET_E_INVALID_REQUEST";
962 errorType = wxWEB_NAV_ERR_REQUEST;
963 break;
964 case INET_E_UNKNOWN_PROTOCOL: // (0x800C000DL or -2146697203)
965 errorCode = "INET_E_UNKNOWN_PROTOCOL";
966 errorType = wxWEB_NAV_ERR_REQUEST;
967 break;
968 case INET_E_SECURITY_PROBLEM: // (0x800C000EL or -2146697202)
969 errorCode = "INET_E_SECURITY_PROBLEM";
970 errorType = wxWEB_NAV_ERR_SECURITY;
971 break;
972 case INET_E_CANNOT_LOAD_DATA: // (0x800C000FL or -2146697201)
973 errorCode = "INET_E_CANNOT_LOAD_DATA";
974 errorType = wxWEB_NAV_ERR_OTHER;
975 break;
976 case INET_E_CANNOT_INSTANTIATE_OBJECT:
977 // CoCreateInstance will return an error code if this happens,
978 // we'll handle this above.
979 return;
980 break;
981 case INET_E_REDIRECT_FAILED: // (0x800C0014L or -2146697196)
982 errorCode = "INET_E_REDIRECT_FAILED";
983 errorType = wxWEB_NAV_ERR_OTHER;
984 break;
985 case INET_E_REDIRECT_TO_DIR: // (0x800C0015L or -2146697195)
986 errorCode = "INET_E_REDIRECT_TO_DIR";
987 errorType = wxWEB_NAV_ERR_REQUEST;
988 break;
989 case INET_E_CANNOT_LOCK_REQUEST: // (0x800C0016L or -2146697194)
990 errorCode = "INET_E_CANNOT_LOCK_REQUEST";
991 errorType = wxWEB_NAV_ERR_OTHER;
992 break;
993 case INET_E_USE_EXTEND_BINDING: // (0x800C0017L or -2146697193)
994 errorCode = "INET_E_USE_EXTEND_BINDING";
995 errorType = wxWEB_NAV_ERR_OTHER;
996 break;
997 case INET_E_TERMINATED_BIND: // (0x800C0018L or -2146697192)
998 errorCode = "INET_E_TERMINATED_BIND";
999 errorType = wxWEB_NAV_ERR_OTHER;
1000 break;
1001 case INET_E_INVALID_CERTIFICATE: // (0x800C0019L or -2146697191)
1002 errorCode = "INET_E_INVALID_CERTIFICATE";
1003 errorType = wxWEB_NAV_ERR_CERTIFICATE;
1004 break;
1005 case INET_E_CODE_DOWNLOAD_DECLINED: // (0x800C0100L or -2146696960)
1006 errorCode = "INET_E_CODE_DOWNLOAD_DECLINED";
1007 errorType = wxWEB_NAV_ERR_USER_CANCELLED;
1008 break;
1009 case INET_E_RESULT_DISPATCHED: // (0x800C0200L or -2146696704)
1010 // cancel request cancelled...
1011 errorCode = "INET_E_RESULT_DISPATCHED";
1012 errorType = wxWEB_NAV_ERR_OTHER;
1013 break;
1014 case INET_E_CANNOT_REPLACE_SFP_FILE: // (0x800C0300L or -2146696448)
1015 errorCode = "INET_E_CANNOT_REPLACE_SFP_FILE";
1016 errorType = wxWEB_NAV_ERR_SECURITY;
1017 break;
1018 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY:
1019 errorCode = "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
1020 errorType = wxWEB_NAV_ERR_SECURITY;
1021 break;
1022 case INET_E_CODE_INSTALL_SUPPRESSED:
1023 errorCode = "INET_E_CODE_INSTALL_SUPPRESSED";
1024 errorType = wxWEB_NAV_ERR_SECURITY;
1025 break;
1026 }
1027
1028 wxString url = evt[1].GetString();
1029 wxString target = evt[2].GetString();
04fa04d8 1030 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
3225a4b8 1031 url, target);
61b98a2d
SL
1032 event.SetEventObject(this);
1033 event.SetInt(errorType);
1034 event.SetString(errorCode);
1035 HandleWindowEvent(event);
1036 break;
1037 }
853b6cd0 1038 case DISPID_NEWWINDOW3:
61b98a2d 1039 {
853b6cd0
SL
1040 wxString url = evt[4].GetString();
1041
04fa04d8 1042 wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
3225a4b8 1043 GetId(), url, wxEmptyString);
853b6cd0
SL
1044 event.SetEventObject(this);
1045 HandleWindowEvent(event);
1046
d676fb21
SL
1047 //We always cancel this event otherwise an Internet Exporer window
1048 //is opened for the url
1049 wxActiveXEventNativeMSW* nativeParams = evt.GetNativeParameters();
1050 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[3]) = VARIANT_TRUE;
be19c556
SL
1051 break;
1052 }
61b98a2d
SL
1053 }
1054
1055 evt.Skip();
1056}
1057
7d8d6163 1058VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
7d3f6b4d 1059{
7d3f6b4d 1060 m_file = NULL;
29365629 1061 m_handler = handler;
7d3f6b4d
SL
1062}
1063
9f194b9d
SL
1064BEGIN_IID_TABLE(VirtualProtocol)
1065 ADD_IID(Unknown)
1066 ADD_RAW_IID(wxIID_IInternetProtocolRoot)
1067 ADD_RAW_IID(wxIID_IInternetProtocol)
1068END_IID_TABLE;
7d3f6b4d 1069
9f194b9d 1070IMPLEMENT_IUNKNOWN_METHODS(VirtualProtocol)
7d3f6b4d 1071
f559d1a2
VZ
1072HRESULT VirtualProtocol::Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink,
1073 wxIInternetBindInfo *pOIBindInfo, DWORD grfPI,
0995b9dc 1074 HANDLE_PTR dwReserved)
7d3f6b4d 1075{
0995b9dc
SL
1076 wxUnusedVar(szUrl);
1077 wxUnusedVar(pOIBindInfo);
1078 wxUnusedVar(grfPI);
1079 wxUnusedVar(dwReserved);
7d3f6b4d 1080 m_protocolSink = pOIProtSink;
60eabdbe 1081
29365629
SL
1082 //We get the file itself from the protocol handler
1083 m_file = m_handler->GetFile(szUrl);
1084
7d3f6b4d
SL
1085
1086 if(!m_file)
1087 return INET_E_RESOURCE_NOT_FOUND;
1088
1089 //We return the stream length for current and total size as we can always
1090 //read the whole file from the stream
666f73c4 1091 wxFileOffset length = m_file->GetStream()->GetLength();
f559d1a2
VZ
1092 m_protocolSink->ReportData(wxBSCF_FIRSTDATANOTIFICATION |
1093 wxBSCF_DATAFULLYAVAILABLE |
1094 wxBSCF_LASTDATANOTIFICATION,
666f73c4 1095 length, length);
60eabdbe 1096 return S_OK;
7d3f6b4d
SL
1097}
1098
1099HRESULT VirtualProtocol::Read(void *pv, ULONG cb, ULONG *pcbRead)
1100{
1101 //If the file is null we return false to indicte it is finished
60eabdbe 1102 if(!m_file)
7d3f6b4d
SL
1103 return S_FALSE;
1104
1105 wxStreamError err = m_file->GetStream()->Read(pv, cb).GetLastError();
1106 *pcbRead = m_file->GetStream()->LastRead();
1107
1108 if(err == wxSTREAM_NO_ERROR)
1109 {
1110 if(*pcbRead < cb)
1111 {
1112 wxDELETE(m_file);
1113 m_protocolSink->ReportResult(S_OK, 0, NULL);
1114 }
1115 //As we are not eof there is more data
1116 return S_OK;
1117 }
1118 else if(err == wxSTREAM_EOF)
1119 {
1120 wxDELETE(m_file);
1121 m_protocolSink->ReportResult(S_OK, 0, NULL);
1122 //We are eof and so finished
1123 return S_OK;
1124 }
1125 else if(err == wxSTREAM_READ_ERROR)
1126 {
1127 wxDELETE(m_file);
1128 return INET_E_DOWNLOAD_FAILURE;
1129 }
0995b9dc
SL
1130 else
1131 {
1132 //Dummy return to surpress a compiler warning
1133 wxFAIL;
1134 return INET_E_DOWNLOAD_FAILURE;
1135 }
7d3f6b4d
SL
1136}
1137
9f194b9d
SL
1138BEGIN_IID_TABLE(ClassFactory)
1139 ADD_IID(Unknown)
1140 ADD_IID(ClassFactory)
1141END_IID_TABLE;
1142
1143IMPLEMENT_IUNKNOWN_METHODS(ClassFactory)
1144
7d3f6b4d
SL
1145HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid,
1146 void ** ppvObject)
1147{
60eabdbe 1148 if (pUnkOuter)
7d3f6b4d 1149 return CLASS_E_NOAGGREGATION;
29365629 1150 VirtualProtocol* vp = new VirtualProtocol(m_handler);
7d3f6b4d
SL
1151 vp->AddRef();
1152 HRESULT hr = vp->QueryInterface(riid, ppvObject);
1153 vp->Release();
1154 return hr;
1155
60eabdbe 1156}
7d3f6b4d
SL
1157
1158STDMETHODIMP ClassFactory::LockServer(BOOL fLock)
1159{
0995b9dc
SL
1160 wxUnusedVar(fLock);
1161 return S_OK;
7d3f6b4d
SL
1162}
1163
accc94d5
SL
1164wxIEContainer::wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk,
1165 DocHostUIHandler* uiHandler) :
1166 wxActiveXContainer(parent,iid,pUnk)
1167{
1168 m_uiHandler = uiHandler;
1169}
1170
1171wxIEContainer::~wxIEContainer()
1172{
1173}
1174
1175bool wxIEContainer::QueryClientSiteInterface(REFIID iid, void **_interface,
1176 const char *&desc)
1177{
1178 if (m_uiHandler && IsEqualIID(iid, wxIID_IDocHostUIHandler))
1179 {
1180 *_interface = (IUnknown *) (wxIDocHostUIHandler *) m_uiHandler;
1181 desc = "IDocHostUIHandler";
1182 return true;
1183 }
1184 return false;
1185}
1186
1187HRESULT DocHostUIHandler::ShowContextMenu(DWORD dwID, POINT *ppt,
1188 IUnknown *pcmdtReserved,
1189 IDispatch *pdispReserved)
1190{
1191 wxUnusedVar(dwID);
1192 wxUnusedVar(ppt);
1193 wxUnusedVar(pcmdtReserved);
1194 wxUnusedVar(pdispReserved);
1195 return E_NOTIMPL;
1196}
1197
1198HRESULT DocHostUIHandler::GetHostInfo(DOCHOSTUIINFO *pInfo)
1199{
1200 //don't show 3d border and ebales themes.
1201 pInfo->dwFlags = pInfo->dwFlags | DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME;
1202 return S_OK;
1203}
1204
1205HRESULT DocHostUIHandler::ShowUI(DWORD dwID,
1206 IOleInPlaceActiveObject *pActiveObject,
1207 IOleCommandTarget *pCommandTarget,
1208 IOleInPlaceFrame *pFrame,
1209 IOleInPlaceUIWindow *pDoc)
1210{
1211 wxUnusedVar(dwID);
1212 wxUnusedVar(pActiveObject);
1213 wxUnusedVar(pCommandTarget);
1214 wxUnusedVar(pFrame);
1215 wxUnusedVar(pDoc);
1216 return S_FALSE;
1217}
1218
1219HRESULT DocHostUIHandler::HideUI(void)
1220{
1221 return E_NOTIMPL;
1222}
1223
1224HRESULT DocHostUIHandler::UpdateUI(void)
1225{
1226 return E_NOTIMPL;
1227}
1228
1229HRESULT DocHostUIHandler::EnableModeless(BOOL fEnable)
1230{
1231 wxUnusedVar(fEnable);
1232 return E_NOTIMPL;
1233}
1234
1235HRESULT DocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
1236{
1237 wxUnusedVar(fActivate);
1238 return E_NOTIMPL;
1239}
1240
1241HRESULT DocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
1242{
1243 wxUnusedVar(fActivate);
1244 return E_NOTIMPL;
1245}
1246
1247HRESULT DocHostUIHandler::ResizeBorder(LPCRECT prcBorder,
1248 IOleInPlaceUIWindow *pUIWindow,
1249 BOOL fFrameWindow)
1250{
1251 wxUnusedVar(prcBorder);
1252 wxUnusedVar(pUIWindow);
1253 wxUnusedVar(fFrameWindow);
1254 return E_NOTIMPL;
1255}
1256
1257HRESULT DocHostUIHandler::TranslateAccelerator(LPMSG lpMsg,
1258 const GUID *pguidCmdGroup,
1259 DWORD nCmdID)
1260{
1261 if(lpMsg && lpMsg->message == WM_KEYDOWN)
1262 {
1263 //control is down?
1264 if((GetKeyState(VK_CONTROL) & 0x8000 ))
1265 {
1266 //skip CTRL-N, CTRL-F and CTRL-P
1267 if(lpMsg->wParam == 'N' || lpMsg->wParam == 'P' || lpMsg->wParam == 'F')
1268 {
1269 return S_OK;
1270 }
1271 }
1272 //skip F5
1273 if(lpMsg->wParam == VK_F5)
1274 {
1275 return S_OK;
1276 }
1277 }
1278
1279 wxUnusedVar(pguidCmdGroup);
1280 wxUnusedVar(nCmdID);
1281 return E_NOTIMPL;
1282}
1283
1284HRESULT DocHostUIHandler::GetOptionKeyPath(LPOLESTR *pchKey,DWORD dw)
1285{
1286 wxUnusedVar(pchKey);
1287 wxUnusedVar(dw);
1288 return E_NOTIMPL;
1289}
1290
1291HRESULT DocHostUIHandler::GetDropTarget(IDropTarget *pDropTarget,
1292 IDropTarget **ppDropTarget)
1293{
1294 wxUnusedVar(pDropTarget);
1295 wxUnusedVar(ppDropTarget);
1296 return E_NOTIMPL;
1297}
1298
1299HRESULT DocHostUIHandler::GetExternal(IDispatch **ppDispatch)
1300{
1301 wxUnusedVar(ppDispatch);
1302 return E_NOTIMPL;
1303}
1304
1305HRESULT DocHostUIHandler::TranslateUrl(DWORD dwTranslate,
1306 OLECHAR *pchURLIn,
1307 OLECHAR **ppchURLOut)
1308{
1309 wxUnusedVar(dwTranslate);
1310 wxUnusedVar(pchURLIn);
1311 wxUnusedVar(ppchURLOut);
1312 return E_NOTIMPL;
1313}
1314
1315HRESULT DocHostUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
1316{
1317 wxUnusedVar(pDO);
1318 wxUnusedVar(ppDORet);
1319 return E_NOTIMPL;
1320}
1321
1322BEGIN_IID_TABLE(DocHostUIHandler)
1323 ADD_IID(Unknown)
1324 ADD_RAW_IID(wxIID_IDocHostUIHandler)
1325END_IID_TABLE;
1326
1327IMPLEMENT_IUNKNOWN_METHODS(DocHostUIHandler)
1328
9d2f31db 1329#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE