void wxWebViewIE::LoadUrl(const wxString& url)
{
- wxVariant out = m_ie.CallMethod("Navigate", (BSTR) url.wc_str(),
- NULL, NULL, NULL, NULL);
-
- // FIXME: why is out value null??
- //(HRESULT)(out.GetLong()) == S_OK;
+ m_ie.CallMethod("Navigate", (BSTR) url.wc_str(), NULL, NULL, NULL, NULL);
}
-void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
+void wxWebViewIE::SetPage(const wxString& html, const wxString&)
{
LoadUrl("about:blank");
IHTMLDocument2* document = GetDocument();
IHTMLElement *bodyTag = NULL;
IHTMLElement *htmlTag = NULL;
- document->get_body(&bodyTag);
- wxASSERT(bodyTag != NULL);
+ BSTR bstr;
+ HRESULT hr = document->get_body(&bodyTag);
+ if(SUCCEEDED(hr))
+ {
+ hr = bodyTag->get_parentElement(&htmlTag);
+ if(SUCCEEDED(hr))
+ {
+ htmlTag->get_outerHTML(&bstr);
+ htmlTag->Release();
+ }
+ bodyTag->Release();
+ }
document->Release();
- bodyTag->get_parentElement(&htmlTag);
- wxASSERT(htmlTag != NULL);
-
- BSTR bstr;
- htmlTag->get_outerHTML(&bstr);
-
- bodyTag->Release();
- htmlTag->Release();
-
- //wxMessageBox(wxString(bstr));
-
- // TODO: check encoding
return wxString(bstr);
}
wxASSERT (result == S_OK);
int zoom = V_I4(&zoomVariant);
- // wxMessageBox(wxString::Format("Zoom : %i", zoom));
VariantClear (&zoomVariant);
return zoom;
bool wxWebViewIE::CanGoForward()
{
if(m_historyEnabled)
- return m_historyPosition != m_historyList.size() - 1;
+ return m_historyPosition != static_cast<int>(m_historyList.size()) - 1;
else
return false;
}
if(m_historyList[i].get() == item.get())
pos = i;
}
- wxASSERT_MSG(pos != m_historyList.size(), "invalid history item");
+ wxASSERT_MSG(pos != static_cast<int>(m_historyList.size()),
+ "invalid history item");
m_historyLoadingFromList = true;
LoadUrl(item->GetUrl());
m_historyPosition = pos;
wxVector<wxSharedPtr<wxWebHistoryItem> > forwardhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand
- for(int i = m_historyPosition + 1; i < m_historyList.size(); i++)
+ for(int i = m_historyPosition + 1; i < static_cast<int>(m_historyList.size()); i++)
{
forwardhist.push_back(m_historyList[i]);
}
void wxWebViewIE::Stop()
{
- wxVariant out = m_ie.CallMethod("Stop");
-
- // FIXME: why is out value null??
- //return (HRESULT)(out.GetLong()) == S_OK;
+ m_ie.CallMethod("Stop");
}
void wxWebViewIE::ClearHistory()
wxString wxWebViewIE::GetCurrentTitle()
{
IHTMLDocument2* document = GetDocument();
-
BSTR title;
+
document->get_nameProp(&title);
+ document->Release();
return wxString(title);
}
document->put_designMode(SysAllocString(L"On"));
else
document->put_designMode(SysAllocString(L"Off"));
+
+ document->Release();
}
bool wxWebViewIE::IsEditable()
return true;
else
return false;
+
+ document->Release();
}
-bool wxWebViewIE::CanExecCommand(wxString command)
+void wxWebViewIE::SelectAll()
+{
+ ExecCommand("SelectAll");
+}
+
+bool wxWebViewIE::HasSelection()
{
IHTMLDocument2* document = GetDocument();
+ IHTMLSelectionObject* selection;
+ BSTR type;
+ HRESULT hr = document->get_selection(&selection);
+ if(SUCCEEDED(hr))
+ {
+ selection->get_type(&type);
+ selection->Release();
+ }
+ document->Release();
+ return wxString(type) != "None";
+}
+
+void wxWebViewIE::DeleteSelection()
+{
+ ExecCommand("Delete");
+}
+
+wxString wxWebViewIE::GetSelectedText()
+{
+ IHTMLDocument2* document = GetDocument();
+ IHTMLSelectionObject* selection;
+ wxString selected;
+ HRESULT hr = document->get_selection(&selection);
+ if(SUCCEEDED(hr))
+ {
+ IDispatch* disrange;
+ hr = selection->createRange(&disrange);
+ if(SUCCEEDED(hr))
+ {
+ IHTMLTxtRange* range;
+ hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
+ if(SUCCEEDED(hr))
+ {
+ BSTR text;
+ range->get_text(&text);
+ selected = wxString(text);
+ range->Release();
+ }
+ disrange->Release();
+ }
+ selection->Release();
+ }
+ document->Release();
+ return selected;
+}
+bool wxWebViewIE::CanExecCommand(wxString command)
+{
+ IHTMLDocument2* document = GetDocument();
VARIANT_BOOL enabled;
+
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
+ document->Release();
return (enabled == VARIANT_TRUE);
}
{
IHTMLDocument2* document = GetDocument();
document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+ document->Release();
}
IHTMLDocument2* wxWebViewIE::GetDocument()
{
//If we are not at the end of the list, then erase everything
//between us and the end before adding the new page
- if(m_historyPosition != m_historyList.size() - 1)
+ if(m_historyPosition != static_cast<int>(m_historyList.size()) - 1)
{
m_historyList.erase(m_historyList.begin() + m_historyPosition + 1,
m_historyList.end());