From 41221abe8460e18d93ef98c12c358018c8e18b2a Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Thu, 7 Nov 2002 13:04:37 +0000 Subject: [PATCH] 64647: implement "Paste without Formatting"; r=akkana; sr=sfraser git-svn-id: svn://10.0.0.236/trunk@133293 18797224-902f-48f8-a5cc-f745e15eee43 --- .../libeditor/html/nsHTMLDataTransfer.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 173c5bcfb55..880caa716e9 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -1405,10 +1405,31 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType) // NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType) { - ///XXX Joe Francis will write this part: bug 64647 - return Paste(aSelectionType); + ForceCompositionEnd(); + + // Get Clipboard Service + nsresult rv; + nsCOMPtr clipboard( do_GetService( kCClipboardCID, &rv ) ); + if ( NS_FAILED(rv) ) + return rv; + + // Get the nsITransferable interface for getting the data from the clipboard. + // use nsPlaintextEditor::PrepareTransferable() to force unicode plaintext data. + nsCOMPtr trans; + rv = nsPlaintextEditor::PrepareTransferable(getter_AddRefs(trans)); + if (NS_SUCCEEDED(rv) && trans) + { + // Get the Data from the clipboard + if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable()) + { + rv = InsertFromTransferable(trans, nsString(), nsString()); + } + } + + return rv; } + NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) { if (!aCanPaste)