1999-03-01 19:54:47 +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 nsHTMLEditor_h__
|
|
|
|
#define nsHTMLEditor_h__
|
|
|
|
|
|
|
|
#include "nsITextEditor.h"
|
1999-03-05 21:05:35 +00:00
|
|
|
#include "nsTextEditor.h"
|
1999-03-01 19:54:47 +00:00
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "InsertTableTxn.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The HTML editor implementation.<br>
|
|
|
|
* Use to edit HTML document represented as a DOM tree.
|
|
|
|
*/
|
1999-03-05 21:05:35 +00:00
|
|
|
class nsHTMLEditor : public nsTextEditor, public nsIHTMLEditor
|
1999-03-01 19:54:47 +00:00
|
|
|
{
|
1999-04-30 22:40:18 +00:00
|
|
|
|
|
|
|
typedef enum {eNoOp=0, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
public:
|
|
|
|
// see nsIHTMLEditor for documentation
|
|
|
|
|
|
|
|
//Interfaces for addref and release and queryinterface
|
1999-03-05 21:05:35 +00:00
|
|
|
//NOTE macro used is for classes that inherit from
|
|
|
|
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-03-01 19:54:47 +00:00
|
|
|
|
|
|
|
nsHTMLEditor();
|
|
|
|
virtual ~nsHTMLEditor();
|
|
|
|
|
1999-03-05 21:05:35 +00:00
|
|
|
//Initialization
|
|
|
|
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
//============================================================================
|
|
|
|
// Methods that are duplicates of nsTextEditor -- exposed here for convenience
|
|
|
|
|
|
|
|
// Editing Operations
|
1999-04-15 06:06:33 +00:00
|
|
|
NS_IMETHOD SetTextProperty(nsIAtom *aProperty,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
|
|
|
NS_IMETHOD GetTextProperty(nsIAtom *aProperty,
|
|
|
|
const nsString *aAttribute, const nsString *aValue,
|
|
|
|
PRBool &aFirst, PRBool &aAny, PRBool &aAll);
|
|
|
|
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
1999-05-05 23:27:17 +00:00
|
|
|
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction);
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
1999-03-10 19:49:18 +00:00
|
|
|
NS_IMETHOD InsertBreak();
|
1999-04-21 18:53:55 +00:00
|
|
|
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
1999-03-01 19:54:47 +00:00
|
|
|
|
|
|
|
// Transaction control
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHOD EnableUndo(PRBool aEnable);
|
|
|
|
NS_IMETHOD Undo(PRUint32 aCount);
|
|
|
|
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
|
|
|
|
NS_IMETHOD Redo(PRUint32 aCount);
|
|
|
|
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
|
|
|
|
NS_IMETHOD BeginTransaction();
|
|
|
|
NS_IMETHOD EndTransaction();
|
1999-03-01 19:54:47 +00:00
|
|
|
|
1999-04-21 18:53:55 +00:00
|
|
|
// Selection and navigation
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHOD MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
|
1999-03-11 19:33:37 +00:00
|
|
|
NS_IMETHOD SelectAll();
|
1999-06-10 21:31:42 +00:00
|
|
|
NS_IMETHOD BeginningOfDocument();
|
|
|
|
NS_IMETHOD EndOfDocument();
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
1999-03-01 19:54:47 +00:00
|
|
|
|
1999-05-07 05:02:35 +00:00
|
|
|
// file handling
|
|
|
|
NS_IMETHOD Save();
|
|
|
|
NS_IMETHOD SaveAs(PRBool aSavingCopy);
|
|
|
|
|
1999-03-10 21:29:41 +00:00
|
|
|
// cut, copy & paste
|
|
|
|
NS_IMETHOD Cut();
|
|
|
|
NS_IMETHOD Copy();
|
|
|
|
NS_IMETHOD Paste();
|
1999-05-27 00:08:15 +00:00
|
|
|
NS_IMETHOD PasteAsQuotation();
|
1999-05-28 00:46:34 +00:00
|
|
|
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
1999-05-27 00:08:15 +00:00
|
|
|
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
1999-05-28 00:46:34 +00:00
|
|
|
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
|
|
|
const nsString& aCitation);
|
1999-03-10 21:29:41 +00:00
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
// Input/Output
|
1999-05-27 00:08:15 +00:00
|
|
|
NS_IMETHOD InsertHTML(const nsString& aInputString);
|
|
|
|
|
1999-05-03 22:57:48 +00:00
|
|
|
NS_IMETHOD BeginComposition(void);
|
1999-06-29 20:31:22 +00:00
|
|
|
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIDOMTextRangeList* aTextRange);
|
1999-05-03 22:57:48 +00:00
|
|
|
NS_IMETHOD EndComposition(void);
|
1999-06-29 20:14:24 +00:00
|
|
|
NS_IMETHOD OutputTextToString(nsString& aOutputString, PRBool aSelectionOnly);
|
|
|
|
NS_IMETHOD OutputHTMLToString(nsString& aOutputString, PRBool aSelectionOnly);
|
|
|
|
NS_IMETHOD OutputTextToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride, PRBool aSelectionOnly);
|
|
|
|
NS_IMETHOD OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride, PRBool aSelectionOnly);
|
1999-03-01 19:54:47 +00:00
|
|
|
|
1999-07-01 19:32:35 +00:00
|
|
|
// Miscellaneous
|
|
|
|
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
|
|
|
|
1999-06-14 20:02:46 +00:00
|
|
|
// Logging methods
|
|
|
|
|
|
|
|
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
|
|
|
NS_IMETHOD StopLogging();
|
|
|
|
|
1999-04-21 18:53:55 +00:00
|
|
|
// End of methods implemented in nsEditor
|
|
|
|
//=============================================================
|
1999-03-01 19:54:47 +00:00
|
|
|
// HTML Editing methods
|
1999-05-26 21:40:51 +00:00
|
|
|
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
|
|
|
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
1999-04-30 22:40:18 +00:00
|
|
|
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList);
|
1999-04-20 17:47:12 +00:00
|
|
|
NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
1999-04-30 22:40:18 +00:00
|
|
|
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
1999-05-05 04:05:19 +00:00
|
|
|
NS_IMETHOD RemoveParagraphStyle();
|
1999-04-22 14:45:48 +00:00
|
|
|
NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
1999-04-20 17:47:12 +00:00
|
|
|
|
1999-05-05 23:29:18 +00:00
|
|
|
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
|
|
|
|
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
|
|
|
|
|
1999-05-17 13:10:29 +00:00
|
|
|
NS_IMETHOD Indent(const nsString& aIndent);
|
|
|
|
NS_IMETHOD Align(const nsString& aAlign);
|
1999-03-29 22:01:26 +00:00
|
|
|
NS_IMETHOD InsertLink(nsString& aURL);
|
|
|
|
NS_IMETHOD InsertImage(nsString& aURL,
|
|
|
|
nsString& aWidth, nsString& aHeight,
|
|
|
|
nsString& aHspace, nsString& aVspace,
|
|
|
|
nsString& aBorder,
|
|
|
|
nsString& aAlt, nsString& aAlignment);
|
1999-05-17 13:10:29 +00:00
|
|
|
NS_IMETHOD InsertList(const nsString& aListType);
|
1999-03-01 19:54:47 +00:00
|
|
|
|
1999-04-21 18:53:55 +00:00
|
|
|
// This should replace InsertLink and InsertImage once it is working
|
|
|
|
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
|
|
|
|
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
|
1999-07-04 23:01:10 +00:00
|
|
|
NS_IMETHOD CanContainElement(nsIDOMNode* aParent, nsIDOMElement* aElement);
|
1999-06-10 21:31:42 +00:00
|
|
|
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
1999-06-12 21:22:12 +00:00
|
|
|
NS_IMETHOD SaveHLineSettings(nsIDOMElement* aElement);
|
1999-05-07 22:26:23 +00:00
|
|
|
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
1999-05-26 21:40:51 +00:00
|
|
|
PRBool IsElementInBody(nsIDOMElement* aElement);
|
|
|
|
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
|
|
|
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
1999-04-21 18:53:55 +00:00
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
// Table Editing (implemented in EditTable.cpp)
|
1999-03-02 05:30:53 +00:00
|
|
|
NS_IMETHOD CreateTxnForInsertTable(const nsIDOMElement *aTableNode, InsertTableTxn ** aTxn);
|
|
|
|
NS_IMETHOD GetColIndexForCell(nsIDOMNode *aCellNode, PRInt32 &aCellIndex);
|
|
|
|
NS_IMETHOD GetRowIndexForCell(nsIDOMNode *aCellNode, PRInt32 &aCellIndex);
|
|
|
|
NS_IMETHOD GetFirstCellInColumn(nsIDOMNode *aCurrentCellNode, nsIDOMNode* &aFirstCellNode);
|
|
|
|
NS_IMETHOD GetNextCellInColumn(nsIDOMNode *aCurrentCellNode, nsIDOMNode* &aNextCellNode);
|
|
|
|
NS_IMETHOD GetFirstCellInRow(nsIDOMNode *aCurrentCellNode, nsIDOMNode* &aCellNode);
|
|
|
|
NS_IMETHOD GetNextCellInRow(nsIDOMNode *aCurrentCellNode, nsIDOMNode* &aNextCellNode);
|
|
|
|
NS_IMETHOD InsertTable();
|
|
|
|
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD DeleteTable();
|
|
|
|
NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD JoinTableCells(PRBool aCellToRight);
|
1999-03-01 19:54:47 +00:00
|
|
|
|
|
|
|
// Data members
|
1999-03-29 08:02:05 +00:00
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
protected:
|
|
|
|
|
1999-03-29 08:02:05 +00:00
|
|
|
// rules initialization
|
|
|
|
|
|
|
|
virtual void InitRules();
|
1999-04-20 17:47:12 +00:00
|
|
|
|
1999-04-30 22:40:18 +00:00
|
|
|
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
|
|
|
|
nsString &aParentTag,
|
|
|
|
BlockTransformationType aTranformation);
|
1999-04-20 17:47:12 +00:00
|
|
|
|
|
|
|
NS_IMETHOD ReParentBlockContent(nsIDOMNode *aNode,
|
|
|
|
nsString &aParentTag,
|
|
|
|
nsIDOMNode *aBlockParentNode,
|
|
|
|
nsString &aBlockParentTag,
|
1999-04-30 22:40:18 +00:00
|
|
|
BlockTransformationType aTranformation,
|
1999-04-20 17:47:12 +00:00
|
|
|
nsIDOMNode **aNewParentNode);
|
1999-03-29 08:02:05 +00:00
|
|
|
|
1999-04-30 22:40:18 +00:00
|
|
|
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange,
|
|
|
|
nsString &aParentTag,
|
|
|
|
BlockTransformationType aTranformation);
|
1999-03-29 08:02:05 +00:00
|
|
|
|
1999-05-05 04:05:19 +00:00
|
|
|
NS_IMETHOD RemoveParagraphStyleFromRange(nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParagraphStyleFromBlockContent(nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParentFromRange(const nsString &aParentTag, nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParentFromBlockContent(const nsString &aParentTag, nsIDOMRange *aRange);
|
|
|
|
|
1999-05-17 14:14:36 +00:00
|
|
|
PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag);
|
1999-05-05 04:05:19 +00:00
|
|
|
|
|
|
|
NS_IMETHOD IsRootTag(nsString &aTag, PRBool &aIsTag);
|
|
|
|
|
|
|
|
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
|
|
|
|
|
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
|
|
|
// For now, the listners are tied to the nsTextEditor class
|
|
|
|
//
|
|
|
|
// nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
|
|
|
// nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
|
|
|
|
1999-05-27 04:10:04 +00:00
|
|
|
// this overrides the base class implementation. It is not exported in nsIHTMLEditor.
|
|
|
|
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
1999-05-03 18:48:39 +00:00
|
|
|
|
1999-03-01 19:54:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsHTMLEditor_h__
|
|
|
|
|