1999-03-29 10:21:01 +04: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://www.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsHTMLEditRules_h__
|
|
|
|
#define nsHTMLEditRules_h__
|
|
|
|
|
|
|
|
#include "nsTextEditRules.h"
|
1999-04-12 16:01:32 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-03-29 10:21:01 +04:00
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
class nsISupportsArray;
|
1999-07-01 17:42:03 +04:00
|
|
|
class nsVoidArray;
|
1999-06-16 09:02:43 +04:00
|
|
|
|
1999-03-29 10:21:01 +04:00
|
|
|
class nsHTMLEditRules : public nsTextEditRules
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsHTMLEditRules();
|
|
|
|
virtual ~nsHTMLEditRules();
|
|
|
|
|
1999-04-05 21:21:59 +04:00
|
|
|
// nsEditRules methods
|
1999-04-12 16:01:32 +04:00
|
|
|
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
|
|
|
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
1999-04-05 21:21:59 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
1999-04-21 18:49:58 +04:00
|
|
|
enum IterDirection
|
|
|
|
{
|
|
|
|
kIterForward,
|
|
|
|
kIterBackward
|
|
|
|
};
|
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
enum RulesEndpoint
|
|
|
|
{
|
|
|
|
kStart,
|
|
|
|
kEnd
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-04-05 21:21:59 +04:00
|
|
|
// nsHTMLEditRules implementation methods
|
1999-04-12 16:01:32 +04:00
|
|
|
nsresult WillInsertText(nsIDOMSelection *aSelection,
|
1999-06-08 10:04:51 +04:00
|
|
|
PRBool *aCancel,
|
1999-04-12 16:01:32 +04:00
|
|
|
PlaceholderTxn **aTxn,
|
|
|
|
const nsString *inString,
|
|
|
|
nsString *outString,
|
1999-06-08 10:04:51 +04:00
|
|
|
TypeInState typeInState,
|
|
|
|
PRInt32 aMaxLength);
|
1999-04-12 16:01:32 +04:00
|
|
|
nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel);
|
1999-05-06 03:27:17 +04:00
|
|
|
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECollapsedSelectionAction aAction, PRBool *aCancel);
|
1999-06-16 09:02:43 +04:00
|
|
|
nsresult WillMakeList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel);
|
1999-06-03 10:01:08 +04:00
|
|
|
nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
1999-06-16 09:02:43 +04:00
|
|
|
nsresult WillAlign(nsIDOMSelection *aSelection, const nsString *alignType, PRBool *aCancel);
|
1999-06-03 10:01:08 +04:00
|
|
|
nsresult WillMakeHeader(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
nsresult WillMakeAddress(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
nsresult WillMakePRE(nsIDOMSelection *aSelection, PRBool *aCancel);
|
1999-04-12 16:01:32 +04:00
|
|
|
|
|
|
|
nsresult InsertTab(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, nsString *outString);
|
|
|
|
nsresult InsertSpace(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, nsString *outString);
|
|
|
|
|
1999-04-26 18:08:52 +04:00
|
|
|
nsresult ReturnInHeader(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
|
|
|
|
nsresult ReturnInParagraph(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel);
|
|
|
|
nsresult ReturnInListItem(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
|
|
|
|
|
1999-04-12 16:01:32 +04:00
|
|
|
// helper methods
|
1999-04-21 18:49:58 +04:00
|
|
|
static nsresult GetTabAsNBSPs(nsString *outString);
|
|
|
|
static nsresult GetTabAsNBSPsAndSpace(nsString *outString);
|
1999-05-29 01:17:30 +04:00
|
|
|
|
1999-04-26 18:08:52 +04:00
|
|
|
static PRBool IsHeader(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsParagraph(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsListItem(nsIDOMNode *aNode);
|
1999-06-16 09:02:43 +04:00
|
|
|
static PRBool IsUnorderedList(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsOrderedList(nsIDOMNode *aNode);
|
1999-04-26 18:08:52 +04:00
|
|
|
static PRBool IsBreak(nsIDOMNode *aNode);
|
1999-06-16 09:02:43 +04:00
|
|
|
static PRBool IsBody(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsBlockquote(nsIDOMNode *aNode);
|
1999-06-25 13:33:02 +04:00
|
|
|
static PRBool IsDiv(nsIDOMNode *aNode);
|
1999-06-16 09:02:43 +04:00
|
|
|
|
|
|
|
static PRBool IsFirstNode(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsLastNode(nsIDOMNode *aNode);
|
|
|
|
static nsresult GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset,
|
|
|
|
PRInt32 actionID, nsCOMPtr<nsIDOMNode> *outNode, PRInt32 *outOffset);
|
1999-07-01 17:42:03 +04:00
|
|
|
static nsresult GetPromotedRanges(nsIDOMSelection *inSelection,
|
|
|
|
nsCOMPtr<nsISupportsArray> *outArrayOfRanges,
|
|
|
|
PRInt32 inOperationType);
|
|
|
|
static nsresult GetNodesForOperation(nsISupportsArray *inArrayOfRanges,
|
|
|
|
nsCOMPtr<nsISupportsArray> *outArrayOfNodes,
|
|
|
|
PRInt32 inOperationType);
|
|
|
|
static nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes,
|
|
|
|
nsVoidArray *inTransitionArray);
|
1999-06-16 09:02:43 +04:00
|
|
|
|
|
|
|
nsresult ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, nsString &aNodeType);
|
1999-06-25 13:33:02 +04:00
|
|
|
nsresult RemoveContainer(nsIDOMNode *inNode);
|
|
|
|
nsresult InsertContainerAbove(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, nsString &aNodeType);
|
1999-06-16 09:02:43 +04:00
|
|
|
|
1999-03-29 10:21:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsHTMLEditRules_h__
|
|
|
|
|