зеркало из https://github.com/mozilla/gecko-dev.git
Landing editor API changes. Removed nsITextEditor and nsTextEditor, split interfaces into more, non-overlapping interfaces, and other general cleanup.
This commit is contained in:
Родитель
7badb78ac8
Коммит
d73dfd8ddb
|
@ -79,7 +79,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
result = mEditor->GetDocument(getter_AddRefs(doc));
|
||||
if ((NS_SUCCEEDED(result)) && (doc))
|
||||
{
|
||||
if (nsIEditor::GetTextNodeTag() == mTag)
|
||||
if (nsEditor::GetTextNodeTag() == mTag)
|
||||
{
|
||||
const nsString stringData;
|
||||
nsCOMPtr<nsIDOMText>newTextNode;
|
||||
|
|
|
@ -123,7 +123,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
else
|
||||
{ // the selection ends in a different node from where it started
|
||||
// delete the relevant content in the start node
|
||||
result = CreateTxnsToDeleteContent(mStartParent, mStartOffset, nsIEditor::eDeleteRight);
|
||||
result = CreateTxnsToDeleteContent(mStartParent, mStartOffset, nsIEditor::eDeleteNext);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
// delete the intervening nodes
|
||||
|
@ -131,7 +131,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
// delete the relevant content in the end node
|
||||
result = CreateTxnsToDeleteContent(mEndParent, mEndOffset, nsIEditor::eDeleteLeft);
|
||||
result = CreateTxnsToDeleteContent(mEndParent, mEndOffset, nsIEditor::eDeletePrevious);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent
|
|||
|
||||
NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
||||
PRUint32 aOffset,
|
||||
nsIEditor::ECollapsedSelectionAction aAction)
|
||||
nsIEditor::ESelectionCollapseDirection aAction)
|
||||
{
|
||||
nsresult result;
|
||||
// see what kind of node we have
|
||||
|
@ -290,7 +290,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
|||
if (textNode)
|
||||
{ // if the node is a text node, then delete text content
|
||||
PRUint32 start, numToDelete;
|
||||
if (nsIEditor::eDeleteRight == aAction)
|
||||
if (nsIEditor::eDeleteNext == aAction)
|
||||
{
|
||||
start=aOffset;
|
||||
textNode->GetLength(&numToDelete);
|
||||
|
|
|
@ -32,6 +32,9 @@ class nsIDOMDocument;
|
|||
0x5ec6b260, 0xac49, 0x11d2, \
|
||||
{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} }
|
||||
|
||||
class nsIDOMRange;
|
||||
class nsIEditor;
|
||||
|
||||
/**
|
||||
* A transaction that deletes an entire range in the content tree
|
||||
*/
|
||||
|
@ -78,7 +81,7 @@ protected:
|
|||
|
||||
NS_IMETHOD CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
||||
PRUint32 aOffset,
|
||||
nsIEditor::ECollapsedSelectionAction aAction);
|
||||
nsIEditor::ESelectionCollapseDirection aAction);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "nsITableLayout.h" // data owned by the table and cell frames
|
||||
#include "nsHTMLEditor.h"
|
||||
|
||||
#include "nsEditorUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
|
||||
// Table Editing methods
|
||||
|
@ -244,7 +246,7 @@ nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell, PRInt32 &aColIndex, PRInt32 &
|
|||
res = NS_ERROR_FAILURE; // we return an error unless we get the index
|
||||
nsISupports *layoutObject=nsnull; // frames are not ref counted, so don't use an nsCOMPtr
|
||||
|
||||
res = nsEditor::GetLayoutObject(aCell, &layoutObject);
|
||||
res = nsHTMLEditor::GetLayoutObject(aCell, &layoutObject);
|
||||
|
||||
if ((NS_SUCCEEDED(res)) && (nsnull!=layoutObject))
|
||||
{ // get the table cell interface from the frame
|
||||
|
@ -268,7 +270,7 @@ nsHTMLEditor::GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **table
|
|||
|
||||
// frames are not ref counted, so don't use an nsCOMPtr
|
||||
nsISupports *layoutObject=nsnull;
|
||||
nsresult res = nsEditor::GetLayoutObject(aTable, &layoutObject);
|
||||
nsresult res = nsHTMLEditor::GetLayoutObject(aTable, &layoutObject);
|
||||
if ((NS_SUCCEEDED(res)) && (nsnull!=layoutObject))
|
||||
{ // get the table interface from the frame
|
||||
|
||||
|
|
|
@ -27,16 +27,15 @@ IS_COMPONENT = 1
|
|||
|
||||
CPPSRCS = \
|
||||
nsEditor.cpp \
|
||||
nsTextEditor.cpp \
|
||||
nsEditorUtils.cpp \
|
||||
nsEditorRegistration.cpp \
|
||||
nsTextEditRules.cpp \
|
||||
TextEditorTest.cpp \
|
||||
nsHTMLEditRules.cpp \
|
||||
nsEditorEventListeners.cpp \
|
||||
nsEditProperty.cpp \
|
||||
nsEditFactory.cpp \
|
||||
nsHTMLEditFactory.cpp \
|
||||
nsEditorFactory.cpp \
|
||||
nsHTMLEditor.cpp \
|
||||
nsTextEditFactory.cpp \
|
||||
ChangeAttributeTxn.cpp \
|
||||
EditTxn.cpp \
|
||||
EditAggregateTxn.cpp \
|
||||
|
@ -53,6 +52,7 @@ CPPSRCS = \
|
|||
JoinElementTxn.cpp \
|
||||
nsStyleSheetTxns.cpp \
|
||||
TransactionFactory.cpp \
|
||||
TypeInState.cpp \
|
||||
nsInternetCiter.cpp \
|
||||
nsAOLCiter.cpp \
|
||||
nsInterfaceState.cpp \
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsITextEditor.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "TextEditorTest.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
|
@ -43,7 +43,7 @@ TextEditorTest::~TextEditorTest()
|
|||
printf("destroyed a TextEditorTest\n");
|
||||
}
|
||||
|
||||
void TextEditorTest::Run(nsITextEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
|
||||
void TextEditorTest::Run(nsIEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
|
||||
{
|
||||
if (!aEditor) return;
|
||||
mTextEditor = do_QueryInterface(aEditor);
|
||||
|
@ -98,9 +98,9 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
|
|||
|
||||
nsresult TextEditorTest::InitDoc()
|
||||
{
|
||||
nsresult result = mTextEditor->SelectAll();
|
||||
nsresult result = mEditor->SelectAll();
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->DeleteSelection(nsIEditor::eDeleteRight);
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeleteNext);
|
||||
TEST_RESULT(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -165,14 +165,14 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first=PR_FALSE;
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_FALSE==first, "first should be false");
|
||||
NS_ASSERTION(PR_FALSE==any, "any should be false");
|
||||
NS_ASSERTION(PR_FALSE==all, "all should be false");
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
@ -181,9 +181,9 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
|
||||
// remove the bold we just set
|
||||
printf("set the whole first text node to not bold\n");
|
||||
result = mTextEditor->RemoveTextProperty(nsIEditProperty::b, nsnull);
|
||||
result = mTextEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_FALSE==first, "first should be false");
|
||||
NS_ASSERTION(PR_FALSE==any, "any should be false");
|
||||
|
@ -194,23 +194,23 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n");
|
||||
selection->Collapse(textNode, 1);
|
||||
selection->Extend(textNode, length-1);
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
NS_ASSERTION(PR_TRUE==all, "all should be true");
|
||||
mEditor->DebugDumpContent();
|
||||
// make all that same text italic
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
NS_ASSERTION(PR_TRUE==all, "all should be true");
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
@ -231,9 +231,9 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
NS_ASSERTION(length==249, "wrong text node");
|
||||
selection->Collapse(textNode, 1);
|
||||
selection->Extend(textNode, length-2);
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#ifdef NS_DEBUG
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
class TextEditorTest
|
||||
{
|
||||
public:
|
||||
|
||||
void Run(nsITextEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
void Run(nsIEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
TextEditorTest();
|
||||
~TextEditorTest();
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected:
|
|||
|
||||
nsresult TestTextProperties();
|
||||
|
||||
nsCOMPtr<nsITextEditor> mTextEditor;
|
||||
nsCOMPtr<nsIHTMLEditor> mTextEditor;
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ChangeAttributeTxn_h__
|
||||
#define ChangeAttributeTxn_h__
|
||||
#ifndef TypeInState_h__
|
||||
#define TypeInState_h__
|
||||
|
||||
#include "nsIDOMSelectionListener.h"
|
||||
#include "nsIEditProperty.h"
|
||||
|
@ -228,4 +228,5 @@ inline void TypeInState::SetPropValue(PRUint32 aProp, const nsString &aValue)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // TypeInState_h__
|
||||
|
||||
|
|
|
@ -22,16 +22,16 @@ include <$(DEPTH)/config/config.mak>
|
|||
LIBRARY_NAME=ender
|
||||
|
||||
CPPSRCS = \
|
||||
nsInsertHTMLTxn.cpp \
|
||||
nsInsertHTMLTxn.cpp \
|
||||
nsEditor.cpp \
|
||||
nsTextEditor.cpp \
|
||||
nsEditorUtils.cpp \
|
||||
nsEditorRegistration.cpp \
|
||||
nsTextEditRules.cpp \
|
||||
nsHTMLEditRules.cpp \
|
||||
TextEditorTest.cpp \
|
||||
nsEditorEventListeners.cpp \
|
||||
nsEditProperty.cpp \
|
||||
nsEditFactory.cpp \
|
||||
nsTextEditFactory.cpp \
|
||||
nsEditProperty.cpp \
|
||||
nsEditorFactory.cpp \
|
||||
EditTxn.cpp \
|
||||
EditAggregateTxn.cpp \
|
||||
ChangeAttributeTxn.cpp \
|
||||
|
@ -46,31 +46,31 @@ CPPSRCS = \
|
|||
JoinElementTxn.cpp \
|
||||
nsStyleSheetTxns.cpp \
|
||||
TransactionFactory.cpp \
|
||||
TypeInState.cpp \
|
||||
nsHTMLEditor.cpp \
|
||||
nsHTMLEditFactory.cpp \
|
||||
EditTable.cpp \
|
||||
nsInternetCiter.cpp \
|
||||
nsAOLCiter.cpp \
|
||||
nsInterfaceState.cpp \
|
||||
nsEditorShell.cpp \
|
||||
nsInternetCiter.cpp \
|
||||
nsAOLCiter.cpp \
|
||||
nsInterfaceState.cpp \
|
||||
nsEditorShell.cpp \
|
||||
nsEditorShellFactory.cpp \
|
||||
nsJSEditorLog.cpp \
|
||||
nsJSTxnLog.cpp \
|
||||
IMETextTxn.cpp \
|
||||
IMECommitTxn.cpp \
|
||||
nsJSEditorLog.cpp \
|
||||
nsJSTxnLog.cpp \
|
||||
IMETextTxn.cpp \
|
||||
IMECommitTxn.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsInsertHTMLTxn.obj \
|
||||
.\$(OBJDIR)\nsInsertHTMLTxn.obj \
|
||||
.\$(OBJDIR)\nsEditor.obj \
|
||||
.\$(OBJDIR)\nsTextEditor.obj \
|
||||
.\$(OBJDIR)\nsEditorUtils.obj \
|
||||
.\$(OBJDIR)\nsEditorRegistration.obj \
|
||||
.\$(OBJDIR)\nsTextEditRules.obj \
|
||||
.\$(OBJDIR)\TextEditorTest.obj \
|
||||
.\$(OBJDIR)\nsHTMLEditRules.obj \
|
||||
.\$(OBJDIR)\nsEditorEventListeners.obj \
|
||||
.\$(OBJDIR)\nsEditProperty.obj \
|
||||
.\$(OBJDIR)\nsEditFactory.obj \
|
||||
.\$(OBJDIR)\nsTextEditFactory.obj \
|
||||
.\$(OBJDIR)\nsEditorFactory.obj \
|
||||
.\$(OBJDIR)\EditTxn.obj \
|
||||
.\$(OBJDIR)\EditAggregateTxn.obj \
|
||||
.\$(OBJDIR)\ChangeAttributeTxn.obj \
|
||||
|
@ -85,17 +85,17 @@ CPP_OBJS = \
|
|||
.\$(OBJDIR)\JoinElementTxn.obj \
|
||||
.\$(OBJDIR)\nsStyleSheetTxns.obj \
|
||||
.\$(OBJDIR)\TransactionFactory.obj \
|
||||
.\$(OBJDIR)\TypeInState.obj \
|
||||
.\$(OBJDIR)\nsHTMLEditor.obj \
|
||||
.\$(OBJDIR)\nsHTMLEditFactory.obj \
|
||||
.\$(OBJDIR)\EditTable.obj \
|
||||
.\$(OBJDIR)\nsInternetCiter.obj \
|
||||
.\$(OBJDIR)\nsAOLCiter.obj \
|
||||
.\$(OBJDIR)\nsInterfaceState.obj \
|
||||
.\$(OBJDIR)\nsEditorShell.obj \
|
||||
.\$(OBJDIR)\nsInternetCiter.obj \
|
||||
.\$(OBJDIR)\nsAOLCiter.obj \
|
||||
.\$(OBJDIR)\nsInterfaceState.obj \
|
||||
.\$(OBJDIR)\nsEditorShell.obj \
|
||||
.\$(OBJDIR)\nsEditorShellFactory.obj \
|
||||
.\$(OBJDIR)\nsJSEditorLog.obj \
|
||||
.\$(OBJDIR)\nsJSTxnLog.obj \
|
||||
.\$(OBJDIR)\IMETextTxn.obj \
|
||||
.\$(OBJDIR)\IMETextTxn.obj \
|
||||
.\$(OBJDIR)\IMECommitTxn.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef nsEditRules_h__
|
||||
#define nsEditRules_h__
|
||||
|
||||
class nsIEditor;
|
||||
class nsHTMLEditor;
|
||||
class nsIDOMSelection;
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -43,9 +43,11 @@ class nsRulesInfo
|
|||
class nsEditRules
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD Init(nsIEditor *aEditor)=0;
|
||||
NS_IMETHOD Init(nsHTMLEditor *aEditor)=0;
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel)=0;
|
||||
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0;
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags)=0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags)=0;
|
||||
|
||||
};
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -19,15 +19,20 @@
|
|||
#ifndef __editor_h__
|
||||
#define __editor_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prmon.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditorIMESupport.h"
|
||||
#include "nsIEditorLogging.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIPrivateTextRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "TransactionFactory.h"
|
||||
|
@ -78,43 +83,10 @@ PRMonitor *GetEditorMonitor();
|
|||
* manager, event interfaces. the idea for the event interfaces is to have them
|
||||
* delegate the actual commands to the editor independent of the XPFE implementation.
|
||||
*/
|
||||
class nsEditor : public nsIEditor
|
||||
class nsEditor : public nsIEditor,
|
||||
public nsIEditorIMESupport,
|
||||
public nsIEditorLogging
|
||||
{
|
||||
private:
|
||||
nsIPresShell *mPresShell;
|
||||
nsIViewManager *mViewManager;
|
||||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
//
|
||||
nsCOMPtr<nsIDOMCharacterData> mIMETextNode;
|
||||
PRUint32 mIMETextOffset;
|
||||
PRUint32 mIMEBufferLength;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
nsVoidArray* mActionListeners;
|
||||
nsCOMPtr<nsISupportsArray> mDocStateListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
PRInt8 mDocDirtyState; // -1 = not initialized
|
||||
|
||||
protected:
|
||||
nsIDOMDocument * mDoc;
|
||||
nsCOMPtr<nsIDTD> mDTD;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
nsJSEditorLog *mJSEditorLog;
|
||||
nsJSTxnLog *mJSTxnLog;
|
||||
#endif // ENABLE_JS_EDITOR_LOG
|
||||
|
||||
public:
|
||||
|
||||
enum IterDirection
|
||||
|
@ -134,77 +106,67 @@ public:
|
|||
* for someone to derive from the nsEditor later? I dont believe so.
|
||||
*/
|
||||
virtual ~nsEditor();
|
||||
|
||||
/*BEGIN nsIEditor for more details*/
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
||||
|
||||
/* ------------ nsIEditor methods -------------- */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD PostCreate();
|
||||
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
|
||||
|
||||
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);
|
||||
|
||||
NS_IMETHOD GetPresShell(nsIPresShell **aPS);
|
||||
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection **aSelection);
|
||||
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable);
|
||||
NS_IMETHOD Do(nsITransaction *aTxn);
|
||||
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 SetProperties(nsVoidArray *aPropList);
|
||||
NS_IMETHOD BeginTransaction();
|
||||
NS_IMETHOD EndTransaction();
|
||||
|
||||
NS_IMETHOD GetProperties(nsVoidArray *aPropList);
|
||||
// file handling
|
||||
NS_IMETHOD Save();
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy);
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
|
||||
|
||||
// these are pure virtual in this base class
|
||||
NS_IMETHOD Cut() = 0;
|
||||
NS_IMETHOD Copy() = 0;
|
||||
NS_IMETHOD Paste() = 0;
|
||||
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
NS_IMETHOD EndOfDocument();
|
||||
|
||||
|
||||
/* Node and element manipulation */
|
||||
NS_IMETHOD SetAttribute(nsIDOMElement * aElement,
|
||||
const nsString& aAttribute,
|
||||
const nsString& aValue);
|
||||
|
||||
|
||||
NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement,
|
||||
const nsString& aAttribute,
|
||||
nsString& aResultValue,
|
||||
PRBool& aResultIsSet);
|
||||
|
||||
|
||||
NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
|
||||
|
||||
//NOTE: Most callers are dealing with Nodes,
|
||||
// but these objects must supports nsIDOMElement
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
|
||||
NS_IMETHOD CreateNode(const nsString& aTag,
|
||||
nsIDOMNode * aParent,
|
||||
PRInt32 aPosition,
|
||||
nsIDOMNode ** aNewNode);
|
||||
|
||||
|
||||
NS_IMETHOD InsertNode(nsIDOMNode * aNode,
|
||||
nsIDOMNode * aParent,
|
||||
PRInt32 aPosition);
|
||||
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply *aReply);
|
||||
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD DumpContentTree();
|
||||
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
|
||||
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode);
|
||||
|
||||
|
||||
NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
|
||||
PRInt32 aOffset,
|
||||
nsIDOMNode ** aNewLeftNode);
|
||||
|
@ -213,69 +175,63 @@ public:
|
|||
nsIDOMNode * aRightNode,
|
||||
nsIDOMNode * aParent);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
|
||||
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable);
|
||||
|
||||
NS_IMETHOD Do(nsITransaction *aTxn);
|
||||
|
||||
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();
|
||||
|
||||
NS_IMETHOD GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject);
|
||||
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
|
||||
NS_IMETHOD EndOfDocument();
|
||||
|
||||
NS_IMETHOD Cut();
|
||||
|
||||
NS_IMETHOD Copy();
|
||||
|
||||
NS_IMETHOD Paste();
|
||||
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
/* output */
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
/* Listeners */
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
|
||||
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
|
||||
|
||||
|
||||
NS_IMETHOD DumpContentTree();
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
|
||||
/* ------------ nsIEditorIMESupport methods -------------- */
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
/* ------------ nsIEditorLogging methods -------------- */
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
NS_IMETHOD StopLogging();
|
||||
|
||||
/*END nsIEditor interfaces*/
|
||||
public:
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert);
|
||||
NS_IMETHOD DeleteSelectionImpl(ESelectionCollapseDirection aAction);
|
||||
|
||||
|
||||
/*BEGIN private methods used by the implementations of the above functions*/
|
||||
protected:
|
||||
|
||||
|
||||
// why not use the one in nsHTMLDocument?
|
||||
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);
|
||||
|
||||
//NOTE: Most callers are dealing with Nodes,
|
||||
// but these objects must supports nsIDOMElement
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
/*
|
||||
NS_IMETHOD SetProperties(nsVoidArray *aPropList);
|
||||
NS_IMETHOD GetProperties(nsVoidArray *aPropList);
|
||||
*/
|
||||
|
||||
/** create a transaction for setting aAttribute to aValue on aElement
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
|
||||
|
@ -308,6 +264,26 @@ protected:
|
|||
NS_IMETHOD CreateTxnForDeleteElement(nsIDOMNode * aElement,
|
||||
DeleteElementTxn ** aTxn);
|
||||
|
||||
|
||||
/** Create an aggregate transaction for deleting current selection
|
||||
* Used by all methods that need to delete current selection,
|
||||
* then insert something new to replace it
|
||||
* @param nsString& aTxnName is the name of the aggregated transaction
|
||||
* @param EditTxn **aAggTxn is the return location of the aggregate TXN,
|
||||
* with the DeleteSelectionTxn as the first child ONLY
|
||||
* if there was a selection to delete.
|
||||
*/
|
||||
NS_IMETHOD CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, EditAggregateTxn **aAggTxn);
|
||||
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteSelection(ESelectionCollapseDirection aAction,
|
||||
EditAggregateTxn ** aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
||||
ESelectionCollapseDirection aAction,
|
||||
EditAggregateTxn *aTxn);
|
||||
|
||||
|
||||
/** create a transaction for inserting aStringToInsert into aTextNode
|
||||
* if aTextNode is null, the string is inserted at the current selection.
|
||||
*/
|
||||
|
@ -326,15 +302,12 @@ protected:
|
|||
/** create a transaction for removing a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
/** insert aStringToInsert as the first text in the document
|
||||
*/
|
||||
NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert);
|
||||
|
||||
NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIPrivateTextRangeList* aTextRangeList);
|
||||
NS_IMETHOD DoInitialInputMethodInsert(const nsString & aStringToInsert, nsIPrivateTextRangeList* aTextRangeList);
|
||||
|
||||
|
||||
NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
|
||||
|
@ -345,14 +318,7 @@ protected:
|
|||
PRUint32 aOffset,
|
||||
PRUint32 aLength,
|
||||
DeleteTextTxn **aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelectionAction aAction,
|
||||
EditAggregateTxn ** aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
||||
nsIEditor::ECollapsedSelectionAction aAction,
|
||||
EditAggregateTxn *aTxn);
|
||||
|
||||
|
||||
NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
|
||||
PRUint32 aOffset,
|
||||
SplitElementTxn **aTxn);
|
||||
|
@ -361,19 +327,8 @@ protected:
|
|||
nsIDOMNode *aRightNode,
|
||||
JoinElementTxn **aTxn);
|
||||
|
||||
/** Create an aggregate transaction for deleting current selection
|
||||
* Used by all methods that need to delete current selection,
|
||||
* then insert something new to replace it
|
||||
* @param nsString& aTxnName is the name of the aggregated transaction
|
||||
* @param EditTxn **aAggTxn is the return location of the aggregate TXN,
|
||||
* with the DeleteSelectionTxn as the first child ONLY
|
||||
* if there was a selection to delete.
|
||||
*/
|
||||
NS_IMETHOD CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, EditAggregateTxn **aAggTxn);
|
||||
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
|
||||
NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList* aTextRangeList);
|
||||
NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList *aTextRangeList);
|
||||
|
||||
// called each time we modify the document. Increments the mod
|
||||
// count of the doc.
|
||||
|
@ -415,9 +370,16 @@ protected:
|
|||
// document after a change via the DOM - gpk 2/13/99
|
||||
void HACKForceRedraw(void);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, PRInt32& offsetOfNewNode);
|
||||
// file handling utils
|
||||
|
||||
NS_IMETHOD SaveDocument(PRBool saveAs, PRBool saveCopy);
|
||||
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
public:
|
||||
|
||||
static nsString& GetTextNodeTag();
|
||||
|
||||
/**
|
||||
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||
|
@ -626,39 +588,45 @@ public:
|
|||
|
||||
nsresult BeginUpdateViewBatch(void);
|
||||
nsresult EndUpdateViewBatch(void);
|
||||
};
|
||||
|
||||
|
||||
class nsAutoEditBatch
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<nsIEditor> mEd;
|
||||
public:
|
||||
nsAutoEditBatch( nsIEditor *aEd) : mEd(do_QueryInterface(aEd))
|
||||
{ if (mEd) mEd->BeginTransaction(); }
|
||||
~nsAutoEditBatch() { if (mEd) mEd->EndTransaction(); }
|
||||
};
|
||||
protected:
|
||||
|
||||
class nsAutoSelectionReset
|
||||
{
|
||||
private:
|
||||
/** ref-counted reference to the selection that we are supposed to restore */
|
||||
nsCOMPtr<nsIDOMSelection> mSel;
|
||||
PRUint32 mFlags; // behavior flags. See nsIHTMLEditor.h for the flags we use.
|
||||
|
||||
nsIPresShell *mPresShell;
|
||||
nsIViewManager *mViewManager;
|
||||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
/** PR_TRUE if this instance initialized itself correctly */
|
||||
PRBool mInitialized;
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
//
|
||||
nsCOMPtr<nsIDOMCharacterData> mIMETextNode;
|
||||
PRUint32 mIMETextOffset;
|
||||
PRUint32 mIMEBufferLength;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mStartNode;
|
||||
nsCOMPtr<nsIDOMNode> mEndNode;
|
||||
PRInt32 mStartOffset;
|
||||
PRInt32 mEndOffset;
|
||||
nsVoidArray* mActionListeners;
|
||||
nsCOMPtr<nsISupportsArray> mDocStateListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
public:
|
||||
/** constructor responsible for remembering all state needed to restore aSel */
|
||||
nsAutoSelectionReset(nsIDOMSelection *aSel);
|
||||
|
||||
/** destructor restores mSel to its former state */
|
||||
~nsAutoSelectionReset();
|
||||
PRInt8 mDocDirtyState; // -1 = not initialized
|
||||
|
||||
nsIDOMDocument * mDoc;
|
||||
nsCOMPtr<nsIDTD> mDTD;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
nsJSEditorLog *mJSEditorLog;
|
||||
nsJSTxnLog *mJSTxnLog;
|
||||
#endif // ENABLE_JS_EDITOR_LOG
|
||||
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
#include "nsEditorEventListeners.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -25,16 +28,11 @@
|
|||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIEditProperty.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIPrivateTextEvent.h"
|
||||
|
||||
// for testing only
|
||||
#include "nsIHTMLEditor.h"
|
||||
// end for testing only
|
||||
#include "nsIEditorMailSupport.h"
|
||||
|
||||
// for repainting hack only
|
||||
#include "nsIView.h"
|
||||
|
@ -142,7 +140,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
// break;
|
||||
|
||||
case nsIDOMUIEvent::VK_DELETE:
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteNext);
|
||||
break;
|
||||
|
||||
// case nsIDOMUIEvent::VK_RETURN:
|
||||
|
@ -181,7 +179,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
{
|
||||
PRUint32 flags=0;
|
||||
mEditor->GetFlags(&flags);
|
||||
if (! (flags & TEXT_EDITOR_FLAG_SINGLELINE))
|
||||
if (! (flags & nsIHTMLEditor::eEditorSingleLineMask))
|
||||
{
|
||||
PRBool ctrlKey, altKey, metaKey;
|
||||
uiEvent->GetCtrlKey(&ctrlKey);
|
||||
|
@ -192,7 +190,10 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
// else we insert the tab straight through
|
||||
nsAutoString key;
|
||||
key += keyCode;
|
||||
mEditor->InsertText(key);
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
htmlEditor->InsertText(key);
|
||||
return NS_ERROR_BASE; // this means "I handled the event, don't do default processing"
|
||||
}
|
||||
else {
|
||||
|
@ -244,14 +245,17 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
if (metaKey)
|
||||
return NS_OK; // don't consume
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (!htmlEditor) return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)))
|
||||
{
|
||||
if (nsIDOMUIEvent::VK_BACK==keyCode) {
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
|
||||
mEditor->DeleteSelection(nsIEditor::eDeletePrevious);
|
||||
return NS_ERROR_BASE; // consumed
|
||||
}
|
||||
if (nsIDOMUIEvent::VK_RETURN==keyCode) {
|
||||
mEditor->InsertBreak();
|
||||
htmlEditor->InsertBreak();
|
||||
return NS_ERROR_BASE; // consumed
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +267,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
return NS_OK; // ignore tabs here, they're handled in keyDown if at all
|
||||
}
|
||||
key += character;
|
||||
mEditor->InsertText(key);
|
||||
htmlEditor->InsertText(key);
|
||||
}
|
||||
|
||||
return NS_ERROR_BASE; // consumed
|
||||
|
@ -333,28 +337,6 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
format = "text/html";
|
||||
res = mEditor->OutputToString(output, format,
|
||||
nsEditor::EditorOutputFormatted);
|
||||
#if 0
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(mEditor));
|
||||
if (htmlEditor)
|
||||
{
|
||||
if (isShift)
|
||||
res = htmlEditor->OutputTextToString(output, PR_TRUE, PR_FALSE);
|
||||
else
|
||||
res = htmlEditor->OutputHTMLToString(output, PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsITextEditor> textEditor (do_QueryInterface(mEditor));
|
||||
if (textEditor)
|
||||
{
|
||||
if (isShift)
|
||||
res = textEditor->OutputTextToString(output, PR_TRUE, PR_FALSE);
|
||||
else
|
||||
res = textEditor->OutputHTMLToString(output, PR_FALSE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
char* buf = output.ToNewCString();
|
||||
|
@ -378,11 +360,15 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
{
|
||||
printf("Getting number of columns\n");
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
printf("Currently wrapping to %d\n", wrap);
|
||||
else
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
PRInt32 wrap;
|
||||
if (NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
printf("Currently wrapping to %d\n", wrap);
|
||||
else
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -390,20 +376,24 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
// hard coded "Decrease wrap size"
|
||||
if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mEditor->SetBodyWrapWidth(wrap - 5);
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mailEditor->SetBodyWrapWidth(wrap - 5);
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -411,20 +401,24 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
// hard coded "Increase wrap size"
|
||||
if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mEditor->SetBodyWrapWidth(wrap + 5);
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mailEditor->SetBodyWrapWidth(wrap + 5);
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -436,7 +430,11 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
if (mEditor)
|
||||
{
|
||||
if (altKey)
|
||||
mEditor->PasteAsQuotation();
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation();
|
||||
}
|
||||
else
|
||||
mEditor->Paste();
|
||||
}
|
||||
|
@ -465,19 +463,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_I:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::i, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::i, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +485,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
else if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(mEditor));
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsString nsstr ("This is <b>bold <em>and emphasized</em></b> text");
|
||||
|
@ -499,19 +498,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_B:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::b, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,19 +521,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_U:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::u, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::u, nsnull);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -544,7 +545,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_1:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -553,9 +555,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
PRBool first = PR_FALSE;
|
||||
nsAutoString color = "COLOR";
|
||||
nsAutoString value = "red";
|
||||
mEditor->GetTextProperty(nsIEditProperty::font, &color, &value, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::font, &color, &value, first, any, all);
|
||||
if (!all) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &color, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &color, &value);
|
||||
}
|
||||
else {
|
||||
printf("NOOP: all selected text is already red\n");
|
||||
|
@ -568,7 +570,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_2:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -576,9 +579,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
nsAutoString color = "COLOR";
|
||||
mEditor->GetTextProperty(nsIEditProperty::font, &color, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::font, &color, nsnull, first, any, all);
|
||||
if (any) {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::font, &color);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::font, &color);
|
||||
}
|
||||
else {
|
||||
printf("NOOP: no color set\n");
|
||||
|
@ -591,7 +594,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_3:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -600,7 +604,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "SIZE";
|
||||
nsAutoString value = "+2";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -609,7 +613,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_4:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -618,7 +623,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "SIZE";
|
||||
nsAutoString value = "-2";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -627,7 +632,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_5:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -636,7 +642,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "FACE";
|
||||
nsAutoString value = "helvetica";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -645,7 +651,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_6:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -654,7 +661,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "FACE";
|
||||
nsAutoString value = "times";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -663,16 +670,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_7:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h1->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h1->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -681,16 +684,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_8:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h2->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h2->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -699,13 +698,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_9:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor) {
|
||||
htmlEditor->RemoveParagraphStyle();
|
||||
}
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor) {
|
||||
htmlEditor->RemoveParagraphStyle();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -714,28 +709,23 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_0:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
printf("testing GetParagraphStyle\n");
|
||||
nsStringArray styles;
|
||||
nsresult result = htmlEditor->GetParagraphStyle(&styles);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
printf("testing GetParagraphStyle\n");
|
||||
nsStringArray styles;
|
||||
nsresult result = htmlEditor->GetParagraphStyle(&styles);
|
||||
if (NS_SUCCEEDED(result))
|
||||
PRInt32 count = styles.Count();
|
||||
PRInt32 i;
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
PRInt32 count = styles.Count();
|
||||
PRInt32 i;
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
nsString *tag = styles.StringAt(i);
|
||||
char *tagCString = tag->ToNewCString();
|
||||
printf("%s ", tagCString);
|
||||
delete [] tagCString;
|
||||
}
|
||||
printf("\n");
|
||||
nsString *tag = styles.StringAt(i);
|
||||
char *tagCString = tag->ToNewCString();
|
||||
printf("%s ", tagCString);
|
||||
delete [] tagCString;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -745,16 +735,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_COMMA:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->AddBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->AddBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -763,16 +749,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_PERIOD:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->RemoveParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->RemoveParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -907,8 +889,11 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
|||
uiEvent->GetCtrlKey(&ctrlKey);
|
||||
|
||||
if (ctrlKey)
|
||||
return editor->PasteAsQuotation();
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation();
|
||||
}
|
||||
return editor->Paste();
|
||||
}
|
||||
|
||||
|
@ -933,24 +918,21 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
nsresult
|
||||
nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsIHTMLEditor * HTMLEditor;
|
||||
if (NS_SUCCEEDED(mEditor->QueryInterface(nsIHTMLEditor::GetIID(), (void**)&HTMLEditor)))
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
if (NS_SUCCEEDED(HTMLEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement)
|
||||
{
|
||||
nsAutoString TagName;
|
||||
selectedElement->GetTagName(TagName);
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString TagName;
|
||||
selectedElement->GetTagName(TagName);
|
||||
TagName.ToLowerCase();
|
||||
|
||||
#if DEBUG_cmanske
|
||||
char szTagName[64];
|
||||
TagName.ToCString(szTagName, 64);
|
||||
printf("Single Selected element found: %s\n", szTagName);
|
||||
char szTagName[64];
|
||||
TagName.ToCString(szTagName, 64);
|
||||
printf("Single Selected element found: %s\n", szTagName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1035,7 +1017,7 @@ nsresult
|
|||
nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
{
|
||||
nsString composedText;
|
||||
nsresult result;
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIPrivateTextEvent> textEvent;
|
||||
nsIPrivateTextRangeList *textRangeList;
|
||||
nsTextEventReply *textEventReply;
|
||||
|
@ -1050,7 +1032,9 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
|||
textEvent->GetInputRange(&textRangeList);
|
||||
textEvent->GetEventReply(&textEventReply);
|
||||
textRangeList->AddRef();
|
||||
result = mEditor->SetCompositionString(composedText,textRangeList,textEventReply);
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor, &result);
|
||||
if (imeEditor)
|
||||
result = imeEditor->SetCompositionString(composedText,textRangeList,textEventReply);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1205,9 +1189,12 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
|
|||
trans->GetAnyTransferData(&textMime, (void **)&str, &len);
|
||||
|
||||
// If the string was not empty then paste it in
|
||||
if (str) {
|
||||
if (str)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
stuffToPaste.SetString(str, len);
|
||||
mEditor->InsertText(stuffToPaste);
|
||||
if (htmlEditor)
|
||||
htmlEditor->InsertText(stuffToPaste);
|
||||
dragSession->SetCanDrop(PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1256,16 @@ nsTextEditorCompositionListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsTextEditorCompositionListener::SetEditor(nsIEditor *aEditor)
|
||||
{
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(aEditor);
|
||||
if (!imeEditor) return; // should return an error here!
|
||||
|
||||
// note that we don't hold an extra reference here.
|
||||
mEditor = imeEditor;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorCompositionListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
|
@ -1291,7 +1288,7 @@ nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionE
|
|||
|
||||
nsresult
|
||||
NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorKeyListener* it = new nsTextEditorKeyListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1307,7 +1304,7 @@ NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
nsresult
|
||||
NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorMouseListener* it = new nsTextEditorMouseListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1321,7 +1318,7 @@ NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
|
||||
nsresult
|
||||
NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor* aEditor)
|
||||
NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
|
||||
{
|
||||
nsTextEditorTextListener* it = new nsTextEditorTextListener();
|
||||
if (nsnull==it) {
|
||||
|
@ -1337,7 +1334,7 @@ NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor
|
|||
|
||||
nsresult
|
||||
NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorDragListener* it = new nsTextEditorDragListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1350,7 +1347,7 @@ NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
}
|
||||
|
||||
nsresult
|
||||
NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor* aEditor)
|
||||
NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
|
||||
{
|
||||
nsTextEditorCompositionListener* it = new nsTextEditorCompositionListener();
|
||||
if (nsnull==it) {
|
||||
|
@ -1362,7 +1359,7 @@ NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITex
|
|||
|
||||
nsresult
|
||||
NS_NewEditorFocusListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorFocusListener* it = new nsTextEditorFocusListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1428,12 +1425,15 @@ nsTextEditorFocusListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
nsresult
|
||||
nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
// turn on selection and caret
|
||||
if (mEditor)
|
||||
{
|
||||
// turn on selection and caret
|
||||
if (mEditor)
|
||||
{
|
||||
PRUint32 flags;
|
||||
mEditor->GetFlags(&flags);
|
||||
if (! (flags & TEXT_EDITOR_FLAG_DISABLED))
|
||||
if (! (flags & nsIHTMLEditor::eEditorDisabledMask))
|
||||
{ // only enable caret and selection if the editor is not disabled
|
||||
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
|
||||
if (editor)
|
||||
|
@ -1442,7 +1442,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
|||
editor->GetPresShell(getter_AddRefs(ps));
|
||||
if (ps)
|
||||
{
|
||||
if (! (flags & TEXT_EDITOR_FLAG_READONLY))
|
||||
if (! (flags & nsIHTMLEditor::eEditorReadonlyMask))
|
||||
{ // only enable caret if the editor is not readonly
|
||||
ps->SetCaretEnabled(PR_TRUE);
|
||||
}
|
||||
|
@ -1474,6 +1474,8 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#ifndef editorInterfaces_h__
|
||||
#define editorInterfaces_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
|
@ -26,8 +29,9 @@
|
|||
#include "nsIDOMDragListener.h"
|
||||
#include "nsIDOMCompositionListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
/** The nsTextEditorKeyListener public nsIDOMKeyListener
|
||||
* This class will delegate events to its editor according to the translation
|
||||
|
@ -45,7 +49,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -63,7 +67,7 @@ protected:
|
|||
virtual nsresult ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aProcessed);
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,7 +86,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -94,11 +98,14 @@ public:
|
|||
/*END implementations of textevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
PRBool mCommitText;
|
||||
PRBool mInTransaction;
|
||||
};
|
||||
|
||||
|
||||
class nsIEditorIMESupport;
|
||||
|
||||
class nsTextEditorCompositionListener : public nsIDOMCompositionListener
|
||||
{
|
||||
public:
|
||||
|
@ -112,7 +119,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor);
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -125,7 +132,7 @@ public:
|
|||
/*END implementations of textevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditorIMESupport* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
@ -144,7 +151,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -161,7 +168,7 @@ public:
|
|||
/*END implementations of mouseevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
|
||||
};
|
||||
|
||||
|
@ -181,7 +188,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -196,7 +203,7 @@ public:
|
|||
/*END implementations of dragevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor;
|
||||
nsIEditor* mEditor;
|
||||
|
||||
};
|
||||
|
||||
|
@ -215,7 +222,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -228,34 +235,34 @@ public:
|
|||
/*END implementations of focus event handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** factory for the editor key listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor mouse listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor text listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor drag listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor composition listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor composition listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
#endif //editorInterfaces_h__
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,8 +15,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsEditorAppCore_h___
|
||||
#define nsEditorAppCore_h___
|
||||
#ifndef nsEditorShell_h___
|
||||
#define nsEditorShell_h___
|
||||
|
||||
//#include "nsAppCores.h"
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "nsIEditorSpellCheck.h"
|
||||
#include "nsISpellChecker.h"
|
||||
#include "nsInterfaceState.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
class nsIBrowserWindow;
|
||||
class nsIWebShell;
|
||||
|
@ -50,13 +51,11 @@ class nsIDOMNode;
|
|||
class nsIURI;
|
||||
class nsIWebShellWindow;
|
||||
class nsIPresShell;
|
||||
class nsIHTMLEditor;
|
||||
class nsITextEditor;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
|
||||
|
||||
#define NS_EDITORAPPCORE_CID \
|
||||
#define NS_EDITORSHELL_CID \
|
||||
{ /* {} */ \
|
||||
0x9afff72b, 0xca9a, 0x11d2, \
|
||||
{ 0x96, 0xc9, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } \
|
||||
|
@ -316,7 +315,7 @@ class nsEditorShell : public nsIEditorShell,
|
|||
|
||||
EEditorType mEditorType;
|
||||
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
||||
nsCOMPtr<nsISupports> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
nsCOMPtr<nsIHTMLEditor> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
|
||||
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
|
||||
|
||||
|
@ -336,4 +335,4 @@ class nsEditorShell : public nsIEditorShell,
|
|||
nsCOMPtr<nsISupportsArray> mDocStateListeners; // contents are nsISupports
|
||||
};
|
||||
|
||||
#endif // nsEditorAppCore_h___
|
||||
#endif // nsEditorShell_h___
|
||||
|
|
|
@ -30,7 +30,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_IID(kEditorShellCID, NS_EDITORAPPCORE_CID);
|
||||
static NS_DEFINE_IID(kEditorShellCID, NS_EDITORSHELL_CID);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// nsEditorShellFactoryImpl
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
*/
|
||||
|
||||
#include "nsHTMLEditRules.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsTextEditor.h"
|
||||
|
||||
#include "PlaceholderTxn.h"
|
||||
#include "InsertTextTxn.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -36,7 +38,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
class nsIFrame;
|
||||
#include "nsEditorUtils.h"
|
||||
|
||||
//const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
|
||||
//const static char* kMOZEditorBogusNodeValue="TRUE";
|
||||
|
@ -56,7 +58,8 @@ enum
|
|||
* Constructor/Destructor
|
||||
********************************************************/
|
||||
|
||||
nsHTMLEditRules::nsHTMLEditRules()
|
||||
nsHTMLEditRules::nsHTMLEditRules(PRUint32 aFlags)
|
||||
: nsTextEditRules(aFlags)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -285,7 +288,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
|
|||
|
||||
|
||||
nsresult
|
||||
nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECollapsedSelectionAction aAction, PRBool *aCancel)
|
||||
nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ESelectionCollapseDirection aAction, PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
// initialize out param
|
||||
|
@ -315,7 +318,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// at beginning of text node and backspaced?
|
||||
if (!offset && (aAction == nsIEditor::eDeleteLeft))
|
||||
if (!offset && (aAction == nsIEditor::eDeletePrevious))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> priorNode;
|
||||
res = mEditor->GetPriorNode(node, PR_TRUE, getter_AddRefs(priorNode));
|
||||
|
@ -368,7 +371,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
|
||||
// at end of text node and deleted?
|
||||
if ((offset == (PRInt32)strLength)
|
||||
&& (aAction == nsIEditor::eDeleteRight))
|
||||
&& (aAction == nsIEditor::eDeleteNext))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> nextNode;
|
||||
res = mEditor->GetNextNode(node, PR_TRUE, getter_AddRefs(nextNode));
|
||||
|
@ -480,7 +483,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
{
|
||||
// first delete the selection
|
||||
*aCancel = PR_TRUE;
|
||||
res = mEditor->nsEditor::DeleteSelection(aAction);
|
||||
res = mEditor->DeleteSelectionImpl(aAction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
// then join para's, insert break
|
||||
res = mEditor->JoinNodeDeep(leftParent,rightParent,aSelection);
|
||||
|
@ -493,7 +496,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
{
|
||||
// first delete the selection
|
||||
*aCancel = PR_TRUE;
|
||||
res = mEditor->nsEditor::DeleteSelection(aAction);
|
||||
res = mEditor->DeleteSelectionImpl(aAction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
// join blocks
|
||||
res = mEditor->JoinNodeDeep(leftParent,rightParent,aSelection);
|
||||
|
@ -1284,7 +1287,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt
|
|||
}
|
||||
|
||||
if (node)
|
||||
offset++; // since this is going to be used for a range _endpoint_, we want to be after the node
|
||||
offset++; // since this is going to be used for a range _endpoint_, we want to be after the node
|
||||
else
|
||||
node = parent;
|
||||
|
||||
|
@ -1859,11 +1862,3 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ class nsHTMLEditRules : public nsTextEditRules
|
|||
{
|
||||
public:
|
||||
|
||||
nsHTMLEditRules();
|
||||
virtual ~nsHTMLEditRules();
|
||||
nsHTMLEditRules(PRUint32 aFlags);
|
||||
virtual ~nsHTMLEditRules();
|
||||
|
||||
// nsEditRules methods
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
||||
|
@ -61,7 +61,7 @@ protected:
|
|||
TypeInState typeInState,
|
||||
PRInt32 aMaxLength);
|
||||
nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECollapsedSelectionAction aAction, PRBool *aCancel);
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ESelectionCollapseDirection aAction, PRBool *aCancel);
|
||||
nsresult WillMakeList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel);
|
||||
nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -19,21 +19,33 @@
|
|||
#ifndef nsHTMLEditor_h__
|
||||
#define nsHTMLEditor_h__
|
||||
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsTextEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsITableEditor.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIEditorStyleSheets.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
#include "TypeInState.h"
|
||||
#include "nsEditRules.h"
|
||||
|
||||
/**
|
||||
* The HTML editor implementation.<br>
|
||||
* Use to edit HTML document represented as a DOM tree.
|
||||
*/
|
||||
class nsHTMLEditor : public nsTextEditor, public nsIHTMLEditor
|
||||
class nsHTMLEditor : public nsEditor,
|
||||
public nsIHTMLEditor,
|
||||
public nsIEditorMailSupport,
|
||||
public nsITableEditor,
|
||||
public nsIEditorStyleSheets
|
||||
{
|
||||
|
||||
typedef enum {eNoOp=0, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
||||
typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
||||
|
||||
public:
|
||||
// see nsIHTMLEditor for documentation
|
||||
|
@ -43,139 +55,77 @@ public:
|
|||
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLEditor();
|
||||
virtual ~nsHTMLEditor();
|
||||
nsHTMLEditor();
|
||||
virtual ~nsHTMLEditor();
|
||||
|
||||
//Initialization
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
||||
/* ------------ nsIHTMLEditor methods -------------- */
|
||||
|
||||
//============================================================================
|
||||
// Methods that are duplicates of nsTextEditor -- exposed here for convenience
|
||||
NS_IMETHOD GetDocumentLength(PRInt32 *aCount);
|
||||
NS_IMETHOD SetMaxTextLength(PRInt32 aMaxTextLength);
|
||||
NS_IMETHOD GetMaxTextLength(PRInt32& aMaxTextLength);
|
||||
|
||||
// Editing Operations
|
||||
NS_IMETHOD SetTextProperty(nsIAtom *aProperty,
|
||||
|
||||
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
NS_IMETHOD GetTextProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute, const nsString *aValue,
|
||||
|
||||
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aFirst, PRBool &aAny, PRBool &aAll);
|
||||
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction);
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
|
||||
// Transaction control
|
||||
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();
|
||||
|
||||
// Selection and navigation
|
||||
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);
|
||||
NS_IMETHOD SelectAll();
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
NS_IMETHOD EndOfDocument();
|
||||
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
// file handling
|
||||
NS_IMETHOD Save();
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy);
|
||||
|
||||
// cut, copy & paste
|
||||
NS_IMETHOD Cut();
|
||||
NS_IMETHOD Copy();
|
||||
NS_IMETHOD Paste();
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation);
|
||||
|
||||
// Input/Output
|
||||
NS_IMETHOD InsertHTML(const nsString& aInputString);
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRange, nsTextEventReply* aReply);
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
// Miscellaneous
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
|
||||
// Logging methods
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
NS_IMETHOD StopLogging();
|
||||
|
||||
// End of methods implemented in nsEditor
|
||||
//=============================================================
|
||||
// HTML Editing methods
|
||||
|
||||
// This sets background on the appropriate container element (table, cell,)
|
||||
// or calls into nsTextEditor to set the page background
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
||||
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList);
|
||||
NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD RemoveParagraphStyle();
|
||||
NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString);
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD DeleteSelection(ESelectionCollapseDirection aAction);
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode);
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
|
||||
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
|
||||
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
|
||||
|
||||
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList);
|
||||
NS_IMETHOD RemoveParagraphStyle();
|
||||
|
||||
NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
||||
|
||||
NS_IMETHOD InsertList(const nsString& aListType);
|
||||
NS_IMETHOD Indent(const nsString& aIndent);
|
||||
NS_IMETHOD Align(const nsString& aAlign);
|
||||
NS_IMETHOD InsertList(const nsString& aListType);
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD SaveHLineSettings(nsIDOMElement* aElement);
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
// Return TRUE if aElement is a table-related elemet and caret was set
|
||||
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
PRBool IsElementInBody(nsIDOMElement* aElement);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
|
||||
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
||||
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
||||
/** Get the row an column index from the layout's cellmap */
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32 & aRowIndex, PRInt32 &aColIndex);
|
||||
/** Get the number of rows and columns in a table from the layout's cellmap */
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
/* ------------ nsIEditorStyleSheets methods -------------- */
|
||||
|
||||
/* Get cell at a cellmap location. Returns NS_TABLELAYOUT_CELL_NOT_FOUND if past end of row or col */
|
||||
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
|
||||
/* Get cell and associated data */
|
||||
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
|
||||
/* ------------ nsIEditorMailSupport methods -------------- */
|
||||
|
||||
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn);
|
||||
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn);
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
/* ------------ nsITableEditor methods -------------- */
|
||||
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
||||
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
|
||||
|
@ -185,15 +135,85 @@ public:
|
|||
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
||||
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
||||
NS_IMETHOD JoinTableCells();
|
||||
|
||||
/** Make table "rectangular" -- fill in all missing cellmap locations
|
||||
* If aTable is null, it uses table enclosing the selection anchor
|
||||
*/
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
|
||||
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
|
||||
|
||||
|
||||
// Selection and navigation
|
||||
/* obsolete
|
||||
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);
|
||||
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
*/
|
||||
|
||||
/* miscellaneous */
|
||||
// This sets background on the appropriate container element (table, cell,)
|
||||
// or calls into nsTextEditor to set the page background
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
||||
|
||||
|
||||
|
||||
/* ------------ Overrides of nsEditor interface methods -------------- */
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD Cut();
|
||||
NS_IMETHOD Copy();
|
||||
NS_IMETHOD Paste();
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void InitRules();
|
||||
|
||||
NS_IMETHOD GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, PRInt32& offsetOfNewNode);
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
|
||||
// Return TRUE if aElement is a table-related elemet and caret was set
|
||||
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
PRBool IsElementInBody(nsIDOMElement* aElement);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
|
||||
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
||||
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
||||
|
||||
// Table utilities
|
||||
|
||||
// All of the above need to get the same basic context data
|
||||
// All of the above need to get the same basic context data
|
||||
NS_IMETHOD GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
|
||||
nsCOMPtr<nsIDOMElement> &aTable, nsCOMPtr<nsIDOMElement> &aCell,
|
||||
nsCOMPtr<nsIDOMNode> &aCellParent, PRInt32& aCellOffset,
|
||||
|
@ -204,15 +224,10 @@ public:
|
|||
|
||||
// Setting caret to a logical place can get tricky,
|
||||
// especially after deleting table stuff
|
||||
typedef enum { ePreviousColumn=0, ePreviousRow } SetCaretSearchDirection;
|
||||
typedef enum { ePreviousColumn, ePreviousRow } SetCaretSearchDirection;
|
||||
|
||||
NS_IMETHOD SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aCol, PRInt32 aRow, SetCaretSearchDirection aDirection);
|
||||
|
||||
protected:
|
||||
|
||||
// rules initialization
|
||||
|
||||
virtual void InitRules();
|
||||
|
||||
|
||||
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
|
||||
nsString &aParentTag,
|
||||
BlockTransformationType aTranformation);
|
||||
|
@ -241,14 +256,178 @@ protected:
|
|||
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
|
||||
|
||||
|
||||
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
||||
// For now, the listners are tied to the nsTextEditor class
|
||||
//
|
||||
// nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
||||
// nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
||||
/** content-based query returns PR_TRUE if <aProperty aAttribute=aValue> effects aNode
|
||||
* If <aProperty aAttribute=aValue> contains aNode,
|
||||
* but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
||||
* more deeply nested than the first, then the first does not effect aNode.
|
||||
*
|
||||
* @param aNode The target of the query
|
||||
* @param aProperty The property that we are querying for
|
||||
* @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
|
||||
* May be null.
|
||||
* @param aValue The value of aAttribute, example: blue in <FONT color="blue">
|
||||
* May be null. Ignored if aAttribute is null.
|
||||
* @param aIsSet [OUT] PR_TRUE if <aProperty aAttribute=aValue> effects aNode.
|
||||
* @param aStyleNode [OUT] set to the node representing <aProperty aAttribute=aValue>, if found.
|
||||
* null if aIsSet is returned as PR_FALSE;
|
||||
*/
|
||||
virtual void IsTextPropertySetByContent(nsIDOMNode *aNode,
|
||||
nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aIsSet,
|
||||
nsIDOMNode **aStyleNode) const;
|
||||
|
||||
// this overrides the base class implementation. It is not exported in nsIHTMLEditor.
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
/** style-based query returns PR_TRUE if (aProperty, aAttribute) is set in aSC.
|
||||
* WARNING: not well tested yet since we don't do style-based queries anywhere.
|
||||
*/
|
||||
virtual void IsTextStyleSet(nsIStyleContext *aSC,
|
||||
nsIAtom *aProperty,
|
||||
const nsString *aAttributes,
|
||||
PRBool &aIsSet) const;
|
||||
|
||||
/** Moves the content between (aNode, aStartOffset) and (aNode, aEndOffset)
|
||||
* into aNewParentNode, splitting aNode as necessary to maintain the relative
|
||||
* position of all leaf content.
|
||||
* @param aNode The node whose content we're repositioning.
|
||||
* aNode can be either a text node or a container node.
|
||||
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
||||
* The caller is responsible for allocating aNewParentNode
|
||||
* @param aStartOffset The start offset of the content of aNode
|
||||
* @param aEndOffset The end offset of the content of aNode.
|
||||
*/
|
||||
NS_IMETHOD MoveContentOfNodeIntoNewParent(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aNewParentNode,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset);
|
||||
|
||||
/** Moves the content between (aStartNode, aStartOffset) and (aEndNode, aEndOffset)
|
||||
* into aNewParentNode, splitting aStartNode and aEndNode as necessary to maintain
|
||||
* the relative position of all leaf content.
|
||||
* The content between the two endpoints MUST be "contiguous" in the sense that
|
||||
* it is all in the same block. Another way of saying this is all content nodes
|
||||
* between aStartNode and aEndNode must be inline.
|
||||
* @see IntermediateNodesAreInline
|
||||
*
|
||||
* @param aStartNode The left node, can be either a text node or a container node.
|
||||
* @param aStartOffset The start offset in the content of aStartNode
|
||||
* @param aEndNode The right node, can be either a text node or a container node.
|
||||
* @param aEndOffset The end offset in the content of aEndNode.
|
||||
* @param aGrandParentNode The common ancestor of aStartNode and aEndNode.
|
||||
* aGrandParentNode will be the parent of aNewParentNode.
|
||||
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
||||
* The caller is responsible for allocating aNewParentNode
|
||||
*/
|
||||
NS_IMETHOD MoveContiguousContentIntoNewParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aGrandParentNode,
|
||||
nsIDOMNode *aNewParentNode);
|
||||
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
|
||||
nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD SetTypeInStateForProperty(TypeInState &aTypeInState,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
void GetTextSelectionOffsetsForRange(nsIDOMSelection *aSelection,
|
||||
nsIDOMNode **aParent,
|
||||
PRInt32 &aStartOffset,
|
||||
PRInt32 &aEndOffset);
|
||||
|
||||
void ResetTextSelectionForRange(nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMSelection *aSelection);
|
||||
|
||||
/** returns the absolute position of the end points of aSelection
|
||||
* in the document as a text stream.
|
||||
*/
|
||||
nsresult GetTextSelectionOffsets(nsIDOMSelection *aSelection,
|
||||
PRInt32 &aStartOffset,
|
||||
PRInt32 &aEndOffset);
|
||||
|
||||
// Methods for handling plaintext quotations
|
||||
NS_IMETHOD PasteAsPlaintextQuotation();
|
||||
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
|
||||
|
||||
// I hate seeing nsCOMPtr return types.
|
||||
nsCOMPtr<nsIDOMElement> FindPreElement();
|
||||
|
||||
TypeInState *GetTypeInState();
|
||||
|
||||
/** simple utility to handle any error with event listener allocation or registration */
|
||||
void HandleEventListenerError();
|
||||
|
||||
// Data members
|
||||
protected:
|
||||
|
||||
TypeInState* mTypeInState;
|
||||
nsEditRules* mRules;
|
||||
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mTextListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mCompositionListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
|
||||
PRBool mIsComposing;
|
||||
PRInt32 mMaxTextLength;
|
||||
PRUint32 mWrapColumn;
|
||||
|
||||
// friends
|
||||
friend class nsHTMLEditRules;
|
||||
friend class nsTextEditRules;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
#include "nsInterfaceState.h"
|
||||
|
@ -88,7 +88,7 @@ nsInterfaceState::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInterfaceState::Init(nsISupports* aEditor, nsIWebShell *aChromeWebShell)
|
||||
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIWebShell *aChromeWebShell)
|
||||
{
|
||||
if (!aEditor)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -153,9 +153,7 @@ nsInterfaceState::UpdateParagraphState(const char* observerName, const char* att
|
|||
{
|
||||
nsStringArray tagList;
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
htmlEditor->GetParagraphStyle(&tagList);
|
||||
mEditor->GetParagraphStyle(&tagList);
|
||||
|
||||
PRInt32 numTags = tagList.Count();
|
||||
if (numTags > 0)
|
||||
|
@ -184,18 +182,14 @@ nsInterfaceState::UpdateListState(const char* observerName, const char* tagName)
|
|||
editor->GetSelection(getter_AddRefs(domSelection));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tagStr(tagName);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
if (domSelection)
|
||||
domSelection->GetAnchorNode(getter_AddRefs(domNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> parentElement;
|
||||
rv = htmlEditor->GetElementOrParentByTagName(tagStr, domNode, getter_AddRefs(parentElement));
|
||||
}
|
||||
nsAutoString tagStr(tagName);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
if (domSelection)
|
||||
domSelection->GetAnchorNode(getter_AddRefs(domNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> parentElement;
|
||||
rv = mEditor->GetElementOrParentByTagName(tagStr, domNode, getter_AddRefs(parentElement));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -212,18 +206,7 @@ nsInterfaceState::UpdateFontFace(const char* observerName, const char* attribute
|
|||
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom("font"));
|
||||
nsAutoString faceStr("face");
|
||||
|
||||
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
{
|
||||
rv = textEditor->GetTextProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
rv = htmlEditor->GetTextProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
|
||||
rv = mEditor->GetInlineProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -240,17 +223,7 @@ nsInterfaceState::UpdateTextState(const char* tagName, const char* observerName,
|
|||
|
||||
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(tagName));
|
||||
|
||||
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
{
|
||||
rv = textEditor->GetTextProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
rv = htmlEditor->GetTextProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
rv = mEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
|
||||
PRBool &behaviour = allOfSelectionHasProp; // change this to alter the behaviour
|
||||
if (behaviour != ioState)
|
||||
|
@ -309,7 +282,7 @@ nsInterfaceState::SetNodeAttribute(const char* nodeID, const char* attributeName
|
|||
}
|
||||
|
||||
|
||||
nsresult NS_NewInterfaceState(nsISupports* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
{
|
||||
nsInterfaceState* newThang = new nsInterfaceState;
|
||||
if (!newThang)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "nsIDocumentStateListener.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
class nsIHTMLEditor;
|
||||
|
||||
// class responsible for communicating changes in local state back to the UI.
|
||||
// This is currently somewhat tied to a given XUL UI implementation
|
||||
|
||||
|
@ -38,7 +40,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsISupports* aEditor, nsIWebShell *aChromeWebShell);
|
||||
NS_IMETHOD Init(nsIHTMLEditor* aEditor, nsIWebShell *aChromeWebShell);
|
||||
|
||||
// nsIDOMSelectionListener interface
|
||||
NS_IMETHOD NotifySelectionChanged();
|
||||
|
@ -67,7 +69,7 @@ protected:
|
|||
// this class should not hold references to the editor or editorShell. Doing
|
||||
// so would result in cirular reference chains.
|
||||
|
||||
nsISupports* mEditor; // the text or HTML editor
|
||||
nsIHTMLEditor* mEditor; // the HTML editor
|
||||
nsIWebShell* mWebShell; // web shell for the chrome area
|
||||
|
||||
// current state
|
||||
|
@ -83,6 +85,6 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
extern "C" nsresult NS_NewInterfaceState(nsISupports* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult);
|
||||
extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult);
|
||||
|
||||
#endif // nsInterfaceState_h__
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
*/
|
||||
|
||||
#include "nsTextEditRules.h"
|
||||
#include "nsTextEditor.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "PlaceholderTxn.h"
|
||||
#include "InsertTextTxn.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -37,7 +38,7 @@
|
|||
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
|
||||
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
||||
if (mFlags & TEXT_EDITOR_FLAG_READONLY || mFlags & TEXT_EDITOR_FLAG_DISABLED) \
|
||||
if ((mFlags & nsIHTMLEditor::eEditorReadonlyMask) || (mFlags & nsIHTMLEditor::eEditorDisabledMask)) \
|
||||
{ \
|
||||
*aCancel = PR_TRUE; \
|
||||
return NS_OK; \
|
||||
|
@ -47,10 +48,10 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
|||
* Constructor/Destructor
|
||||
********************************************************/
|
||||
|
||||
nsTextEditRules::nsTextEditRules()
|
||||
nsTextEditRules::nsTextEditRules(PRUint32 aFlags)
|
||||
: mEditor(nsnull)
|
||||
, mFlags(aFlags)
|
||||
{
|
||||
mEditor = nsnull;
|
||||
mFlags=0;
|
||||
}
|
||||
|
||||
nsTextEditRules::~nsTextEditRules()
|
||||
|
@ -64,10 +65,11 @@ nsTextEditRules::~nsTextEditRules()
|
|||
********************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::Init(nsIEditor *aEditor)
|
||||
nsTextEditRules::Init(nsHTMLEditor *aEditor)
|
||||
{
|
||||
if (!aEditor) { return NS_ERROR_NULL_POINTER; }
|
||||
mEditor = (nsTextEditor*)aEditor; // we hold a non-refcounted reference back to our editor
|
||||
|
||||
mEditor = aEditor; // we hold a non-refcounted reference back to our editor
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
mEditor->GetSelection(getter_AddRefs(selection));
|
||||
NS_ASSERTION(selection, "editor cannot get selection");
|
||||
|
@ -92,19 +94,19 @@ nsTextEditRules::SetFlags(PRUint32 aFlags)
|
|||
// a style attribute on it, don't know why.
|
||||
// SetFlags() is really meant to only be called once
|
||||
// and at editor init time.
|
||||
if (aFlags & TEXT_EDITOR_FLAG_PLAINTEXT)
|
||||
if (aFlags & nsIHTMLEditor::eEditorPlaintextMask)
|
||||
{
|
||||
if (!(mFlags & TEXT_EDITOR_FLAG_PLAINTEXT))
|
||||
if (!(mFlags & nsIHTMLEditor::eEditorPlaintextMask))
|
||||
{
|
||||
// we are converting TO a plaintext editor
|
||||
// put a "white-space: pre" style on the body
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
nsresult res = mEditor->GetBodyElement(getter_AddRefs(bodyElement));
|
||||
if (NS_SUCCEEDED(res) && bodyElement)
|
||||
{
|
||||
// not going through the editor to do this.
|
||||
bodyElement->SetAttribute("style", "white-space: pre");
|
||||
}
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
nsresult res = mEditor->GetBodyElement(getter_AddRefs(bodyElement));
|
||||
if (NS_SUCCEEDED(res) && bodyElement)
|
||||
{
|
||||
// not going through the editor to do this.
|
||||
bodyElement->SetAttribute("style", "white-space: pre");
|
||||
}
|
||||
}
|
||||
}
|
||||
mFlags = aFlags;
|
||||
|
@ -194,7 +196,9 @@ nsTextEditRules::DidDoAction(nsIDOMSelection *aSelection,
|
|||
nsresult
|
||||
nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
if (!aSelection || !aCancel)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
CANCEL_OPERATION_IF_READONLY_OR_DISABLED
|
||||
|
||||
// initialize out param
|
||||
|
@ -223,7 +227,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
|
|||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
CANCEL_OPERATION_IF_READONLY_OR_DISABLED
|
||||
if (mFlags & TEXT_EDITOR_FLAG_SINGLELINE) {
|
||||
if (mFlags & nsIHTMLEditor::eEditorSingleLineMask) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -256,7 +260,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
nsString inString = *aInString; // we might want to mutate the input
|
||||
// before setting the output, do that in a local var
|
||||
|
||||
if ((-1 != aMaxLength) && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT))
|
||||
if ((-1 != aMaxLength) && (mFlags & nsIHTMLEditor::eEditorPlaintextMask))
|
||||
{
|
||||
// Get the current text length.
|
||||
// Get the length of inString.
|
||||
|
@ -278,14 +282,14 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
if (selectionLength<0) { selectionLength *= (-1); }
|
||||
PRInt32 resultingDocLength = docLength - selectionLength;
|
||||
if (resultingDocLength >= aMaxLength)
|
||||
{
|
||||
*aOutString = "";
|
||||
*aCancel = PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 inCount = inString.Length();
|
||||
{
|
||||
*aOutString = "";
|
||||
*aCancel = PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 inCount = inString.Length();
|
||||
if ((inCount+resultingDocLength) > aMaxLength)
|
||||
{
|
||||
inString.Truncate(aMaxLength-resultingDocLength);
|
||||
|
@ -298,7 +302,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
// initialize out params
|
||||
*aCancel = PR_FALSE;
|
||||
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
// manage the password buffer
|
||||
PRInt32 start, end;
|
||||
|
@ -589,7 +593,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
|
|||
result = mEditor->CreateNode(tag, aParentNode, 0, getter_AddRefs(newStyleNode));
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
result = mEditor->CreateNode(nsIEditor::GetTextNodeTag(), newStyleNode, 0, getter_AddRefs(newTextNode));
|
||||
result = mEditor->CreateNode(nsEditor::GetTextNodeTag(), newStyleNode, 0, getter_AddRefs(newTextNode));
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
if (aSelection) {
|
||||
|
@ -606,7 +610,7 @@ nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCance
|
|||
nsresult result = NS_OK;
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
if (TEXT_EDITOR_FLAG_PLAINTEXT & mFlags) {
|
||||
if (nsIHTMLEditor::eEditorPlaintextMask & mFlags) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
|
@ -624,7 +628,7 @@ nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCa
|
|||
nsresult result = NS_OK;
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
if (TEXT_EDITOR_FLAG_PLAINTEXT & mFlags) {
|
||||
if (nsIHTMLEditor::eEditorPlaintextMask & mFlags) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
|
@ -638,7 +642,7 @@ nsTextEditRules::DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aRe
|
|||
|
||||
nsresult
|
||||
nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
|
@ -652,17 +656,17 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
|||
*aCancel = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
// manage the password buffer
|
||||
PRInt32 start, end;
|
||||
mEditor->GetTextSelectionOffsets(aSelection, start, end);
|
||||
if (end==start)
|
||||
{ // collapsed selection
|
||||
if (nsIEditor::eDeleteLeft==aCollapsedAction && 0<start) { // del back
|
||||
if (nsIEditor::eDeletePrevious==aCollapsedAction && 0<start) { // del back
|
||||
mPasswordText.Cut(start-1, 1);
|
||||
}
|
||||
else if (nsIEditor::eDeleteRight==aCollapsedAction) { // del forward
|
||||
else if (nsIEditor::eDeleteNext==aCollapsedAction) { // del forward
|
||||
mPasswordText.Cut(start, 1);
|
||||
}
|
||||
// otherwise nothing to do for this collapsed selection
|
||||
|
@ -682,7 +686,7 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
|||
// if we ended up with consecutive text nodes, merge them
|
||||
nsresult
|
||||
nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
nsresult aResult)
|
||||
{
|
||||
nsresult result = aResult; // if aResult is an error, we just return it
|
||||
|
@ -869,7 +873,7 @@ nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection,
|
|||
// initialize out param
|
||||
*aCancel = PR_FALSE;
|
||||
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
*aOutString = mPasswordText;
|
||||
*aCancel = PR_TRUE;
|
||||
|
@ -927,7 +931,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection)
|
|||
if ((NS_SUCCEEDED(result)) && mBogusNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>newTNode;
|
||||
result = mEditor->CreateNode(nsIEditor::GetTextNodeTag(), mBogusNode, 0,
|
||||
result = mEditor->CreateNode(nsEditor::GetTextNodeTag(), mBogusNode, 0,
|
||||
getter_AddRefs(newTNode));
|
||||
if ((NS_SUCCEEDED(result)) && newTNode)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
#ifndef nsTextEditRules_h__
|
||||
#define nsTextEditRules_h__
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsEditRules.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
#include "nsEditRules.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
class PlaceholderTxn;
|
||||
|
@ -43,11 +45,11 @@ class nsTextEditRules : public nsEditRules
|
|||
{
|
||||
public:
|
||||
|
||||
nsTextEditRules();
|
||||
virtual ~nsTextEditRules();
|
||||
nsTextEditRules(PRUint32 aFlags);
|
||||
virtual ~nsTextEditRules();
|
||||
|
||||
// nsEditRules methods
|
||||
NS_IMETHOD Init(nsIEditor *aEditor);
|
||||
NS_IMETHOD Init(nsHTMLEditor *aEditor);
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
||||
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
|
@ -96,10 +98,10 @@ protected:
|
|||
nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult);
|
||||
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
PRBool *aCancel);
|
||||
nsresult DidDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
nsresult aResult);
|
||||
|
||||
nsresult WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
|
@ -154,7 +156,7 @@ protected:
|
|||
nsresult PinSelectionInPRE(nsIDOMSelection *aSelection);
|
||||
|
||||
// data
|
||||
nsTextEditor *mEditor; // note that we do not refcount the editor
|
||||
nsHTMLEditor *mEditor; // note that we do not refcount the editor
|
||||
nsString mPasswordText; // a buffer we use to store the real value of password editors
|
||||
nsCOMPtr<nsIDOMNode> mBogusNode; // magic node acts as placeholder in empty doc
|
||||
PRUint32 mFlags;
|
||||
|
@ -173,7 +175,7 @@ class nsTextRulesInfo : public nsRulesInfo
|
|||
outString(0),
|
||||
typeInState(),
|
||||
maxLength(-1),
|
||||
collapsedAction(nsIEditor::eDeleteRight)
|
||||
collapsedAction(nsIEditor::eDeleteNext)
|
||||
{};
|
||||
|
||||
virtual ~nsTextRulesInfo() {};
|
||||
|
@ -186,7 +188,7 @@ class nsTextRulesInfo : public nsRulesInfo
|
|||
PRInt32 maxLength;
|
||||
|
||||
// kDeleteSelection
|
||||
nsIEditor::ECollapsedSelectionAction collapsedAction;
|
||||
nsIEditor::ESelectionCollapseDirection collapsedAction;
|
||||
|
||||
// kMakeList
|
||||
PRBool bOrdered;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,8 +15,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsEditorAppCore_h___
|
||||
#define nsEditorAppCore_h___
|
||||
#ifndef nsEditorShell_h___
|
||||
#define nsEditorShell_h___
|
||||
|
||||
//#include "nsAppCores.h"
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "nsIEditorSpellCheck.h"
|
||||
#include "nsISpellChecker.h"
|
||||
#include "nsInterfaceState.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
class nsIBrowserWindow;
|
||||
class nsIWebShell;
|
||||
|
@ -50,13 +51,11 @@ class nsIDOMNode;
|
|||
class nsIURI;
|
||||
class nsIWebShellWindow;
|
||||
class nsIPresShell;
|
||||
class nsIHTMLEditor;
|
||||
class nsITextEditor;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
|
||||
|
||||
#define NS_EDITORAPPCORE_CID \
|
||||
#define NS_EDITORSHELL_CID \
|
||||
{ /* {} */ \
|
||||
0x9afff72b, 0xca9a, 0x11d2, \
|
||||
{ 0x96, 0xc9, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } \
|
||||
|
@ -316,7 +315,7 @@ class nsEditorShell : public nsIEditorShell,
|
|||
|
||||
EEditorType mEditorType;
|
||||
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
||||
nsCOMPtr<nsISupports> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
nsCOMPtr<nsIHTMLEditor> mEditor; // this can be either an HTML or plain text (or other?) editor
|
||||
|
||||
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
|
||||
|
||||
|
@ -336,4 +335,4 @@ class nsEditorShell : public nsIEditorShell,
|
|||
nsCOMPtr<nsISupportsArray> mDocStateListeners; // contents are nsISupports
|
||||
};
|
||||
|
||||
#endif // nsEditorAppCore_h___
|
||||
#endif // nsEditorShell_h___
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
#include "nsInterfaceState.h"
|
||||
|
@ -88,7 +88,7 @@ nsInterfaceState::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInterfaceState::Init(nsISupports* aEditor, nsIWebShell *aChromeWebShell)
|
||||
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIWebShell *aChromeWebShell)
|
||||
{
|
||||
if (!aEditor)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -153,9 +153,7 @@ nsInterfaceState::UpdateParagraphState(const char* observerName, const char* att
|
|||
{
|
||||
nsStringArray tagList;
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
htmlEditor->GetParagraphStyle(&tagList);
|
||||
mEditor->GetParagraphStyle(&tagList);
|
||||
|
||||
PRInt32 numTags = tagList.Count();
|
||||
if (numTags > 0)
|
||||
|
@ -184,18 +182,14 @@ nsInterfaceState::UpdateListState(const char* observerName, const char* tagName)
|
|||
editor->GetSelection(getter_AddRefs(domSelection));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tagStr(tagName);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
if (domSelection)
|
||||
domSelection->GetAnchorNode(getter_AddRefs(domNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> parentElement;
|
||||
rv = htmlEditor->GetElementOrParentByTagName(tagStr, domNode, getter_AddRefs(parentElement));
|
||||
}
|
||||
nsAutoString tagStr(tagName);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
if (domSelection)
|
||||
domSelection->GetAnchorNode(getter_AddRefs(domNode));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> parentElement;
|
||||
rv = mEditor->GetElementOrParentByTagName(tagStr, domNode, getter_AddRefs(parentElement));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -212,18 +206,7 @@ nsInterfaceState::UpdateFontFace(const char* observerName, const char* attribute
|
|||
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom("font"));
|
||||
nsAutoString faceStr("face");
|
||||
|
||||
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
{
|
||||
rv = textEditor->GetTextProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
rv = htmlEditor->GetTextProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
|
||||
rv = mEditor->GetInlineProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -240,17 +223,7 @@ nsInterfaceState::UpdateTextState(const char* tagName, const char* observerName,
|
|||
|
||||
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(tagName));
|
||||
|
||||
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
{
|
||||
rv = textEditor->GetTextProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
rv = htmlEditor->GetTextProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
}
|
||||
rv = mEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
|
||||
|
||||
PRBool &behaviour = allOfSelectionHasProp; // change this to alter the behaviour
|
||||
if (behaviour != ioState)
|
||||
|
@ -309,7 +282,7 @@ nsInterfaceState::SetNodeAttribute(const char* nodeID, const char* attributeName
|
|||
}
|
||||
|
||||
|
||||
nsresult NS_NewInterfaceState(nsISupports* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
{
|
||||
nsInterfaceState* newThang = new nsInterfaceState;
|
||||
if (!newThang)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "nsIDocumentStateListener.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
class nsIHTMLEditor;
|
||||
|
||||
// class responsible for communicating changes in local state back to the UI.
|
||||
// This is currently somewhat tied to a given XUL UI implementation
|
||||
|
||||
|
@ -38,7 +40,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsISupports* aEditor, nsIWebShell *aChromeWebShell);
|
||||
NS_IMETHOD Init(nsIHTMLEditor* aEditor, nsIWebShell *aChromeWebShell);
|
||||
|
||||
// nsIDOMSelectionListener interface
|
||||
NS_IMETHOD NotifySelectionChanged();
|
||||
|
@ -67,7 +69,7 @@ protected:
|
|||
// this class should not hold references to the editor or editorShell. Doing
|
||||
// so would result in cirular reference chains.
|
||||
|
||||
nsISupports* mEditor; // the text or HTML editor
|
||||
nsIHTMLEditor* mEditor; // the HTML editor
|
||||
nsIWebShell* mWebShell; // web shell for the chrome area
|
||||
|
||||
// current state
|
||||
|
@ -83,6 +85,6 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
extern "C" nsresult NS_NewInterfaceState(nsISupports* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult);
|
||||
extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult);
|
||||
|
||||
#endif // nsInterfaceState_h__
|
||||
|
|
|
@ -79,7 +79,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
result = mEditor->GetDocument(getter_AddRefs(doc));
|
||||
if ((NS_SUCCEEDED(result)) && (doc))
|
||||
{
|
||||
if (nsIEditor::GetTextNodeTag() == mTag)
|
||||
if (nsEditor::GetTextNodeTag() == mTag)
|
||||
{
|
||||
const nsString stringData;
|
||||
nsCOMPtr<nsIDOMText>newTextNode;
|
||||
|
|
|
@ -123,7 +123,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
else
|
||||
{ // the selection ends in a different node from where it started
|
||||
// delete the relevant content in the start node
|
||||
result = CreateTxnsToDeleteContent(mStartParent, mStartOffset, nsIEditor::eDeleteRight);
|
||||
result = CreateTxnsToDeleteContent(mStartParent, mStartOffset, nsIEditor::eDeleteNext);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
// delete the intervening nodes
|
||||
|
@ -131,7 +131,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
// delete the relevant content in the end node
|
||||
result = CreateTxnsToDeleteContent(mEndParent, mEndOffset, nsIEditor::eDeleteLeft);
|
||||
result = CreateTxnsToDeleteContent(mEndParent, mEndOffset, nsIEditor::eDeletePrevious);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent
|
|||
|
||||
NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
||||
PRUint32 aOffset,
|
||||
nsIEditor::ECollapsedSelectionAction aAction)
|
||||
nsIEditor::ESelectionCollapseDirection aAction)
|
||||
{
|
||||
nsresult result;
|
||||
// see what kind of node we have
|
||||
|
@ -290,7 +290,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
|||
if (textNode)
|
||||
{ // if the node is a text node, then delete text content
|
||||
PRUint32 start, numToDelete;
|
||||
if (nsIEditor::eDeleteRight == aAction)
|
||||
if (nsIEditor::eDeleteNext == aAction)
|
||||
{
|
||||
start=aOffset;
|
||||
textNode->GetLength(&numToDelete);
|
||||
|
|
|
@ -32,6 +32,9 @@ class nsIDOMDocument;
|
|||
0x5ec6b260, 0xac49, 0x11d2, \
|
||||
{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} }
|
||||
|
||||
class nsIDOMRange;
|
||||
class nsIEditor;
|
||||
|
||||
/**
|
||||
* A transaction that deletes an entire range in the content tree
|
||||
*/
|
||||
|
@ -78,7 +81,7 @@ protected:
|
|||
|
||||
NS_IMETHOD CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
||||
PRUint32 aOffset,
|
||||
nsIEditor::ECollapsedSelectionAction aAction);
|
||||
nsIEditor::ESelectionCollapseDirection aAction);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef nsEditRules_h__
|
||||
#define nsEditRules_h__
|
||||
|
||||
class nsIEditor;
|
||||
class nsHTMLEditor;
|
||||
class nsIDOMSelection;
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -43,9 +43,11 @@ class nsRulesInfo
|
|||
class nsEditRules
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD Init(nsIEditor *aEditor)=0;
|
||||
NS_IMETHOD Init(nsHTMLEditor *aEditor)=0;
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel)=0;
|
||||
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0;
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags)=0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags)=0;
|
||||
|
||||
};
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -19,15 +19,20 @@
|
|||
#ifndef __editor_h__
|
||||
#define __editor_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prmon.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditorIMESupport.h"
|
||||
#include "nsIEditorLogging.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIPrivateTextRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "TransactionFactory.h"
|
||||
|
@ -78,43 +83,10 @@ PRMonitor *GetEditorMonitor();
|
|||
* manager, event interfaces. the idea for the event interfaces is to have them
|
||||
* delegate the actual commands to the editor independent of the XPFE implementation.
|
||||
*/
|
||||
class nsEditor : public nsIEditor
|
||||
class nsEditor : public nsIEditor,
|
||||
public nsIEditorIMESupport,
|
||||
public nsIEditorLogging
|
||||
{
|
||||
private:
|
||||
nsIPresShell *mPresShell;
|
||||
nsIViewManager *mViewManager;
|
||||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
//
|
||||
nsCOMPtr<nsIDOMCharacterData> mIMETextNode;
|
||||
PRUint32 mIMETextOffset;
|
||||
PRUint32 mIMEBufferLength;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
nsVoidArray* mActionListeners;
|
||||
nsCOMPtr<nsISupportsArray> mDocStateListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
PRInt8 mDocDirtyState; // -1 = not initialized
|
||||
|
||||
protected:
|
||||
nsIDOMDocument * mDoc;
|
||||
nsCOMPtr<nsIDTD> mDTD;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
nsJSEditorLog *mJSEditorLog;
|
||||
nsJSTxnLog *mJSTxnLog;
|
||||
#endif // ENABLE_JS_EDITOR_LOG
|
||||
|
||||
public:
|
||||
|
||||
enum IterDirection
|
||||
|
@ -134,77 +106,67 @@ public:
|
|||
* for someone to derive from the nsEditor later? I dont believe so.
|
||||
*/
|
||||
virtual ~nsEditor();
|
||||
|
||||
/*BEGIN nsIEditor for more details*/
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
||||
|
||||
/* ------------ nsIEditor methods -------------- */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
NS_IMETHOD PostCreate();
|
||||
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
|
||||
|
||||
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);
|
||||
|
||||
NS_IMETHOD GetPresShell(nsIPresShell **aPS);
|
||||
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection **aSelection);
|
||||
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable);
|
||||
NS_IMETHOD Do(nsITransaction *aTxn);
|
||||
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 SetProperties(nsVoidArray *aPropList);
|
||||
NS_IMETHOD BeginTransaction();
|
||||
NS_IMETHOD EndTransaction();
|
||||
|
||||
NS_IMETHOD GetProperties(nsVoidArray *aPropList);
|
||||
// file handling
|
||||
NS_IMETHOD Save();
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy);
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
|
||||
|
||||
// these are pure virtual in this base class
|
||||
NS_IMETHOD Cut() = 0;
|
||||
NS_IMETHOD Copy() = 0;
|
||||
NS_IMETHOD Paste() = 0;
|
||||
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
NS_IMETHOD EndOfDocument();
|
||||
|
||||
|
||||
/* Node and element manipulation */
|
||||
NS_IMETHOD SetAttribute(nsIDOMElement * aElement,
|
||||
const nsString& aAttribute,
|
||||
const nsString& aValue);
|
||||
|
||||
|
||||
NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement,
|
||||
const nsString& aAttribute,
|
||||
nsString& aResultValue,
|
||||
PRBool& aResultIsSet);
|
||||
|
||||
|
||||
NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
|
||||
|
||||
//NOTE: Most callers are dealing with Nodes,
|
||||
// but these objects must supports nsIDOMElement
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
|
||||
NS_IMETHOD CreateNode(const nsString& aTag,
|
||||
nsIDOMNode * aParent,
|
||||
PRInt32 aPosition,
|
||||
nsIDOMNode ** aNewNode);
|
||||
|
||||
|
||||
NS_IMETHOD InsertNode(nsIDOMNode * aNode,
|
||||
nsIDOMNode * aParent,
|
||||
PRInt32 aPosition);
|
||||
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply *aReply);
|
||||
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD DumpContentTree();
|
||||
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
|
||||
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode);
|
||||
|
||||
|
||||
NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
|
||||
PRInt32 aOffset,
|
||||
nsIDOMNode ** aNewLeftNode);
|
||||
|
@ -213,69 +175,63 @@ public:
|
|||
nsIDOMNode * aRightNode,
|
||||
nsIDOMNode * aParent);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
|
||||
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable);
|
||||
|
||||
NS_IMETHOD Do(nsITransaction *aTxn);
|
||||
|
||||
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();
|
||||
|
||||
NS_IMETHOD GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject);
|
||||
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
|
||||
NS_IMETHOD EndOfDocument();
|
||||
|
||||
NS_IMETHOD Cut();
|
||||
|
||||
NS_IMETHOD Copy();
|
||||
|
||||
NS_IMETHOD Paste();
|
||||
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
/* output */
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
/* Listeners */
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
|
||||
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
|
||||
|
||||
|
||||
NS_IMETHOD DumpContentTree();
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
|
||||
/* ------------ nsIEditorIMESupport methods -------------- */
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
/* ------------ nsIEditorLogging methods -------------- */
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
NS_IMETHOD StopLogging();
|
||||
|
||||
/*END nsIEditor interfaces*/
|
||||
public:
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert);
|
||||
NS_IMETHOD DeleteSelectionImpl(ESelectionCollapseDirection aAction);
|
||||
|
||||
|
||||
/*BEGIN private methods used by the implementations of the above functions*/
|
||||
protected:
|
||||
|
||||
|
||||
// why not use the one in nsHTMLDocument?
|
||||
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);
|
||||
|
||||
//NOTE: Most callers are dealing with Nodes,
|
||||
// but these objects must supports nsIDOMElement
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
/*
|
||||
NS_IMETHOD SetProperties(nsVoidArray *aPropList);
|
||||
NS_IMETHOD GetProperties(nsVoidArray *aPropList);
|
||||
*/
|
||||
|
||||
/** create a transaction for setting aAttribute to aValue on aElement
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
|
||||
|
@ -308,6 +264,26 @@ protected:
|
|||
NS_IMETHOD CreateTxnForDeleteElement(nsIDOMNode * aElement,
|
||||
DeleteElementTxn ** aTxn);
|
||||
|
||||
|
||||
/** Create an aggregate transaction for deleting current selection
|
||||
* Used by all methods that need to delete current selection,
|
||||
* then insert something new to replace it
|
||||
* @param nsString& aTxnName is the name of the aggregated transaction
|
||||
* @param EditTxn **aAggTxn is the return location of the aggregate TXN,
|
||||
* with the DeleteSelectionTxn as the first child ONLY
|
||||
* if there was a selection to delete.
|
||||
*/
|
||||
NS_IMETHOD CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, EditAggregateTxn **aAggTxn);
|
||||
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteSelection(ESelectionCollapseDirection aAction,
|
||||
EditAggregateTxn ** aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
||||
ESelectionCollapseDirection aAction,
|
||||
EditAggregateTxn *aTxn);
|
||||
|
||||
|
||||
/** create a transaction for inserting aStringToInsert into aTextNode
|
||||
* if aTextNode is null, the string is inserted at the current selection.
|
||||
*/
|
||||
|
@ -326,15 +302,12 @@ protected:
|
|||
/** create a transaction for removing a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
/** insert aStringToInsert as the first text in the document
|
||||
*/
|
||||
NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert);
|
||||
|
||||
NS_IMETHOD DoInitialInputMethodInsert(const nsString& aStringToInsert,nsIPrivateTextRangeList* aTextRangeList);
|
||||
NS_IMETHOD DoInitialInputMethodInsert(const nsString & aStringToInsert, nsIPrivateTextRangeList* aTextRangeList);
|
||||
|
||||
|
||||
NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
|
||||
|
@ -345,14 +318,7 @@ protected:
|
|||
PRUint32 aOffset,
|
||||
PRUint32 aLength,
|
||||
DeleteTextTxn **aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelectionAction aAction,
|
||||
EditAggregateTxn ** aTxn);
|
||||
|
||||
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
||||
nsIEditor::ECollapsedSelectionAction aAction,
|
||||
EditAggregateTxn *aTxn);
|
||||
|
||||
|
||||
NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
|
||||
PRUint32 aOffset,
|
||||
SplitElementTxn **aTxn);
|
||||
|
@ -361,19 +327,8 @@ protected:
|
|||
nsIDOMNode *aRightNode,
|
||||
JoinElementTxn **aTxn);
|
||||
|
||||
/** Create an aggregate transaction for deleting current selection
|
||||
* Used by all methods that need to delete current selection,
|
||||
* then insert something new to replace it
|
||||
* @param nsString& aTxnName is the name of the aggregated transaction
|
||||
* @param EditTxn **aAggTxn is the return location of the aggregate TXN,
|
||||
* with the DeleteSelectionTxn as the first child ONLY
|
||||
* if there was a selection to delete.
|
||||
*/
|
||||
NS_IMETHOD CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, EditAggregateTxn **aAggTxn);
|
||||
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
|
||||
NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList* aTextRangeList);
|
||||
NS_IMETHOD SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRangeList *aTextRangeList);
|
||||
|
||||
// called each time we modify the document. Increments the mod
|
||||
// count of the doc.
|
||||
|
@ -415,9 +370,16 @@ protected:
|
|||
// document after a change via the DOM - gpk 2/13/99
|
||||
void HACKForceRedraw(void);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, PRInt32& offsetOfNewNode);
|
||||
// file handling utils
|
||||
|
||||
NS_IMETHOD SaveDocument(PRBool saveAs, PRBool saveCopy);
|
||||
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
public:
|
||||
|
||||
static nsString& GetTextNodeTag();
|
||||
|
||||
/**
|
||||
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||
|
@ -626,39 +588,45 @@ public:
|
|||
|
||||
nsresult BeginUpdateViewBatch(void);
|
||||
nsresult EndUpdateViewBatch(void);
|
||||
};
|
||||
|
||||
|
||||
class nsAutoEditBatch
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<nsIEditor> mEd;
|
||||
public:
|
||||
nsAutoEditBatch( nsIEditor *aEd) : mEd(do_QueryInterface(aEd))
|
||||
{ if (mEd) mEd->BeginTransaction(); }
|
||||
~nsAutoEditBatch() { if (mEd) mEd->EndTransaction(); }
|
||||
};
|
||||
protected:
|
||||
|
||||
class nsAutoSelectionReset
|
||||
{
|
||||
private:
|
||||
/** ref-counted reference to the selection that we are supposed to restore */
|
||||
nsCOMPtr<nsIDOMSelection> mSel;
|
||||
PRUint32 mFlags; // behavior flags. See nsIHTMLEditor.h for the flags we use.
|
||||
|
||||
nsIPresShell *mPresShell;
|
||||
nsIViewManager *mViewManager;
|
||||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
/** PR_TRUE if this instance initialized itself correctly */
|
||||
PRBool mInitialized;
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
//
|
||||
nsCOMPtr<nsIDOMCharacterData> mIMETextNode;
|
||||
PRUint32 mIMETextOffset;
|
||||
PRUint32 mIMEBufferLength;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mStartNode;
|
||||
nsCOMPtr<nsIDOMNode> mEndNode;
|
||||
PRInt32 mStartOffset;
|
||||
PRInt32 mEndOffset;
|
||||
nsVoidArray* mActionListeners;
|
||||
nsCOMPtr<nsISupportsArray> mDocStateListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
public:
|
||||
/** constructor responsible for remembering all state needed to restore aSel */
|
||||
nsAutoSelectionReset(nsIDOMSelection *aSel);
|
||||
|
||||
/** destructor restores mSel to its former state */
|
||||
~nsAutoSelectionReset();
|
||||
PRInt8 mDocDirtyState; // -1 = not initialized
|
||||
|
||||
nsIDOMDocument * mDoc;
|
||||
nsCOMPtr<nsIDTD> mDTD;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
nsJSEditorLog *mJSEditorLog;
|
||||
nsJSTxnLog *mJSTxnLog;
|
||||
#endif // ENABLE_JS_EDITOR_LOG
|
||||
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsITextEditor.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "TextEditorTest.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
|
@ -43,7 +43,7 @@ TextEditorTest::~TextEditorTest()
|
|||
printf("destroyed a TextEditorTest\n");
|
||||
}
|
||||
|
||||
void TextEditorTest::Run(nsITextEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
|
||||
void TextEditorTest::Run(nsIEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
|
||||
{
|
||||
if (!aEditor) return;
|
||||
mTextEditor = do_QueryInterface(aEditor);
|
||||
|
@ -98,9 +98,9 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
|
|||
|
||||
nsresult TextEditorTest::InitDoc()
|
||||
{
|
||||
nsresult result = mTextEditor->SelectAll();
|
||||
nsresult result = mEditor->SelectAll();
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->DeleteSelection(nsIEditor::eDeleteRight);
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeleteNext);
|
||||
TEST_RESULT(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -165,14 +165,14 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first=PR_FALSE;
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_FALSE==first, "first should be false");
|
||||
NS_ASSERTION(PR_FALSE==any, "any should be false");
|
||||
NS_ASSERTION(PR_FALSE==all, "all should be false");
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
@ -181,9 +181,9 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
|
||||
// remove the bold we just set
|
||||
printf("set the whole first text node to not bold\n");
|
||||
result = mTextEditor->RemoveTextProperty(nsIEditProperty::b, nsnull);
|
||||
result = mTextEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_FALSE==first, "first should be false");
|
||||
NS_ASSERTION(PR_FALSE==any, "any should be false");
|
||||
|
@ -194,23 +194,23 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n");
|
||||
selection->Collapse(textNode, 1);
|
||||
selection->Extend(textNode, length-1);
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
NS_ASSERTION(PR_TRUE==all, "all should be true");
|
||||
mEditor->DebugDumpContent();
|
||||
// make all that same text italic
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
NS_ASSERTION(PR_TRUE==all, "all should be true");
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
@ -231,9 +231,9 @@ nsresult TextEditorTest::TestTextProperties()
|
|||
NS_ASSERTION(length==249, "wrong text node");
|
||||
selection->Collapse(textNode, 1);
|
||||
selection->Extend(textNode, length-2);
|
||||
result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
result = mTextEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
TEST_RESULT(result);
|
||||
result = mTextEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
result = mTextEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
TEST_RESULT(result);
|
||||
NS_ASSERTION(PR_TRUE==first, "first should be true");
|
||||
NS_ASSERTION(PR_TRUE==any, "any should be true");
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#ifdef NS_DEBUG
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
class TextEditorTest
|
||||
{
|
||||
public:
|
||||
|
||||
void Run(nsITextEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
void Run(nsIEditor *aEditor, PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
TextEditorTest();
|
||||
~TextEditorTest();
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected:
|
|||
|
||||
nsresult TestTextProperties();
|
||||
|
||||
nsCOMPtr<nsITextEditor> mTextEditor;
|
||||
nsCOMPtr<nsIHTMLEditor> mTextEditor;
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ChangeAttributeTxn_h__
|
||||
#define ChangeAttributeTxn_h__
|
||||
#ifndef TypeInState_h__
|
||||
#define TypeInState_h__
|
||||
|
||||
#include "nsIDOMSelectionListener.h"
|
||||
#include "nsIEditProperty.h"
|
||||
|
@ -228,4 +228,5 @@ inline void TypeInState::SetPropValue(PRUint32 aProp, const nsString &aValue)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // TypeInState_h__
|
||||
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
*/
|
||||
|
||||
#include "nsHTMLEditRules.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsTextEditor.h"
|
||||
|
||||
#include "PlaceholderTxn.h"
|
||||
#include "InsertTextTxn.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -36,7 +38,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
class nsIFrame;
|
||||
#include "nsEditorUtils.h"
|
||||
|
||||
//const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
|
||||
//const static char* kMOZEditorBogusNodeValue="TRUE";
|
||||
|
@ -56,7 +58,8 @@ enum
|
|||
* Constructor/Destructor
|
||||
********************************************************/
|
||||
|
||||
nsHTMLEditRules::nsHTMLEditRules()
|
||||
nsHTMLEditRules::nsHTMLEditRules(PRUint32 aFlags)
|
||||
: nsTextEditRules(aFlags)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -285,7 +288,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
|
|||
|
||||
|
||||
nsresult
|
||||
nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECollapsedSelectionAction aAction, PRBool *aCancel)
|
||||
nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ESelectionCollapseDirection aAction, PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
// initialize out param
|
||||
|
@ -315,7 +318,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// at beginning of text node and backspaced?
|
||||
if (!offset && (aAction == nsIEditor::eDeleteLeft))
|
||||
if (!offset && (aAction == nsIEditor::eDeletePrevious))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> priorNode;
|
||||
res = mEditor->GetPriorNode(node, PR_TRUE, getter_AddRefs(priorNode));
|
||||
|
@ -368,7 +371,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
|
||||
// at end of text node and deleted?
|
||||
if ((offset == (PRInt32)strLength)
|
||||
&& (aAction == nsIEditor::eDeleteRight))
|
||||
&& (aAction == nsIEditor::eDeleteNext))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> nextNode;
|
||||
res = mEditor->GetNextNode(node, PR_TRUE, getter_AddRefs(nextNode));
|
||||
|
@ -480,7 +483,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
{
|
||||
// first delete the selection
|
||||
*aCancel = PR_TRUE;
|
||||
res = mEditor->nsEditor::DeleteSelection(aAction);
|
||||
res = mEditor->DeleteSelectionImpl(aAction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
// then join para's, insert break
|
||||
res = mEditor->JoinNodeDeep(leftParent,rightParent,aSelection);
|
||||
|
@ -493,7 +496,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
|
|||
{
|
||||
// first delete the selection
|
||||
*aCancel = PR_TRUE;
|
||||
res = mEditor->nsEditor::DeleteSelection(aAction);
|
||||
res = mEditor->DeleteSelectionImpl(aAction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
// join blocks
|
||||
res = mEditor->JoinNodeDeep(leftParent,rightParent,aSelection);
|
||||
|
@ -1284,7 +1287,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt
|
|||
}
|
||||
|
||||
if (node)
|
||||
offset++; // since this is going to be used for a range _endpoint_, we want to be after the node
|
||||
offset++; // since this is going to be used for a range _endpoint_, we want to be after the node
|
||||
else
|
||||
node = parent;
|
||||
|
||||
|
@ -1859,11 +1862,3 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ class nsHTMLEditRules : public nsTextEditRules
|
|||
{
|
||||
public:
|
||||
|
||||
nsHTMLEditRules();
|
||||
virtual ~nsHTMLEditRules();
|
||||
nsHTMLEditRules(PRUint32 aFlags);
|
||||
virtual ~nsHTMLEditRules();
|
||||
|
||||
// nsEditRules methods
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
||||
|
@ -61,7 +61,7 @@ protected:
|
|||
TypeInState typeInState,
|
||||
PRInt32 aMaxLength);
|
||||
nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECollapsedSelectionAction aAction, PRBool *aCancel);
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ESelectionCollapseDirection aAction, PRBool *aCancel);
|
||||
nsresult WillMakeList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel);
|
||||
nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -19,21 +19,33 @@
|
|||
#ifndef nsHTMLEditor_h__
|
||||
#define nsHTMLEditor_h__
|
||||
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsTextEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsITableEditor.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIEditorStyleSheets.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
#include "TypeInState.h"
|
||||
#include "nsEditRules.h"
|
||||
|
||||
/**
|
||||
* The HTML editor implementation.<br>
|
||||
* Use to edit HTML document represented as a DOM tree.
|
||||
*/
|
||||
class nsHTMLEditor : public nsTextEditor, public nsIHTMLEditor
|
||||
class nsHTMLEditor : public nsEditor,
|
||||
public nsIHTMLEditor,
|
||||
public nsIEditorMailSupport,
|
||||
public nsITableEditor,
|
||||
public nsIEditorStyleSheets
|
||||
{
|
||||
|
||||
typedef enum {eNoOp=0, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
||||
typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
||||
|
||||
public:
|
||||
// see nsIHTMLEditor for documentation
|
||||
|
@ -43,139 +55,77 @@ public:
|
|||
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLEditor();
|
||||
virtual ~nsHTMLEditor();
|
||||
nsHTMLEditor();
|
||||
virtual ~nsHTMLEditor();
|
||||
|
||||
//Initialization
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
|
||||
/* ------------ nsIHTMLEditor methods -------------- */
|
||||
|
||||
//============================================================================
|
||||
// Methods that are duplicates of nsTextEditor -- exposed here for convenience
|
||||
NS_IMETHOD GetDocumentLength(PRInt32 *aCount);
|
||||
NS_IMETHOD SetMaxTextLength(PRInt32 aMaxTextLength);
|
||||
NS_IMETHOD GetMaxTextLength(PRInt32& aMaxTextLength);
|
||||
|
||||
// Editing Operations
|
||||
NS_IMETHOD SetTextProperty(nsIAtom *aProperty,
|
||||
|
||||
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
NS_IMETHOD GetTextProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute, const nsString *aValue,
|
||||
|
||||
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aFirst, PRBool &aAny, PRBool &aAll);
|
||||
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction);
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD CopyAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
||||
|
||||
// Transaction control
|
||||
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();
|
||||
|
||||
// Selection and navigation
|
||||
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);
|
||||
NS_IMETHOD SelectAll();
|
||||
NS_IMETHOD BeginningOfDocument();
|
||||
NS_IMETHOD EndOfDocument();
|
||||
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
|
||||
// file handling
|
||||
NS_IMETHOD Save();
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy);
|
||||
|
||||
// cut, copy & paste
|
||||
NS_IMETHOD Cut();
|
||||
NS_IMETHOD Copy();
|
||||
NS_IMETHOD Paste();
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
||||
const nsString& aCitation);
|
||||
|
||||
// Input/Output
|
||||
NS_IMETHOD InsertHTML(const nsString& aInputString);
|
||||
|
||||
NS_IMETHOD BeginComposition(void);
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRange, nsTextEventReply* aReply);
|
||||
NS_IMETHOD EndComposition(void);
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
// Miscellaneous
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
|
||||
// Logging methods
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
NS_IMETHOD StopLogging();
|
||||
|
||||
// End of methods implemented in nsEditor
|
||||
//=============================================================
|
||||
// HTML Editing methods
|
||||
|
||||
// This sets background on the appropriate container element (table, cell,)
|
||||
// or calls into nsTextEditor to set the page background
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
||||
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList);
|
||||
NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD RemoveParagraphStyle();
|
||||
NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString);
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD DeleteSelection(ESelectionCollapseDirection aAction);
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode);
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
|
||||
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
|
||||
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
|
||||
|
||||
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList);
|
||||
NS_IMETHOD RemoveParagraphStyle();
|
||||
|
||||
NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
||||
NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
||||
|
||||
NS_IMETHOD InsertList(const nsString& aListType);
|
||||
NS_IMETHOD Indent(const nsString& aIndent);
|
||||
NS_IMETHOD Align(const nsString& aAlign);
|
||||
NS_IMETHOD InsertList(const nsString& aListType);
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
||||
|
||||
NS_IMETHOD SaveHLineSettings(nsIDOMElement* aElement);
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
||||
// Return TRUE if aElement is a table-related elemet and caret was set
|
||||
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
PRBool IsElementInBody(nsIDOMElement* aElement);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
|
||||
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
||||
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
||||
/** Get the row an column index from the layout's cellmap */
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32 & aRowIndex, PRInt32 &aColIndex);
|
||||
/** Get the number of rows and columns in a table from the layout's cellmap */
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
/* ------------ nsIEditorStyleSheets methods -------------- */
|
||||
|
||||
/* Get cell at a cellmap location. Returns NS_TABLELAYOUT_CELL_NOT_FOUND if past end of row or col */
|
||||
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
|
||||
/* Get cell and associated data */
|
||||
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
|
||||
/* ------------ nsIEditorMailSupport methods -------------- */
|
||||
|
||||
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn);
|
||||
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn);
|
||||
NS_IMETHOD PasteAsQuotation();
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
/* ------------ nsITableEditor methods -------------- */
|
||||
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
||||
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
|
||||
|
@ -185,15 +135,85 @@ public:
|
|||
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
||||
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
||||
NS_IMETHOD JoinTableCells();
|
||||
|
||||
/** Make table "rectangular" -- fill in all missing cellmap locations
|
||||
* If aTable is null, it uses table enclosing the selection anchor
|
||||
*/
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
|
||||
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
|
||||
|
||||
|
||||
// Selection and navigation
|
||||
/* obsolete
|
||||
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);
|
||||
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
||||
*/
|
||||
|
||||
/* miscellaneous */
|
||||
// This sets background on the appropriate container element (table, cell,)
|
||||
// or calls into nsTextEditor to set the page background
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
||||
|
||||
|
||||
|
||||
/* ------------ Overrides of nsEditor interface methods -------------- */
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD Cut();
|
||||
NS_IMETHOD Copy();
|
||||
NS_IMETHOD Paste();
|
||||
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void InitRules();
|
||||
|
||||
NS_IMETHOD GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject);
|
||||
|
||||
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, PRInt32& offsetOfNewNode);
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
|
||||
// Return TRUE if aElement is a table-related elemet and caret was set
|
||||
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
PRBool IsElementInBody(nsIDOMElement* aElement);
|
||||
|
||||
// Table Editing (implemented in EditTable.cpp)
|
||||
|
||||
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
||||
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
||||
|
||||
// Table utilities
|
||||
|
||||
// All of the above need to get the same basic context data
|
||||
// All of the above need to get the same basic context data
|
||||
NS_IMETHOD GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
|
||||
nsCOMPtr<nsIDOMElement> &aTable, nsCOMPtr<nsIDOMElement> &aCell,
|
||||
nsCOMPtr<nsIDOMNode> &aCellParent, PRInt32& aCellOffset,
|
||||
|
@ -204,15 +224,10 @@ public:
|
|||
|
||||
// Setting caret to a logical place can get tricky,
|
||||
// especially after deleting table stuff
|
||||
typedef enum { ePreviousColumn=0, ePreviousRow } SetCaretSearchDirection;
|
||||
typedef enum { ePreviousColumn, ePreviousRow } SetCaretSearchDirection;
|
||||
|
||||
NS_IMETHOD SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aCol, PRInt32 aRow, SetCaretSearchDirection aDirection);
|
||||
|
||||
protected:
|
||||
|
||||
// rules initialization
|
||||
|
||||
virtual void InitRules();
|
||||
|
||||
|
||||
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
|
||||
nsString &aParentTag,
|
||||
BlockTransformationType aTranformation);
|
||||
|
@ -241,14 +256,178 @@ protected:
|
|||
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
|
||||
|
||||
|
||||
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
||||
// For now, the listners are tied to the nsTextEditor class
|
||||
//
|
||||
// nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
||||
// nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
||||
/** content-based query returns PR_TRUE if <aProperty aAttribute=aValue> effects aNode
|
||||
* If <aProperty aAttribute=aValue> contains aNode,
|
||||
* but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
||||
* more deeply nested than the first, then the first does not effect aNode.
|
||||
*
|
||||
* @param aNode The target of the query
|
||||
* @param aProperty The property that we are querying for
|
||||
* @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
|
||||
* May be null.
|
||||
* @param aValue The value of aAttribute, example: blue in <FONT color="blue">
|
||||
* May be null. Ignored if aAttribute is null.
|
||||
* @param aIsSet [OUT] PR_TRUE if <aProperty aAttribute=aValue> effects aNode.
|
||||
* @param aStyleNode [OUT] set to the node representing <aProperty aAttribute=aValue>, if found.
|
||||
* null if aIsSet is returned as PR_FALSE;
|
||||
*/
|
||||
virtual void IsTextPropertySetByContent(nsIDOMNode *aNode,
|
||||
nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aIsSet,
|
||||
nsIDOMNode **aStyleNode) const;
|
||||
|
||||
// this overrides the base class implementation. It is not exported in nsIHTMLEditor.
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
||||
/** style-based query returns PR_TRUE if (aProperty, aAttribute) is set in aSC.
|
||||
* WARNING: not well tested yet since we don't do style-based queries anywhere.
|
||||
*/
|
||||
virtual void IsTextStyleSet(nsIStyleContext *aSC,
|
||||
nsIAtom *aProperty,
|
||||
const nsString *aAttributes,
|
||||
PRBool &aIsSet) const;
|
||||
|
||||
/** Moves the content between (aNode, aStartOffset) and (aNode, aEndOffset)
|
||||
* into aNewParentNode, splitting aNode as necessary to maintain the relative
|
||||
* position of all leaf content.
|
||||
* @param aNode The node whose content we're repositioning.
|
||||
* aNode can be either a text node or a container node.
|
||||
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
||||
* The caller is responsible for allocating aNewParentNode
|
||||
* @param aStartOffset The start offset of the content of aNode
|
||||
* @param aEndOffset The end offset of the content of aNode.
|
||||
*/
|
||||
NS_IMETHOD MoveContentOfNodeIntoNewParent(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aNewParentNode,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset);
|
||||
|
||||
/** Moves the content between (aStartNode, aStartOffset) and (aEndNode, aEndOffset)
|
||||
* into aNewParentNode, splitting aStartNode and aEndNode as necessary to maintain
|
||||
* the relative position of all leaf content.
|
||||
* The content between the two endpoints MUST be "contiguous" in the sense that
|
||||
* it is all in the same block. Another way of saying this is all content nodes
|
||||
* between aStartNode and aEndNode must be inline.
|
||||
* @see IntermediateNodesAreInline
|
||||
*
|
||||
* @param aStartNode The left node, can be either a text node or a container node.
|
||||
* @param aStartOffset The start offset in the content of aStartNode
|
||||
* @param aEndNode The right node, can be either a text node or a container node.
|
||||
* @param aEndOffset The end offset in the content of aEndNode.
|
||||
* @param aGrandParentNode The common ancestor of aStartNode and aEndNode.
|
||||
* aGrandParentNode will be the parent of aNewParentNode.
|
||||
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
||||
* The caller is responsible for allocating aNewParentNode
|
||||
*/
|
||||
NS_IMETHOD MoveContiguousContentIntoNewParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aGrandParentNode,
|
||||
nsIDOMNode *aNewParentNode);
|
||||
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
|
||||
nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD RemoveTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStartNode,
|
||||
PRInt32 aStartOffset,
|
||||
nsIDOMNode *aEndNode,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMNode *aParent,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute);
|
||||
|
||||
NS_IMETHOD SetTypeInStateForProperty(TypeInState &aTypeInState,
|
||||
nsIAtom *aPropName,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue);
|
||||
|
||||
void GetTextSelectionOffsetsForRange(nsIDOMSelection *aSelection,
|
||||
nsIDOMNode **aParent,
|
||||
PRInt32 &aStartOffset,
|
||||
PRInt32 &aEndOffset);
|
||||
|
||||
void ResetTextSelectionForRange(nsIDOMNode *aParent,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsIDOMSelection *aSelection);
|
||||
|
||||
/** returns the absolute position of the end points of aSelection
|
||||
* in the document as a text stream.
|
||||
*/
|
||||
nsresult GetTextSelectionOffsets(nsIDOMSelection *aSelection,
|
||||
PRInt32 &aStartOffset,
|
||||
PRInt32 &aEndOffset);
|
||||
|
||||
// Methods for handling plaintext quotations
|
||||
NS_IMETHOD PasteAsPlaintextQuotation();
|
||||
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
|
||||
|
||||
// I hate seeing nsCOMPtr return types.
|
||||
nsCOMPtr<nsIDOMElement> FindPreElement();
|
||||
|
||||
TypeInState *GetTypeInState();
|
||||
|
||||
/** simple utility to handle any error with event listener allocation or registration */
|
||||
void HandleEventListenerError();
|
||||
|
||||
// Data members
|
||||
protected:
|
||||
|
||||
TypeInState* mTypeInState;
|
||||
nsEditRules* mRules;
|
||||
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mTextListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mCompositionListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
|
||||
PRBool mIsComposing;
|
||||
PRInt32 mMaxTextLength;
|
||||
PRUint32 mWrapColumn;
|
||||
|
||||
// friends
|
||||
friend class nsHTMLEditRules;
|
||||
friend class nsTextEditRules;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
#include "nsEditorEventListeners.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -25,16 +28,11 @@
|
|||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIEditProperty.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIPrivateTextEvent.h"
|
||||
|
||||
// for testing only
|
||||
#include "nsIHTMLEditor.h"
|
||||
// end for testing only
|
||||
#include "nsIEditorMailSupport.h"
|
||||
|
||||
// for repainting hack only
|
||||
#include "nsIView.h"
|
||||
|
@ -142,7 +140,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
// break;
|
||||
|
||||
case nsIDOMUIEvent::VK_DELETE:
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteNext);
|
||||
break;
|
||||
|
||||
// case nsIDOMUIEvent::VK_RETURN:
|
||||
|
@ -181,7 +179,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
{
|
||||
PRUint32 flags=0;
|
||||
mEditor->GetFlags(&flags);
|
||||
if (! (flags & TEXT_EDITOR_FLAG_SINGLELINE))
|
||||
if (! (flags & nsIHTMLEditor::eEditorSingleLineMask))
|
||||
{
|
||||
PRBool ctrlKey, altKey, metaKey;
|
||||
uiEvent->GetCtrlKey(&ctrlKey);
|
||||
|
@ -192,7 +190,10 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
// else we insert the tab straight through
|
||||
nsAutoString key;
|
||||
key += keyCode;
|
||||
mEditor->InsertText(key);
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
htmlEditor->InsertText(key);
|
||||
return NS_ERROR_BASE; // this means "I handled the event, don't do default processing"
|
||||
}
|
||||
else {
|
||||
|
@ -244,14 +245,17 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
if (metaKey)
|
||||
return NS_OK; // don't consume
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (!htmlEditor) return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)))
|
||||
{
|
||||
if (nsIDOMUIEvent::VK_BACK==keyCode) {
|
||||
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
|
||||
mEditor->DeleteSelection(nsIEditor::eDeletePrevious);
|
||||
return NS_ERROR_BASE; // consumed
|
||||
}
|
||||
if (nsIDOMUIEvent::VK_RETURN==keyCode) {
|
||||
mEditor->InsertBreak();
|
||||
htmlEditor->InsertBreak();
|
||||
return NS_ERROR_BASE; // consumed
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +267,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
return NS_OK; // ignore tabs here, they're handled in keyDown if at all
|
||||
}
|
||||
key += character;
|
||||
mEditor->InsertText(key);
|
||||
htmlEditor->InsertText(key);
|
||||
}
|
||||
|
||||
return NS_ERROR_BASE; // consumed
|
||||
|
@ -333,28 +337,6 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
format = "text/html";
|
||||
res = mEditor->OutputToString(output, format,
|
||||
nsEditor::EditorOutputFormatted);
|
||||
#if 0
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(mEditor));
|
||||
if (htmlEditor)
|
||||
{
|
||||
if (isShift)
|
||||
res = htmlEditor->OutputTextToString(output, PR_TRUE, PR_FALSE);
|
||||
else
|
||||
res = htmlEditor->OutputHTMLToString(output, PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsITextEditor> textEditor (do_QueryInterface(mEditor));
|
||||
if (textEditor)
|
||||
{
|
||||
if (isShift)
|
||||
res = textEditor->OutputTextToString(output, PR_TRUE, PR_FALSE);
|
||||
else
|
||||
res = textEditor->OutputHTMLToString(output, PR_FALSE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
char* buf = output.ToNewCString();
|
||||
|
@ -378,11 +360,15 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
{
|
||||
printf("Getting number of columns\n");
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
printf("Currently wrapping to %d\n", wrap);
|
||||
else
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
PRInt32 wrap;
|
||||
if (NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
printf("Currently wrapping to %d\n", wrap);
|
||||
else
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -390,20 +376,24 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
// hard coded "Decrease wrap size"
|
||||
if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mEditor->SetBodyWrapWidth(wrap - 5);
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mailEditor->SetBodyWrapWidth(wrap - 5);
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -411,20 +401,24 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
// hard coded "Increase wrap size"
|
||||
if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mEditor->SetBodyWrapWidth(wrap + 5);
|
||||
if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
PRInt32 wrap;
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
mailEditor->SetBodyWrapWidth(wrap + 5);
|
||||
if (!NS_SUCCEEDED(mailEditor->GetBodyWrapWidth(&wrap)))
|
||||
{
|
||||
printf("Second GetBodyWrapWidth returned an error\n");
|
||||
break;
|
||||
}
|
||||
else printf("Now wrapping to %d\n", wrap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -436,7 +430,11 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
if (mEditor)
|
||||
{
|
||||
if (altKey)
|
||||
mEditor->PasteAsQuotation();
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation();
|
||||
}
|
||||
else
|
||||
mEditor->Paste();
|
||||
}
|
||||
|
@ -465,19 +463,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_I:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::i, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::i, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +485,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
else if (PR_TRUE==altKey)
|
||||
{
|
||||
aProcessed=PR_TRUE;
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(mEditor));
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsString nsstr ("This is <b>bold <em>and emphasized</em></b> text");
|
||||
|
@ -499,19 +498,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_B:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::b, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,19 +521,20 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_U:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
PRBool any = PR_FALSE;
|
||||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
mEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
|
||||
if (PR_FALSE==first) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull);
|
||||
}
|
||||
else {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::u, nsnull);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::u, nsnull);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -544,7 +545,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_1:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -553,9 +555,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
PRBool first = PR_FALSE;
|
||||
nsAutoString color = "COLOR";
|
||||
nsAutoString value = "red";
|
||||
mEditor->GetTextProperty(nsIEditProperty::font, &color, &value, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::font, &color, &value, first, any, all);
|
||||
if (!all) {
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &color, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &color, &value);
|
||||
}
|
||||
else {
|
||||
printf("NOOP: all selected text is already red\n");
|
||||
|
@ -568,7 +570,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_2:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -576,9 +579,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
PRBool all = PR_FALSE;
|
||||
PRBool first = PR_FALSE;
|
||||
nsAutoString color = "COLOR";
|
||||
mEditor->GetTextProperty(nsIEditProperty::font, &color, nsnull, first, any, all);
|
||||
htmlEditor->GetInlineProperty(nsIEditProperty::font, &color, nsnull, first, any, all);
|
||||
if (any) {
|
||||
mEditor->RemoveTextProperty(nsIEditProperty::font, &color);
|
||||
htmlEditor->RemoveInlineProperty(nsIEditProperty::font, &color);
|
||||
}
|
||||
else {
|
||||
printf("NOOP: no color set\n");
|
||||
|
@ -591,7 +594,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_3:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -600,7 +604,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "SIZE";
|
||||
nsAutoString value = "+2";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -609,7 +613,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_4:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -618,7 +623,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "SIZE";
|
||||
nsAutoString value = "-2";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -627,7 +632,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_5:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -636,7 +642,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "FACE";
|
||||
nsAutoString value = "helvetica";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -645,7 +651,8 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_6:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
// XXX: move this logic down into texteditor rules delegate
|
||||
// should just call mEditor->ChangeTextProperty(prop)
|
||||
|
@ -654,7 +661,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
//PRBool first = PR_FALSE;
|
||||
nsAutoString prop = "FACE";
|
||||
nsAutoString value = "times";
|
||||
mEditor->SetTextProperty(nsIEditProperty::font, &prop, &value);
|
||||
htmlEditor->SetInlineProperty(nsIEditProperty::font, &prop, &value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -663,16 +670,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_7:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h1->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h1->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -681,16 +684,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_8:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h2->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::h2->ToString(tag);
|
||||
htmlEditor->ReplaceBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -699,13 +698,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_9:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor) {
|
||||
htmlEditor->RemoveParagraphStyle();
|
||||
}
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor) {
|
||||
htmlEditor->RemoveParagraphStyle();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -714,28 +709,23 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_0:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
printf("testing GetParagraphStyle\n");
|
||||
nsStringArray styles;
|
||||
nsresult result = htmlEditor->GetParagraphStyle(&styles);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
printf("testing GetParagraphStyle\n");
|
||||
nsStringArray styles;
|
||||
nsresult result = htmlEditor->GetParagraphStyle(&styles);
|
||||
if (NS_SUCCEEDED(result))
|
||||
PRInt32 count = styles.Count();
|
||||
PRInt32 i;
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
PRInt32 count = styles.Count();
|
||||
PRInt32 i;
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
nsString *tag = styles.StringAt(i);
|
||||
char *tagCString = tag->ToNewCString();
|
||||
printf("%s ", tagCString);
|
||||
delete [] tagCString;
|
||||
}
|
||||
printf("\n");
|
||||
nsString *tag = styles.StringAt(i);
|
||||
char *tagCString = tag->ToNewCString();
|
||||
printf("%s ", tagCString);
|
||||
delete [] tagCString;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -745,16 +735,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_COMMA:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->AddBlockParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->AddBlockParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -763,16 +749,12 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
|||
case nsIDOMUIEvent::VK_PERIOD:
|
||||
if (PR_TRUE==ctrlKey)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor>htmlEditor;
|
||||
htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->RemoveParent(tag);
|
||||
}
|
||||
nsAutoString tag;
|
||||
nsIEditProperty::blockquote->ToString(tag);
|
||||
htmlEditor->RemoveParent(tag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -907,8 +889,11 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
|||
uiEvent->GetCtrlKey(&ctrlKey);
|
||||
|
||||
if (ctrlKey)
|
||||
return editor->PasteAsQuotation();
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation();
|
||||
}
|
||||
return editor->Paste();
|
||||
}
|
||||
|
||||
|
@ -933,24 +918,21 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
nsresult
|
||||
nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
if (mEditor)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (htmlEditor)
|
||||
{
|
||||
nsIHTMLEditor * HTMLEditor;
|
||||
if (NS_SUCCEEDED(mEditor->QueryInterface(nsIHTMLEditor::GetIID(), (void**)&HTMLEditor)))
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
if (NS_SUCCEEDED(htmlEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
if (NS_SUCCEEDED(HTMLEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement)
|
||||
{
|
||||
nsAutoString TagName;
|
||||
selectedElement->GetTagName(TagName);
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString TagName;
|
||||
selectedElement->GetTagName(TagName);
|
||||
TagName.ToLowerCase();
|
||||
|
||||
#if DEBUG_cmanske
|
||||
char szTagName[64];
|
||||
TagName.ToCString(szTagName, 64);
|
||||
printf("Single Selected element found: %s\n", szTagName);
|
||||
char szTagName[64];
|
||||
TagName.ToCString(szTagName, 64);
|
||||
printf("Single Selected element found: %s\n", szTagName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1035,7 +1017,7 @@ nsresult
|
|||
nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
{
|
||||
nsString composedText;
|
||||
nsresult result;
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIPrivateTextEvent> textEvent;
|
||||
nsIPrivateTextRangeList *textRangeList;
|
||||
nsTextEventReply *textEventReply;
|
||||
|
@ -1050,7 +1032,9 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
|||
textEvent->GetInputRange(&textRangeList);
|
||||
textEvent->GetEventReply(&textEventReply);
|
||||
textRangeList->AddRef();
|
||||
result = mEditor->SetCompositionString(composedText,textRangeList,textEventReply);
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor, &result);
|
||||
if (imeEditor)
|
||||
result = imeEditor->SetCompositionString(composedText,textRangeList,textEventReply);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1205,9 +1189,12 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
|
|||
trans->GetAnyTransferData(&textMime, (void **)&str, &len);
|
||||
|
||||
// If the string was not empty then paste it in
|
||||
if (str) {
|
||||
if (str)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
stuffToPaste.SetString(str, len);
|
||||
mEditor->InsertText(stuffToPaste);
|
||||
if (htmlEditor)
|
||||
htmlEditor->InsertText(stuffToPaste);
|
||||
dragSession->SetCanDrop(PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1256,16 @@ nsTextEditorCompositionListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsTextEditorCompositionListener::SetEditor(nsIEditor *aEditor)
|
||||
{
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(aEditor);
|
||||
if (!imeEditor) return; // should return an error here!
|
||||
|
||||
// note that we don't hold an extra reference here.
|
||||
mEditor = imeEditor;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorCompositionListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
|
@ -1291,7 +1288,7 @@ nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionE
|
|||
|
||||
nsresult
|
||||
NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorKeyListener* it = new nsTextEditorKeyListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1307,7 +1304,7 @@ NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
nsresult
|
||||
NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorMouseListener* it = new nsTextEditorMouseListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1321,7 +1318,7 @@ NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
|
||||
nsresult
|
||||
NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor* aEditor)
|
||||
NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
|
||||
{
|
||||
nsTextEditorTextListener* it = new nsTextEditorTextListener();
|
||||
if (nsnull==it) {
|
||||
|
@ -1337,7 +1334,7 @@ NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor
|
|||
|
||||
nsresult
|
||||
NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorDragListener* it = new nsTextEditorDragListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1350,7 +1347,7 @@ NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
}
|
||||
|
||||
nsresult
|
||||
NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor* aEditor)
|
||||
NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
|
||||
{
|
||||
nsTextEditorCompositionListener* it = new nsTextEditorCompositionListener();
|
||||
if (nsnull==it) {
|
||||
|
@ -1362,7 +1359,7 @@ NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITex
|
|||
|
||||
nsresult
|
||||
NS_NewEditorFocusListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
nsTextEditorFocusListener* it = new nsTextEditorFocusListener();
|
||||
if (nsnull == it) {
|
||||
|
@ -1428,12 +1425,15 @@ nsTextEditorFocusListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
nsresult
|
||||
nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
// turn on selection and caret
|
||||
if (mEditor)
|
||||
{
|
||||
// turn on selection and caret
|
||||
if (mEditor)
|
||||
{
|
||||
PRUint32 flags;
|
||||
mEditor->GetFlags(&flags);
|
||||
if (! (flags & TEXT_EDITOR_FLAG_DISABLED))
|
||||
if (! (flags & nsIHTMLEditor::eEditorDisabledMask))
|
||||
{ // only enable caret and selection if the editor is not disabled
|
||||
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
|
||||
if (editor)
|
||||
|
@ -1442,7 +1442,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
|||
editor->GetPresShell(getter_AddRefs(ps));
|
||||
if (ps)
|
||||
{
|
||||
if (! (flags & TEXT_EDITOR_FLAG_READONLY))
|
||||
if (! (flags & nsIHTMLEditor::eEditorReadonlyMask))
|
||||
{ // only enable caret if the editor is not readonly
|
||||
ps->SetCaretEnabled(PR_TRUE);
|
||||
}
|
||||
|
@ -1474,6 +1474,8 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#ifndef editorInterfaces_h__
|
||||
#define editorInterfaces_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
|
@ -26,8 +29,9 @@
|
|||
#include "nsIDOMDragListener.h"
|
||||
#include "nsIDOMCompositionListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
||||
/** The nsTextEditorKeyListener public nsIDOMKeyListener
|
||||
* This class will delegate events to its editor according to the translation
|
||||
|
@ -45,7 +49,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -63,7 +67,7 @@ protected:
|
|||
virtual nsresult ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aProcessed);
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,7 +86,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -94,11 +98,14 @@ public:
|
|||
/*END implementations of textevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
PRBool mCommitText;
|
||||
PRBool mInTransaction;
|
||||
};
|
||||
|
||||
|
||||
class nsIEditorIMESupport;
|
||||
|
||||
class nsTextEditorCompositionListener : public nsIDOMCompositionListener
|
||||
{
|
||||
public:
|
||||
|
@ -112,7 +119,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor);
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -125,7 +132,7 @@ public:
|
|||
/*END implementations of textevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditorIMESupport* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
@ -144,7 +151,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -161,7 +168,7 @@ public:
|
|||
/*END implementations of mouseevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
|
||||
};
|
||||
|
||||
|
@ -181,7 +188,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -196,7 +203,7 @@ public:
|
|||
/*END implementations of dragevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor;
|
||||
nsIEditor* mEditor;
|
||||
|
||||
};
|
||||
|
||||
|
@ -215,7 +222,7 @@ public:
|
|||
/** SetEditor gives an address to the editor that will be accessed
|
||||
* @param aEditor the editor this listener calls for editing operations
|
||||
*/
|
||||
void SetEditor(nsITextEditor *aEditor){mEditor = aEditor;}
|
||||
void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -228,34 +235,34 @@ public:
|
|||
/*END implementations of focus event handler interface*/
|
||||
|
||||
protected:
|
||||
nsITextEditor* mEditor; // weak reference
|
||||
nsIEditor* mEditor; // weak reference
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** factory for the editor key listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor mouse listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor text listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor drag listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor composition listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
/** factory for the editor composition listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
extern nsresult NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
|
||||
|
||||
#endif //editorInterfaces_h__
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
*/
|
||||
|
||||
#include "nsTextEditRules.h"
|
||||
#include "nsTextEditor.h"
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "PlaceholderTxn.h"
|
||||
#include "InsertTextTxn.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -37,7 +38,7 @@
|
|||
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
||||
|
||||
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
||||
if (mFlags & TEXT_EDITOR_FLAG_READONLY || mFlags & TEXT_EDITOR_FLAG_DISABLED) \
|
||||
if ((mFlags & nsIHTMLEditor::eEditorReadonlyMask) || (mFlags & nsIHTMLEditor::eEditorDisabledMask)) \
|
||||
{ \
|
||||
*aCancel = PR_TRUE; \
|
||||
return NS_OK; \
|
||||
|
@ -47,10 +48,10 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
|
|||
* Constructor/Destructor
|
||||
********************************************************/
|
||||
|
||||
nsTextEditRules::nsTextEditRules()
|
||||
nsTextEditRules::nsTextEditRules(PRUint32 aFlags)
|
||||
: mEditor(nsnull)
|
||||
, mFlags(aFlags)
|
||||
{
|
||||
mEditor = nsnull;
|
||||
mFlags=0;
|
||||
}
|
||||
|
||||
nsTextEditRules::~nsTextEditRules()
|
||||
|
@ -64,10 +65,11 @@ nsTextEditRules::~nsTextEditRules()
|
|||
********************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::Init(nsIEditor *aEditor)
|
||||
nsTextEditRules::Init(nsHTMLEditor *aEditor)
|
||||
{
|
||||
if (!aEditor) { return NS_ERROR_NULL_POINTER; }
|
||||
mEditor = (nsTextEditor*)aEditor; // we hold a non-refcounted reference back to our editor
|
||||
|
||||
mEditor = aEditor; // we hold a non-refcounted reference back to our editor
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
mEditor->GetSelection(getter_AddRefs(selection));
|
||||
NS_ASSERTION(selection, "editor cannot get selection");
|
||||
|
@ -92,19 +94,19 @@ nsTextEditRules::SetFlags(PRUint32 aFlags)
|
|||
// a style attribute on it, don't know why.
|
||||
// SetFlags() is really meant to only be called once
|
||||
// and at editor init time.
|
||||
if (aFlags & TEXT_EDITOR_FLAG_PLAINTEXT)
|
||||
if (aFlags & nsIHTMLEditor::eEditorPlaintextMask)
|
||||
{
|
||||
if (!(mFlags & TEXT_EDITOR_FLAG_PLAINTEXT))
|
||||
if (!(mFlags & nsIHTMLEditor::eEditorPlaintextMask))
|
||||
{
|
||||
// we are converting TO a plaintext editor
|
||||
// put a "white-space: pre" style on the body
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
nsresult res = mEditor->GetBodyElement(getter_AddRefs(bodyElement));
|
||||
if (NS_SUCCEEDED(res) && bodyElement)
|
||||
{
|
||||
// not going through the editor to do this.
|
||||
bodyElement->SetAttribute("style", "white-space: pre");
|
||||
}
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
nsresult res = mEditor->GetBodyElement(getter_AddRefs(bodyElement));
|
||||
if (NS_SUCCEEDED(res) && bodyElement)
|
||||
{
|
||||
// not going through the editor to do this.
|
||||
bodyElement->SetAttribute("style", "white-space: pre");
|
||||
}
|
||||
}
|
||||
}
|
||||
mFlags = aFlags;
|
||||
|
@ -194,7 +196,9 @@ nsTextEditRules::DidDoAction(nsIDOMSelection *aSelection,
|
|||
nsresult
|
||||
nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
if (!aSelection || !aCancel)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
CANCEL_OPERATION_IF_READONLY_OR_DISABLED
|
||||
|
||||
// initialize out param
|
||||
|
@ -223,7 +227,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
|
|||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
CANCEL_OPERATION_IF_READONLY_OR_DISABLED
|
||||
if (mFlags & TEXT_EDITOR_FLAG_SINGLELINE) {
|
||||
if (mFlags & nsIHTMLEditor::eEditorSingleLineMask) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -256,7 +260,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
nsString inString = *aInString; // we might want to mutate the input
|
||||
// before setting the output, do that in a local var
|
||||
|
||||
if ((-1 != aMaxLength) && (mFlags&TEXT_EDITOR_FLAG_PLAINTEXT))
|
||||
if ((-1 != aMaxLength) && (mFlags & nsIHTMLEditor::eEditorPlaintextMask))
|
||||
{
|
||||
// Get the current text length.
|
||||
// Get the length of inString.
|
||||
|
@ -278,14 +282,14 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
if (selectionLength<0) { selectionLength *= (-1); }
|
||||
PRInt32 resultingDocLength = docLength - selectionLength;
|
||||
if (resultingDocLength >= aMaxLength)
|
||||
{
|
||||
*aOutString = "";
|
||||
*aCancel = PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 inCount = inString.Length();
|
||||
{
|
||||
*aOutString = "";
|
||||
*aCancel = PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 inCount = inString.Length();
|
||||
if ((inCount+resultingDocLength) > aMaxLength)
|
||||
{
|
||||
inString.Truncate(aMaxLength-resultingDocLength);
|
||||
|
@ -298,7 +302,7 @@ nsTextEditRules::WillInsertText(nsIDOMSelection *aSelection,
|
|||
// initialize out params
|
||||
*aCancel = PR_FALSE;
|
||||
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
// manage the password buffer
|
||||
PRInt32 start, end;
|
||||
|
@ -589,7 +593,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
|
|||
result = mEditor->CreateNode(tag, aParentNode, 0, getter_AddRefs(newStyleNode));
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
result = mEditor->CreateNode(nsIEditor::GetTextNodeTag(), newStyleNode, 0, getter_AddRefs(newTextNode));
|
||||
result = mEditor->CreateNode(nsEditor::GetTextNodeTag(), newStyleNode, 0, getter_AddRefs(newTextNode));
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
if (aSelection) {
|
||||
|
@ -606,7 +610,7 @@ nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCance
|
|||
nsresult result = NS_OK;
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
if (TEXT_EDITOR_FLAG_PLAINTEXT & mFlags) {
|
||||
if (nsIHTMLEditor::eEditorPlaintextMask & mFlags) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
|
@ -624,7 +628,7 @@ nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCa
|
|||
nsresult result = NS_OK;
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
if (TEXT_EDITOR_FLAG_PLAINTEXT & mFlags) {
|
||||
if (nsIHTMLEditor::eEditorPlaintextMask & mFlags) {
|
||||
*aCancel = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
|
@ -638,7 +642,7 @@ nsTextEditRules::DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aRe
|
|||
|
||||
nsresult
|
||||
nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
PRBool *aCancel)
|
||||
{
|
||||
if (!aSelection || !aCancel) { return NS_ERROR_NULL_POINTER; }
|
||||
|
@ -652,17 +656,17 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
|||
*aCancel = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
// manage the password buffer
|
||||
PRInt32 start, end;
|
||||
mEditor->GetTextSelectionOffsets(aSelection, start, end);
|
||||
if (end==start)
|
||||
{ // collapsed selection
|
||||
if (nsIEditor::eDeleteLeft==aCollapsedAction && 0<start) { // del back
|
||||
if (nsIEditor::eDeletePrevious==aCollapsedAction && 0<start) { // del back
|
||||
mPasswordText.Cut(start-1, 1);
|
||||
}
|
||||
else if (nsIEditor::eDeleteRight==aCollapsedAction) { // del forward
|
||||
else if (nsIEditor::eDeleteNext==aCollapsedAction) { // del forward
|
||||
mPasswordText.Cut(start, 1);
|
||||
}
|
||||
// otherwise nothing to do for this collapsed selection
|
||||
|
@ -682,7 +686,7 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
|
|||
// if we ended up with consecutive text nodes, merge them
|
||||
nsresult
|
||||
nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
nsresult aResult)
|
||||
{
|
||||
nsresult result = aResult; // if aResult is an error, we just return it
|
||||
|
@ -869,7 +873,7 @@ nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection,
|
|||
// initialize out param
|
||||
*aCancel = PR_FALSE;
|
||||
|
||||
if (mFlags&TEXT_EDITOR_FLAG_PASSWORD)
|
||||
if (mFlags & nsIHTMLEditor::eEditorPasswordMask)
|
||||
{
|
||||
*aOutString = mPasswordText;
|
||||
*aCancel = PR_TRUE;
|
||||
|
@ -927,7 +931,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection)
|
|||
if ((NS_SUCCEEDED(result)) && mBogusNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>newTNode;
|
||||
result = mEditor->CreateNode(nsIEditor::GetTextNodeTag(), mBogusNode, 0,
|
||||
result = mEditor->CreateNode(nsEditor::GetTextNodeTag(), mBogusNode, 0,
|
||||
getter_AddRefs(newTNode));
|
||||
if ((NS_SUCCEEDED(result)) && newTNode)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
#ifndef nsTextEditRules_h__
|
||||
#define nsTextEditRules_h__
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsEditRules.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
#include "nsEditRules.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
class PlaceholderTxn;
|
||||
|
@ -43,11 +45,11 @@ class nsTextEditRules : public nsEditRules
|
|||
{
|
||||
public:
|
||||
|
||||
nsTextEditRules();
|
||||
virtual ~nsTextEditRules();
|
||||
nsTextEditRules(PRUint32 aFlags);
|
||||
virtual ~nsTextEditRules();
|
||||
|
||||
// nsEditRules methods
|
||||
NS_IMETHOD Init(nsIEditor *aEditor);
|
||||
NS_IMETHOD Init(nsHTMLEditor *aEditor);
|
||||
NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel);
|
||||
NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
|
@ -96,10 +98,10 @@ protected:
|
|||
nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult);
|
||||
|
||||
nsresult WillDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
PRBool *aCancel);
|
||||
nsresult DidDeleteSelection(nsIDOMSelection *aSelection,
|
||||
nsIEditor::ECollapsedSelectionAction aCollapsedAction,
|
||||
nsIEditor::ESelectionCollapseDirection aCollapsedAction,
|
||||
nsresult aResult);
|
||||
|
||||
nsresult WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel);
|
||||
|
@ -154,7 +156,7 @@ protected:
|
|||
nsresult PinSelectionInPRE(nsIDOMSelection *aSelection);
|
||||
|
||||
// data
|
||||
nsTextEditor *mEditor; // note that we do not refcount the editor
|
||||
nsHTMLEditor *mEditor; // note that we do not refcount the editor
|
||||
nsString mPasswordText; // a buffer we use to store the real value of password editors
|
||||
nsCOMPtr<nsIDOMNode> mBogusNode; // magic node acts as placeholder in empty doc
|
||||
PRUint32 mFlags;
|
||||
|
@ -173,7 +175,7 @@ class nsTextRulesInfo : public nsRulesInfo
|
|||
outString(0),
|
||||
typeInState(),
|
||||
maxLength(-1),
|
||||
collapsedAction(nsIEditor::eDeleteRight)
|
||||
collapsedAction(nsIEditor::eDeleteNext)
|
||||
{};
|
||||
|
||||
virtual ~nsTextRulesInfo() {};
|
||||
|
@ -186,7 +188,7 @@ class nsTextRulesInfo : public nsRulesInfo
|
|||
PRInt32 maxLength;
|
||||
|
||||
// kDeleteSelection
|
||||
nsIEditor::ECollapsedSelectionAction collapsedAction;
|
||||
nsIEditor::ESelectionCollapseDirection collapsedAction;
|
||||
|
||||
// kMakeList
|
||||
PRBool bOrdered;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIHighLevelHTMLEditor.h"
|
||||
#include "nsTextServicesDocument.h"
|
||||
|
||||
#define LOCK_DOC(doc)
|
||||
|
@ -1849,7 +1850,7 @@ nsTextServicesDocument::DeleteSelection()
|
|||
|
||||
// Now delete the actual content!
|
||||
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeletePrevious);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
|
@ -1953,7 +1954,9 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
|||
return result;
|
||||
}
|
||||
|
||||
result = mEditor->InsertText(*aText);
|
||||
nsCOMPtr<nsIHighLevelHTMLEditor> htmlEditor = do_QueryInterface(mEditor, &result);
|
||||
if (htmlEditor)
|
||||
result = htmlEditor->InsertText(*aText);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
|
|
Двоичные данные
editor/macbuild/editor.mcp
Двоичные данные
editor/macbuild/editor.mcp
Двоичный файл не отображается.
|
@ -17,9 +17,13 @@
|
|||
#
|
||||
|
||||
nsIEditor.h
|
||||
nsITextEditor.h
|
||||
nsEditorCID.h
|
||||
nsIHTMLEditor.h
|
||||
nsIEditRules.h
|
||||
# nsIEditRules.h
|
||||
nsIEditActionListener.h
|
||||
nsICiter.h
|
||||
nsIEditorIMESupport.h
|
||||
nsIEditorLogging.h
|
||||
nsIEditorMailSupport.h
|
||||
nsIEditorStyleSheets.h
|
||||
nsIHTMLEditor.h
|
||||
nsITableEditor.h
|
||||
|
|
|
@ -22,14 +22,17 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXPORTS = \
|
||||
nsIEditActionListener.h \
|
||||
nsIEditor.h \
|
||||
nsIHTMLEditor.h \
|
||||
nsITextEditor.h \
|
||||
nsIEditRules.h \
|
||||
nsEditorCID.h \
|
||||
nsICiter.h \
|
||||
EXPORTS = \
|
||||
nsIEditActionListener.h \
|
||||
nsIEditor.h \
|
||||
nsEditorCID.h \
|
||||
nsICiter.h \
|
||||
nsIEditorIMESupport.h \
|
||||
nsIEditorLogging.h \
|
||||
nsIEditorMailSupport.h \
|
||||
nsIEditorStyleSheets.h \
|
||||
nsIHTMLEditor.h \
|
||||
nsITableEditor.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
DEPTH=..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
EXPORTS = \
|
||||
nsIEditActionListener.h \
|
||||
nsIEditor.h \
|
||||
nsITextEditor.h \
|
||||
nsIHTMLEditor.h \
|
||||
nsIEditRules.h \
|
||||
nsEditorCID.h \
|
||||
nsICiter.h \
|
||||
EXPORTS = \
|
||||
nsIEditActionListener.h \
|
||||
nsIEditor.h \
|
||||
nsEditorCID.h \
|
||||
nsICiter.h \
|
||||
nsIEditorIMESupport.h \
|
||||
nsIEditorLogging.h \
|
||||
nsIEditorMailSupport.h \
|
||||
nsIEditorStyleSheets.h \
|
||||
nsIHTMLEditor.h \
|
||||
nsITableEditor.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = editor
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
0xd3de3431, 0x8a75, 0x11d2, \
|
||||
{ 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
|
||||
|
||||
#define NS_TEXTEDITOR_CID \
|
||||
{/* {bc37c640-c144-11d2-8f4c-006008159b0c}*/ \
|
||||
0xbc37c640, 0xc144, 0x11d2, \
|
||||
{ 0x8f, 0x4c, 0x0, 0x60, 0x08, 0x15, 0x9b, 0x0c } }
|
||||
|
||||
#define NS_HTMLEDITOR_CID \
|
||||
{/* {ed0244e0-c144-11d2-8f4c-006008159b0c}*/ \
|
||||
0xed0244e0, 0xc144, 0x11d2, \
|
||||
|
|
|
@ -21,65 +21,38 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsITransaction;
|
||||
class nsIEditActionListener;
|
||||
class nsIFileSpec;
|
||||
class nsIPrivateTextRangeList;
|
||||
class nsICSSStyleSheet;
|
||||
class nsIOutputStream;
|
||||
class nsIDocumentStateListener;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMSelection;
|
||||
class nsIPresShell;
|
||||
class nsString;
|
||||
struct nsTextEventReply;
|
||||
/*
|
||||
Editor interface to outside world
|
||||
*/
|
||||
|
||||
#define NS_IEDITOR_IID \
|
||||
{/* A3C5EE71-742E-11d2-8F2C-006008310194*/ \
|
||||
0xa3c5ee71, 0x742e, 0x11d2, \
|
||||
{0x8f, 0x2c, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94} }
|
||||
|
||||
#define NS_IEDITORFACTORY_IID \
|
||||
{ /* {E2F4C7F1-864A-11d2-8F38-006008310194}*/ \
|
||||
0xe2f4c7f1, 0x864a, 0x11d2, \
|
||||
{ 0x8f, 0x38, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
|
||||
|
||||
#define NS_ITEXTEDITORFACTORY_IID \
|
||||
{ /* {4a1f5ce0-c1f9-11d2-8f4c-006008159b0c}*/ \
|
||||
0x4a1f5ce0, 0xc1f9, 0x11d2, \
|
||||
{ 0x8f, 0x4c, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc } }
|
||||
class nsString;
|
||||
|
||||
#define NS_IHTMLEDITORFACTORY_IID \
|
||||
{ /* BD62F312-CB8A-11d2-983A-00805F8AA8B8 */ \
|
||||
0xbd62f312, 0xcb8a, 0x11d2, \
|
||||
{ 0x98, 0x3a, 0x0, 0x80, 0x5f, 0x8a, 0xa8, 0xb8 } }
|
||||
class nsIPresShell;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMSelection;
|
||||
class nsITransaction;
|
||||
class nsIOutputStream;
|
||||
class nsIEditActionListener;
|
||||
class nsIDocumentStateListener;
|
||||
|
||||
|
||||
/**
|
||||
* A generic editor interface.
|
||||
* <P>
|
||||
* nsIEditor is the base interface used by applications to communicate with the editor.
|
||||
* It makes no assumptions about the kind of content it is editing,
|
||||
* other than the content being a DOM tree.
|
||||
*/
|
||||
class nsIEditor : public nsISupports{
|
||||
class nsIEditor : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IEDITOR_IID; return iid; }
|
||||
|
||||
|
||||
/* An enum used to describe how to collpase a non-collapsed selection */
|
||||
typedef enum {
|
||||
eDoNothing,
|
||||
eDeleteRight,
|
||||
eDeleteLeft
|
||||
} ECollapsedSelectionAction;
|
||||
eDeleteNext,
|
||||
eDeletePrevious
|
||||
} ESelectionCollapseDirection;
|
||||
|
||||
static nsString& GetTextNodeTag();
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IEDITOR_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Init is to tell the implementation of nsIEditor to begin its services
|
||||
|
@ -88,8 +61,9 @@ public:
|
|||
* once events can tell us from what pres shell they originated,
|
||||
* this will no longer be necessary and the editor will no longer be
|
||||
* linked to a single pres shell.
|
||||
* @param aFlags A bitmask of flags for specifying the behavior of the editor.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell )=0;
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags)=0;
|
||||
|
||||
/**
|
||||
* PostCreate should be called after Init, and is the time that the editor tells
|
||||
|
@ -97,6 +71,12 @@ public:
|
|||
*/
|
||||
NS_IMETHOD PostCreate()=0;
|
||||
|
||||
/** return the edit flags for this editor */
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags)=0;
|
||||
|
||||
/** set the edit flags for this editor. May be called at any time. */
|
||||
NS_IMETHOD SetFlags(PRUint32 aFlags)=0;
|
||||
|
||||
/**
|
||||
* return the DOM Document this editor is associated with
|
||||
*
|
||||
|
@ -118,6 +98,137 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection **aSelection)=0;
|
||||
|
||||
/* ------------ Selected content removal -------------- */
|
||||
|
||||
/**
|
||||
* DeleteSelection removes all nodes in the current selection.
|
||||
* @param aDir if eLTR, delete to the right (for example, the DEL key)
|
||||
* if eRTL, delete to the left (for example, the BACKSPACE key)
|
||||
*/
|
||||
NS_IMETHOD DeleteSelection(ESelectionCollapseDirection aAction)=0;
|
||||
|
||||
|
||||
/* ------------ Document info methods -------------- */
|
||||
|
||||
/** Respond to the menu 'Save' command; this may put up save UI if the document
|
||||
* hasn't been saved yet.
|
||||
*/
|
||||
NS_IMETHOD Save()=0;
|
||||
|
||||
/** Respond to the menu 'Save As' command; this will put up save UI
|
||||
* @param aSavingCopy true if we are saving off a copy of the document
|
||||
* without changing the disk file associated with the doc.
|
||||
* This would correspond to a 'Save Copy As' menu command.
|
||||
*/
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy)=0;
|
||||
|
||||
/** Returns true if the document is modifed and needs saving */
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified)=0;
|
||||
|
||||
|
||||
|
||||
/* ------------ Transaction methods -------------- */
|
||||
|
||||
/** Do() fires a transaction. It is provided here so clients can create their own transactions.
|
||||
* If a transaction manager is present, it is used.
|
||||
* Otherwise, the transaction is just executed directly.
|
||||
*
|
||||
* @param aTxn the transaction to execute
|
||||
*/
|
||||
NS_IMETHOD Do(nsITransaction *aTxn)=0;
|
||||
|
||||
|
||||
/** turn the undo system on or off
|
||||
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
|
||||
* if PR_FALSE the undo system is turned off if it was previously on
|
||||
* @return if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly
|
||||
* if aEnable is PR_FALSE, returns NS_OK.
|
||||
*/
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable)=0;
|
||||
|
||||
/** Undo reverses the effects of the last Do operation, if Undo is enabled in the editor.
|
||||
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
||||
* If a transaction manager is present, it is told to undo and the result of
|
||||
* that undo is returned.
|
||||
* Otherwise, the Undo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Undo(PRUint32 aCount)=0;
|
||||
|
||||
/** returns state information about the undo system.
|
||||
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
|
||||
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
|
||||
*/
|
||||
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;
|
||||
|
||||
/** Redo reverses the effects of the last Undo operation
|
||||
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
||||
* If a transaction manager is present, it is told to redo and the result of the previously undone
|
||||
* transaction is reapplied to the document.
|
||||
* If no transaction is available for Redo, or if the document has no transaction manager,
|
||||
* the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Redo(PRUint32 aCount)=0;
|
||||
|
||||
/** returns state information about the redo system.
|
||||
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
|
||||
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
|
||||
*/
|
||||
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
|
||||
|
||||
/** BeginTransaction is a signal from the caller to the editor that the caller will execute multiple updates
|
||||
* to the content tree that should be treated as a single logical operation,
|
||||
* in the most efficient way possible.<br>
|
||||
* All transactions executed between a call to BeginTransaction and EndTransaction will be undoable as
|
||||
* an atomic action.<br>
|
||||
* EndTransaction must be called after BeginTransaction.<br>
|
||||
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginUpdate.
|
||||
*/
|
||||
NS_IMETHOD BeginTransaction()=0;
|
||||
|
||||
/** EndTransaction is a signal to the editor that the caller is finished updating the content model.<br>
|
||||
* BeginUpdate must be called before EndTransaction is called.<br>
|
||||
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
|
||||
*/
|
||||
NS_IMETHOD EndTransaction()=0;
|
||||
|
||||
|
||||
/* ------------ Clipboard methods -------------- */
|
||||
|
||||
/** cut the currently selected text, putting it into the OS clipboard
|
||||
* What if no text is selected?
|
||||
* What about mixed selections?
|
||||
* What are the clipboard formats?
|
||||
*/
|
||||
NS_IMETHOD Cut()=0;
|
||||
|
||||
/** copy the currently selected text, putting it into the OS clipboard
|
||||
* What if no text is selected?
|
||||
* What about mixed selections?
|
||||
* What are the clipboard formats?
|
||||
*/
|
||||
NS_IMETHOD Copy()=0;
|
||||
|
||||
/** paste the text in the OS clipboard at the cursor position, replacing
|
||||
* the selected text (if any)
|
||||
*/
|
||||
NS_IMETHOD Paste()=0;
|
||||
|
||||
/* ------------ Selection methods -------------- */
|
||||
|
||||
/** sets the document selection to the entire contents of the document */
|
||||
NS_IMETHOD SelectAll()=0;
|
||||
|
||||
/** sets the document selection to the beginning of the document */
|
||||
NS_IMETHOD BeginningOfDocument()=0;
|
||||
|
||||
/** sets the document selection to the end of the document */
|
||||
NS_IMETHOD EndOfDocument()=0;
|
||||
|
||||
|
||||
/* ------------ Node manipulation methods -------------- */
|
||||
|
||||
/**
|
||||
* SetAttribute() sets the attribute of aElement.
|
||||
* No checking is done to see if aAttribute is a legal attribute of the node,
|
||||
|
@ -181,83 +292,6 @@ public:
|
|||
PRInt32 aPosition)=0;
|
||||
|
||||
|
||||
/**
|
||||
* InsertText() Inserts a string at the current location, given by the selection.
|
||||
* If the selection is not collapsed, the selection is deleted and the insertion
|
||||
* takes place at the resulting collapsed selection.
|
||||
*
|
||||
* NOTE: what happens if the string contains a CR?
|
||||
*
|
||||
* @param aString the string to be inserted
|
||||
*/
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
|
||||
|
||||
/**
|
||||
* BeginComposition() Handles the start of inline input composition.
|
||||
*/
|
||||
|
||||
NS_IMETHOD BeginComposition(void) = 0;
|
||||
|
||||
/**
|
||||
* SetCompositionString() Sets the inline input composition string.
|
||||
* BeginComposition must be called prior to this.
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList, nsTextEventReply* aReply) = 0;
|
||||
|
||||
/**
|
||||
* BeginComposition() Handles the end of inline input composition.
|
||||
*/
|
||||
|
||||
NS_IMETHOD EndComposition(void) = 0;
|
||||
|
||||
/**
|
||||
* Output methods flags:
|
||||
*/
|
||||
enum {
|
||||
EditorOutputSelectionOnly = 1,
|
||||
EditorOutputFormatted = 2,
|
||||
EditorOutputNoDoctype = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Output methods:
|
||||
* aFormatType is a mime type, like text/plain.
|
||||
*/
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags) = 0;
|
||||
/**
|
||||
* And a debug method -- show us what the tree looks like right now
|
||||
*/
|
||||
NS_IMETHOD DumpContentTree() = 0;
|
||||
|
||||
/**
|
||||
* DeleteNode removes aChild from aParent.
|
||||
* @param aChild The node to delete
|
||||
*/
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild)=0;
|
||||
|
||||
/**
|
||||
* DeleteSelection removes all nodes in the current selection.
|
||||
* @param aAction: direction to delete if selection is collapsed:
|
||||
* if eDeleteRight, delete to the right (for example, the DEL key)
|
||||
* if DeleteLeft, delete to the left (for example, the BACKSPACE key)
|
||||
*/
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction)=0;
|
||||
|
||||
/**
|
||||
* DeleteSelectionAndCreateNode combines DeleteSelection and CreateNode
|
||||
* It deletes only if there is something selected (doesn't do DEL, BACKSPACE action)
|
||||
* @param aTag The type of object to create
|
||||
* @param aNewNode [OUT] The node created. Caller must release aNewNode.
|
||||
*/
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode)=0;
|
||||
|
||||
/**
|
||||
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||
|
@ -280,153 +314,40 @@ public:
|
|||
NS_IMETHOD JoinNodes(nsIDOMNode *aLeftNode,
|
||||
nsIDOMNode *aRightNode,
|
||||
nsIDOMNode *aParent)=0;
|
||||
|
||||
|
||||
/**
|
||||
* DeleteNode removes aChild from aParent.
|
||||
* @param aChild The node to delete
|
||||
*/
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode * aChild)=0;
|
||||
|
||||
/* ------------ Output methods -------------- */
|
||||
|
||||
/**
|
||||
* Output methods flags:
|
||||
*/
|
||||
enum {
|
||||
EditorOutputSelectionOnly = 1,
|
||||
EditorOutputFormatted = 2,
|
||||
EditorOutputNoDoctype = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Insert a break into the content model.<br>
|
||||
* The interpretation of a break is up to the rule system:
|
||||
* it may enter a character, split a node in the tree, etc.
|
||||
* Output methods:
|
||||
* aFormatType is a mime type, like text/plain.
|
||||
*/
|
||||
NS_IMETHOD InsertBreak()=0;
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
/** turn the undo system on or off
|
||||
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
|
||||
* if PR_FALSE the undo system is turned off if it was previously on
|
||||
* @return if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly
|
||||
* if aEnable is PR_FALSE, returns NS_OK.
|
||||
*/
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable)=0;
|
||||
|
||||
/** Do() fires a transaction. It is provided here so clients can create their own transactions.
|
||||
* If a transaction manager is present, it is used.
|
||||
* Otherwise, the transaction is just executed directly.
|
||||
*
|
||||
* @param aTxn the transaction to execute
|
||||
*/
|
||||
NS_IMETHOD Do(nsITransaction *aTxn)=0;
|
||||
|
||||
/** Undo reverses the effects of the last Do operation, if Undo is enabled in the editor.
|
||||
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
||||
* If a transaction manager is present, it is told to undo and the result of
|
||||
* that undo is returned.
|
||||
* Otherwise, the Undo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Undo(PRUint32 aCount)=0;
|
||||
|
||||
/** returns state information about the undo system.
|
||||
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
|
||||
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
|
||||
*/
|
||||
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;
|
||||
|
||||
/** Redo reverses the effects of the last Undo operation
|
||||
* It is provided here so clients need no knowledge of whether the editor has a transaction manager or not.
|
||||
* If a transaction manager is present, it is told to redo and the result of the previously undone
|
||||
* transaction is reapplied to the document.
|
||||
* If no transaction is available for Redo, or if the document has no transaction manager,
|
||||
* the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Redo(PRUint32 aCount)=0;
|
||||
|
||||
/** returns state information about the redo system.
|
||||
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
|
||||
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
|
||||
*/
|
||||
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
|
||||
|
||||
/** BeginTransaction is a signal from the caller to the editor that the caller will execute multiple updates
|
||||
* to the content tree that should be treated as a single logical operation,
|
||||
* in the most efficient way possible.<br>
|
||||
* All transactions executed between a call to BeginTransaction and EndTransaction will be undoable as
|
||||
* an atomic action.<br>
|
||||
* EndTransaction must be called after BeginTransaction.<br>
|
||||
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginUpdate.
|
||||
*/
|
||||
NS_IMETHOD BeginTransaction()=0;
|
||||
|
||||
/** EndTransaction is a signal to the editor that the caller is finished updating the content model.<br>
|
||||
* BeginUpdate must be called before EndTransaction is called.<br>
|
||||
* Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
|
||||
*/
|
||||
NS_IMETHOD EndTransaction()=0;
|
||||
|
||||
/** Get the layout's frame object associated with the node
|
||||
* Needed when we must get geometric layout info, such as what column a table cell is in.
|
||||
* @param aNode The DOM node we need the frame for
|
||||
* @param aLayoutObject The pointer where the resulting object is placed
|
||||
*/
|
||||
NS_IMETHOD GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject)=0;
|
||||
|
||||
/** scroll the viewport so the selection is in view.
|
||||
* @param aScrollToBegin PR_TRUE if the beginning of the selection is to be scrolled into view.
|
||||
* PR_FALSE if the end of the selection is to be scrolled into view
|
||||
*/
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin)=0;
|
||||
|
||||
/** sets the document selection to the entire contents of the document */
|
||||
NS_IMETHOD SelectAll()=0;
|
||||
|
||||
/** sets the document selection to the beginning of the document */
|
||||
NS_IMETHOD BeginningOfDocument()=0;
|
||||
|
||||
/** sets the document selection to the end of the document */
|
||||
NS_IMETHOD EndOfDocument()=0;
|
||||
|
||||
/** cut the currently selected text, putting it into the OS clipboard
|
||||
* What if no text is selected?
|
||||
* What about mixed selections?
|
||||
* What are the clipboard formats?
|
||||
*/
|
||||
NS_IMETHOD Cut()=0;
|
||||
|
||||
/** copy the currently selected text, putting it into the OS clipboard
|
||||
* What if no text is selected?
|
||||
* What about mixed selections?
|
||||
* What are the clipboard formats?
|
||||
*/
|
||||
NS_IMETHOD Copy()=0;
|
||||
|
||||
/** paste the text in the OS clipboard at the cursor position, replacing
|
||||
* the selected text (if any)
|
||||
*/
|
||||
NS_IMETHOD Paste()=0;
|
||||
|
||||
/** paste the text in the OS clipboard at the cursor position,
|
||||
* replacing the selected text (if any).
|
||||
* Method of quotation will depend on what type of editor we are,
|
||||
* and also on preference settings.
|
||||
* @param aCitation The "mid" URL of the source message
|
||||
*/
|
||||
NS_IMETHOD PasteAsQuotation()=0;
|
||||
|
||||
/** insert a string as quoted text,
|
||||
* replacing the selected text (if any).
|
||||
* Method of quotation will depend on what type of editor we are,
|
||||
* and also on preference settings.
|
||||
* @param aQuotedText The actual text to be quoted
|
||||
* @param aCitation The "mid" URL of the source message
|
||||
*/
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
|
||||
|
||||
/** load and apply the style sheet, specified by aURL, to
|
||||
* the editor's document. This can involve asynchronous
|
||||
* network I/O
|
||||
* @param aURL The style sheet to be loaded and applied.
|
||||
*/
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0;
|
||||
|
||||
/** Add the given Style Sheet to the editor's document
|
||||
* This is always synchronous
|
||||
* @param aSheet The style sheet to be applied.
|
||||
*/
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet)=0;
|
||||
|
||||
/** Remove the given Style Sheet from the editor's document
|
||||
* This is always synchronous
|
||||
* @param aSheet The style sheet to be applied.
|
||||
*/
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet)=0;
|
||||
/* ------------ Various listeners methods -------------- */
|
||||
|
||||
/** add an EditActionListener to the editors list of listeners. */
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener)=0;
|
||||
|
@ -439,22 +360,24 @@ public:
|
|||
|
||||
/** Remove a DocumentStateListener to the editors list of doc state listeners. */
|
||||
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener)=0;
|
||||
|
||||
/** Returns true if the document is modifed and needs saving */
|
||||
NS_IMETHOD GetDocumentModified(PRBool *outDocModified)=0;
|
||||
|
||||
|
||||
|
||||
/* ------------ Debug methods -------------- */
|
||||
|
||||
/**
|
||||
* And a debug method -- show us what the tree looks like right now
|
||||
*/
|
||||
NS_IMETHOD DumpContentTree() = 0;
|
||||
|
||||
/** Dumps a text representation of the content tree to standard out */
|
||||
NS_IMETHOD DebugDumpContent() const =0;
|
||||
|
||||
/* Run unit tests. Noop in optimized builds */
|
||||
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)=0;
|
||||
|
||||
/* Start logging */
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0;
|
||||
|
||||
/* Stop logging */
|
||||
NS_IMETHOD StopLogging()=0;
|
||||
};
|
||||
|
||||
|
||||
#endif //nsIEditor_h__
|
||||
|
||||
|
|
|
@ -16,126 +16,197 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsIHTMLEditor_h__
|
||||
#define nsIHTMLEditor_h__
|
||||
|
||||
#define NS_IHTMLEDITOR_IID \
|
||||
{/*BD62F311-CB8A-11d2-983A-00805F8AA8B8*/ \
|
||||
0xbd62f311, 0xcb8a, 0x11d2, \
|
||||
{ 0x98, 0x3a, 0x0, 0x80, 0x5f, 0x8a, 0xa8, 0xb8 } }
|
||||
|
||||
#define NS_IHTMLEDITOR_IID \
|
||||
{ /* 4805e683-49b9-11d3-9ce4-ed60bd6cb5bc} */ \
|
||||
0x4805e683, 0x49b9, 0x11d3, \
|
||||
{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } }
|
||||
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nscore.h"
|
||||
//#include "nsIDOMDocumentFragment.h"
|
||||
|
||||
class nsIEditorCallback;
|
||||
class nsISupportsArray;
|
||||
class nsString;
|
||||
class nsStringArray;
|
||||
class nsIAtom;
|
||||
class nsIOutputStream;
|
||||
class nsIDOMWindow;
|
||||
class nsIFileSpec;
|
||||
struct nsTextEventReply;
|
||||
|
||||
/**
|
||||
* The HTML editor interface.
|
||||
* <P>
|
||||
* Use to edit text and other HTML objects represented as a DOM tree.
|
||||
*/
|
||||
class nsIHTMLEditor : public nsISupports{
|
||||
class nsIAtom;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMElement;
|
||||
|
||||
|
||||
class nsIHTMLEditor : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITOR_IID; return iid; }
|
||||
|
||||
typedef enum {eSaveFileText = 0, eSaveFileHTML = 1 } ESaveFileType;
|
||||
|
||||
/** Initialize the HTML editor
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc,
|
||||
nsIPresShell *aPresShell)=0;
|
||||
// the bits in an editor behavior mask.
|
||||
enum {
|
||||
eEditorPlaintextBit = 0, // only plain text entry is allowed via events
|
||||
eEditorSingleLineBit, // enter key and CR-LF handled specially
|
||||
eEditorPasswordBit, // text is not entered into content, only a representative character
|
||||
eEditorReadonlyBit, // editing events are disabled. Editor may still accept focus.
|
||||
eEditorDisabledBit, // all events are disabled (like scrolling). Editor will not accept focus.
|
||||
eEditorFilterInputBit // text input is limited to certain character types, use mFilter
|
||||
|
||||
// max 32 bits
|
||||
};
|
||||
|
||||
enum {
|
||||
eEditorPlaintextMask = (1 << eEditorPlaintextBit),
|
||||
eEditorSingleLineMask = (1 << eEditorSingleLineBit),
|
||||
eEditorPasswordMask = (1 << eEditorPasswordBit),
|
||||
eEditorReadonlyMask = (1 << eEditorReadonlyBit),
|
||||
eEditorDisabledMask = (1 << eEditorDisabledBit),
|
||||
eEditorFilterInputMask = (1 << eEditorFilterInputBit)
|
||||
};
|
||||
|
||||
|
||||
/* ------------ Document info methods -------------- */
|
||||
|
||||
// Methods shared with nsITextEditor (see nsITextEditor.h for details)
|
||||
NS_IMETHOD SetTextProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue)=0;
|
||||
NS_IMETHOD GetTextProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aFirst, PRBool &aAll, PRBool &aAny)=0;
|
||||
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat)=0;
|
||||
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat)=0;
|
||||
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute)=0;
|
||||
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction)=0;
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
|
||||
NS_IMETHOD InsertBreak()=0;
|
||||
NS_IMETHOD EnableUndo(PRBool aEnable)=0;
|
||||
NS_IMETHOD Undo(PRUint32 aCount)=0;
|
||||
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;
|
||||
NS_IMETHOD Redo(PRUint32 aCount)=0;
|
||||
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
|
||||
NS_IMETHOD BeginTransaction()=0;
|
||||
NS_IMETHOD EndTransaction()=0;
|
||||
NS_IMETHOD MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
|
||||
NS_IMETHOD SelectAll()=0;
|
||||
NS_IMETHOD BeginningOfDocument()=0;
|
||||
NS_IMETHOD EndOfDocument()=0;
|
||||
NS_IMETHOD ScrollUp(nsIAtom *aIncrement)=0;
|
||||
NS_IMETHOD ScrollDown(nsIAtom *aIncrement)=0;
|
||||
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin)=0;
|
||||
/** get the length of the document in characters */
|
||||
NS_IMETHOD GetDocumentLength(PRInt32 *aCount)=0;
|
||||
|
||||
NS_IMETHOD Save()=0;
|
||||
NS_IMETHOD SaveAs(PRBool aSavingCopy)=0;
|
||||
NS_IMETHOD SetMaxTextLength(PRInt32 aMaxTextLength)=0;
|
||||
NS_IMETHOD GetMaxTextLength(PRInt32& aMaxTextLength)=0;
|
||||
|
||||
NS_IMETHOD Cut()=0;
|
||||
NS_IMETHOD Copy()=0;
|
||||
NS_IMETHOD Paste()=0;
|
||||
NS_IMETHOD PasteAsQuotation()=0;
|
||||
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation)=0;
|
||||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
|
||||
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation)=0;
|
||||
/* ------------ Inline property methods -------------- */
|
||||
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString)=0;
|
||||
|
||||
/**
|
||||
* Output methods:
|
||||
* aFormatType is a mime type, like text/plain.
|
||||
* SetInlineProperty() sets the aggregate properties on the current selection
|
||||
*
|
||||
* @param aProperty the property to set on the selection
|
||||
* @param aAttribute the attribute of the property, if applicable. May be null.
|
||||
* Example: aProperty="font", aAttribute="color"
|
||||
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
|
||||
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
|
||||
*/
|
||||
NS_IMETHOD OutputToString(nsString& aOutputString,
|
||||
const nsString& aFormatType,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsString& aFormatType,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue)=0;
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0;
|
||||
|
||||
// Miscellaneous Methods
|
||||
/** Set the background color of the selected table cell, row, columne, or table,
|
||||
* or the document background if not in a table
|
||||
/**
|
||||
* GetInlineProperty() gets the aggregate properties of the current selection.
|
||||
* All object in the current selection are scanned and their attributes are
|
||||
* represented in a list of Property object.
|
||||
*
|
||||
* @param aProperty the property to get on the selection
|
||||
* @param aAttribute the attribute of the property, if applicable. May be null.
|
||||
* Example: aProperty="font", aAttribute="color"
|
||||
* @param aValue if aAttribute is not null, the value of the attribute. May be null.
|
||||
* Example: aProperty="font", aAttribute="color", aValue="0x00FFFF"
|
||||
* @param aFirst [OUT] PR_TRUE if the first text node in the selection has the property
|
||||
* @param aAny [OUT] PR_TRUE if any of the text nodes in the selection have the property
|
||||
* @param aAll [OUT] PR_TRUE if all of the text nodes in the selection have the property
|
||||
*/
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor)=0;
|
||||
/** Set any BODY element attribute
|
||||
*/
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue)=0;
|
||||
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
|
||||
const nsString *aAttribute,
|
||||
const nsString *aValue,
|
||||
PRBool &aFirst, PRBool &aAny, PRBool &aAll)=0;
|
||||
|
||||
/*
|
||||
NS_IMETHOD CheckSpelling()=0;
|
||||
NS_IMETHOD SpellingLanguage(nsIAtom *aLanguage)=0;
|
||||
*/
|
||||
/* The editor doesn't know anything about specific services like SpellChecking.
|
||||
* Services can be invoked on the content, and these services can use the editor if they choose
|
||||
* to get transactioning/undo/redo.
|
||||
* For things like auto-spellcheck, the App should implement nsIDocumentObserver and
|
||||
* trigger off of ContentChanged notifications.
|
||||
/**
|
||||
* RemoveInlineProperty() deletes the properties from all text in the current selection.
|
||||
* If aProperty is not set on the selection, nothing is done.
|
||||
*
|
||||
* @param aProperty the property to reomve from the selection
|
||||
* @param aAttribute the attribute of the property, if applicable. May be null.
|
||||
* Example: aProperty="font", aAttribute="color"
|
||||
* nsIEditProperty::allAttributes is special. It indicates that
|
||||
* all content-based text properties are to be removed from the selection.
|
||||
*/
|
||||
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute)=0;
|
||||
|
||||
|
||||
/* ------------ HTML content methods -------------- */
|
||||
|
||||
/**
|
||||
* Insert a break into the content model.<br>
|
||||
* The interpretation of a break is up to the rule system:
|
||||
* it may enter a character, split a node in the tree, etc.
|
||||
*/
|
||||
NS_IMETHOD InsertBreak()=0;
|
||||
|
||||
/**
|
||||
* InsertText() Inserts a string at the current location, given by the selection.
|
||||
* If the selection is not collapsed, the selection is deleted and the insertion
|
||||
* takes place at the resulting collapsed selection.
|
||||
*
|
||||
* NOTE: what happens if the string contains a CR?
|
||||
*
|
||||
* @param aString the string to be inserted
|
||||
*/
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
|
||||
|
||||
/**
|
||||
* document me!
|
||||
*/
|
||||
NS_IMETHOD InsertHTML(const nsString &aInputString)=0;
|
||||
|
||||
|
||||
/** Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
* be useful for other elements.
|
||||
*
|
||||
* @param aElement The element to insert
|
||||
* @param aDeleteSelection Delete the selection before inserting
|
||||
* If aDeleteSelection is PR_FALSE, then the element is inserted
|
||||
* after the end of the selection for all element except
|
||||
* Named Anchors, which insert before the selection
|
||||
*/
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* DeleteSelectionAndCreateNode combines DeleteSelection and CreateNode
|
||||
* It deletes only if there is something selected (doesn't do DEL, BACKSPACE action)
|
||||
* @param aTag The type of object to create
|
||||
* @param aNewNode [OUT] The node created. Caller must release aNewNode.
|
||||
*/
|
||||
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode)=0;
|
||||
|
||||
/* ------------ Selection manipulation -------------- */
|
||||
/* Should these be moved to nsIDOMSelection? */
|
||||
|
||||
/** Set the selection at the suppled element
|
||||
*
|
||||
* @param aElement An element in the document
|
||||
*/
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement)=0;
|
||||
|
||||
/** Create a collapsed selection just after aElement
|
||||
*
|
||||
* XXX could we parameterize SelectElement(before/select/after>?
|
||||
*
|
||||
* The selection is set to parent-of-aElement with an
|
||||
* offset 1 greater than aElement's offset
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
* be useful for other elements.
|
||||
*
|
||||
* @param aElement An element in the document
|
||||
*/
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat)=0;
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat)=0;
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParagraphStyle(nsStringArray *aTagList)=0;
|
||||
|
||||
/** Add a block parent node around the selected content.
|
||||
|
@ -167,8 +238,22 @@ public:
|
|||
*/
|
||||
NS_IMETHOD RemoveParent(const nsString &aParentTag)=0;
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertList(const nsString& aListType)=0;
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Indent(const nsString& aIndent)=0;
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Align(const nsString& aAlign)=0;
|
||||
|
||||
/** Return the input node or a parent matching the given aTagName,
|
||||
|
@ -205,6 +290,9 @@ public:
|
|||
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn)=0;
|
||||
|
||||
/** Return a new element with default attribute values
|
||||
*
|
||||
* This does not rely on the selection, and is not sensitive to context.
|
||||
*
|
||||
* Used primarily to supply new element for various insert element dialogs
|
||||
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
||||
* are the only returned elements as of 7/25/99)
|
||||
|
@ -217,23 +305,12 @@ public:
|
|||
* (an "A" tag with the "name" attribute set)
|
||||
*/
|
||||
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn)=0;
|
||||
|
||||
/** Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
* be useful for other elements.
|
||||
*
|
||||
* @param aElement The element to insert
|
||||
* @param aDeleteSelection Delete the selection before inserting
|
||||
* If aDeleteSelection is PR_FALSE, then the element is inserted
|
||||
* after the end of the selection for all element except
|
||||
* Named Anchors, which insert before the selection
|
||||
*/
|
||||
NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)=0;
|
||||
|
||||
/** Save the attributes of a Horizontal Rule in user preferences
|
||||
* These prefs are used when the user inserts a new Horizontal line
|
||||
*
|
||||
* XXX this functionality should move to the editorShell.
|
||||
*
|
||||
* @param aElement An HR element
|
||||
*/
|
||||
NS_IMETHOD SaveHLineSettings(nsIDOMElement* aElement)=0;
|
||||
|
@ -244,133 +321,20 @@ public:
|
|||
* @param aElement An "A" element with a non-empty "href" attribute
|
||||
*/
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)=0;
|
||||
|
||||
/** Set the selection at the suppled element
|
||||
*
|
||||
* @param aElement An element in the document
|
||||
*/
|
||||
NS_IMETHOD SelectElement(nsIDOMElement* aElement)=0;
|
||||
|
||||
/** Create a collapsed selection just after aElement
|
||||
* The selection is set to parent-of-aElement with an
|
||||
* offset 1 greater than aElement's offset
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
* be useful for other elements.
|
||||
*
|
||||
* @param aElement An element in the document
|
||||
*/
|
||||
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement)=0;
|
||||
|
||||
// MHTML helper methods
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList)=0;
|
||||
|
||||
// Table editing Methods
|
||||
/** Insert table methods
|
||||
* Insert relative to the selected cell or the
|
||||
* cell enclosing the selection anchor
|
||||
* The selection is collapsed and is left in the new cell
|
||||
* at the same row,col location as the original anchor cell
|
||||
*
|
||||
* @param aNumber Number of items to insert
|
||||
* @param aAfter If TRUE, insert after the current cell,
|
||||
* else insert before current cell
|
||||
*/
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter)=0;
|
||||
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter)=0;
|
||||
NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter)=0;
|
||||
|
||||
/** Delete table methods
|
||||
* Delete starting at the selected cell or the
|
||||
* cell (or table) enclosing the selection anchor
|
||||
* The selection is collapsed and is left in the
|
||||
* cell at the same row,col location as
|
||||
* the previous selection anchor, if possible,
|
||||
* else in the closest neigboring cell
|
||||
*
|
||||
* @param aNumber Number of items to insert/delete
|
||||
*/
|
||||
NS_IMETHOD DeleteTable()=0;
|
||||
NS_IMETHOD DeleteTableCell(PRInt32 aNumber)=0;
|
||||
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber)=0;
|
||||
NS_IMETHOD DeleteTableRow(PRInt32 aNumber)=0;
|
||||
|
||||
/** Join the contents of the selected cells into one cell,
|
||||
* expanding that cells ROWSPAN and COLSPAN to take up
|
||||
* the same number of cellmap locations as before.
|
||||
* Cells whose contents were moved are deleted.
|
||||
* If there's one cell selected or caret is in one cell,
|
||||
* it is joined with the cell to the right, if it exists
|
||||
*/
|
||||
NS_IMETHOD JoinTableCells()=0;
|
||||
|
||||
/** Scan through all rows and add cells as needed so
|
||||
* all locations in the cellmap are occupied.
|
||||
* Used after inserting single cells or pasting
|
||||
* a collection of cells that extend past the
|
||||
* previous size of the table
|
||||
* If aTable is null, it uses table enclosing the selection anchor
|
||||
*/
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable)=0;
|
||||
|
||||
/** Get the row an column index from the layout's cellmap
|
||||
* If aTable is null, it will try to find enclosing table of selection ancho
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex)=0;
|
||||
|
||||
/** Get the number of rows and columns in a table from the layout's cellmap
|
||||
* If aTable is null, it will try to find enclosing table of selection ancho
|
||||
* Note that all rows in table will not have this many because of
|
||||
* ROWSPAN effects or if table is not "rectangular" (has short rows)
|
||||
*/
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount)=0;
|
||||
|
||||
/** Get a cell element at cellmap grid coordinates
|
||||
* A cell that spans across multiple cellmap locations will
|
||||
* be returned multiple times, once for each location it occupies
|
||||
*
|
||||
* @param aTable A table in the document
|
||||
* @param aRowIndex, aColIndex The 0-based cellmap indexes
|
||||
*
|
||||
* Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND
|
||||
* when a cell is not found at the given indexes,
|
||||
* but this passes the NS_SUCCEEDED() test,
|
||||
* so you can scan for all cells in a row or column
|
||||
* by iterating through the appropriate indexes
|
||||
* until the returned aCell is null
|
||||
*/
|
||||
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell)=0;
|
||||
|
||||
/** Get a cell at cellmap grid coordinates and associated data
|
||||
* A cell that spans across multiple cellmap locations will
|
||||
* be returned multiple times, once for each location it occupies
|
||||
* Examine the returned aStartRowIndex and aStartColIndex to see
|
||||
* if it is in the same layout column or layout row:
|
||||
* A "layout row" is all cells sharing the same top edge
|
||||
* A "layout column" is all cells sharing the same left edge
|
||||
* This is important to determine what to do when inserting or deleting a column or row
|
||||
*
|
||||
* @param aTable A table in the document
|
||||
* @param aRowIndex, aColIndex The 0-based cellmap indexes
|
||||
*
|
||||
* Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND
|
||||
* when a cell is not found at the given indexes (see note for GetCellAt())
|
||||
*/
|
||||
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected)=0;
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetBackgroundColor(const nsString& aColor)=0;
|
||||
|
||||
|
||||
// IME editing Methods
|
||||
NS_IMETHOD BeginComposition(void)=0;
|
||||
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply *aReply)=0;
|
||||
NS_IMETHOD EndComposition(void)=0;
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue)=0;
|
||||
|
||||
|
||||
// Logging Methods
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0;
|
||||
NS_IMETHOD StopLogging()=0;
|
||||
};
|
||||
|
||||
#endif //nsIEditor_h__
|
||||
|
||||
#endif // nsIHTMLEditor_h__
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIHighLevelHTMLEditor.h"
|
||||
#include "nsTextServicesDocument.h"
|
||||
|
||||
#define LOCK_DOC(doc)
|
||||
|
@ -1849,7 +1850,7 @@ nsTextServicesDocument::DeleteSelection()
|
|||
|
||||
// Now delete the actual content!
|
||||
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
|
||||
result = mEditor->DeleteSelection(nsIEditor::eDeletePrevious);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
|
@ -1953,7 +1954,9 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
|||
return result;
|
||||
}
|
||||
|
||||
result = mEditor->InsertText(*aText);
|
||||
nsCOMPtr<nsIHighLevelHTMLEditor> htmlEditor = do_QueryInterface(mEditor, &result);
|
||||
if (htmlEditor)
|
||||
result = htmlEditor->InsertText(*aText);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче