From a5f76e94f786ddf25e4e155e630cff4e08c81343 Mon Sep 17 00:00:00 2001 From: "mike%neoplanet.com" Date: Tue, 21 Sep 1999 02:39:53 +0000 Subject: [PATCH] Implemented cut/copy/paste. Added stubs for a couple other functions. git-svn-id: svn://10.0.0.236/trunk@48485 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webshell/embed/ActiveX/MozillaBrowser.cpp | 214 +++++++++++++++--- .../webshell/embed/ActiveX/MozillaBrowser.h | 73 ++++-- mozilla/webshell/embed/ActiveX/StdAfx.h | 4 + .../embed/ActiveX/WebShellContainer.cpp | 31 ++- .../embed/ActiveX/WebShellContainer.h | 2 +- 5 files changed, 263 insertions(+), 61 deletions(-) diff --git a/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp b/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp index 2eb23506256..333ddcf5f95 100644 --- a/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp +++ b/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp @@ -309,20 +309,84 @@ LRESULT CMozillaBrowser::OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, B // Handle ID_PRINT command LRESULT CMozillaBrowser::OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { + nsresult res; + // Print the contents if (m_pIWebShell) { nsIContentViewer *pContentViewer = nsnull; - m_pIWebShell->GetContentViewer(&pContentViewer); - if (nsnull != pContentViewer) + res = m_pIWebShell->GetContentViewer(&pContentViewer); + if ( NS_SUCCEEDED(res) ) { pContentViewer->Print(); NS_RELEASE(pContentViewer); } } + + return res; +} + +LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + MessageBox(_T("No Save As Yet!"), _T("Control Message"), MB_OK); + // TODO show the save as dialog return 0; } +LRESULT CMozillaBrowser::OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + MessageBox(_T("No Properties Yet!"), _T("Control Message"), MB_OK); + // TODO show the properties dialog + return 0; +} + +LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + nsresult res; + + nsIPresShell* presShell = nsnull; + res=GetPresShell(&presShell); //Get the presentation shell for the document + if ( NS_FAILED(res) ) return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr selection; //Get a pointer to the DOM selection + res = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection)); + if ( NS_FAILED(res) ) return res; + + res = presShell->DoCopy(); //Copy the selection to the clipboard + if ( NS_SUCCEEDED(res) ) + { + res = selection->DeleteFromDocument(); //Delete the selection from the document + } + + return res; +} + +LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + nsresult res; + + nsIPresShell* presShell = nsnull; + res=GetPresShell(&presShell); //Get the presentation shell for the document + if ( NS_FAILED(res) ) return NS_ERROR_NOT_INITIALIZED; + + res = presShell->DoCopy(); + + return res; +} + +LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + MessageBox(_T("No Paste Yet!"), _T("Control Message"), MB_OK); + // TODO enable pasting + return 0; +} + +LRESULT CMozillaBrowser::OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + MessageBox(_T("No Select All Yet!"), _T("Control Message"), MB_OK); + // TODO enable Select All + return 0; +} // Handle ID_VIEWSOURCE command LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) @@ -424,7 +488,7 @@ HRESULT CMozillaBrowser::CreateWebShell() rv = nsServiceManager::GetService(kPrefCID, nsIPref::GetIID(), (nsISupports **)&m_pIPref); - if (NS_OK != rv) + if (NS_FAILED(rv)) { NG_ASSERT(0); m_sErrorMessage = _T("Error - could not create preference object"); @@ -435,7 +499,7 @@ HRESULT CMozillaBrowser::CreateWebShell() rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&m_pIWebShell); - if (NS_OK != rv) + if (NS_FAILED(rv)) { NG_ASSERT(0); m_sErrorMessage = _T("Error - could not create web shell, check PATH settings"); @@ -459,7 +523,7 @@ HRESULT CMozillaBrowser::CreateWebShell() nsScrollPreference_kAuto, aAllowPlugins, aIsSunkenBorder); - NG_ASSERT(rv == NS_OK); + NG_ASSERT(NS_SUCCEEDED(rv)); // Create the container object m_pWebShellContainer = new CWebShellContainer(this); @@ -605,6 +669,9 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID) // Returns the presentation shell HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell) { + NG_TRACE_METHOD(CMozillaBrowser::GetPresShell); + nsresult res; + // Test for stupid args if (pPresShell == NULL) { @@ -621,17 +688,18 @@ HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell) } nsIContentViewer* pIContentViewer = nsnull; - m_pIWebShell->GetContentViewer(&pIContentViewer); - if (pIContentViewer != nsnull) + res = m_pIWebShell->GetContentViewer(&pIContentViewer); + if ( NS_SUCCEEDED(res) ) { nsIDocumentViewer* pIDocViewer = nsnull; - if (pIContentViewer->QueryInterface(kIDocumentViewerIID, (void**) &pIDocViewer) == NS_OK) + res = pIContentViewer->QueryInterface(kIDocumentViewerIID, (void**) &pIDocViewer); + if ( NS_SUCCEEDED(res) ) { nsIPresContext * pIPresContent = nsnull; - pIDocViewer->GetPresContext(pIPresContent); - if (pIPresContent != nsnull) + res = pIDocViewer->GetPresContext(pIPresContent); + if ( NS_SUCCEEDED(res) ) { - pIPresContent->GetShell(pPresShell); + res = pIPresContent->GetShell(pPresShell); NS_RELEASE(pIPresContent); } NS_RELEASE(pIDocViewer); @@ -639,13 +707,16 @@ HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell) NS_RELEASE(pIContentViewer); } - return S_OK; + return res; } // Return the root DOM document HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument) { + NG_TRACE_METHOD(CMozillaBrowser::GetDOMDocument); + nsresult res; + // Test for stupid args if (pDocument == NULL) { @@ -662,20 +733,18 @@ HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument) } nsIContentViewer * pCViewer = nsnull; - - m_pIWebShell->GetContentViewer(&pCViewer); - if (nsnull != pCViewer) + res = m_pIWebShell->GetContentViewer(&pCViewer); + if ( NS_SUCCEEDED(res) ) { nsIDocumentViewer * pDViewer = nsnull; - if (pCViewer->QueryInterface(kIDocumentViewerIID, (void**) &pDViewer) == NS_OK) + res = pCViewer->QueryInterface(kIDocumentViewerIID, (void**) &pDViewer); + if ( NS_SUCCEEDED(res) ) { nsIDocument * pDoc = nsnull; - pDViewer->GetDocument(pDoc); - if (pDoc != nsnull) + res = pDViewer->GetDocument(pDoc); + if ( NS_SUCCEEDED(res) ) { - if (pDoc->QueryInterface(kIDOMDocumentIID, (void**) pDocument) == NS_OK) - { - } + res = pDoc->QueryInterface(kIDOMDocumentIID, (void**) pDocument); NS_RELEASE(pDoc); } NS_RELEASE(pDViewer); @@ -683,7 +752,7 @@ HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument) NS_RELEASE(pCViewer); } - return S_OK; + return res; } @@ -1050,6 +1119,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR { NG_TRACE_METHOD(CMozillaBrowser::Navigate); + //Make sure m_pIWebShell is valid if (!IsValid()) { NG_ASSERT(0); @@ -1071,6 +1141,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR } // Check for a view-source op - this is a bit kludgy + // TODO if (sUrl.Compare(L"view-source:", PR_TRUE, 12) == 0) { sUrl.Left(sCommand, 11); @@ -1160,7 +1231,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR // Load the URL char *tmpCommand = sCommand.ToNewCString(); - m_pIWebShell->LoadURL(sUrl.GetUnicode()); + nsresult res = m_pIWebShell->LoadURL(sUrl.GetUnicode()); /* , tmpCommand, pIPostData, bModifyHistory); NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, @@ -1173,7 +1244,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR #endif const PRUint32 aLocalIP=0) = 0; */ - return S_OK; + return res; } @@ -1181,11 +1252,14 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh(void) { NG_TRACE_METHOD(CMozillaBrowser::Refresh); - if (!IsValid()) +//Uneccessary since this gets called again in Refresh2 +#if 0 + if (!IsValid()) { NG_ASSERT(0); RETURN_E_UNEXPECTED(); } +#endif // Reload the page CComVariant vRefreshType(REFRESH_NORMAL); @@ -1338,6 +1412,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Container(IDispatch __RPC_FAR *__ RETURN_E_INVALIDARG(); } + //TODO: Implement get_Container: Retrieve a pointer to the IDispatch interface of the container. *ppDisp = NULL; RETURN_E_UNEXPECTED(); } @@ -1407,7 +1482,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_TopLevelContainer(VARIANT_BOOL __ RETURN_E_INVALIDARG(); } - *pBool = VARIANT_TRUE; + //TODO: Implement get_TopLevelContainer + *pBool = VARIANT_FALSE; return S_OK; } @@ -1422,6 +1498,24 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Type(BSTR __RPC_FAR *Type) RETURN_E_UNEXPECTED(); } + //NOTE: This code should work in theory, but can't be verified because GetDoctype + // has not been implemented yet. +#if 0 + nsIDOMDocument *pIDOMDocument = nsnull; + if ( SUCCEEDED(GetDOMDocument(&pIDOMDocument)) ) + { + nsIDOMDocumentType *pIDOMDocumentType = nsnull; + if ( SUCCEEDED(pIDOMDocument->GetDoctype(&pIDOMDocumentType)) ) + { + nsString docName; + pIDOMDocumentType->GetName(docName); + //NG_TRACE("pIDOMDocumentType returns: %s", docName); + //Still need to manipulate docName so that it goes into *Type param of this function. + } + } +#endif + + //TODO: Implement get_Type RETURN_ERROR(_T("get_Type: failed"), E_FAIL); } @@ -1441,6 +1535,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Left(long __RPC_FAR *pl) NG_ASSERT(0); RETURN_E_INVALIDARG(); } + + //TODO: Implement get_Left - Should return the left position of this control. *pl = 0; return S_OK; } @@ -1474,6 +1570,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Top(long __RPC_FAR *pl) NG_ASSERT(0); RETURN_E_INVALIDARG(); } + + //TODO: Implement get_Top - Should return the top position of this control. *pl = 0; return S_OK; } @@ -1488,6 +1586,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Top(long Top) NG_ASSERT(0); RETURN_E_UNEXPECTED(); } + + //TODO: Implement set_Top - Should set the top position of this control. return S_OK; } @@ -1507,6 +1607,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Width(long __RPC_FAR *pl) NG_ASSERT(0); RETURN_E_INVALIDARG(); } + + //TODO: Implement get_Width- Should return the width of this control. *pl = 0; return S_OK; } @@ -1521,6 +1623,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Width(long Width) NG_ASSERT(0); RETURN_E_UNEXPECTED(); } + + //TODO: Implement put_Width - Should set the width of this control. return S_OK; } @@ -1538,6 +1642,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Height(long __RPC_FAR *pl) { RETURN_E_INVALIDARG(); } + + //TODO: Implement get_Height - Should return the hieght of this control. *pl = 0; return S_OK; } @@ -1552,6 +1658,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Height(long Height) NG_ASSERT(0); RETURN_E_UNEXPECTED(); } + + //TODO: Implement put_Height - Should set the height of this control. return S_OK; } @@ -1658,6 +1766,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Quit(void) RETURN_E_UNEXPECTED(); } + //This generates an exception in the IE control. // TODO fire quit event return S_OK; } @@ -1673,6 +1782,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::ClientToWindow(int __RPC_FAR *pcx, in RETURN_E_UNEXPECTED(); } + //This generates an exception in the IE control. // TODO convert points to be relative to browser return S_OK; } @@ -1762,7 +1872,9 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Name(BSTR __RPC_FAR *Name) { RETURN_E_INVALIDARG(); } - *Name = SysAllocString(L""); // TODO get Mozilla's executable name + + // TODO: Implement get_Name (get Mozilla's executable name) + *Name = SysAllocString(L"Mozilla Web Browser Control"); return S_OK; } @@ -1783,6 +1895,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_HWND(long __RPC_FAR *pHWND) RETURN_E_INVALIDARG(); } + //This generates an exception in the IE control. *pHWND = NULL; return S_OK; } @@ -1803,6 +1916,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_FullName(BSTR __RPC_FAR *FullName { RETURN_E_INVALIDARG(); } + + // TODO: Implement get_FullName (Return the full path of the executable containing this control) *FullName = SysAllocString(L""); // TODO get Mozilla's executable name return S_OK; } @@ -1823,7 +1938,9 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Path(BSTR __RPC_FAR *Path) { RETURN_E_INVALIDARG(); } - *Path = SysAllocString(L""); // TODO get Mozilla's path + + // TODO: Implement get_Path (get Mozilla's path) + *Path = SysAllocString(L""); return S_OK; } @@ -1843,6 +1960,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Visible(VARIANT_BOOL __RPC_FAR *p { RETURN_E_INVALIDARG(); } + + //TODO: Implement get_Visible *pBool = VARIANT_FALSE; return S_OK; } @@ -1858,6 +1977,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Visible(VARIANT_BOOL Value) RETURN_E_UNEXPECTED(); } + //TODO: Implement put_Visible return S_OK; } @@ -1877,6 +1997,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_StatusBar(VARIANT_BOOL __RPC_FAR { RETURN_E_INVALIDARG(); } + + //There is no StatusBar in this control. *pBool = VARIANT_FALSE; return S_OK; } @@ -1892,6 +2014,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_StatusBar(VARIANT_BOOL Value) RETURN_E_UNEXPECTED(); } + //There is no StatusBar in this control. return S_OK; } @@ -1911,7 +2034,9 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_StatusText(BSTR __RPC_FAR *Status { RETURN_E_INVALIDARG(); } - *StatusText = SysAllocString(L""); // TODO + + //TODO: Implement get_StatusText + *StatusText = SysAllocString(L""); return S_OK; } @@ -1926,6 +2051,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_StatusText(BSTR StatusText) RETURN_E_UNEXPECTED(); } + //TODO: Implement put_StatusText return S_OK; } @@ -1945,6 +2071,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_ToolBar(int __RPC_FAR *Value) { RETURN_E_INVALIDARG(); } + + //There is no ToolBar in this control. *Value = FALSE; return S_OK; } @@ -1960,7 +2088,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_ToolBar(int Value) RETURN_E_UNEXPECTED(); } - // No toolbar in control! + //There is no ToolBar in this control. return S_OK; } @@ -1980,6 +2108,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_MenuBar(VARIANT_BOOL __RPC_FAR *V { RETURN_E_INVALIDARG(); } + + //There is no MenuBar in this control. *Value = VARIANT_FALSE; return S_OK; } @@ -1995,7 +2125,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_MenuBar(VARIANT_BOOL Value) RETURN_E_UNEXPECTED(); } - // No menu in control! + //There is no MenuBar in this control. return S_OK; } @@ -2015,6 +2145,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_FullScreen(VARIANT_BOOL __RPC_FAR { RETURN_E_INVALIDARG(); } + + //FullScreen mode doesn't really apply to this control. *pbFullScreen = VARIANT_FALSE; return S_OK; } @@ -2030,7 +2162,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_FullScreen(VARIANT_BOOL bFullScre RETURN_E_UNEXPECTED(); } - // No fullscreen mode in control! + //FullScreen mode doesn't really apply to this control. return S_OK; } @@ -2043,6 +2175,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate2(VARIANT __RPC_FAR *URL, VAR { NG_TRACE_METHOD(CMozillaBrowser::Navigate2); +//Redundant code... taken care of in CMozillaBrowser::Navigate +#if 0 if (!IsValid()) { NG_ASSERT(0); @@ -2055,6 +2189,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate2(VARIANT __RPC_FAR *URL, VAR RETURN_E_INVALIDARG(); } +#endif + CComVariant vURLAsString; if (vURLAsString.ChangeType(VT_BSTR, URL) != S_OK) { @@ -2159,6 +2295,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Offline(VARIANT_BOOL __RPC_FAR *p RETURN_E_INVALIDARG(); } + //TODO: Implement get_Offline *pbOffline = VARIANT_FALSE; return S_OK; } @@ -2174,6 +2311,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Offline(VARIANT_BOOL bOffline) RETURN_E_UNEXPECTED(); } + //TODO: Implement get_Offline return S_OK; } @@ -2193,6 +2331,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Silent(VARIANT_BOOL __RPC_FAR *pb RETURN_E_INVALIDARG(); } + //Only really applies to the IE app, not a control *pbSilent = VARIANT_FALSE; return S_OK; } @@ -2208,7 +2347,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Silent(VARIANT_BOOL bSilent) RETURN_E_UNEXPECTED(); } - // IGNORE + //Only really applies to the IE app, not a control return S_OK; } @@ -2229,6 +2368,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_RegisterAsBrowser(VARIANT_BOOL __ RETURN_E_INVALIDARG(); } + //TODO: Implement get_RegisterAsBrowser *pbRegister = VARIANT_FALSE; return S_OK; } @@ -2244,6 +2384,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_RegisterAsBrowser(VARIANT_BOOL bR RETURN_E_UNEXPECTED(); } + //TODO: Implement put_RegisterAsBrowser return S_OK; } @@ -2352,7 +2493,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_TheaterMode(VARIANT_BOOL __RPC_FA RETURN_E_INVALIDARG(); } - // No theatermode! + //TheaterMode doesn't apply to this control. *pbRegister = VARIANT_FALSE; return S_OK; @@ -2369,6 +2510,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_TheaterMode(VARIANT_BOOL bRegiste RETURN_E_UNEXPECTED(); } + //TheaterMode doesn't apply to this control. return S_OK; } @@ -2388,6 +2530,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_AddressBar(VARIANT_BOOL __RPC_FAR RETURN_E_INVALIDARG(); } + //There is no AddressBar in this control. *Value = VARIANT_FALSE; return S_OK; } @@ -2403,6 +2546,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_AddressBar(VARIANT_BOOL Value) RETURN_E_UNEXPECTED(); } + //There is no AddressBar in this control. return S_OK; } @@ -2423,6 +2567,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Resizable(VARIANT_BOOL __RPC_FAR RETURN_E_INVALIDARG(); } + //TODO: Not sure if this should actually be implemented or not. *Value = VARIANT_FALSE; return S_OK; } @@ -2438,6 +2583,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Resizable(VARIANT_BOOL Value) RETURN_E_UNEXPECTED(); } + //TODO: Not sure if this should actually be implemented or not. return S_OK; } diff --git a/mozilla/webshell/embed/ActiveX/MozillaBrowser.h b/mozilla/webshell/embed/ActiveX/MozillaBrowser.h index c638447ac0e..5e4f6fb01c3 100644 --- a/mozilla/webshell/embed/ActiveX/MozillaBrowser.h +++ b/mozilla/webshell/embed/ActiveX/MozillaBrowser.h @@ -25,9 +25,15 @@ #include "CPMozillaControl.h" // Commands sent via WM_COMMAND -#define ID_PRINT 1 -#define ID_PAGESETUP 2 -#define ID_VIEWSOURCE 3 +#define ID_PRINT 1 +#define ID_PAGESETUP 2 +#define ID_VIEWSOURCE 3 +#define ID_SAVEAS 4 +#define ID_PROPERTIES 5 +#define ID_CUT 6 +#define ID_COPY 7 +#define ID_PASTE 8 +#define ID_SELECTALL 9 // Command group and IDs exposed through IOleCommandTarget extern const GUID CGID_IWebBrowser; @@ -80,31 +86,48 @@ DECLARE_REGISTRY_RESOURCEID(IDR_MOZILLABROWSER) BEGIN_COM_MAP(CMozillaBrowser) // IE web browser interface - COM_INTERFACE_ENTRY(IWebBrowser2) - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IWebBrowser2) - COM_INTERFACE_ENTRY_IID(IID_IWebBrowser, IWebBrowser2) - COM_INTERFACE_ENTRY_IID(IID_IWebBrowserApp, IWebBrowser2) - COM_INTERFACE_ENTRY_IMPL(IViewObjectEx) - COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx) + COM_INTERFACE_ENTRY(IWebBrowser2) //CMozillaBrowser Derives from IWebBrowser2 + COM_INTERFACE_ENTRY_IID(IID_IDispatch, IWebBrowser2) //Requests to IWebBrowser will actually get the vtable of IWebBrowser2 + COM_INTERFACE_ENTRY_IID(IID_IWebBrowser, IWebBrowser2) //ditto + COM_INTERFACE_ENTRY_IID(IID_IWebBrowserApp, IWebBrowser2) //ditto + + COM_INTERFACE_ENTRY_IMPL(IViewObjectEx) //CMozillaBrowser derives from IViewObjectEx + COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx) //Request to IViewObject2 will actually get the vtable of IViewObjectEx COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx) + COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless) + COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject) + COM_INTERFACE_ENTRY_IMPL(IOleControl) + COM_INTERFACE_ENTRY_IMPL(IOleObject) + // COM_INTERFACE_ENTRY_IMPL(IQuickActivate) // This causes size assertion in ATL + COM_INTERFACE_ENTRY_IMPL(IPersistStorage) + COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit) + COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages) + COM_INTERFACE_ENTRY_IMPL(IDataObject) + COM_INTERFACE_ENTRY(IOleCommandTarget) + COM_INTERFACE_ENTRY(IProvideClassInfo) + COM_INTERFACE_ENTRY(IProvideClassInfo2) + COM_INTERFACE_ENTRY(ISupportErrorInfo) + COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer) - COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents, CDWebBrowserEvents1) - COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents2, CDWebBrowserEvents2) + + COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents, CDWebBrowserEvents1) //Requests to DWebBrowserEvents will get the vtable of CDWebBrowserEvents1 + + COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents2, CDWebBrowserEvents2) //Requests to DWebBrowserEvents2 will get the vtable of CDWebBrowserEvents2 END_COM_MAP() BEGIN_PROPERTY_MAP(CMozillaBrowser) @@ -116,7 +139,7 @@ END_PROPERTY_MAP() BEGIN_CONNECTION_POINT_MAP(CMozillaBrowser) // Fires IE events - CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents2) + CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents2) //Connection points for the client's event sinks CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents) END_CONNECTION_POINT_MAP() @@ -130,6 +153,12 @@ BEGIN_MSG_MAP(CMozillaBrowser) MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) COMMAND_ID_HANDLER(ID_PRINT, OnPrint) COMMAND_ID_HANDLER(ID_PAGESETUP, OnPageSetup) + COMMAND_ID_HANDLER(ID_SAVEAS, OnSaveAs) + COMMAND_ID_HANDLER(ID_PROPERTIES, OnProperties) + COMMAND_ID_HANDLER(ID_CUT, OnCut) + COMMAND_ID_HANDLER(ID_COPY, OnCopy) + COMMAND_ID_HANDLER(ID_PASTE, OnPaste) + COMMAND_ID_HANDLER(ID_SELECTALL, OnSelectAll)\ END_MSG_MAP() static HRESULT _stdcall EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); @@ -138,18 +167,19 @@ END_MSG_MAP() BEGIN_OLECOMMAND_TABLE() // Standard "common" commands OLECOMMAND_MESSAGE(OLECMDID_PRINT, NULL, ID_PRINT, L"Print", L"Print the page") - OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, 0, L"SaveAs", L"Save the page") OLECOMMAND_MESSAGE(OLECMDID_PAGESETUP, NULL, ID_PAGESETUP, L"Page Setup", L"Page Setup") - OLECOMMAND_MESSAGE(OLECMDID_PROPERTIES, NULL, 0, L"Properties", L"Show page properties") - OLECOMMAND_MESSAGE(OLECMDID_CUT, NULL, 0, L"Cut", L"Cut selection") - OLECOMMAND_MESSAGE(OLECMDID_COPY, NULL, 0, L"Copy", L"Copy selection") - OLECOMMAND_MESSAGE(OLECMDID_PASTE, NULL, 0, L"Paste", L"Paste as selection") OLECOMMAND_MESSAGE(OLECMDID_UNDO, NULL, 0, L"Undo", L"Undo") OLECOMMAND_MESSAGE(OLECMDID_REDO, NULL, 0, L"Redo", L"Redo") - OLECOMMAND_MESSAGE(OLECMDID_SELECTALL, NULL, 0, L"SelectAll", L"Select all") OLECOMMAND_MESSAGE(OLECMDID_REFRESH, NULL, 0, L"Refresh", L"Refresh") OLECOMMAND_MESSAGE(OLECMDID_STOP, NULL, 0, L"Stop", L"Stop") OLECOMMAND_MESSAGE(OLECMDID_ONUNLOAD, NULL, 0, L"OnUnload", L"OnUnload") + OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, ID_SAVEAS, L"SaveAs", L"Save the page") + OLECOMMAND_MESSAGE(OLECMDID_CUT, NULL, ID_CUT, L"Cut", L"Cut selection") + OLECOMMAND_MESSAGE(OLECMDID_COPY, NULL, ID_COPY, L"Copy", L"Copy selection") + OLECOMMAND_MESSAGE(OLECMDID_PASTE, NULL, ID_PASTE, L"Paste", L"Paste as selection") + OLECOMMAND_MESSAGE(OLECMDID_SELECTALL, NULL, ID_SELECTALL, L"SelectAll", L"Select all") + OLECOMMAND_MESSAGE(OLECMDID_PROPERTIES, NULL, ID_PROPERTIES, L"Properties", L"Show page properties") + // Unsupported IE 4.x command group OLECOMMAND_MESSAGE(HTMLID_FIND, &CGID_IWebBrowser, 0, L"Find", L"Find") OLECOMMAND_MESSAGE(HTMLID_VIEWSOURCE, &CGID_IWebBrowser, 0, L"ViewSource", L"View Source") @@ -259,6 +289,13 @@ END_OLECOMMAND_TABLE() LRESULT OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); diff --git a/mozilla/webshell/embed/ActiveX/StdAfx.h b/mozilla/webshell/embed/ActiveX/StdAfx.h index 9a3e022e3a0..c0fe2d91b79 100644 --- a/mozilla/webshell/embed/ActiveX/StdAfx.h +++ b/mozilla/webshell/embed/ActiveX/StdAfx.h @@ -96,6 +96,9 @@ typedef long int32; #include "nsIWebShell.h" #include "nsIBrowserWindow.h" #include "nsIContentViewer.h" +#include "nsIPresShell.h" +#include "nsCOMPtr.h" +#include "nsIDOMSelection.h" #include "nsIPresContext.h" #include "nsIPresShell.h" @@ -115,6 +118,7 @@ typedef long int32; #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" #include "nsIDOMDocument.h" +#include "nsIDOMDocumentType.h" #include "nsIDOMElement.h" #endif diff --git a/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp b/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp index 69f9fd4df6f..a5b232952bf 100644 --- a/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp +++ b/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp @@ -195,6 +195,11 @@ NS_IMETHODIMP CWebShellContainer::SetStatus(const PRUnichar* aStatus) { NG_TRACE_METHOD(CWebShellContainer::SetStatus); + + BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aStatus)); + m_pEvents1->Fire_StatusTextChange(bstrStatus); + m_pEvents2->Fire_StatusTextChange(bstrStatus); + return NS_OK; } @@ -276,8 +281,8 @@ CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) NG_TRACE(_T("CWebShellContainer::BeginLoadURL(..., \"%s\")\n"), W2T(aURL)); // Fire a DownloadBegin -// m_pEvents1->Fire_DownloadBegin(); - //m_pEvents2->Fire_DownloadBegin(); + m_pEvents1->Fire_DownloadBegin(); + m_pEvents2->Fire_DownloadBegin(); // Fire a BeforeNavigate event OLECHAR *pszURL = W2OLE((WCHAR *)aURL); @@ -366,20 +371,22 @@ CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsres CComVariant vURL(bstrURL); m_pEvents2->Fire_NavigateComplete2(m_pOwner, &vURL); - // Fire the new NavigateForward state + // Fire the new NavigateForward state VARIANT_BOOL bEnableForward = VARIANT_FALSE; - if (m_pOwner->m_pIWebShell->CanForward() == NS_OK) + if ( m_pOwner->m_pIWebShell->CanForward() == NS_OK ) { bEnableForward = VARIANT_TRUE; } + m_pEvents2->Fire_CommandStateChange(CSC_NAVIGATEFORWARD, bEnableForward); // Fire the new NavigateBack state VARIANT_BOOL bEnableBack = VARIANT_FALSE; - if (m_pOwner->m_pIWebShell->CanBack() == NS_OK) + if ( m_pOwner->m_pIWebShell->CanBack() == NS_OK ) { bEnableBack = VARIANT_TRUE; } + m_pEvents2->Fire_CommandStateChange(CSC_NAVIGATEBACK, bEnableBack); m_pOwner->m_bBusy = FALSE; @@ -458,6 +465,7 @@ CWebShellContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { USES_CONVERSION; NG_TRACE(_T("CWebShellContainer::OnStartRequest(...)\n")); + return NS_OK; } @@ -523,7 +531,10 @@ CWebShellContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChann NS_IMETHODIMP CWebShellContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, PRUint32 aProgress, PRUint32 aProgressMax) { - return NS_OK; + USES_CONVERSION; + NG_TRACE(_T("CWebShellContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); + + return NS_OK; } // we don't care about these. @@ -554,15 +565,16 @@ CWebShellContainer::OnStartRequest(nsIURI* aURL, const char *aContentType) { USES_CONVERSION; NG_TRACE(_T("CWebShellContainer::OnStartRequest(..., \"%s\")\n"), A2CT(aContentType)); + return NS_OK; } - NS_IMETHODIMP CWebShellContainer::OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { USES_CONVERSION; NG_TRACE(_T("CWebShellContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); + return NS_OK; } @@ -640,7 +652,10 @@ CWebShellContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons NS_IMETHODIMP CWebShellContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { - return NS_OK; + USES_CONVERSION; + NG_TRACE(_T("CWebShellContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); + + return NS_OK; } // we don't care about these. diff --git a/mozilla/webshell/embed/ActiveX/WebShellContainer.h b/mozilla/webshell/embed/ActiveX/WebShellContainer.h index 90c83cd15ef..6ad516e2228 100644 --- a/mozilla/webshell/embed/ActiveX/WebShellContainer.h +++ b/mozilla/webshell/embed/ActiveX/WebShellContainer.h @@ -115,7 +115,7 @@ public: NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType, nsIContentViewer* aViewer); NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax); NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, nsString& aMsg); - NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus); + NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, nsresult aStatus); NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader, nsIURI *aURL,const char *aContentType,const char *aCommand ); #endif };