From a3a8f77f463929f1a61b4326ae64fa0a4338bc98 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Thu, 1 Apr 1999 14:40:52 +0000 Subject: [PATCH] Updated clipboard support to use converters --- widget/src/windows/nsClipboard.cpp | 39 +++++++++++++++++++++++++++++- widget/src/windows/nsClipboard.h | 5 ---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/widget/src/windows/nsClipboard.cpp b/widget/src/windows/nsClipboard.cpp index ffed75a33251..c07322755f01 100644 --- a/widget/src/windows/nsClipboard.cpp +++ b/widget/src/windows/nsClipboard.cpp @@ -24,6 +24,7 @@ #include "nsISupportsArray.h" #include "nsIClipboardOwner.h" #include "nsIDataFlavor.h" +#include "nsIFormatConverter.h" #include "nsIWidget.h" #include "nsIComponentManager.h" @@ -156,7 +157,8 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData() // for getting the data out of it mDataObj->SetTransferable(mTransferable); - // Walk through flavors and register them on the native clipboard, + // Walk through flavors that contain data and register them + // into the DataObj as supported flavors PRUint32 i; for (i=0;iCount();i++) { nsIDataFlavor * df; @@ -176,6 +178,41 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData() } NS_RELEASE(supports); } + // Delete the data flavors list + NS_RELEASE(dfList); + + // Now check to see if there is a converter for the transferable + // and then register any of it's output formats + // Get the transferable list of data flavors + nsIFormatConverter * converter; + mTransferable->GetConverter(&converter); + if (nsnull != converter) { + // Get list of output flavors + converter->GetOutputDataFlavors(&dfList); + if (nsnull != dfList) { + for (i=0;iCount();i++) { + nsIDataFlavor * df; + nsISupports * supports = dfList->ElementAt(i); + if (NS_OK == supports->QueryInterface(kIDataFlavorIID, (void **)&df)) { + nsString mime; + df->GetMimeType(mime); + UINT format = GetFormat(mime); + + FORMATETC fe; + SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, 0, TYMED_HGLOBAL); + + // Now tell the native IDataObject about both the DataFlavor and + // the native data format + mDataObj->AddDataFlavor(df, &fe); + NS_RELEASE(df); + } + NS_RELEASE(supports); + } + NS_RELEASE(dfList); + } + NS_RELEASE(converter); + } + // cast our native DataObject to its IDataObject pointer // and put it on the clipboard diff --git a/widget/src/windows/nsClipboard.h b/widget/src/windows/nsClipboard.h index 78527cd2d8e2..7e1c11637325 100644 --- a/widget/src/windows/nsClipboard.h +++ b/widget/src/windows/nsClipboard.h @@ -49,12 +49,7 @@ protected: NS_IMETHOD SetNativeClipboardData(); NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable); - PRBool mIgnoreEmptyNotification; - - nsIClipboardOwner * mClipboardOwner; - nsITransferable * mTransferable; nsIWidget * mWindow; - nsDataObj * mDataObj; };