From a07e05a429d21d576f89ec5a3a4591d6f0f2d36b Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Fri, 5 Jan 2001 23:47:09 +0000 Subject: [PATCH] Submitting patch from MarkH@ActiveState.com to allow multi-file drops from external applications. r=saari/sr=hyatt. bug# 60924 --- widget/src/windows/nsDragService.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/widget/src/windows/nsDragService.cpp b/widget/src/windows/nsDragService.cpp index dd7eed5f8aa..dbcc890c0b9 100644 --- a/widget/src/windows/nsDragService.cpp +++ b/widget/src/windows/nsDragService.cpp @@ -18,6 +18,8 @@ * Rights Reserved. * * Contributor(s): + * Mike Pinkerton (pinkerton@netscape.com) + * Mark Hammond (MarkH@ActiveState.com) */ #include "nsDragService.h" @@ -185,23 +187,34 @@ NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 if ( !mDataObject ) return NS_ERROR_FAILURE; + nsresult dataFound = NS_ERROR_FAILURE; + if ( IsCollectionObject(mDataObject) ) { // multiple items, use |anItem| as an index into our collection nsDataObjCollection * dataObjCol = NS_STATIC_CAST(nsDataObjCollection*, mDataObject); PRUint32 cnt = dataObjCol->GetNumDataObjects(); if (anItem >= 0 && anItem < cnt) { IDataObject * dataObj = dataObjCol->GetDataObjectAt(anItem); - return nsClipboard::GetDataFromDataObject(dataObj, 0, nsnull, aTransferable); + dataFound = nsClipboard::GetDataFromDataObject(dataObj, 0, nsnull, aTransferable); } + else + NS_WARNING ( "Index out of range!" ); } else { - // Since there is only one object, they better be asking for item "0" + // If they are asking for item "0", we can just get it... if (anItem == 0) - return nsClipboard::GetDataFromDataObject(mDataObject, anItem, nsnull, aTransferable); - else - return NS_ERROR_FAILURE; + dataFound = nsClipboard::GetDataFromDataObject(mDataObject, anItem, nsnull, aTransferable); + else { + // It better be a file drop, or else non-zero indexes are invalid! + FORMATETC fe2; + SET_FORMATETC(fe2, CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL); + if ( mDataObject->QueryGetData(&fe2) == S_OK ) + dataFound = nsClipboard::GetDataFromDataObject(mDataObject, anItem, nsnull, aTransferable); + else + NS_WARNING ( "Reqesting non-zero index, but clipboard data is not a collection!" ); + } } - return NS_ERROR_FAILURE; + return dataFound; } //---------------------------------------------------------