--- chimera/NSBrowserView.mm 2002/02/04 07:15:33 1.6 +++ chimera/NSBrowserView.mm 2002/02/05 10:16:31 1.16 @@ -37,6 +37,7 @@ #import "NSBrowserView.h" #import "ProgressDlgController.h" +#import "FindDlgController.h" #import "nsCocoaBrowserService.h" // Embedding includes @@ -56,6 +57,11 @@ #include "nsXPIDLString.h" #include "nsCOMPtr.h" +// Printing +#include "nsIWebBrowserPrint.h" +#include "nsIPrintSettings.h" + +// Saving of links/images/docs #include "nsIWebBrowserFocus.h" #include "nsIDOMHTMLDocument.h" #include "nsIDocument.h" @@ -72,6 +78,10 @@ #include "nsIHistoryEntry.h" #include "nsISHEntry.h" +// Cut/copy/paste +#include "nsIClipboardCommands.h" +#include "nsIInterfaceRequestorUtils.h" + const char* persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1"; const char* dirServiceContractID = "@mozilla.org/file/directory_service;1"; @@ -906,12 +916,11 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb - (void)dealloc { - NSLog(@"NSBrowserView got dealloced."); - NS_RELEASE(_listener); NS_IF_RELEASE(_webBrowser); - nsCocoaBrowserService::TermEmbedding(); - + + nsCocoaBrowserService::BrowserClosed(); + [super dealloc]; } @@ -1151,6 +1160,49 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb webPersist->SaveURI(aURI, nsnull, tmpFile); } +-(void)printDocument +{ + nsCOMPtr domWindow; + _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); + nsCOMPtr ir(do_QueryInterface(domWindow)); + nsCOMPtr print; + ir->GetInterface(NS_GET_IID(nsIWebBrowserPrint), getter_AddRefs(print)); + print->Print(nsnull, nsnull); +} + +-(void)printPreview +{ + nsCOMPtr domWindow; + _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); + nsCOMPtr ir(do_QueryInterface(domWindow)); + nsCOMPtr print; + ir->GetInterface(NS_GET_IID(nsIWebBrowserPrint), getter_AddRefs(print)); + print->PrintPreview(nsnull); +} + +-(void)findInPage +{ + FindDlgController* findDialog = [[FindDlgController alloc] initWithWindowNibName: @"FindDialog"]; + nsCOMPtr wbf(do_QueryInterface(_webBrowser)); + nsCOMPtr rootWindow; + nsCOMPtr focusedWindow; + _webBrowser->GetContentDOMWindow(getter_AddRefs(rootWindow)); + wbf->GetFocusedWindow(getter_AddRefs(focusedWindow)); + if (!focusedWindow) + focusedWindow = rootWindow; + nsCOMPtr webFind(do_GetInterface(_webBrowser)); + nsCOMPtr framesFind(do_QueryInterface(webFind)); + framesFind->SetRootSearchFrame(rootWindow); + framesFind->SetCurrentSearchFrame(focusedWindow); + + [findDialog setFind: webFind]; + [findDialog showWindow: findDialog]; +} + +-(void)findAgain +{ +} + -(void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList { nsCOMPtr wbf(do_QueryInterface(_webBrowser)); @@ -1178,5 +1230,36 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb filterList: aFilterList]; } + +-(IBAction)cut:(id)aSender +{ + nsCOMPtr clipboard(do_GetInterface(_webBrowser)); + clipboard->CutSelection(); +} + +-(IBAction)copy:(id)aSender +{ + nsCOMPtr clipboard(do_GetInterface(_webBrowser)); + clipboard->CopySelection(); +} + +-(IBAction)paste:(id)aSender +{ + nsCOMPtr clipboard(do_GetInterface(_webBrowser)); + clipboard->Paste(); +} + +-(IBAction)clear:(id)aSender +{ + nsCOMPtr clipboard(do_GetInterface(_webBrowser)); + clipboard->SelectNone(); +} + +-(IBAction)selectAll:(id)aSender +{ + nsCOMPtr clipboard(do_GetInterface(_webBrowser)); + clipboard->SelectAll(); +} + @end