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"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
|
|
|
|
#include "nsIEditorShell.h"
|
|
|
|
#include "nsIDocumentLoaderObserver.h"
|
1999-07-14 22:30:39 +00:00
|
|
|
#include "nsIDOMSelectionListener.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"
|
|
|
|
#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
|
|
|
|
|
|
|
class nsIWebShell;
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsIDOMWindow;
|
|
|
|
class nsIDOMElement;
|
|
|
|
class nsIDOMNode;
|
1999-06-23 03:29:44 +00:00
|
|
|
class nsIURI;
|
1999-06-10 23:50:26 +00:00
|
|
|
class nsIWebShellWindow;
|
|
|
|
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,
|
1999-06-10 23:50:26 +00:00
|
|
|
public nsIDocumentLoaderObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
1999-09-03 01:23:19 +00:00
|
|
|
// 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;
|
|
|
|
|
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
|
|
|
|
1999-06-10 23:50:26 +00:00
|
|
|
protected:
|
1999-07-19 22:36:12 +00:00
|
|
|
nsIDOMWindow *mToolbarWindow; // weak reference
|
|
|
|
nsIDOMWindow *mContentWindow; // weak reference
|
|
|
|
|
|
|
|
nsIWebShellWindow *mWebShellWin; // weak reference
|
|
|
|
nsIWebShell *mWebShell; // weak reference
|
|
|
|
nsIWebShell *mContentAreaWebShell; // weak reference
|
1999-06-10 23:50:26 +00:00
|
|
|
|
|
|
|
typedef enum {
|
1999-07-14 22:30:39 +00:00
|
|
|
eUninitializedEditorType = 0,
|
1999-06-10 23:50:26 +00:00
|
|
|
ePlainTextEditorType = 1,
|
|
|
|
eHTMLTextEditorType = 2
|
|
|
|
} EEditorType;
|
|
|
|
|
|
|
|
nsIPresShell* GetPresShellFor(nsIWebShell* aWebShell);
|
|
|
|
NS_IMETHOD DoEditorMode(nsIWebShell *aWebShell);
|
|
|
|
NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript);
|
|
|
|
NS_IMETHOD InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
1999-11-25 04:11:51 +00:00
|
|
|
NS_IMETHOD ScrollSelectionIntoView();
|
1999-08-03 00:57:57 +00:00
|
|
|
NS_IMETHOD TransferDocumentStateListeners();
|
1999-06-10 23:50:26 +00:00
|
|
|
NS_IMETHOD RemoveOneProperty(const nsString& aProp, const nsString& aAttr);
|
|
|
|
void SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, const nsString &aResName);
|
1999-08-03 00:57:57 +00:00
|
|
|
NS_IMETHOD PrepareDocumentForEditing(nsIURI *aUrl);
|
1999-06-10 23:50:26 +00:00
|
|
|
NS_IMETHOD DoFind(PRBool aFindNext);
|
1999-09-01 01:22:37 +00:00
|
|
|
|
1999-09-03 01:23:19 +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!
|
1999-09-03 01:23:19 +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
|
|
|
|
EConfirmResult ConfirmWithCancel(const nsString& aTitle, const nsString& aQuestion,
|
|
|
|
const nsString *aYesString, const nsString *aNoString);
|
1999-08-31 00:51:23 +00:00
|
|
|
|
1999-06-19 22:13:46 +00:00
|
|
|
// this returns an AddReffed nsIScriptContext. You must relase it.
|
|
|
|
nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin);
|
1999-06-10 23:50:26 +00:00
|
|
|
|
|
|
|
nsString mEnableScript;
|
|
|
|
nsString mDisableScript;
|
|
|
|
|
|
|
|
EEditorType mEditorType;
|
|
|
|
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
1999-08-09 01:37:50 +00:00
|
|
|
nsCOMPtr<nsIHTMLEditor> mEditor; // this can be either an HTML or plain text (or other?) editor
|
1999-06-10 23:50:26 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
|
1999-07-14 22:30:39 +00:00
|
|
|
|
2000-03-16 23:45:41 +00:00
|
|
|
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
|
1999-07-14 18:54:29 +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
|
1999-07-19 22:36:12 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISpellChecker> mSpellChecker;
|
|
|
|
nsStringArray mSuggestedWordList;
|
|
|
|
PRInt32 mSuggestedWordIndex;
|
|
|
|
NS_IMETHOD DeleteSuggestedWordList();
|
|
|
|
nsStringArray mDictionaryList;
|
|
|
|
PRInt32 mDictionaryIndex;
|
1999-08-03 00:57:57 +00:00
|
|
|
|
|
|
|
// this is a holding pen for doc state listeners. They will be registered with
|
|
|
|
// the editor when that gets created.
|
1999-08-28 02:40:18 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mDocStateListeners; // contents are nsISupports
|
1999-08-31 00:51:23 +00:00
|
|
|
|
|
|
|
// Get a string from the string bundle file
|
1999-10-15 22:06:41 +00:00
|
|
|
nsString GetString(const nsString& name);
|
1999-10-20 14:15:25 +00:00
|
|
|
|
|
|
|
// Get the text of the <title> tag
|
2000-01-13 23:33:00 +00:00
|
|
|
NS_IMETHOD GetDocumentTitleString(nsString& title);
|
1999-10-15 22:06:41 +00:00
|
|
|
|
|
|
|
// Get the current document title an use it as part of the window title
|
|
|
|
// Uses "(Untitled)" for empty title
|
|
|
|
NS_IMETHOD UpdateWindowTitle();
|
1999-08-31 00:51:23 +00:00
|
|
|
|
|
|
|
private:
|
1999-08-28 02:40:18 +00:00
|
|
|
// Pointer to localized strings used for UI
|
|
|
|
nsCOMPtr<nsIStringBundle> mStringBundle;
|
1999-09-29 21:45:50 +00:00
|
|
|
// Pointer to the EditorContent style sheet we load/unload
|
|
|
|
// for "Edit Mode"/"Browser mode" display
|
|
|
|
nsCOMPtr<nsIStyleSheet> mEditModeStyleSheet;
|
1999-06-10 23:50:26 +00:00
|
|
|
};
|
|
|
|
|
1999-08-09 01:37:50 +00:00
|
|
|
#endif // nsEditorShell_h___
|