/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): */ #ifndef nsEditorShell_h___ #define nsEditorShell_h___ //#include "nsAppCores.h" #include "nscore.h" #include "nsCOMPtr.h" #include "nsWeakReference.h"//XXX adding weak ref knowledge #include "nsString.h" #include "nsISupports.h" #include "nsIEditorShell.h" #include "nsIEditorController.h" #include "nsIWebProgressListener.h" #include "nsISelectionListener.h" #include "nsIDOMEventReceiver.h" #include "nsIPrompt.h" #include "nsIDOMDocument.h" #include "nsIDOMEventListener.h" #include "nsIURIContentListener.h" #include "nsVoidArray.h" #include "nsTextServicesCID.h" #include "nsIEditorSpellCheck.h" #include "nsISpellChecker.h" #include "nsInterfaceState.h" #include "nsIHTMLEditor.h" #include "nsIStringBundle.h" #include "nsICSSStyleSheet.h" // Parser Observation #include "nsEditorParserObserver.h" class nsIDocShell; class nsIScriptContext; class nsIDOMWindowInternal; class nsIDOMElement; class nsIDOMNode; class nsIURI; class nsIPresShell; class nsIOutputStream; class nsISupportsArray; class nsIStringBundleService; class nsIStringBundle; class nsIStyleSheet; #define NS_EDITORSHELL_CID \ { /* {} */ \ 0x9afff72b, 0xca9a, 0x11d2, \ { 0x96, 0xc9, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } \ } //////////////////////////////////////////////////////////////////////////////// // nsEditorShell: //////////////////////////////////////////////////////////////////////////////// class nsEditorShell : public nsIEditorShell, public nsIEditorSpellCheck, public nsIWebProgressListener, public nsIURIContentListener, public nsSupportsWeakReference { public: // These must map onto the button-order for nsICommonDialog::Confirm results // which are rather ugly right now (Cancel in the middle!) typedef enum {eYes = 0, eCancel = 1, eNo = 2 } EConfirmResult; nsEditorShell(); virtual ~nsEditorShell(); NS_DECL_ISUPPORTS /* Declare all methods in the nsIEditorShell interface */ NS_DECL_NSIEDITORSHELL /* Declare all methods in the nsIEditorSpellCheck interface */ NS_DECL_NSIEDITORSPELLCHECK // nsIWebProgressListener NS_DECL_NSIWEBPROGRESSLISTENER // nsIURIContentListener NS_DECL_NSIURICONTENTLISTENER protected: typedef enum { eUninitializedEditorType = 0, ePlainTextEditorType = 1, eHTMLTextEditorType = 2 } EEditorType; typedef enum { eCantEditNoReason = 0, eCantEditFramesets = 1, eCantEditMimeType = 2, eCantEditOther = 3 } ECantEditReason; nsresult DoEditorMode(nsIDocShell *aDocShell); // nuke any existing editor in the editorShell, thus preparing it to edit // a(nother) document. nsresult ResetEditingState(); nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); nsresult PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl); nsresult ScrollSelectionIntoView(); nsresult TransferDocumentStateListeners(); nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); nsresult DoFind(PRBool aFindNext); // To allow executing JavaScript commands from C++ via nsIEditorControler interface nsresult DoControllerCommand(const nsAReadableString& aCommand); void Alert(const nsString& aTitle, const nsString& aMsg); // Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well! PRBool Confirm(const nsString& aTitle, const nsString& aQuestion); // Return value: No=0, Yes=1, Cancel=2 // aYesString and aNoString are optional: // if null, then "Yes" and "No" are used EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion, const nsString *aYesString, const nsString *aNoString); // Get a string from the string bundle file. If the string is not found // this returns an empty string. void GetBundleString(const nsAReadableString &stringName, nsAWritableString &outString); // Get the text of the