1998-11-11 06:34:37 +03:00
|
|
|
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://wwwt.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
1998-12-01 00:17:59 +03:00
|
|
|
#include "prmon.h"
|
1998-11-11 06:34:37 +03:00
|
|
|
#include "nsIEditor.h"
|
1998-11-24 00:53:14 +03:00
|
|
|
#include "nsIContextLoader.h"
|
1998-12-10 01:19:41 +03:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
1998-12-17 22:26:17 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-11-11 23:44:02 +03:00
|
|
|
#include "editorInterfaces.h"
|
1999-01-06 23:29:11 +03:00
|
|
|
#include "nsITransactionManager.h"
|
1998-11-28 04:19:53 +03:00
|
|
|
//#include "nsISelection.h"
|
|
|
|
|
|
|
|
|
|
|
|
//This is the monitor for the editor.
|
|
|
|
PRMonitor *getEditorMonitor();
|
|
|
|
|
1998-11-11 06:34:37 +03:00
|
|
|
|
1998-11-11 11:12:57 +03:00
|
|
|
/** implementation of an editor object. it will be the controler/focal point
|
1998-12-09 22:57:09 +03:00
|
|
|
* for the main editor services. i.e. the GUIManager, publishing, transaction
|
1998-11-11 11:12:57 +03:00
|
|
|
* manager, event interfaces. the idea for the event interfaces is to have them
|
|
|
|
* delegate the actual commands to the editor independent of the XPFE implementation.
|
|
|
|
*/
|
1998-11-18 03:49:02 +03:00
|
|
|
class nsEditor : public nsIEditor
|
1998-11-11 06:34:37 +03:00
|
|
|
{
|
|
|
|
private:
|
1998-12-17 22:26:17 +03:00
|
|
|
nsCOMPtr<nsIDOMDocument> mDomInterfaceP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
|
|
|
// nsCOMPtr<nsISelection> mSelectionP;
|
1999-01-06 23:29:11 +03:00
|
|
|
//nsCOMPtr<nsITransactionManager> mTxnMgrP;
|
|
|
|
nsITransactionManager * mTxnMgr;
|
|
|
|
|
1998-11-11 06:34:37 +03:00
|
|
|
public:
|
1998-11-11 12:26:42 +03:00
|
|
|
/** The default constructor. This should suffice. the setting of the interfaces is done
|
|
|
|
* after the construction of the editor class.
|
|
|
|
*/
|
1998-11-18 03:49:02 +03:00
|
|
|
nsEditor();
|
1998-11-11 12:26:42 +03:00
|
|
|
/** The default destructor. This should suffice. Should this be pure virtual
|
1998-11-18 03:49:02 +03:00
|
|
|
* for someone to derive from the nsEditor later? I dont believe so.
|
1998-11-11 12:26:42 +03:00
|
|
|
*/
|
1998-11-20 22:30:50 +03:00
|
|
|
virtual ~nsEditor();
|
1998-11-11 12:26:42 +03:00
|
|
|
|
1998-11-11 11:12:57 +03:00
|
|
|
/*BEGIN nsIEditor interfaces*/
|
1998-11-15 10:04:45 +03:00
|
|
|
/*see the nsIEditor for more details*/
|
|
|
|
|
|
|
|
/*interfaces for addref and release and queryinterface*/
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1998-11-18 03:49:02 +03:00
|
|
|
virtual nsresult Init(nsIDOMDocument *aDomInterface);
|
1998-11-11 06:34:37 +03:00
|
|
|
|
1998-11-24 00:53:14 +03:00
|
|
|
virtual nsresult GetDomInterface(nsIDOMDocument **aDomInterface);
|
1998-11-11 06:34:37 +03:00
|
|
|
|
1998-11-24 00:53:14 +03:00
|
|
|
virtual nsresult SetProperties(PROPERTIES aProperty);
|
1998-11-18 03:49:02 +03:00
|
|
|
|
1998-11-24 00:53:14 +03:00
|
|
|
virtual nsresult GetProperties(PROPERTIES **);
|
1998-11-18 03:49:02 +03:00
|
|
|
|
1999-01-06 23:29:11 +03:00
|
|
|
virtual nsresult SetAttribute(nsIDOMElement * aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
const nsString& aValue);
|
|
|
|
|
|
|
|
virtual nsresult GetAttributeValue(nsIDOMElement * aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
nsString& aResultValue,
|
|
|
|
PRBool& aResultIsSet);
|
|
|
|
|
|
|
|
virtual nsresult RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
|
|
|
|
|
1998-11-18 03:49:02 +03:00
|
|
|
virtual nsresult InsertString(nsString *aString);
|
|
|
|
|
1998-11-24 00:53:14 +03:00
|
|
|
virtual nsresult Commit(PRBool aCtrlKey);
|
|
|
|
|
1999-01-06 23:29:11 +03:00
|
|
|
|
|
|
|
|
1998-11-11 11:12:57 +03:00
|
|
|
/*END nsIEditor interfaces*/
|
1998-11-11 06:34:37 +03:00
|
|
|
|
1998-11-18 03:49:02 +03:00
|
|
|
/*BEGIN nsEditor interfaces*/
|
1998-11-11 11:12:57 +03:00
|
|
|
|
1998-11-11 06:34:37 +03:00
|
|
|
|
|
|
|
/*KeyListener Methods*/
|
1998-11-11 12:26:42 +03:00
|
|
|
/** KeyDown is called from the key event lister "probably"
|
1998-11-11 11:12:57 +03:00
|
|
|
* @param int aKeycode the keycode or ascii
|
|
|
|
* value of the key that was hit for now
|
|
|
|
* @return False if ignored
|
|
|
|
*/
|
1998-11-11 23:44:02 +03:00
|
|
|
PRBool KeyDown(int aKeycode);
|
1998-11-11 06:34:37 +03:00
|
|
|
|
|
|
|
/*MouseListener Methods*/
|
1998-11-11 11:12:57 +03:00
|
|
|
/** MouseClick
|
|
|
|
* @param int x the xposition of the click
|
|
|
|
* @param int y the yposition of the click
|
|
|
|
*/
|
1998-11-11 23:44:02 +03:00
|
|
|
PRBool MouseClick(int aX,int aY); //it should also tell us the dom element that was selected.
|
1998-11-18 03:49:02 +03:00
|
|
|
|
|
|
|
/*BEGIN private methods used by the implementations of the above functions*/
|
|
|
|
|
|
|
|
/** AppendText is a private method that accepts a pointer to a string
|
|
|
|
* and will append it to the current node. this will be depricated
|
|
|
|
* @param nsString *aStr is the pointer to the valid string
|
|
|
|
*/
|
|
|
|
nsresult AppendText(nsString *aStr);
|
|
|
|
|
|
|
|
/** GetCurrentNode ADDREFFS and will get the current node from selection.
|
|
|
|
* now it simply returns the first node in the dom
|
|
|
|
* @param nsIDOMNode **aNode is the return location of the dom node
|
|
|
|
*/
|
|
|
|
nsresult GetCurrentNode(nsIDOMNode ** aNode);
|
|
|
|
|
|
|
|
/** GetFirstTextNode ADDREFFS and will get the next available text node from the passed
|
|
|
|
* in node parameter it can also return NS_ERROR_FAILURE if no text nodes are available
|
|
|
|
* now it simply returns the first node in the dom
|
|
|
|
* @param nsIDOMNode *aNode is the node to start looking from
|
|
|
|
* @param nsIDOMNode **aRetNode is the return location of the text dom node
|
|
|
|
*/
|
|
|
|
nsresult GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode);
|
|
|
|
|
1999-01-06 23:29:11 +03:00
|
|
|
/** GetFirstNodeOfType ADDREFFS and will get the next available node from the passed
|
|
|
|
* in aStartNode parameter of type aTag.
|
|
|
|
* It can also return NS_ERROR_FAILURE if no such nodes are available
|
|
|
|
* @param nsIDOMNode *aStartNode is the node to start looking from
|
|
|
|
* @param nsIAtom *aTag is the type of node we are searching for
|
|
|
|
* @param nsIDOMNode **aResult is the node we found, or nsnull if there is none
|
|
|
|
*/
|
|
|
|
nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode, const nsString &aTag, nsIDOMNode **aResult);
|
|
|
|
|
|
|
|
/** ExecuteTransaction fires a transaction. It is provided here so
|
|
|
|
* clients need no knowledge of whether the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is used.
|
|
|
|
* Otherwise, the transaction is just executed directly.
|
|
|
|
*
|
|
|
|
* @param aTxn the transaction to execute
|
|
|
|
*/
|
|
|
|
nsresult ExecuteTransaction(nsITransaction *aTxn);
|
|
|
|
|
|
|
|
/** Undo reverses the effects of the last ExecuteTransaction operation
|
|
|
|
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to undo and the result of
|
|
|
|
* that undo is returned.
|
|
|
|
* Otherwise, the Undo request is ignored.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsresult Undo();
|
|
|
|
|
|
|
|
/** Redo reverses the effects of the last Undo operation
|
|
|
|
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to redo and the result of
|
|
|
|
* that redo is returned.
|
|
|
|
* Otherwise, the Redo request is ignored.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsresult Redo();
|
|
|
|
|
1998-11-18 03:49:02 +03:00
|
|
|
/*END private methods of nsEditor*/
|
1998-11-11 06:34:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-11-15 10:04:45 +03:00
|
|
|
/*
|
|
|
|
factory method(s)
|
|
|
|
*/
|
1998-11-24 00:53:14 +03:00
|
|
|
|
|
|
|
nsresult NS_MakeEditorLoader(nsIContextLoader **aResult);
|