1999-06-10 23:50:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* 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/
|
1999-06-10 23:50:26 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* 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.
|
1999-06-10 23:50:26 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-06-10 23:50:26 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:43:54 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-06-10 23:50:26 +00:00
|
|
|
*/
|
1999-08-09 01:37:50 +00:00
|
|
|
#ifndef nsEditorShell_h___
|
|
|
|
#define nsEditorShell_h___
|
1999-06-10 23:50:26 +00:00
|
|
|
|
|
|
|
//#include "nsAppCores.h"
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2000-05-14 05:27:17 +00:00
|
|
|
#include "nsWeakReference.h"//XXX adding weak ref knowledge
|
1999-06-10 23:50:26 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
|
|
|
|
#include "nsIEditorShell.h"
|
2000-05-01 21:49:52 +00:00
|
|
|
#include "nsIEditorController.h"
|
1999-06-10 23:50:26 +00:00
|
|
|
#include "nsIDocumentLoaderObserver.h"
|
2000-09-14 11:45:01 +00:00
|
|
|
#include "nsISelectionListener.h"
|
2000-05-09 23:03:41 +00:00
|
|
|
#include "nsIDOMEventReceiver.h"
|
1999-07-01 19:30:20 +00:00
|
|
|
#include "nsIPrompt.h"
|
1999-06-10 23:50:26 +00:00
|
|
|
#include "nsIStreamObserver.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2000-05-09 23:03:41 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
2000-10-14 01:44:31 +00:00
|
|
|
#include "nsIURIContentListener.h"
|
1999-06-10 23:50:26 +00:00
|
|
|
#include "nsVoidArray.h"
|
|
|
|
#include "nsTextServicesCID.h"
|
1999-06-11 22:43:19 +00:00
|
|
|
#include "nsIEditorSpellCheck.h"
|
1999-06-10 23:50:26 +00:00
|
|
|
#include "nsISpellChecker.h"
|
1999-07-28 02:54:35 +00:00
|
|
|
#include "nsInterfaceState.h"
|
1999-08-09 01:37:50 +00:00
|
|
|
#include "nsIHTMLEditor.h"
|
1999-08-28 02:40:18 +00:00
|
|
|
#include "nsIStringBundle.h"
|
1999-09-29 21:45:50 +00:00
|
|
|
#include "nsICSSStyleSheet.h"
|
1999-06-10 23:50:26 +00:00
|
|
|
|
2000-03-31 02:13:00 +00:00
|
|
|
// Parser Observation
|
|
|
|
#include "nsEditorParserObserver.h"
|
|
|
|
|
2000-04-11 23:48:14 +00:00
|
|
|
class nsIDocShell;
|
1999-06-10 23:50:26 +00:00
|
|
|
class nsIScriptContext;
|
2000-09-01 01:54:35 +00:00
|
|
|
class nsIDOMWindowInternal;
|
1999-06-10 23:50:26 +00:00
|
|
|
class nsIDOMElement;
|
|
|
|
class nsIDOMNode;
|
1999-06-23 03:29:44 +00:00
|
|
|
class nsIURI;
|
1999-06-10 23:50:26 +00:00
|
|
|
class nsIPresShell;
|
|
|
|
class nsIOutputStream;
|
1999-07-19 22:36:12 +00:00
|
|
|
class nsISupportsArray;
|
1999-08-28 02:40:18 +00:00
|
|
|
class nsIStringBundleService;
|
|
|
|
class nsIStringBundle;
|
1999-09-29 21:45:50 +00:00
|
|
|
class nsIStyleSheet;
|
1999-06-10 23:50:26 +00:00
|
|
|
|
1999-08-09 01:37:50 +00:00
|
|
|
#define NS_EDITORSHELL_CID \
|
1999-06-10 23:50:26 +00:00
|
|
|
{ /* {} */ \
|
|
|
|
0x9afff72b, 0xca9a, 0x11d2, \
|
|
|
|
{ 0x96, 0xc9, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } \
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsEditorShell:
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class nsEditorShell : public nsIEditorShell,
|
1999-06-11 22:43:19 +00:00
|
|
|
public nsIEditorSpellCheck,
|
2000-10-14 01:44:31 +00:00
|
|
|
public nsIDocumentLoaderObserver,
|
|
|
|
public nsIURIContentListener
|
1999-06-10 23:50:26 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
// These must map onto the button-order for nsICommonDialog::Confirm results
|
1999-09-03 01:23:19 +00:00
|
|
|
// which are rather ugly right now (Cancel in the middle!)
|
|
|
|
typedef enum {eYes = 0, eCancel = 1, eNo = 2 } EConfirmResult;
|
|
|
|
|
1999-06-10 23:50:26 +00:00
|
|
|
nsEditorShell();
|
|
|
|
virtual ~nsEditorShell();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/* Declare all methods in the nsIEditorShell interface */
|
|
|
|
NS_DECL_NSIEDITORSHELL
|
1999-06-10 23:50:26 +00:00
|
|
|
|
1999-08-21 08:54:47 +00:00
|
|
|
/* Declare all methods in the nsIEditorSpellCheck interface */
|
|
|
|
NS_DECL_NSIEDITORSPELLCHECK
|
1999-06-10 23:50:26 +00:00
|
|
|
|
|
|
|
// nsIDocumentLoaderObserver
|
2000-03-11 01:01:39 +00:00
|
|
|
NS_DECL_NSIDOCUMENTLOADEROBSERVER
|
1999-06-28 13:01:55 +00:00
|
|
|
|
2000-10-14 01:44:31 +00:00
|
|
|
// nsIURIContentListener
|
|
|
|
NS_DECL_NSIURICONTENTLISTENER
|
|
|
|
|
1999-06-10 23:50:26 +00:00
|
|
|
protected:
|
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
typedef enum {
|
|
|
|
eUninitializedEditorType = 0,
|
|
|
|
ePlainTextEditorType = 1,
|
|
|
|
eHTMLTextEditorType = 2
|
|
|
|
} EEditorType;
|
2000-05-26 23:42:25 +00:00
|
|
|
|
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
typedef enum {
|
2000-05-26 23:42:25 +00:00
|
|
|
eCantEditNoReason = 0,
|
|
|
|
eCantEditFramesets = 1,
|
|
|
|
eCantEditMimeType = 2,
|
|
|
|
eCantEditOther = 3
|
2000-08-14 12:07:10 +00:00
|
|
|
} ECantEditReason;
|
|
|
|
|
|
|
|
nsresult DoEditorMode(nsIDocShell *aDocShell);
|
2000-05-05 23:19:08 +00:00
|
|
|
// nuke any existing editor in the editorShell, thus preparing it to edit
|
|
|
|
// a(nother) document.
|
|
|
|
nsresult ResetEditingState();
|
2000-08-14 12:07:10 +00:00
|
|
|
nsresult InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
|
|
|
nsresult PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUrl);
|
|
|
|
nsresult ScrollSelectionIntoView();
|
2000-04-04 01:06:25 +00:00
|
|
|
nsresult TransferDocumentStateListeners();
|
2000-08-14 12:07:10 +00:00
|
|
|
nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr);
|
|
|
|
nsresult DoFind(PRBool aFindNext);
|
2000-06-05 20:26:40 +00:00
|
|
|
// To allow executing JavaScript commands from C++ via nsIEditorControler interface
|
|
|
|
nsresult DoControllerCommand(nsString& aCommand);
|
2000-04-04 01:06:25 +00:00
|
|
|
|
|
|
|
void Alert(const nsString& aTitle, const nsString& aMsg);
|
1999-08-31 00:51:23 +00:00
|
|
|
// Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well!
|
2000-04-04 01:06:25 +00:00
|
|
|
PRBool Confirm(const nsString& aTitle, const nsString& aQuestion);
|
1999-09-01 01:22:37 +00:00
|
|
|
// Return value: No=0, Yes=1, Cancel=2
|
1999-09-03 01:23:19 +00:00
|
|
|
// aYesString and aNoString are optional:
|
|
|
|
// if null, then "Yes" and "No" are used
|
2000-04-04 01:06:25 +00:00
|
|
|
EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion,
|
1999-09-03 01:23:19 +00:00
|
|
|
const nsString *aYesString, const nsString *aNoString);
|
1999-08-31 00:51:23 +00:00
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
// this returns an AddReffed nsIScriptContext. You must relase it.
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIScriptContext* GetScriptContext(nsIDOMWindowInternal * aWin);
|
1999-06-10 23:50:26 +00:00
|
|
|
|
2000-04-04 01:06:25 +00:00
|
|
|
// Get a string from the string bundle file
|
|
|
|
void GetBundleString(const nsString& name, nsString &outString);
|
1999-07-14 22:30:39 +00:00
|
|
|
|
2000-04-04 01:06:25 +00:00
|
|
|
// Get the text of the <title> tag
|
|
|
|
nsresult GetDocumentTitleString(nsString& title);
|
1999-07-14 18:54:29 +00:00
|
|
|
|
2000-04-04 01:06:25 +00:00
|
|
|
nsresult DeleteSuggestedWordList();
|
1999-07-19 22:36:12 +00:00
|
|
|
|
2000-04-04 01:06:25 +00:00
|
|
|
// Get the current document title an use it as part of the window title
|
|
|
|
// Uses "(Untitled)" for empty title
|
|
|
|
nsresult UpdateWindowTitle();
|
1999-08-03 00:57:57 +00:00
|
|
|
|
2000-04-04 01:06:25 +00:00
|
|
|
// does the document being loaded contain subframes?
|
|
|
|
nsresult DocumentContainsFrames(nsIDocumentLoader* aLoader, PRBool& outHasFrames);
|
|
|
|
// is the document being loaded the root of a frameset, or a non-frameset doc?
|
|
|
|
nsresult DocumentIsRootDoc(nsIDocumentLoader* aLoader, PRBool& outIsRoot);
|
2000-07-11 23:41:22 +00:00
|
|
|
|
|
|
|
// Check a preference and call NormalizeTable if pref is true
|
|
|
|
// Use after deleting or inserting table cells to automatically
|
|
|
|
// fix rowspan, colspan, and missing cells problems
|
|
|
|
nsresult CheckPrefAndNormalizeTable();
|
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
nsCOMPtr<nsIHTMLEditor> mEditor; // this can be either an HTML or plain text (or other?) editor
|
2000-05-09 23:03:41 +00:00
|
|
|
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
|
|
|
|
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
|
|
|
|
|
|
|
// Let UI detect and process double click on elements for AdvancedProperties
|
|
|
|
// (see nsEditorShellMouseEventListener)
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
|
|
|
// We need this to add mMouseListenerP to document
|
|
|
|
nsresult GetDocumentEventReceiver(nsIDOMEventReceiver **aEventReceiver);
|
2000-04-04 01:06:25 +00:00
|
|
|
|
2000-05-02 03:24:11 +00:00
|
|
|
PRBool mMailCompose;
|
|
|
|
|
2000-06-22 05:24:42 +00:00
|
|
|
// These doc listeners are registered with the editor when that gets
|
|
|
|
// created. We also keep them in this list so we can register if we have
|
|
|
|
// to blow away the editor (e.g. URL reload)
|
2000-08-14 12:07:10 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mDocStateListeners; // contents are nsISupports
|
1999-10-15 22:06:41 +00:00
|
|
|
|
1999-08-28 02:40:18 +00:00
|
|
|
// Pointer to localized strings used for UI
|
2000-04-04 01:06:25 +00:00
|
|
|
nsCOMPtr<nsIStringBundle> mStringBundle;
|
2000-03-31 04:18:29 +00:00
|
|
|
|
|
|
|
// Pointer to extra style sheets we load/unload
|
|
|
|
// for various Edit Modes or for Paragraph Marks
|
2000-04-04 01:06:25 +00:00
|
|
|
nsCOMPtr<nsICSSStyleSheet> mEditModeStyleSheet;
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> mAllTagsModeStyleSheet;
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> mParagraphMarksStyleSheet;
|
2000-05-02 03:24:11 +00:00
|
|
|
|
|
|
|
// The override style sheet that we never unload while editing
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> mBaseStyleSheet;
|
|
|
|
|
|
|
|
// Saves the current display mode to reload style sheets
|
|
|
|
// after loading a url
|
|
|
|
PRInt32 mDisplayMode;
|
2000-07-11 23:41:22 +00:00
|
|
|
// We don't store the HTMLSource mode in mDisplayMode,
|
|
|
|
// so we need to track it separately
|
|
|
|
PRBool mHTMLSourceMode;
|
2000-04-04 01:06:25 +00:00
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal *mWebShellWindow; // weak reference
|
|
|
|
//nsIDOMWindowInternal *mContentWindow; // weak reference
|
2000-05-14 05:27:17 +00:00
|
|
|
nsWeakPtr mContentWindow; // weak reference
|
2000-04-04 01:06:25 +00:00
|
|
|
|
2000-05-01 21:49:52 +00:00
|
|
|
nsEditorParserObserver *mParserObserver; // we hold the owning ref to this.
|
|
|
|
nsInterfaceState *mStateMaintainer; // we hold the owning ref to this.
|
2000-04-18 22:39:10 +00:00
|
|
|
|
2000-05-01 21:49:52 +00:00
|
|
|
nsIEditorController *mEditorController; // temporary weak ref to the editor controller
|
2000-08-14 12:07:10 +00:00
|
|
|
nsIDocShell *mDocShell; // weak reference
|
2000-04-04 01:06:25 +00:00
|
|
|
|
|
|
|
// The webshell that contains the document being edited.
|
|
|
|
// Don't assume that webshell directly contains the document being edited;
|
|
|
|
// if we are in a frameset, this assumption is false.
|
2000-08-14 12:07:10 +00:00
|
|
|
nsIDocShell *mContentAreaDocShell; // weak reference
|
2000-04-04 01:06:25 +00:00
|
|
|
|
2000-10-10 01:45:46 +00:00
|
|
|
PRPackedBool mInitted;
|
2000-04-04 01:06:25 +00:00
|
|
|
PRPackedBool mCloseWindowWhenLoaded; // error on load. Close window when loaded
|
2000-05-26 23:42:25 +00:00
|
|
|
ECantEditReason mCantEditReason;
|
|
|
|
|
2000-08-14 12:07:10 +00:00
|
|
|
EEditorType mEditorType;
|
|
|
|
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
2000-04-04 01:06:25 +00:00
|
|
|
PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while
|
|
|
|
|
|
|
|
nsStringArray mSuggestedWordList;
|
|
|
|
PRInt32 mSuggestedWordIndex;
|
|
|
|
|
|
|
|
nsStringArray mDictionaryList;
|
|
|
|
PRInt32 mDictionaryIndex;
|
2000-03-31 02:13:00 +00:00
|
|
|
|
1999-06-10 23:50:26 +00:00
|
|
|
};
|
|
|
|
|
1999-08-09 01:37:50 +00:00
|
|
|
#endif // nsEditorShell_h___
|