mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
new clipboard interfaces for unix selection clipboard.
This commit is contained in:
parent
ffb1e41243
commit
7990ffae73
@ -4251,7 +4251,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste()
|
||||
trans->AddDataFlavor(kUnicodeMime);
|
||||
|
||||
// Get the Data from the clipboard
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans)))
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans, nsIClipboard::kGlobalClipboard)))
|
||||
{
|
||||
char* bestFlavor = nsnull;
|
||||
nsCOMPtr<nsISupports> genericDataObj;
|
||||
@ -4362,7 +4362,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRBool &aCanPaste)
|
||||
}
|
||||
|
||||
PRBool haveFlavors;
|
||||
rv = clipboard->HasDataMatchingFlavors(flavorsList, &haveFlavors);
|
||||
rv = clipboard->HasDataMatchingFlavors(flavorsList, nsIClipboard::kGlobalClipboard, &haveFlavors);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aCanPaste = haveFlavors;
|
||||
@ -4452,7 +4452,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
|
||||
trans->AddDataFlavor(kUnicodeMime);
|
||||
|
||||
// Get the Data from the clipboard
|
||||
clipboard->GetData(trans);
|
||||
clipboard->GetData(trans, nsIClipboard::kGlobalClipboard);
|
||||
|
||||
// Now we ask the transferable for the data
|
||||
// it still owns the data, we just have a pointer to it.
|
||||
|
@ -4251,7 +4251,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste()
|
||||
trans->AddDataFlavor(kUnicodeMime);
|
||||
|
||||
// Get the Data from the clipboard
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans)))
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans, nsIClipboard::kGlobalClipboard)))
|
||||
{
|
||||
char* bestFlavor = nsnull;
|
||||
nsCOMPtr<nsISupports> genericDataObj;
|
||||
@ -4362,7 +4362,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRBool &aCanPaste)
|
||||
}
|
||||
|
||||
PRBool haveFlavors;
|
||||
rv = clipboard->HasDataMatchingFlavors(flavorsList, &haveFlavors);
|
||||
rv = clipboard->HasDataMatchingFlavors(flavorsList, nsIClipboard::kGlobalClipboard, &haveFlavors);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aCanPaste = haveFlavors;
|
||||
@ -4452,7 +4452,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation()
|
||||
trans->AddDataFlavor(kUnicodeMime);
|
||||
|
||||
// Get the Data from the clipboard
|
||||
clipboard->GetData(trans);
|
||||
clipboard->GetData(trans, nsIClipboard::kGlobalClipboard);
|
||||
|
||||
// Now we ask the transferable for the data
|
||||
// it still owns the data, we just have a pointer to it.
|
||||
|
@ -2680,7 +2680,7 @@ PresShell::DoCopy()
|
||||
}
|
||||
|
||||
// put the transferable on the clipboard
|
||||
clipboard->SetData(trans, nsnull);
|
||||
clipboard->SetData(trans, nsnull, nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2680,7 +2680,7 @@ PresShell::DoCopy()
|
||||
}
|
||||
|
||||
// put the transferable on the clipboard
|
||||
clipboard->SetData(trans, nsnull);
|
||||
clipboard->SetData(trans, nsnull, nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,43 +30,51 @@
|
||||
[scriptable, uuid(8B5314BA-DB01-11d2-96CE-0060B0FB9956)]
|
||||
interface nsIClipboard : nsISupports
|
||||
{
|
||||
const long kSelectionClipboard = 0;
|
||||
const long kGlobalClipboard = 1;
|
||||
|
||||
/**
|
||||
* Given a transferable, set the data on the native clipboard
|
||||
*
|
||||
* @param aTransferable The transferable
|
||||
* @param anOwner The owner of the transferable
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
void setData ( in nsITransferable aTransferable, in nsIClipboardOwner anOwner) ;
|
||||
void setData ( in nsITransferable aTransferable, in nsIClipboardOwner anOwner,
|
||||
in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
* Given a transferable, get the clipboard data.
|
||||
*
|
||||
* @param aTransferable The transferable
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
void getData ( in nsITransferable aTransferable ) ;
|
||||
void getData ( in nsITransferable aTransferable, in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
* This empties the clipboard and notifies the clipboard owner.
|
||||
* This empties the "logical" clipboard. It does not clear the native clipboard.
|
||||
*
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
|
||||
void emptyClipboard ( ) ;
|
||||
void emptyClipboard ( in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
* Some platforms support deferred notification for putting data on the clipboard
|
||||
* This method forces the data onto the clipboard in its various formats
|
||||
* This may be used if the application going away.
|
||||
*
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
|
||||
void forceDataToClipboard ( ) ;
|
||||
void forceDataToClipboard ( in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
* This provides a way to give correct UI feedback about, for instance, a paste
|
||||
@ -75,11 +83,20 @@ interface nsIClipboard : nsISupports
|
||||
* any of the flavors in the given list.
|
||||
*
|
||||
* @aFlavorList - nsISupportsString's in a nsISupportsArray (for JavaScript).
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @outResult - if data is present matching one of
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
boolean hasDataMatchingFlavors ( in nsISupportsArray aFlavorList ) ;
|
||||
|
||||
boolean hasDataMatchingFlavors ( in nsISupportsArray aFlavorList, in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
* Allows clients to determine if the implementation supports the concept of a
|
||||
* separate clipboard for selection.
|
||||
*
|
||||
* @outResult - true if
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
boolean supportsSelectionClipboard ( ) ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -73,8 +73,11 @@ nsClipboard::~nsClipboard()
|
||||
// do it on an app switch.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsClipboard :: SetNativeClipboardData()
|
||||
nsClipboard :: SetNativeClipboardData ( PRInt32 aWhichClipboard )
|
||||
{
|
||||
if ( aWhichClipboard != kGlobalClipboard )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult errCode = NS_OK;
|
||||
|
||||
mIgnoreEmptyNotification = PR_TRUE;
|
||||
@ -189,8 +192,11 @@ nsClipboard :: SetNativeClipboardData()
|
||||
// Take data off the native clip and put it on the transferable.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsClipboard :: GetNativeClipboardData(nsITransferable * aTransferable)
|
||||
nsClipboard :: GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 aWhichClipboard )
|
||||
{
|
||||
if ( aWhichClipboard != kGlobalClipboard )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult errCode = NS_OK;
|
||||
|
||||
// make sure we have a good transferable
|
||||
@ -362,9 +368,11 @@ nsClipboard :: GetDataOffClipboard ( ResType inMacFlavor, void** outData, PRInt3
|
||||
// pull the data off the clipboard.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsClipboard :: HasDataMatchingFlavors ( nsISupportsArray* aFlavorList, PRBool * outResult )
|
||||
nsClipboard :: HasDataMatchingFlavors ( nsISupportsArray* aFlavorList, PRInt32 aWhichClipboard, PRBool * outResult )
|
||||
{
|
||||
*outResult = PR_FALSE; // assume there is nothing there we want.
|
||||
if ( aWhichClipboard != kGlobalClipboard )
|
||||
return NS_OK;
|
||||
|
||||
// create a mime mapper. It's ok for this to fail because the data may come from
|
||||
// another app which obviously wouldn't put our mime mapping data on the clipboard.
|
||||
|
@ -47,13 +47,13 @@ public:
|
||||
|
||||
// nsIClipboard
|
||||
//NS_IMETHOD ForceDataToClipboard();
|
||||
NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRBool *_retval);
|
||||
NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, PRBool *_retval);
|
||||
|
||||
protected:
|
||||
|
||||
// impelement the native clipboard behavior
|
||||
NS_IMETHOD SetNativeClipboardData();
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable);
|
||||
NS_IMETHOD SetNativeClipboardData ( PRInt32 aWhichClipboard );
|
||||
NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 aWhichClipboard );
|
||||
|
||||
// helper to get the data off the clipboard. Caller responsible for deleting
|
||||
// |outData| with delete[].
|
||||
|
@ -57,7 +57,8 @@ nsBaseClipboard::nsBaseClipboard()
|
||||
//-------------------------------------------------------------------------
|
||||
nsBaseClipboard::~nsBaseClipboard()
|
||||
{
|
||||
EmptyClipboard();
|
||||
EmptyClipboard(kSelectionClipboard);
|
||||
EmptyClipboard(kGlobalClipboard);
|
||||
}
|
||||
|
||||
|
||||
@ -65,13 +66,14 @@ nsBaseClipboard::~nsBaseClipboard()
|
||||
* Sets the transferable object
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipboardOwner * anOwner)
|
||||
NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipboardOwner * anOwner,
|
||||
PRInt32 aWhichClipboard)
|
||||
{
|
||||
if (aTransferable == mTransferable && anOwner == mClipboardOwner) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EmptyClipboard();
|
||||
EmptyClipboard(aWhichClipboard);
|
||||
|
||||
mClipboardOwner = anOwner;
|
||||
if (nsnull != anOwner) {
|
||||
@ -84,7 +86,7 @@ NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipb
|
||||
|
||||
if (nsnull != mTransferable) {
|
||||
NS_ADDREF(mTransferable);
|
||||
rv = SetNativeClipboardData();
|
||||
rv = SetNativeClipboardData(aWhichClipboard);
|
||||
} else {
|
||||
printf(" nsBaseClipboard::SetData(), aTransferable is NULL.\n");
|
||||
}
|
||||
@ -96,10 +98,10 @@ NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipb
|
||||
* Gets the transferable object
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsBaseClipboard::GetData(nsITransferable * aTransferable)
|
||||
NS_IMETHODIMP nsBaseClipboard::GetData(nsITransferable * aTransferable, PRInt32 aWhichClipboard)
|
||||
{
|
||||
if (nsnull != aTransferable) {
|
||||
return GetNativeClipboardData(aTransferable);
|
||||
return GetNativeClipboardData(aTransferable, aWhichClipboard);
|
||||
} else {
|
||||
printf(" nsBaseClipboard::GetData(), aTransferable is NULL.\n");
|
||||
}
|
||||
@ -112,7 +114,7 @@ NS_IMETHODIMP nsBaseClipboard::GetData(nsITransferable * aTransferable)
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsBaseClipboard::EmptyClipboard()
|
||||
NS_IMETHODIMP nsBaseClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
|
||||
{
|
||||
if (mIgnoreEmptyNotification) {
|
||||
return NS_OK;
|
||||
@ -135,15 +137,23 @@ NS_IMETHODIMP nsBaseClipboard::EmptyClipboard()
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsBaseClipboard::ForceDataToClipboard()
|
||||
NS_IMETHODIMP nsBaseClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseClipboard :: HasDataMatchingFlavors ( nsISupportsArray* aFlavorList, PRBool * outResult )
|
||||
nsBaseClipboard :: HasDataMatchingFlavors ( nsISupportsArray* aFlavorList, PRInt32 aWhichClipboard, PRBool * outResult )
|
||||
{
|
||||
*outResult = PR_TRUE; // say we always do.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseClipboard :: SupportsSelectionClipboard ( PRBool *_retval )
|
||||
{
|
||||
*_retval = PR_FALSE; // we don't suport the selection clipboard by default.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD SetNativeClipboardData() = 0;
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable) = 0;
|
||||
NS_IMETHOD SetNativeClipboardData ( PRInt32 aWhichClipboard ) = 0;
|
||||
NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 aWhichClipboard ) = 0;
|
||||
|
||||
PRBool mIgnoreEmptyNotification;
|
||||
nsIClipboardOwner * mClipboardOwner;
|
||||
|
@ -900,7 +900,7 @@ int main(int argc, char* argv[])
|
||||
// scoping this in a block to force release
|
||||
NS_WITH_SERVICE(nsIClipboard, clipService, "component://netscape/widget/clipboard", &rv);
|
||||
if ( clipService )
|
||||
clipService->ForceDataToClipboard();
|
||||
clipService->ForceDataToClipboard(nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
|
||||
rv = NS_ShutdownXPCOM( NULL );
|
||||
|
Loading…
Reference in New Issue
Block a user