1999-03-01 22:54:47 +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://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-06 00:05:35 +03:00
|
|
|
#include "nsTextEditor.h"
|
1999-03-01 22:54:47 +03: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-06 00:05:35 +03:00
|
|
|
class nsHTMLEditor : public nsTextEditor, public nsIHTMLEditor
|
1999-03-01 22:54:47 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// see nsIHTMLEditor for documentation
|
|
|
|
|
|
|
|
//Interfaces for addref and release and queryinterface
|
1999-03-06 00:05:35 +03: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 22:54:47 +03:00
|
|
|
|
|
|
|
nsHTMLEditor();
|
|
|
|
virtual ~nsHTMLEditor();
|
|
|
|
|
1999-03-06 00:05:35 +03:00
|
|
|
//Initialization
|
|
|
|
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
//============================================================================
|
|
|
|
// Methods that are duplicates of nsTextEditor -- exposed here for convenience
|
|
|
|
|
|
|
|
// Editing Operations
|
1999-03-02 10:52:41 +03:00
|
|
|
NS_IMETHOD SetTextProperty(nsIAtom *aProperty);
|
|
|
|
NS_IMETHOD GetTextProperty(nsIAtom *aProperty, PRBool &aAny, PRBool &aAll);
|
|
|
|
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty);
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD DeleteSelection(nsIEditor::Direction aDir);
|
|
|
|
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
1999-03-10 22:49:18 +03:00
|
|
|
NS_IMETHOD InsertBreak();
|
1999-03-01 22:54:47 +03:00
|
|
|
|
|
|
|
// Transaction control
|
1999-03-02 08:30:53 +03: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 22:54:47 +03:00
|
|
|
|
|
|
|
// Selection and navigation -- exposed here for convenience
|
1999-03-02 08:30:53 +03: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 22:33:37 +03:00
|
|
|
NS_IMETHOD SelectAll();
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-03-11 00:29:41 +03:00
|
|
|
// cut, copy & paste
|
|
|
|
NS_IMETHOD Cut();
|
|
|
|
NS_IMETHOD Copy();
|
|
|
|
NS_IMETHOD Paste();
|
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
// Input/Output
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Insert(nsIInputStream *aInputStream);
|
1999-03-06 23:32:48 +03:00
|
|
|
NS_IMETHOD OutputText(nsString& aOutputString);
|
|
|
|
NS_IMETHOD OutputHTML(nsString& aOutputString);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
|
|
|
//=====================================
|
|
|
|
// HTML Editing methods
|
|
|
|
|
|
|
|
// Table Editing (implemented in EditTable.cpp)
|
1999-03-02 08:30:53 +03: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 22:54:47 +03:00
|
|
|
|
|
|
|
// Data members
|
1999-03-29 12:02:05 +04:00
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
protected:
|
|
|
|
|
1999-03-29 12:02:05 +04:00
|
|
|
// rules initialization
|
|
|
|
|
|
|
|
virtual void InitRules();
|
|
|
|
|
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
|
|
|
// For now, the listners are tied to the nsTextEditor class
|
|
|
|
//
|
|
|
|
// nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
|
|
|
// nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsHTMLEditor_h__
|
|
|
|
|