use new transferable interfaces that were previously in here as placeholders.

This commit is contained in:
pinkerton%netscape.com 1999-04-02 18:22:59 +00:00
Родитель 2a1b764154
Коммит 5d2f11bfc1
2 изменённых файлов: 6 добавлений и 81 удалений

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

@ -22,6 +22,10 @@
//
// See header file for details.
//
// Remaining Work:
// * only convert data to clipboard on an app switch.
// * better mime type --> OS type conversion needed. Only a few formats supported now.
//
#include "nsCOMPtr.h"
#include "nsClipboard.h"
@ -40,21 +44,16 @@
NS_IMPL_ADDREF_INHERITED(nsClipboard, nsBaseClipboard)
NS_IMPL_RELEASE_INHERITED(nsClipboard, nsBaseClipboard)
//-------------------------------------------------------------------------
//
// nsClipboard constructor
//
//-------------------------------------------------------------------------
nsClipboard::nsClipboard() : nsBaseClipboard()
{
}
//-------------------------------------------------------------------------
//
// nsClipboard destructor
//
//-------------------------------------------------------------------------
nsClipboard::~nsClipboard()
{
}
@ -125,74 +124,6 @@ nsClipboard :: MapMimeTypeToMacOSType ( const nsString & aMimeStr )
} // MapMimeTypeToMacOSType
//
// FlavorsTransferableCanImport
//
// Computes a list of flavors that the transferable can accept into it, either through
// intrinsic knowledge or input data converters.
//
nsresult
nsClipboard :: FlavorsTransferableCanImport ( nsITransferable* aTransferable, nsISupportsArray** outFlavorList )
{
if ( !aTransferable || !outFlavorList )
return NS_ERROR_INVALID_ARG;
// Get the flavor list, and on to the end of it, append the list of flavors we
// can also get to through a converter. This is so that we can just walk the list
// in one go, looking for the desired flavor.
aTransferable->GetTransferDataFlavors(outFlavorList); // addrefs
nsCOMPtr<nsIFormatConverter> converter;
aTransferable->GetConverter(getter_AddRefs(converter));
if ( converter ) {
nsCOMPtr<nsISupportsArray> convertedList;
converter->GetInputDataFlavors(getter_AddRefs(convertedList));
if ( convertedList ) {
for (int i=0;i<convertedList->Count();i++) {
nsCOMPtr<nsISupports> temp = getter_AddRefs(convertedList->ElementAt(i));
(*outFlavorList)->AppendElement(temp); // this addref's for us
} // foreach flavor that can be converted to
}
} // if a converter exists
return NS_OK;
} // FlavorsTransferableCanImport
//
// FlavorsTransferableCanExport
//
// Computes a list of flavors that the transferable can export, either through
// intrinsic knowledge or output data converters.
//
nsresult
nsClipboard :: FlavorsTransferableCanExport ( nsITransferable* aTransferable, nsISupportsArray** outFlavorList )
{
if ( !aTransferable || !outFlavorList )
return NS_ERROR_INVALID_ARG;
// Get the flavor list, and on to the end of it, append the list of flavors we
// can also get to through a converter. This is so that we can just walk the list
// in one go, looking for the desired flavor.
aTransferable->GetTransferDataFlavors(outFlavorList); // addrefs
nsCOMPtr<nsIFormatConverter> converter;
aTransferable->GetConverter(getter_AddRefs(converter));
if ( converter ) {
nsCOMPtr<nsISupportsArray> convertedList;
converter->GetOutputDataFlavors(getter_AddRefs(convertedList));
if ( convertedList ) {
for (int i=0;i<convertedList->Count();i++) {
nsCOMPtr<nsISupports> temp = getter_AddRefs(convertedList->ElementAt(i));
(*outFlavorList)->AppendElement(temp); // this addref's for us
} // foreach flavor that can be converted to
}
} // if a converter exists
return NS_OK;
} // FlavorsTransferableCanImport
//
// SetNativeClipboardData
//
@ -219,7 +150,7 @@ nsClipboard :: SetNativeClipboardData()
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
errCode = FlavorsTransferableCanExport ( mTransferable, getter_AddRefs(flavorList) );
errCode = mTransferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) );
if ( errCode != NS_OK )
return NS_ERROR_FAILURE;
@ -257,7 +188,6 @@ nsClipboard :: SetNativeClipboardData()
} // SetNativeClipboardData
//
// GetNativeClipboardData
//
@ -275,7 +205,7 @@ nsClipboard :: GetNativeClipboardData(nsITransferable * aTransferable)
// get flavor list that includes all acceptable flavors (including ones obtained through
// conversion)
nsCOMPtr<nsISupportsArray> flavorList;
errCode = FlavorsTransferableCanImport ( aTransferable, getter_AddRefs(flavorList) );
errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) );
if ( errCode != NS_OK )
return NS_ERROR_FAILURE;

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

@ -53,11 +53,6 @@ protected:
static ResType MapMimeTypeToMacOSType ( const nsString & aMimeStr ) ;
// Utility routines. Closure of intrinsic flavors + those obtainable through conversion
// XXX Move into the transferable with permission
nsresult FlavorsTransferableCanImport ( nsITransferable* aTrans, nsISupportsArray** outFlavorList ) ;
nsresult FlavorsTransferableCanExport ( nsITransferable* aTrans, nsISupportsArray** outFlavorList ) ;
}; // nsClipboard
#endif // nsClipboard_h__