pjs/editor/base/nsTextEditor.h

116 строки
4.8 KiB
C++

/* -*- 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 nsTextEditor_h__
#define nsTextEditor_h__
#include "nsITextEditor.h"
#include "nsCOMPtr.h"
#include "nsIDOMEventListener.h"
class nsISupportsArray;
/**
* The text editor implementation.<br>
* Use to edit text represented as a DOM tree.
* This class is used for editing both plain text and rich text (attributed text).
*/
class nsTextEditor : public nsITextEditor
{
public:
// see nsITextEditor for documentation
//Interfaces for addref and release and queryinterface
NS_DECL_ISUPPORTS
//Initialization
nsTextEditor();
virtual nsresult InitTextEditor(nsIDOMDocument *aDoc,
nsIPresShell *aPresShell,
nsIEditorCallback *aCallback=nsnull);
virtual ~nsTextEditor();
// Editing Operations
virtual nsresult SetTextProperties(nsISupportsArray *aPropList);
virtual nsresult GetTextProperties(nsISupportsArray *aPropList);
virtual nsresult RemoveTextProperties(nsISupportsArray *aPropList);
virtual nsresult DeleteSelection(nsIEditor::Direction aDir);
virtual nsresult InsertText(const nsString& aStringToInsert);
virtual nsresult InsertBreak(PRBool aCtrlKey);
// Transaction control
virtual nsresult EnableUndo(PRBool aEnable);
virtual nsresult Undo(PRUint32 aCount);
virtual nsresult CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
virtual nsresult Redo(PRUint32 aCount);
virtual nsresult CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
virtual nsresult BeginTransaction();
virtual nsresult EndTransaction();
// Selection and navigation -- exposed here for convenience
virtual nsresult MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
virtual nsresult ScrollUp(nsIAtom *aIncrement);
virtual nsresult ScrollDown(nsIAtom *aIncrement);
virtual nsresult ScrollIntoView(PRBool aScrollToBegin);
// Input/Output
virtual nsresult Insert(nsIInputStream *aInputStream);
virtual nsresult OutputText(nsIOutputStream *aOutputStream);
virtual nsresult OutputHTML(nsIOutputStream *aOutputStream);
protected:
// Utility Methods
virtual nsresult SetTextPropertiesForNode(nsIDOMNode *aNode,
nsIDOMNode *aParent,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsIAtom *aPropName);
virtual nsresult SetTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
PRInt32 aStartOffset,
nsIDOMNode *aEndNode,
PRInt32 aEndOffset,
nsIDOMNode *aParent,
nsIAtom *aPropName);
virtual nsresult SetTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStartNode,
PRInt32 aStartOffset,
nsIDOMNode *aEndNode,
PRInt32 aEndOffset,
nsIDOMNode *aParent,
nsIAtom *aPropName);
virtual nsresult SetTagFromProperty(nsAutoString &aTag, nsIAtom *aPropName) const;
// Data members
protected:
nsCOMPtr<nsIEditor> mEditor;
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
};
#endif //nsTextEditor_h__