зеркало из https://github.com/mozilla/gecko-dev.git
fix for 78010 (implement nsIClipboardHelper). r=pavlov, pinkerton, hewitt, sr=hyatt
This commit is contained in:
Родитель
fa4b889925
Коммит
2d2e67c3fa
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Travis Bogard <travis@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
|
@ -1195,34 +1195,39 @@ nsWebShell::DoCommand ( const nsAReadableString & inCommand )
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::CanCutSelection(PRBool* aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ( aResult )
|
||||
rv = IsCommandEnabled ( NS_LITERAL_STRING("cmd_cut"), aResult );
|
||||
|
||||
return rv;
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_cut"), aResult );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCopySelection(PRBool* aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_copy"), aResult );
|
||||
}
|
||||
|
||||
if ( aResult )
|
||||
rv = IsCommandEnabled ( NS_LITERAL_STRING("cmd_copy"), aResult );
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCopyLinkLocation(PRBool* aResult)
|
||||
{
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_copyLink"), aResult );
|
||||
}
|
||||
|
||||
return rv;
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCopyImageLocation(PRBool* aResult)
|
||||
{
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_copyImageLocation"),
|
||||
aResult );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCopyImageContents(PRBool* aResult)
|
||||
{
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_copyImageContents"),
|
||||
aResult );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanPaste(PRBool* aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ( aResult )
|
||||
rv = IsCommandEnabled ( NS_LITERAL_STRING("cmd_paste"), aResult );
|
||||
|
||||
return rv;
|
||||
return IsCommandEnabled ( NS_LITERAL_STRING("cmd_paste"), aResult );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1240,7 +1245,19 @@ nsWebShell::CopySelection(void)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::CopyLinkLocation(void)
|
||||
{
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_copy_link") );
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_copyLink") );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CopyImageLocation(void)
|
||||
{
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_copyImageLocation") );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CopyImageContents(void)
|
||||
{
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_copyImageContents") );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* chrome://inspector/content/jsutil/rdf/RDFArray.js
|
||||
* chrome://inspector/content/jsutil/rdf/RDFU.js
|
||||
* chrome://inspector/content/jsutil/xul/FrameExchange.js
|
||||
* chrome://inspector/content/jsutil/system/ClipboardUtils.js
|
||||
* chrome://inspector/content/jsutil/system/file.js
|
||||
****************************************************************/
|
||||
|
||||
|
@ -32,6 +31,9 @@ const kWindowMediatorIID = "@mozilla.org/rdf/datasource;1?name=window-mediator
|
|||
const kObserverServiceIID = "@mozilla.org/observer-service;1";
|
||||
const kDirServiceCID = "@mozilla.org/file/directory_service;1"
|
||||
|
||||
const kClipboardHelperCID = "@mozilla.org/widget/clipboardhelper;1";
|
||||
const kGlobalClipboard = Components.interfaces.nsIClipboard.kGlobalClipboard
|
||||
|
||||
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
@ -79,6 +81,7 @@ InspectorApp.prototype =
|
|||
mInitialized: false,
|
||||
mFlasher: null,
|
||||
mIsViewingContent: false,
|
||||
mClipboardHelper: null,
|
||||
|
||||
get document() { return this.mDocViewerPane.viewer.viewee },
|
||||
get searchRegistry() { return this.mSearchService },
|
||||
|
@ -96,6 +99,8 @@ InspectorApp.prototype =
|
|||
this.toggleBrowser(true, false);
|
||||
this.toggleSearch(true, false);
|
||||
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
|
||||
|
||||
this.mClipboardHelper = XPCU.getService(kClipboardHelperCID, "nsIClipboardHelper");
|
||||
},
|
||||
|
||||
initViewerPanes: function()
|
||||
|
@ -292,13 +297,13 @@ InspectorApp.prototype =
|
|||
var mod = this.mSearchService.currentModule;
|
||||
var idx = this.mSearchService.getSelectedIndex(0);
|
||||
var text = mod.getItemText(idx);
|
||||
ClipboardUtils.writeString(text);
|
||||
this.mClipboardHelper.writeStringToClipboard(text, kGlobalClipboard);
|
||||
},
|
||||
|
||||
copySearchItemAll: function()
|
||||
{
|
||||
var text = this.getAllSearchItemText();
|
||||
ClipboardUtils.writeString(text);
|
||||
this.mClipboardHelper.writeStringToClipboard(text, kGlobalClipboard);
|
||||
},
|
||||
|
||||
saveSearchItemText: function()
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/rdf/RDFArray.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xul/FrameExchange.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/ClipboardUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/PrefUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/file.js"/>
|
||||
|
|
|
@ -23,7 +23,6 @@ inspector.jar:
|
|||
content/inspector/extensions/wsm-colorpicker.js (extensions/wsm-colorpicker.js)
|
||||
content/inspector/jsutil/rdf/RDFU.js (jsutil/rdf/RDFU.js)
|
||||
content/inspector/jsutil/rdf/RDFArray.js (jsutil/rdf/RDFArray.js)
|
||||
content/inspector/jsutil/system/ClipboardUtils.js (jsutil/system/ClipboardUtils.js)
|
||||
content/inspector/jsutil/system/PrefUtils.js (jsutil/system/PrefUtils.js)
|
||||
content/inspector/jsutil/system/FilePickerUtils.js (jsutil/system/FilePickerUtils.js)
|
||||
content/inspector/jsutil/system/DiskSearch.js (jsutil/system/DiskSearch.js)
|
||||
|
@ -77,4 +76,4 @@ inspector.jar:
|
|||
content/inspector/viewers/stylesheets/stylesheets.xul (viewers/stylesheets/stylesheets.xul)
|
||||
content/inspector/viewers/stylesheets/stylesheets.js (viewers/stylesheets/stylesheets.js)
|
||||
content/inspector/viewers/xblBindings/xblBindings.xul (viewers/xblBindings/xblBindings.xul)
|
||||
content/inspector/viewers/xblBindings/xblBindings.js (viewers/xblBindings/xblBindings.js)
|
||||
content/inspector/viewers/xblBindings/xblBindings.js (viewers/xblBindings/xblBindings.js)
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/***************************************************************
|
||||
* ClipboardUtils -------------------------------------------------
|
||||
* Utility functions for painless clipboard interaction.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class ClipboardUtils
|
||||
|
||||
var ClipboardUtils = {
|
||||
|
||||
writeString: function(aString)
|
||||
{
|
||||
var clipboard = XPCU.getService("@mozilla.org/widget/clipboard;1", "nsIClipboard");
|
||||
var transferable = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable");
|
||||
|
||||
if (clipboard && transferable) {
|
||||
transferable.addDataFlavor("text/unicode");
|
||||
|
||||
var data = XPCU.createInstance("@mozilla.org/supports-wstring;1", "nsISupportsWString");
|
||||
|
||||
if (data) {
|
||||
data.data = aString;
|
||||
transferable.setTransferData("text/unicode", data, aString.length * 2);
|
||||
clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
|
@ -124,6 +124,7 @@
|
|||
// Drag & Drop, Clipboard
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIClipboardHelper.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
@ -1203,11 +1204,6 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
// copy string to clipboard methods
|
||||
static nsresult CopyStringToClipboard(nsString& aString,
|
||||
PRInt32 aClipboardID);
|
||||
static nsresult CopyStringToClipboard(nsString& aString);
|
||||
|
||||
void FreeDynamicStack();
|
||||
|
||||
//helper funcs for disabing autoscrolling
|
||||
|
@ -4009,79 +4005,6 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// CopyStringToClipboard: copy simple string to clipboard
|
||||
nsresult PresShell::CopyStringToClipboard(nsString& aString,
|
||||
PRInt32 aClipboardID)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// get the clipboard
|
||||
nsCOMPtr<nsIClipboard>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// create a transferable for putting data on the clipboard
|
||||
nsCOMPtr<nsITransferable>
|
||||
trans(do_CreateInstance("@mozilla.org/widget/transferable;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
|
||||
|
||||
// Add the text data flavor to the transferable
|
||||
rv = trans->AddDataFlavor(kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get wStrings to hold clip data
|
||||
nsCOMPtr<nsISupportsWString>
|
||||
data(do_CreateInstance("@mozilla.org/supports-wstring;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(data, NS_ERROR_FAILURE);
|
||||
|
||||
// populate the string
|
||||
rv = data->SetData(NS_CONST_CAST(PRUnichar*, aString.GetUnicode()));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// qi the data object an |nsISupports| so that when the transferable holds
|
||||
// onto it, it will addref the correct interface.
|
||||
nsCOMPtr<nsISupports> genericData(do_QueryInterface(data, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(genericData, NS_ERROR_FAILURE);
|
||||
|
||||
// set the transfer data
|
||||
rv = trans->SetTransferData(kUnicodeMime, genericData,
|
||||
aString.Length() * 2);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// put the transferable on the clipboard
|
||||
rv = clipboard->SetData(trans, nsnull, aClipboardID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// CopyStringToClipboard: copy string to clipboard(s) for platform
|
||||
nsresult PresShell::CopyStringToClipboard(nsString& aString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: CopyStringToClipboard: %s\n",
|
||||
NS_ConvertUCS2toUTF8(aString).get());
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// copy to the global clipboard
|
||||
rv = CopyStringToClipboard(aString, nsIClipboard::kGlobalClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef XP_UNIX
|
||||
// unix also needs us to copy to the selection clipboard
|
||||
rv = CopyStringToClipboard(aString, nsIClipboard::kSelectionClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// DoCopyLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
{
|
||||
|
@ -4096,11 +4019,19 @@ NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
|||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (anchor) {
|
||||
// if so, copy the link:
|
||||
// if so, get the href
|
||||
nsAutoString anchorText;
|
||||
rv = anchor->GetHref(anchorText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CopyStringToClipboard(anchorText);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(anchorText);
|
||||
}
|
||||
|
||||
// if no link, fail.
|
||||
|
@ -4121,11 +4052,19 @@ NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
|||
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (img) {
|
||||
// if so, copy the location:
|
||||
// if so, get the src
|
||||
nsAutoString srcText;
|
||||
rv = img->GetSrc(srcText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CopyStringToClipboard(srcText);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the src onto the clipboard
|
||||
return clipboard->CopyString(srcText);
|
||||
}
|
||||
|
||||
// if no image, fail.
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
// Drag & Drop, Clipboard
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIClipboardHelper.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
@ -1203,11 +1204,6 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
// copy string to clipboard methods
|
||||
static nsresult CopyStringToClipboard(nsString& aString,
|
||||
PRInt32 aClipboardID);
|
||||
static nsresult CopyStringToClipboard(nsString& aString);
|
||||
|
||||
void FreeDynamicStack();
|
||||
|
||||
//helper funcs for disabing autoscrolling
|
||||
|
@ -4009,79 +4005,6 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// CopyStringToClipboard: copy simple string to clipboard
|
||||
nsresult PresShell::CopyStringToClipboard(nsString& aString,
|
||||
PRInt32 aClipboardID)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// get the clipboard
|
||||
nsCOMPtr<nsIClipboard>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// create a transferable for putting data on the clipboard
|
||||
nsCOMPtr<nsITransferable>
|
||||
trans(do_CreateInstance("@mozilla.org/widget/transferable;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
|
||||
|
||||
// Add the text data flavor to the transferable
|
||||
rv = trans->AddDataFlavor(kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get wStrings to hold clip data
|
||||
nsCOMPtr<nsISupportsWString>
|
||||
data(do_CreateInstance("@mozilla.org/supports-wstring;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(data, NS_ERROR_FAILURE);
|
||||
|
||||
// populate the string
|
||||
rv = data->SetData(NS_CONST_CAST(PRUnichar*, aString.GetUnicode()));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// qi the data object an |nsISupports| so that when the transferable holds
|
||||
// onto it, it will addref the correct interface.
|
||||
nsCOMPtr<nsISupports> genericData(do_QueryInterface(data, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(genericData, NS_ERROR_FAILURE);
|
||||
|
||||
// set the transfer data
|
||||
rv = trans->SetTransferData(kUnicodeMime, genericData,
|
||||
aString.Length() * 2);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// put the transferable on the clipboard
|
||||
rv = clipboard->SetData(trans, nsnull, aClipboardID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// CopyStringToClipboard: copy string to clipboard(s) for platform
|
||||
nsresult PresShell::CopyStringToClipboard(nsString& aString)
|
||||
{
|
||||
#ifdef DEBUG_dr
|
||||
printf("dr :: CopyStringToClipboard: %s\n",
|
||||
NS_ConvertUCS2toUTF8(aString).get());
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// copy to the global clipboard
|
||||
rv = CopyStringToClipboard(aString, nsIClipboard::kGlobalClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef XP_UNIX
|
||||
// unix also needs us to copy to the selection clipboard
|
||||
rv = CopyStringToClipboard(aString, nsIClipboard::kSelectionClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// DoCopyLinkLocation: copy link location to clipboard
|
||||
NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
||||
{
|
||||
|
@ -4096,11 +4019,19 @@ NS_IMETHODIMP PresShell::DoCopyLinkLocation(nsIDOMNode* aNode)
|
|||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (anchor) {
|
||||
// if so, copy the link:
|
||||
// if so, get the href
|
||||
nsAutoString anchorText;
|
||||
rv = anchor->GetHref(anchorText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CopyStringToClipboard(anchorText);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the href onto the clipboard
|
||||
return clipboard->CopyString(anchorText);
|
||||
}
|
||||
|
||||
// if no link, fail.
|
||||
|
@ -4121,11 +4052,19 @@ NS_IMETHODIMP PresShell::DoCopyImageLocation(nsIDOMNode* aNode)
|
|||
nsCOMPtr<nsIDOMHTMLImageElement> img(do_QueryInterface(aNode, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (img) {
|
||||
// if so, copy the location:
|
||||
// if so, get the src
|
||||
nsAutoString srcText;
|
||||
rv = img->GetSrc(srcText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CopyStringToClipboard(srcText);
|
||||
|
||||
// get the clipboard helper
|
||||
nsCOMPtr<nsIClipboardHelper>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// copy the src onto the clipboard
|
||||
return clipboard->CopyString(srcText);
|
||||
}
|
||||
|
||||
// if no image, fail.
|
||||
|
|
|
@ -687,35 +687,11 @@ function CopyEmailAddress(emailAddressNode)
|
|||
if (emailAddressNode)
|
||||
{
|
||||
var emailAddress = emailAddressNode.getAttribute("emailAddress");
|
||||
if (emailAddress)
|
||||
{
|
||||
// This code stolen from nsContextMenu.js.
|
||||
// Get clipboard.
|
||||
var iid = Components.interfaces[ "nsIClipboard" ];
|
||||
var clipboard = Components.classes[ "@mozilla.org/widget/clipboard;1" ].getService( iid );
|
||||
|
||||
// Create tranferable that will transfer the text.
|
||||
iid = Components.interfaces[ "nsITransferable" ];
|
||||
var transferable = Components.classes[ "@mozilla.org/widget/transferable;1" ].createInstance( iid );
|
||||
|
||||
if ( clipboard && transferable )
|
||||
{
|
||||
transferable.addDataFlavor( "text/unicode" );
|
||||
// Create wrapper for text.
|
||||
iid = Components.interfaces[ "nsISupportsWString" ];
|
||||
var data = Components.classes[ "@mozilla.org/supports-wstring;1" ].createInstance( iid );
|
||||
|
||||
if ( data )
|
||||
{
|
||||
data.data = emailAddress;
|
||||
transferable.setTransferData( "text/unicode", data, emailAddress.length * 2 );
|
||||
// Put on clipboard.
|
||||
clipboard.setData( transferable,
|
||||
null,
|
||||
Components.interfaces.nsIClipboard.kGlobalClipboard );
|
||||
}
|
||||
}
|
||||
}
|
||||
var contractid = "@mozilla.org/widget/clipboardhelper;1";
|
||||
var iid = Components.interfaces.nsIClipboardHelper;
|
||||
var clipboard = Components.classes[contractid].getService(iid);
|
||||
clipboard.copyString(emailAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -17,6 +17,7 @@
|
|||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
@ -27,50 +28,78 @@
|
|||
|
||||
[scriptable, uuid(b8100c90-73be-11d2-92a5-00105a1b0d64)]
|
||||
interface nsIClipboardCommands : nsISupports {
|
||||
/**
|
||||
* Returns whether there is a selection and it is not read-only.
|
||||
*/
|
||||
boolean canCutSelection();
|
||||
|
||||
/**
|
||||
* Returns whether there is a selection and it is copyable.
|
||||
*/
|
||||
boolean canCopySelection();
|
||||
/**
|
||||
* Returns whether there is a selection and it is not read-only.
|
||||
*/
|
||||
boolean canCutSelection();
|
||||
|
||||
/**
|
||||
* Returns whether the current contents of the clipboard can be
|
||||
* pasted and if the current selection is not read-only.
|
||||
*/
|
||||
boolean canPaste();
|
||||
/**
|
||||
* Returns whether there is a selection and it is copyable.
|
||||
*/
|
||||
boolean canCopySelection();
|
||||
|
||||
/**
|
||||
* Cut the current selection onto the clipboard.
|
||||
*/
|
||||
void cutSelection();
|
||||
/**
|
||||
* Returns whether we can copy a link location.
|
||||
*/
|
||||
boolean canCopyLinkLocation();
|
||||
|
||||
/**
|
||||
* Copy the current selection onto the clipboard.
|
||||
*/
|
||||
void copySelection();
|
||||
|
||||
/**
|
||||
* Copy the URL of the current selection, say for an <IMG> inside an <A>
|
||||
*/
|
||||
void copyLinkLocation();
|
||||
/**
|
||||
* Returns whether we can copy an image location.
|
||||
*/
|
||||
boolean canCopyImageLocation();
|
||||
|
||||
/**
|
||||
* Paste the contents of the clipboard into the current selection.
|
||||
*/
|
||||
void paste();
|
||||
/**
|
||||
* Returns whether we can copy an image's contents.
|
||||
*/
|
||||
boolean canCopyImageContents();
|
||||
|
||||
/**
|
||||
* Select the entire contents.
|
||||
*/
|
||||
void selectAll();
|
||||
/**
|
||||
* Returns whether the current contents of the clipboard can be
|
||||
* pasted and if the current selection is not read-only.
|
||||
*/
|
||||
boolean canPaste();
|
||||
|
||||
/**
|
||||
* Cut the current selection onto the clipboard.
|
||||
*/
|
||||
void cutSelection();
|
||||
|
||||
/**
|
||||
* Copy the current selection onto the clipboard.
|
||||
*/
|
||||
void copySelection();
|
||||
|
||||
/**
|
||||
* Copy the link location of the current selection (e.g.,
|
||||
* the |href| attribute of a selected |a| tag).
|
||||
*/
|
||||
void copyLinkLocation();
|
||||
|
||||
/**
|
||||
* Copy the location of the selected image.
|
||||
*/
|
||||
void copyImageLocation();
|
||||
|
||||
/**
|
||||
* Copy the contents of the selected image.
|
||||
*/
|
||||
void copyImageContents();
|
||||
|
||||
/**
|
||||
* Paste the contents of the clipboard into the current selection.
|
||||
*/
|
||||
void paste();
|
||||
|
||||
/**
|
||||
* Select the entire contents.
|
||||
*/
|
||||
void selectAll();
|
||||
|
||||
/**
|
||||
* Clear the current selection (if any). Insertion point ends up
|
||||
* at beginning of current selection.
|
||||
*/
|
||||
void selectNone();
|
||||
|
||||
/**
|
||||
* Clear the current selection (if any). Insertion point ends up
|
||||
* at beginning of current selection.
|
||||
*/
|
||||
void selectNone();
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ nsIDragSession.idl
|
|||
nsIDragService.idl
|
||||
nsIFormatConverter.idl
|
||||
nsIClipboard.idl
|
||||
nsIClipboardHelper.idl
|
||||
nsIClipboardOwner.idl
|
||||
nsIRollupListener.idl
|
||||
nsIBaseWindow.idl
|
||||
|
|
|
@ -87,6 +87,7 @@ XPIDLSRCS = \
|
|||
nsIDragTracker.idl \
|
||||
nsIFormatConverter.idl \
|
||||
nsIClipboard.idl \
|
||||
nsIClipboardHelper.idl \
|
||||
nsIClipboardOwner.idl \
|
||||
nsIRollupListener.idl \
|
||||
nsIMenuRollup.idl \
|
||||
|
|
|
@ -39,6 +39,7 @@ XPIDLSRCS = \
|
|||
.\nsIDragTracker.idl \
|
||||
.\nsIFormatConverter.idl \
|
||||
.\nsIClipboard.idl \
|
||||
.\nsIClipboardHelper.idl \
|
||||
.\nsIClipboardOwner.idl \
|
||||
.\nsIRollupListener.idl \
|
||||
.\nsIMenuRollup.idl \
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 2001 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIClipboard.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsString.h" // needed for AString -> nsAReadableString, unfortunately
|
||||
%}
|
||||
|
||||
/**
|
||||
* helper service for common uses of nsIClipboard.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(44073a98-1dd2-11b2-8600-d0ae854dbe93)]
|
||||
interface nsIClipboardHelper : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* copy string to given clipboard
|
||||
*
|
||||
* @param aString, the string to copy to the clipboard
|
||||
* @param aClipboardID, the ID of the clipboard to copy to
|
||||
* (eg. kSelectionClipboard -- see nsIClipboard.idl)
|
||||
*/
|
||||
void copyStringToClipboard(in AString aString, in long aClipboardID);
|
||||
|
||||
/**
|
||||
* copy string to (default) clipboard
|
||||
*
|
||||
* @param aString, the string to copy to the clipboard
|
||||
*/
|
||||
void copyString(in AString aString);
|
||||
|
||||
};
|
|
@ -17,7 +17,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
/* 2d96b3d0-c051-11d1-a827-0040959a28c9 */
|
||||
|
@ -192,6 +193,10 @@
|
|||
#define NS_CLIPBOARD_CID \
|
||||
{ 0x8b5314ba, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
// {77221D5A-1DD2-11B2-8C69-C710F15D2ED5}
|
||||
#define NS_CLIPBOARDHELPER_CID \
|
||||
{ 0x77221d5a, 0x1dd2, 0x11b2, { 0x8c, 0x69, 0xc7, 0x10, 0xf1, 0x5d, 0x2e, 0xd5 } }
|
||||
|
||||
// {8B5314BD-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_DATAFLAVOR_CID \
|
||||
{ 0x8b5314bd, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
@ -48,6 +49,7 @@
|
|||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsDragService.h"
|
||||
|
@ -76,6 +78,7 @@ static NS_DEFINE_IID(kCFontRetrieverService, NS_FONTRETRIEVERSERVICE_CID);
|
|||
// Drag & Drop, Clipboard
|
||||
static NS_DEFINE_IID(kCDataObj, NS_DATAOBJ_CID);
|
||||
static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID);
|
||||
static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_IID(kCDataFlavor, NS_DATAFLAVOR_CID);
|
||||
static NS_DEFINE_IID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID);
|
||||
|
@ -223,6 +226,9 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
else if (mClassID.Equals(kCClipboard)) {
|
||||
inst = (nsISupports*)new nsClipboard();
|
||||
}
|
||||
else if (mClassID.Equals(kCClipboardHelper)) {
|
||||
inst = (nsISupports*)new nsClipboardHelper();
|
||||
}
|
||||
else if (mClassID.Equals(kCHTMLFormatConverter)) {
|
||||
inst = (nsISupports*)new nsHTMLFormatConverter();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
@ -46,6 +47,7 @@
|
|||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsDragService.h"
|
||||
|
@ -67,6 +69,7 @@ static NS_DEFINE_IID(kCTimerManager, NS_TIMERMANAGER_CID);
|
|||
// Drag & Drop, Clipboard
|
||||
static NS_DEFINE_IID(kCDataObj, NS_DATAOBJ_CID);
|
||||
static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID);
|
||||
static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_IID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID);
|
||||
static NS_DEFINE_IID(kCDragService, NS_DRAGSERVICE_CID);
|
||||
|
@ -202,6 +205,9 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
|||
else if (mClassID.Equals(kCClipboard)) {
|
||||
inst = (nsISupports*)(nsBaseClipboard *)new nsClipboard();
|
||||
}
|
||||
else if (mClassID.Equals(kCClipboardHelper)) {
|
||||
inst = (nsISupports*)new nsClipboardHelper();
|
||||
}
|
||||
else if (mClassID.Equals(kCDragService)) {
|
||||
inst = (nsISupports*)(nsIDragService *)new nsDragService();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsClipboard.h"
|
||||
|
@ -271,7 +272,9 @@ NS_IMETHODIMP nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
|
|||
|
||||
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE; // we don't suport the selection clipboard by default.
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = PR_TRUE; // we support the selection clipboard on unix.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* Contributor(s):
|
||||
* Christopher Blizzzard <blizzard@mozilla.org>
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include "nsLabel.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsFontRetrieverService.h"
|
||||
#include "nsDragService.h"
|
||||
|
@ -61,6 +63,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
|
@ -183,9 +186,9 @@ static nsModuleComponentInfo components[] =
|
|||
// "@mozilla.org/widget/sound/gtk;1"
|
||||
"@mozilla.org/sound;1",
|
||||
nsSoundConstructor },
|
||||
{ "Transferrable",
|
||||
{ "Transferable",
|
||||
NS_TRANSFERABLE_CID,
|
||||
// "@mozilla.org/widget/transferrable/gtk;1",
|
||||
// "@mozilla.org/widget/transferable/gtk;1",
|
||||
"@mozilla.org/widget/transferable;1",
|
||||
nsTransferableConstructor },
|
||||
{ "Gtk Clipboard",
|
||||
|
@ -193,6 +196,10 @@ static nsModuleComponentInfo components[] =
|
|||
// "@mozilla.org/widget/clipboard/gtk;1",
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
nsClipboardConstructor },
|
||||
{ "Clipboard Helper",
|
||||
NS_CLIPBOARDHELPER_CID,
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
nsClipboardHelperConstructor },
|
||||
{ "HTML Format Converter",
|
||||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter/gtk;1",
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
@ -55,6 +56,7 @@
|
|||
#include "nsFileWidget.h"
|
||||
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsDragService.h"
|
||||
|
@ -108,6 +110,7 @@ static NS_DEFINE_CID(kCPopUpMenu, NS_POPUPMENU_CID);
|
|||
// Drag and Drop/Clipboard
|
||||
static NS_DEFINE_CID(kCDataFlavor, NS_DATAFLAVOR_CID);
|
||||
static NS_DEFINE_CID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_CID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID);
|
||||
static NS_DEFINE_CID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_CID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID);
|
||||
static NS_DEFINE_CID(kCDragService, NS_DRAGSERVICE_CID);
|
||||
|
@ -269,6 +272,8 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
inst = (nsISupports*)new nsHTMLFormatConverter();
|
||||
else if (mClassID.Equals(kCClipboard))
|
||||
inst = (nsISupports*)new nsClipboard();
|
||||
else if (mClassID.Equals(kCClipboardHelper))
|
||||
inst = (nsISupports*)new nsClipboardHelper();
|
||||
else if (mClassID.Equals(kCDragService))
|
||||
inst = (nsISupports*)NS_STATIC_CAST(nsIDragService*, new nsDragService());
|
||||
#ifdef IBMBIDI
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
@ -44,6 +45,7 @@
|
|||
|
||||
// Drag & Drop, Clipboard
|
||||
// #include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
|
||||
|
@ -77,6 +79,7 @@ static NS_DEFINE_IID(kCFontRetrieverService, NS_FONTRETRIEVERSERVICE_CID);
|
|||
// Drag & Drop, Clipboard
|
||||
static NS_DEFINE_IID(kCDataObj, NS_DATAOBJ_CID);
|
||||
static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID);
|
||||
static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_IID(kCDataFlavor, NS_DATAFLAVOR_CID);
|
||||
static NS_DEFINE_IID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID);
|
||||
|
@ -219,6 +222,9 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
// else if (mClassID.Equals(kCClipboard)) {
|
||||
// inst = (nsISupports*)new nsClipboard();
|
||||
// }
|
||||
else if (mClassID.Equals(kCClipboardHelper)) {
|
||||
inst = (nsISupports*)new nsClipboardHelper();
|
||||
}
|
||||
else if (mClassID.Equals(kCHTMLFormatConverter)) {
|
||||
inst = (nsISupports*)new nsHTMLFormatConverter();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*
|
||||
* This Original Code has been modified by IBM Corporation.
|
||||
* Modifications made by IBM described herein are
|
||||
* Copyright (c) International Business Machines
|
||||
|
@ -62,6 +64,7 @@
|
|||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
// OS2TODO #include "nsDragService.h"
|
||||
|
@ -72,6 +75,7 @@
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCanvas)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService)
|
||||
|
@ -240,6 +244,10 @@ static nsModuleComponentInfo components[] =
|
|||
NS_CLIPBOARD_CID,
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
nsClipboardConstructor },
|
||||
{ "Clipboard Helper",
|
||||
NS_CLIPBOARDHELPER_CID,
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
nsClipboardHelperConstructor },
|
||||
|
||||
// OS2TODO
|
||||
#if 0
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* Contributor(s):
|
||||
* Christopher Blizzzard <blizzard@mozilla.org>
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -32,6 +33,7 @@
|
|||
#include "nsLookAndFeel.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsFileSpecWithUIImpl.h"
|
||||
|
@ -48,6 +50,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl)
|
||||
|
@ -150,6 +153,10 @@ static nsModuleComponentInfo components[] =
|
|||
// "@mozilla.org/widget/clipboard/ph;1",
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
nsClipboardConstructor },
|
||||
{ "Clipboard Helper",
|
||||
NS_CLIPBOARDHELPER_CID,
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
nsClipboardHelperConstructor },
|
||||
{ "HTML Format Converter",
|
||||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter/ph;1",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -18,9 +18,9 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
@ -331,6 +331,8 @@ NS_IMETHODIMP nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
|
|||
|
||||
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE; // we support the selection clipboard by default.
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = PR_TRUE; // we support the selection clipboard on unix.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* Blizzard. Portions created by Christopher Blizzard are
|
||||
* Copyright (C) 2000 Christopher Blizzard. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include "nsLookAndFeel.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsFileSpecWithUIImpl.h"
|
||||
|
@ -48,6 +49,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl)
|
||||
|
@ -145,6 +147,10 @@ static nsModuleComponentInfo components[] =
|
|||
NS_CLIPBOARD_CID,
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
nsClipboardConstructor },
|
||||
{ "Clipboard Helper",
|
||||
NS_CLIPBOARDHELPER_CID,
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
nsClipboardHelperConstructor },
|
||||
{ "HTML Format Converter",
|
||||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter/qt;1",
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
|
@ -425,6 +425,8 @@ NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval) {
|
||||
*_retval = PR_TRUE;
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = PR_TRUE; // we support the selection clipboard on unix.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -38,6 +39,7 @@
|
|||
#include "nsLabel.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
//#include "nsFontRetrieverService.h"
|
||||
#include "nsDragService.h"
|
||||
|
@ -61,6 +63,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
|
@ -193,6 +196,10 @@ static nsModuleComponentInfo components[] =
|
|||
// "@mozilla.org/widget/clipboard/xlib;1",
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
nsClipboardConstructor },
|
||||
{ "Clipboard Helper",
|
||||
NS_CLIPBOARDHELPER_CID,
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
nsClipboardHelperConstructor },
|
||||
{ "HTML Format Converter",
|
||||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter/xlib;1",
|
||||
|
|
|
@ -42,6 +42,7 @@ CPPSRCS = \
|
|||
nsFileSpecWithUIImpl.cpp \
|
||||
nsPrimitiveHelpers.cpp \
|
||||
nsXPLookAndFeel.cpp \
|
||||
nsClipboardHelper.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
|
||||
|
|
|
@ -26,11 +26,12 @@ LIBRARY_NAME = raptorbasewidget_s
|
|||
DEFINES =-D_IMPL_NS_WIDGET -DUSE_TLS_FOR_TOOLKIT
|
||||
|
||||
CPPSRCS = \
|
||||
nsBaseDragService.cpp \
|
||||
nsBaseWidget.cpp \
|
||||
nsBaseDragService.cpp \
|
||||
nsBaseWidget.cpp \
|
||||
nsBaseFilePicker.cpp \
|
||||
nsFileSpecWithUIImpl.cpp \
|
||||
nsBaseClipboard.cpp \
|
||||
nsClipboardHelper.cpp \
|
||||
nsTransferable.cpp \
|
||||
nsHTMLFormatConverter.cpp \
|
||||
nsPrimitiveHelpers.cpp \
|
||||
|
@ -45,6 +46,7 @@ OBJS= \
|
|||
.\$(OBJDIR)\nsBaseFilePicker.obj \
|
||||
.\$(OBJDIR)\nsFileSpecWithUIImpl.obj \
|
||||
.\$(OBJDIR)\nsBaseClipboard.obj \
|
||||
.\$(OBJDIR)\nsClipboardHelper.obj \
|
||||
.\$(OBJDIR)\nsTransferable.obj \
|
||||
.\$(OBJDIR)\nsHTMLFormatConverter.obj \
|
||||
.\$(OBJDIR)\nsPrimitiveHelpers.obj \
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 2001 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsClipboardHelper.h"
|
||||
|
||||
// basics
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
// helpers
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsClipboardHelper, nsIClipboardHelper);
|
||||
|
||||
/*****************************************************************************
|
||||
* nsClipboardHelper ctor / dtor
|
||||
*****************************************************************************/
|
||||
|
||||
nsClipboardHelper::nsClipboardHelper()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsClipboardHelper::~nsClipboardHelper()
|
||||
{
|
||||
// no members, nothing to destroy
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* nsIClipboardHelper methods
|
||||
*****************************************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboardHelper::CopyStringToClipboard(const nsAReadableString& aString,
|
||||
PRInt32 aClipboardID)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// get the clipboard
|
||||
nsCOMPtr<nsIClipboard>
|
||||
clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
|
||||
|
||||
// don't go any further if they're asking for the selection
|
||||
// clipboard on a platform which doesn't support it (i.e., unix)
|
||||
if (nsIClipboard::kSelectionClipboard == aClipboardID) {
|
||||
PRBool clipboardSupported;
|
||||
rv = clipboard->SupportsSelectionClipboard(&clipboardSupported);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!clipboardSupported)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// create a transferable for putting data on the clipboard
|
||||
nsCOMPtr<nsITransferable>
|
||||
trans(do_CreateInstance("@mozilla.org/widget/transferable;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
|
||||
|
||||
// Add the text data flavor to the transferable
|
||||
rv = trans->AddDataFlavor(kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get wStrings to hold clip data
|
||||
nsCOMPtr<nsISupportsWString>
|
||||
data(do_CreateInstance("@mozilla.org/supports-wstring;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(data, NS_ERROR_FAILURE);
|
||||
|
||||
// populate the string
|
||||
rv = data->AdoptData(ToNewUnicode(aString));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// qi the data object an |nsISupports| so that when the transferable holds
|
||||
// onto it, it will addref the correct interface.
|
||||
nsCOMPtr<nsISupports> genericData(do_QueryInterface(data, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(genericData, NS_ERROR_FAILURE);
|
||||
|
||||
// set the transfer data
|
||||
rv = trans->SetTransferData(kUnicodeMime, genericData,
|
||||
aString.Length() * 2);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// put the transferable on the clipboard
|
||||
rv = clipboard->SetData(trans, nsnull, aClipboardID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboardHelper::CopyString(const nsAReadableString& aString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// copy to the global clipboard. it's bad if this fails in any way.
|
||||
rv = CopyStringToClipboard(aString, nsIClipboard::kGlobalClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// unix also needs us to copy to the selection clipboard. this will
|
||||
// fail in CopyStringToClipboard if we're not on a platform that
|
||||
// supports the selection clipboard. (this could have been #ifdef
|
||||
// XP_UNIX, but using the SupportsSelectionClipboard call is the
|
||||
// more correct thing to do.
|
||||
//
|
||||
// if this fails in any way other than "not being unix", we'll get
|
||||
// the assertion we need in CopyStringToClipboard, and we needn't
|
||||
// assert again here.
|
||||
CopyStringToClipboard(aString, nsIClipboard::kSelectionClipboard);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 2001 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Dan Rosen <dr@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsClipboardHelper_h__
|
||||
#define nsClipboardHelper_h__
|
||||
|
||||
// interfaces
|
||||
#include "nsIClipboardHelper.h"
|
||||
|
||||
// basics
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* impl class for nsIClipboardHelper, a helper for common uses of nsIClipboard.
|
||||
*/
|
||||
|
||||
class nsClipboardHelper : public nsIClipboardHelper
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLIPBOARDHELPER
|
||||
|
||||
nsClipboardHelper();
|
||||
virtual ~nsClipboardHelper();
|
||||
|
||||
};
|
||||
|
||||
#endif // nsClipboardHelper_h__
|
Загрузка…
Ссылка в новой задаче