I have a XULRunner application that needs to copy image data to the clipboard. I have figured out how to handle copying text to the clipboard, and I can paste PNG data from the clipboard. What I can't figure out is how to get data from a data URL into the clipboard so that it can be pasted into other applications.
This is the code I use to copy text (well, XUL):
var transferObject=Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
var stringWrapper=Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
var systemClipboard=Components.classes["@mozilla.org/widget/clipboard;1"].
createInstance(Components.interfaces.nsIClipboard);
var objToSerialize=aDOMNode;
transferObject.addDataFlavor("text/xul");
var xmls=new XMLSerializer();
var serializedObj=xmls.serializeToString(objToSerialize);
stringWrapper.data=serializedObj;
transferObject.setTransferData("text/xul",stringWrapper,serializedObj.length*2);
And, as I said, the data I'm trying to transfer is a PNG as a data URL. So I'm looking for the equivalent to the above that will allow, e.g. Paint.NET to paste my app's data.