19610: Change InsertAsQuotation API to return inserted node r=rhp

This commit is contained in:
akkana%netscape.com 1999-11-24 20:48:59 +00:00
Родитель 8af93bb957
Коммит e8544d1c6c
13 изменённых файлов: 122 добавлений и 57 удалений

Просмотреть файл

@ -2115,7 +2115,8 @@ nsEditorShell::PasteAsCitedQuotation(const PRUnichar *cite)
}
NS_IMETHODIMP
nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText,
nsIDOMNode** aNodeInserted)
{
nsresult err = NS_NOINTERFACE;
@ -2128,7 +2129,7 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
if (mailEditor)
err = mailEditor->InsertAsQuotation(aQuotedText);
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
}
break;
@ -2140,7 +2141,9 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
}
NS_IMETHODIMP
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnichar *cite)
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
const PRUnichar *cite,
nsIDOMNode** aNodeInserted)
{
nsresult err = NS_NOINTERFACE;
@ -2152,9 +2155,9 @@ nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnich
case ePlainTextEditorType:
case eHTMLTextEditorType:
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
if (mailEditor)
err = mailEditor->InsertAsQuotation(aQuotedText);
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
}
break;

Просмотреть файл

@ -3613,7 +3613,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
textDataObj->ToString ( &text );
stuffToPaste.SetString ( text, len );
nsAutoEditBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste);
rv = InsertAsPlaintextQuotation(stuffToPaste, 0);
}
}
else if (flavor.Equals(kUnicodeMime))
@ -3625,7 +3625,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
textDataObj->ToString ( &text );
stuffToPaste.SetString ( text, len / 2 );
nsAutoEditBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste);
rv = InsertAsPlaintextQuotation(stuffToPaste, 0);
}
}
nsCRT::free(flav);
@ -3634,17 +3634,20 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
return rv;
}
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText)
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
if (mFlags & eEditorPlaintextMask)
return InsertAsPlaintextQuotation(aQuotedText);
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
nsAutoString citation ("");
return InsertAsCitedQuotation(aQuotedText, citation);
return InsertAsCitedQuotation(aQuotedText, citation, aNodeInserted);
}
// text insert.
NS_IMETHODIMP nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText)
NS_IMETHODIMP
nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
// Now we have the text. Cite it appropriately:
nsCOMPtr<nsICiter> citer;
@ -3693,11 +3696,22 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedTe
selection->Collapse(preNode, 0);
}
return InsertText(quotedStuff);
rv = InsertText(quotedStuff);
if (aNodeInserted)
{
if (NS_SUCCEEDED(rv))
{
*aNodeInserted = preNode;
NS_IF_ADDREF(*aNodeInserted);
}
}
return rv;
}
NS_IMETHODIMP nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation)
NS_IMETHODIMP
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation,
nsIDOMNode **aNodeInserted)
{
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIDOMNode> newNode;
@ -3725,6 +3739,14 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
}
res = InsertHTML(aQuotedText);
if (aNodeInserted)
{
if (NS_SUCCEEDED(res))
{
*aNodeInserted = newNode;
NS_IF_ADDREF(*aNodeInserted);
}
}
return res;
}

Просмотреть файл

@ -143,9 +143,9 @@ public:
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn);
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn);
NS_IMETHOD PasteAsQuotation();
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode **aNodeInserted);
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
@ -471,7 +471,8 @@ protected:
// Methods for handling plaintext quotations
NS_IMETHOD PasteAsPlaintextQuotation();
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted);
TypeInState *GetTypeInState();

Просмотреть файл

@ -405,7 +405,8 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation)
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText)
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -418,11 +419,12 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText)
Flush();
}
return nsHTMLEditor::InsertAsQuotation(aQuotedText);
return nsHTMLEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText)
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -435,11 +437,13 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText)
Flush();
}
return nsHTMLEditor::InsertAsPlaintextQuotation(aQuotedText);
return nsHTMLEditor::InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation)
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -454,7 +458,8 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, const nsStr
Flush();
}
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation);
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation,
aNodeInserted);
}
NS_IMETHODIMP

Просмотреть файл

@ -75,9 +75,9 @@ public:
NS_IMETHOD PasteAsQuotation();
NS_IMETHOD PasteAsPlaintextQuotation();
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);

Просмотреть файл

@ -2115,7 +2115,8 @@ nsEditorShell::PasteAsCitedQuotation(const PRUnichar *cite)
}
NS_IMETHODIMP
nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText,
nsIDOMNode** aNodeInserted)
{
nsresult err = NS_NOINTERFACE;
@ -2128,7 +2129,7 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
if (mailEditor)
err = mailEditor->InsertAsQuotation(aQuotedText);
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
}
break;
@ -2140,7 +2141,9 @@ nsEditorShell::InsertAsQuotation(const PRUnichar *quotedText)
}
NS_IMETHODIMP
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnichar *cite)
nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
const PRUnichar *cite,
nsIDOMNode** aNodeInserted)
{
nsresult err = NS_NOINTERFACE;
@ -2152,9 +2155,9 @@ nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnich
case ePlainTextEditorType:
case eHTMLTextEditorType:
{
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
if (mailEditor)
err = mailEditor->InsertAsQuotation(aQuotedText);
err = mailEditor->InsertAsQuotation(aQuotedText, aNodeInserted);
}
break;

Просмотреть файл

@ -141,8 +141,9 @@ interface nsIEditorShell : nsISupports
void PasteAsQuotation();
void PasteAsCitedQuotation(in wstring cite);
void InsertAsQuotation(in wstring quotedText);
void InsertAsCitedQuotation(in wstring quotedText, in wstring cite);
void InsertAsQuotation(in wstring quotedText, out nsIDOMNode nodeInserted);
void InsertAsCitedQuotation(in wstring quotedText, in wstring cite,
out nsIDOMNode nodeInserted);
void SelectAll();
void DeleteSelection(in PRInt32 action);

Просмотреть файл

@ -3613,7 +3613,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
textDataObj->ToString ( &text );
stuffToPaste.SetString ( text, len );
nsAutoEditBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste);
rv = InsertAsPlaintextQuotation(stuffToPaste, 0);
}
}
else if (flavor.Equals(kUnicodeMime))
@ -3625,7 +3625,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
textDataObj->ToString ( &text );
stuffToPaste.SetString ( text, len / 2 );
nsAutoEditBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste);
rv = InsertAsPlaintextQuotation(stuffToPaste, 0);
}
}
nsCRT::free(flav);
@ -3634,17 +3634,20 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
return rv;
}
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText)
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
if (mFlags & eEditorPlaintextMask)
return InsertAsPlaintextQuotation(aQuotedText);
return InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
nsAutoString citation ("");
return InsertAsCitedQuotation(aQuotedText, citation);
return InsertAsCitedQuotation(aQuotedText, citation, aNodeInserted);
}
// text insert.
NS_IMETHODIMP nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText)
NS_IMETHODIMP
nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
// Now we have the text. Cite it appropriately:
nsCOMPtr<nsICiter> citer;
@ -3693,11 +3696,22 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedTe
selection->Collapse(preNode, 0);
}
return InsertText(quotedStuff);
rv = InsertText(quotedStuff);
if (aNodeInserted)
{
if (NS_SUCCEEDED(rv))
{
*aNodeInserted = preNode;
NS_IF_ADDREF(*aNodeInserted);
}
}
return rv;
}
NS_IMETHODIMP nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation)
NS_IMETHODIMP
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation,
nsIDOMNode **aNodeInserted)
{
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIDOMNode> newNode;
@ -3725,6 +3739,14 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
}
res = InsertHTML(aQuotedText);
if (aNodeInserted)
{
if (NS_SUCCEEDED(res))
{
*aNodeInserted = newNode;
NS_IF_ADDREF(*aNodeInserted);
}
}
return res;
}

Просмотреть файл

@ -143,9 +143,9 @@ public:
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn);
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn);
NS_IMETHOD PasteAsQuotation();
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode **aNodeInserted);
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
@ -471,7 +471,8 @@ protected:
// Methods for handling plaintext quotations
NS_IMETHOD PasteAsPlaintextQuotation();
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted);
TypeInState *GetTypeInState();

Просмотреть файл

@ -405,7 +405,8 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation)
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText)
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -418,11 +419,12 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText)
Flush();
}
return nsHTMLEditor::InsertAsQuotation(aQuotedText);
return nsHTMLEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText)
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -435,11 +437,13 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText)
Flush();
}
return nsHTMLEditor::InsertAsPlaintextQuotation(aQuotedText);
return nsHTMLEditor::InsertAsPlaintextQuotation(aQuotedText, aNodeInserted);
}
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation)
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation,
nsIDOMNode **aNodeInserted)
{
nsAutoHTMLEditorLogLock logLock(this);
@ -454,7 +458,8 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, const nsStr
Flush();
}
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation);
return nsHTMLEditor::InsertAsCitedQuotation(aQuotedText, aCitation,
aNodeInserted);
}
NS_IMETHODIMP

Просмотреть файл

@ -75,9 +75,9 @@ public:
NS_IMETHOD PasteAsQuotation();
NS_IMETHOD PasteAsPlaintextQuotation();
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);

Просмотреть файл

@ -65,7 +65,8 @@ public:
* @param aQuotedText The actual text to be quoted
* @param aCitation The "mid" URL of the source message
*/
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText,
nsIDOMNode** aNodeInserted)=0;
/**
* Document me!
@ -78,7 +79,8 @@ public:
*
*/
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
const nsString& aCitation)=0;
const nsString& aCitation,
nsIDOMNode** aNodeInserted)=0;
/**
* Document me!

Просмотреть файл

@ -184,7 +184,7 @@ nsresult nsMsgCompose::ConvertAndLoadComposeWindow(nsIEditorShell *aEditorShell,
}
if (aBuf != "")
aEditorShell->InsertAsQuotation(aBuf.GetUnicode());
aEditorShell->InsertAsQuotation(aBuf.GetUnicode(), 0);
if (aSignature != "")
{