From 9ce72431343518766d710009ea2b364076107e2a Mon Sep 17 00:00:00 2001 From: "anthonyd%netscape.com" Date: Tue, 13 Mar 2001 02:48:17 +0000 Subject: [PATCH] bug fix for 67985 - needed methods for nsEditor impl r=jfrancis sr=sfraser git-svn-id: svn://10.0.0.236/trunk@89436 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsEditor.cpp | 98 ++++++++++++++++++++++ mozilla/editor/base/nsEditor.h | 24 +++--- mozilla/editor/libeditor/base/nsEditor.cpp | 98 ++++++++++++++++++++++ mozilla/editor/libeditor/base/nsEditor.h | 24 +++--- 4 files changed, 222 insertions(+), 22 deletions(-) diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 1be8202b590..6b9c93e7d1f 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -315,6 +315,20 @@ nsEditor::PreDestroy() return NS_OK; } +NS_IMETHODIMP +nsEditor::GetFlags(PRUint32 *aFlags) +{ + *aFlags = mFlags; + return NS_OK; +} + +NS_IMETHODIMP +nsEditor::SetFlags(PRUint32 aFlags) +{ + mFlags = aFlags; + return NS_OK; +} + NS_IMETHODIMP nsEditor::GetDocument(nsIDOMDocument **aDoc) { @@ -360,6 +374,13 @@ nsEditor::GetSelectionController(nsISelectionController **aSel) } +NS_IMETHODIMP +nsEditor::DeleteSelection(EDirection aAction) +{ + return DeleteSelectionImpl(aAction); +} + + NS_IMETHODIMP nsEditor::GetSelection(nsISelection **aSelection) @@ -680,6 +701,26 @@ NS_IMETHODIMP nsEditor::ShouldTxnSetSelection(PRBool *aResult) } +NS_IMETHODIMP +nsEditor::GetDocumentIsEmpty(PRBool *aDocumentIsEmpty) +{ + nsCOMPtr rootElement; + nsresult res = GetRootElement(getter_AddRefs(rootElement)); + if (NS_FAILED(res)) return res; + if (!rootElement) return NS_ERROR_NULL_POINTER; + nsCOMPtr rootNode = do_QueryInterface(rootElement); + nsCOMPtr firstChild; + res = rootNode->GetFirstChild(getter_AddRefs(firstChild)); + + if(NS_SUCCEEDED(res)) + *aDocumentIsEmpty = PR_TRUE; + else + *aDocumentIsEmpty = PR_FALSE; + + return res; +} + + // XXX: the rule system should tell us which node to select all on (ie, the root, or the body) NS_IMETHODIMP nsEditor::SelectAll() { @@ -921,6 +962,63 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, return rv; } + + +NS_IMETHODIMP +nsEditor::Cut() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanCut(PRBool &aCanCut) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::Copy() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanCopy(PRBool &aCanCopy) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::Paste(PRInt32 aSelectionType) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::DoDrag(nsIDOMEvent *aEvent) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::InsertFromDrop(nsIDOMEvent *aEvent) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_IMETHODIMP nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue) { diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index 9197fd038e6..0d0510b8713 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -129,13 +129,14 @@ public: NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags); NS_IMETHOD PostCreate(); NS_IMETHOD PreDestroy(); - NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0; - NS_IMETHOD SetFlags(PRUint32 aFlags) = 0; + NS_IMETHOD GetFlags(PRUint32 *aFlags); + NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD GetDocument(nsIDOMDocument **aDoc); NS_IMETHOD GetRootElement(nsIDOMElement **aElement); NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetSelectionController(nsISelectionController **aSel); NS_IMETHOD GetSelection(nsISelection **aSelection); + NS_IMETHOD DeleteSelection(EDirection aAction); NS_IMETHOD EnableUndo(PRBool aEnable); NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager); @@ -152,8 +153,7 @@ public: NS_IMETHOD EndPlaceHolderTransaction(); NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult); - // pure virtual, because the definition of 'empty' depends on the doc type - NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty)=0; + NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty); // file handling NS_IMETHOD GetDocumentModified(PRBool *outDocModified); @@ -161,13 +161,15 @@ public: NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat); - // these are pure virtual in this base class - NS_IMETHOD Cut() = 0; - NS_IMETHOD CanCut(PRBool &aCanCut)=0; - NS_IMETHOD Copy() = 0; - NS_IMETHOD CanCopy(PRBool &aCanCopy)=0; - NS_IMETHOD Paste(PRInt32 aSelectionType) = 0; - NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)=0; + NS_IMETHOD Cut(); + NS_IMETHOD CanCut(PRBool &aCanCut); + NS_IMETHOD Copy(); + NS_IMETHOD CanCopy(PRBool &aCanCopy); + NS_IMETHOD Paste(PRInt32 aSelectionType); + NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); + NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag); + NS_IMETHOD DoDrag(nsIDOMEvent *aEvent); + NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent); NS_IMETHOD SelectAll(); diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 1be8202b590..6b9c93e7d1f 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -315,6 +315,20 @@ nsEditor::PreDestroy() return NS_OK; } +NS_IMETHODIMP +nsEditor::GetFlags(PRUint32 *aFlags) +{ + *aFlags = mFlags; + return NS_OK; +} + +NS_IMETHODIMP +nsEditor::SetFlags(PRUint32 aFlags) +{ + mFlags = aFlags; + return NS_OK; +} + NS_IMETHODIMP nsEditor::GetDocument(nsIDOMDocument **aDoc) { @@ -360,6 +374,13 @@ nsEditor::GetSelectionController(nsISelectionController **aSel) } +NS_IMETHODIMP +nsEditor::DeleteSelection(EDirection aAction) +{ + return DeleteSelectionImpl(aAction); +} + + NS_IMETHODIMP nsEditor::GetSelection(nsISelection **aSelection) @@ -680,6 +701,26 @@ NS_IMETHODIMP nsEditor::ShouldTxnSetSelection(PRBool *aResult) } +NS_IMETHODIMP +nsEditor::GetDocumentIsEmpty(PRBool *aDocumentIsEmpty) +{ + nsCOMPtr rootElement; + nsresult res = GetRootElement(getter_AddRefs(rootElement)); + if (NS_FAILED(res)) return res; + if (!rootElement) return NS_ERROR_NULL_POINTER; + nsCOMPtr rootNode = do_QueryInterface(rootElement); + nsCOMPtr firstChild; + res = rootNode->GetFirstChild(getter_AddRefs(firstChild)); + + if(NS_SUCCEEDED(res)) + *aDocumentIsEmpty = PR_TRUE; + else + *aDocumentIsEmpty = PR_FALSE; + + return res; +} + + // XXX: the rule system should tell us which node to select all on (ie, the root, or the body) NS_IMETHODIMP nsEditor::SelectAll() { @@ -921,6 +962,63 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, return rv; } + + +NS_IMETHODIMP +nsEditor::Cut() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanCut(PRBool &aCanCut) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::Copy() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanCopy(PRBool &aCanCopy) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::Paste(PRInt32 aSelectionType) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::DoDrag(nsIDOMEvent *aEvent) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsEditor::InsertFromDrop(nsIDOMEvent *aEvent) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_IMETHODIMP nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue) { diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 9197fd038e6..0d0510b8713 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -129,13 +129,14 @@ public: NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags); NS_IMETHOD PostCreate(); NS_IMETHOD PreDestroy(); - NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0; - NS_IMETHOD SetFlags(PRUint32 aFlags) = 0; + NS_IMETHOD GetFlags(PRUint32 *aFlags); + NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD GetDocument(nsIDOMDocument **aDoc); NS_IMETHOD GetRootElement(nsIDOMElement **aElement); NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetSelectionController(nsISelectionController **aSel); NS_IMETHOD GetSelection(nsISelection **aSelection); + NS_IMETHOD DeleteSelection(EDirection aAction); NS_IMETHOD EnableUndo(PRBool aEnable); NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager); @@ -152,8 +153,7 @@ public: NS_IMETHOD EndPlaceHolderTransaction(); NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult); - // pure virtual, because the definition of 'empty' depends on the doc type - NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty)=0; + NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty); // file handling NS_IMETHOD GetDocumentModified(PRBool *outDocModified); @@ -161,13 +161,15 @@ public: NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat); - // these are pure virtual in this base class - NS_IMETHOD Cut() = 0; - NS_IMETHOD CanCut(PRBool &aCanCut)=0; - NS_IMETHOD Copy() = 0; - NS_IMETHOD CanCopy(PRBool &aCanCopy)=0; - NS_IMETHOD Paste(PRInt32 aSelectionType) = 0; - NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)=0; + NS_IMETHOD Cut(); + NS_IMETHOD CanCut(PRBool &aCanCut); + NS_IMETHOD Copy(); + NS_IMETHOD CanCopy(PRBool &aCanCopy); + NS_IMETHOD Paste(PRInt32 aSelectionType); + NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); + NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag); + NS_IMETHOD DoDrag(nsIDOMEvent *aEvent); + NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent); NS_IMETHOD SelectAll();