1999-03-29 06:21:01 +00: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-07-01 23:41:29 +00:00
|
|
|
#include "nsISupportsArray.h"
|
1999-04-12 12:01:32 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-03-29 06:21:01 +00:00
|
|
|
|
1999-06-16 05:02:43 +00:00
|
|
|
class nsISupportsArray;
|
1999-07-01 13:42:03 +00:00
|
|
|
class nsVoidArray;
|
1999-06-16 05:02:43 +00:00
|
|
|
|
1999-03-29 06:21:01 +00:00
|
|
|
class nsHTMLEditRules : public nsTextEditRules
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
1999-08-09 18:39:49 +00:00
|
|
|
nsHTMLEditRules();
|
1999-08-09 01:37:50 +00:00
|
|
|
virtual ~nsHTMLEditRules();
|
1999-03-29 06:21:01 +00:00
|
|
|
|
1999-04-05 17:21:59 +00:00
|
|
|
// nsEditRules methods
|
1999-04-12 12:01:32 +00:00
|
|
|
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
|
|
|
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
1999-04-05 17:21:59 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
1999-06-16 05:02:43 +00:00
|
|
|
enum RulesEndpoint
|
|
|
|
{
|
|
|
|
kStart,
|
|
|
|
kEnd
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-04-05 17:21:59 +00:00
|
|
|
// nsHTMLEditRules implementation methods
|
1999-04-12 12:01:32 +00:00
|
|
|
nsresult WillInsertText(nsIDOMSelection *aSelection,
|
1999-06-08 06:04:51 +00:00
|
|
|
PRBool *aCancel,
|
1999-04-12 12:01:32 +00:00
|
|
|
PlaceholderTxn **aTxn,
|
|
|
|
const nsString *inString,
|
|
|
|
nsString *outString,
|
1999-06-08 06:04:51 +00:00
|
|
|
TypeInState typeInState,
|
|
|
|
PRInt32 aMaxLength);
|
1999-04-12 12:01:32 +00:00
|
|
|
nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel);
|
1999-08-09 01:37:50 +00:00
|
|
|
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ESelectionCollapseDirection aAction, PRBool *aCancel);
|
1999-06-16 05:02:43 +00:00
|
|
|
nsresult WillMakeList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel);
|
1999-09-06 19:51:59 +00:00
|
|
|
nsresult WillRemoveList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel);
|
1999-06-03 06:01:08 +00:00
|
|
|
nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
|
|
|
nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
1999-06-16 05:02:43 +00:00
|
|
|
nsresult WillAlign(nsIDOMSelection *aSelection, const nsString *alignType, PRBool *aCancel);
|
1999-08-18 08:13:06 +00:00
|
|
|
nsresult WillMakeBasicBlock(nsIDOMSelection *aSelection, const nsString *aBlockType, PRBool *aCancel);
|
1999-04-12 12:01:32 +00:00
|
|
|
|
|
|
|
nsresult InsertTab(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, nsString *outString);
|
|
|
|
nsresult InsertSpace(nsIDOMSelection *aSelection, PRBool *aCancel, PlaceholderTxn **aTxn, nsString *outString);
|
|
|
|
|
1999-04-26 14:08:52 +00: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 12:01:32 +00:00
|
|
|
// helper methods
|
1999-04-21 14:49:58 +00:00
|
|
|
static nsresult GetTabAsNBSPs(nsString *outString);
|
|
|
|
static nsresult GetTabAsNBSPsAndSpace(nsString *outString);
|
1999-05-28 21:17:30 +00:00
|
|
|
|
1999-04-26 14:08:52 +00:00
|
|
|
static PRBool IsHeader(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsParagraph(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsListItem(nsIDOMNode *aNode);
|
1999-08-18 08:13:06 +00:00
|
|
|
static PRBool IsList(nsIDOMNode *aNode);
|
1999-06-16 05:02:43 +00:00
|
|
|
static PRBool IsUnorderedList(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsOrderedList(nsIDOMNode *aNode);
|
1999-04-26 14:08:52 +00:00
|
|
|
static PRBool IsBreak(nsIDOMNode *aNode);
|
1999-06-16 05:02:43 +00:00
|
|
|
static PRBool IsBody(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsBlockquote(nsIDOMNode *aNode);
|
1999-06-25 09:33:02 +00:00
|
|
|
static PRBool IsDiv(nsIDOMNode *aNode);
|
1999-09-06 19:51:59 +00:00
|
|
|
static PRBool IsMailCite(nsIDOMNode *aNode);
|
1999-09-09 22:22:14 +00:00
|
|
|
|
|
|
|
static PRBool InBody(nsIDOMNode *aNode);
|
|
|
|
|
1999-08-09 21:49:25 +00:00
|
|
|
nsresult IsEmptyBlock(nsIDOMNode *aNode, PRBool *outIsEmptyBlock);
|
1999-09-06 19:51:59 +00:00
|
|
|
nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyNode);
|
1999-07-01 18:42:28 +00:00
|
|
|
PRBool IsFirstNode(nsIDOMNode *aNode);
|
|
|
|
PRBool IsLastNode(nsIDOMNode *aNode);
|
1999-09-12 01:36:07 +00:00
|
|
|
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
|
|
|
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
|
|
|
nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
|
|
|
nsresult GetNextHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
1999-08-18 08:13:06 +00:00
|
|
|
|
1999-07-01 18:42:28 +00:00
|
|
|
nsresult GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset,
|
|
|
|
PRInt32 actionID, nsCOMPtr<nsIDOMNode> *outNode, PRInt32 *outOffset);
|
|
|
|
nsresult GetPromotedRanges(nsIDOMSelection *inSelection,
|
|
|
|
nsCOMPtr<nsISupportsArray> *outArrayOfRanges,
|
|
|
|
PRInt32 inOperationType);
|
1999-08-18 08:13:06 +00:00
|
|
|
nsresult GetNodesForOperation(nsISupportsArray *inArrayOfRanges,
|
1999-07-01 13:42:03 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> *outArrayOfNodes,
|
|
|
|
PRInt32 inOperationType);
|
1999-08-18 08:13:06 +00:00
|
|
|
nsresult GetChildNodesForOperation(nsIDOMNode *inNode,
|
|
|
|
nsCOMPtr<nsISupportsArray> *outArrayOfNodes);
|
|
|
|
nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes,
|
1999-07-01 13:42:03 +00:00
|
|
|
nsVoidArray *inTransitionArray);
|
1999-08-18 08:13:06 +00:00
|
|
|
|
|
|
|
nsresult ShouldMakeEmptyBlock(nsIDOMSelection *aSelection, const nsString *blockTag, PRBool *outMakeEmpty);
|
|
|
|
nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag);
|
|
|
|
|
|
|
|
nsresult ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, const nsString &aNodeType);
|
1999-06-25 09:33:02 +00:00
|
|
|
nsresult RemoveContainer(nsIDOMNode *inNode);
|
|
|
|
nsresult InsertContainerAbove(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, nsString &aNodeType);
|
1999-06-16 05:02:43 +00:00
|
|
|
|
1999-08-24 08:56:51 +00:00
|
|
|
nsresult IsFirstEditableChild( nsIDOMNode *aNode, PRBool *aOutIsFirst);
|
|
|
|
nsresult IsLastEditableChild( nsIDOMNode *aNode, PRBool *aOutIsLast);
|
|
|
|
|
1999-09-01 21:23:47 +00:00
|
|
|
nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft,
|
|
|
|
nsIDOMNode *aNodeRight,
|
|
|
|
nsCOMPtr<nsIDOMNode> *aOutMergeParent,
|
|
|
|
PRInt32 *aOutMergeOffset);
|
|
|
|
|
1999-09-06 19:51:59 +00:00
|
|
|
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutCiteNode);
|
|
|
|
nsresult CleanUpSelection(nsIDOMSelection *aSelection);
|
|
|
|
nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList);
|
|
|
|
|
1999-03-29 06:21:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsHTMLEditRules_h__
|
|
|
|
|