From 4b0cb3efa11798419a1f55ddf90342785e2d6ecc Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 7 May 1999 14:13:09 +0000 Subject: [PATCH] Added the Equals method --- widget/public/nsIDataFlavor.h | 14 ++++++++++++-- widget/src/xpwidgets/nsDataFlavor.cpp | 20 +++++++------------- widget/src/xpwidgets/nsDataFlavor.h | 14 +++----------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/widget/public/nsIDataFlavor.h b/widget/public/nsIDataFlavor.h index 92b85d9c690..6f28d1c040d 100644 --- a/widget/public/nsIDataFlavor.h +++ b/widget/public/nsIDataFlavor.h @@ -43,6 +43,8 @@ #define kGIFImageMime "image/gif" #define kDropFilesMime "text/dropfiles" +class nsIDataFlavor; + class nsIDataFlavor : public nsISupports { public: @@ -62,14 +64,22 @@ class nsIDataFlavor : public nsISupports { * * @param aMimeStr string to be set */ - NS_IMETHOD GetMimeType(nsString & aMimeStr) = 0; + NS_IMETHOD GetMimeType(nsString & aMimeStr) const = 0; /** * Gets the Human readable version of the mime string * * @param aReadableStr string to be set */ - NS_IMETHOD GetHumanPresentableName(nsString & aReadableStr) = 0; + NS_IMETHOD GetHumanPresentableName(nsString & aReadableStr) const = 0; + + /** + * Check to see if aDataFlavor's Mime type is the same + * + * @param aDataFlavor flavor to check + * @returns NS_OK if the Mime Type string are identical otherwise, it returns NS_ERROR_FAILURE + */ + NS_IMETHOD Equals(const nsIDataFlavor * aDataFlavor) = 0; }; diff --git a/widget/src/xpwidgets/nsDataFlavor.cpp b/widget/src/xpwidgets/nsDataFlavor.cpp index d426baf3c14..7a5ea49feab 100644 --- a/widget/src/xpwidgets/nsDataFlavor.cpp +++ b/widget/src/xpwidgets/nsDataFlavor.cpp @@ -86,7 +86,7 @@ NS_METHOD nsDataFlavor::Init(const nsString & aMimeType, const nsString & aHuman * * */ -NS_METHOD nsDataFlavor::GetMimeType(nsString & aMimeStr) +NS_METHOD nsDataFlavor::GetMimeType(nsString & aMimeStr) const { aMimeStr = mMimeType; return NS_OK; @@ -96,7 +96,7 @@ NS_METHOD nsDataFlavor::GetMimeType(nsString & aMimeStr) * * */ -NS_METHOD nsDataFlavor::GetHumanPresentableName(nsString & aHumanPresentableName) +NS_METHOD nsDataFlavor::GetHumanPresentableName(nsString & aHumanPresentableName) const { aHumanPresentableName = mHumanPresentableName; return NS_OK; @@ -106,17 +106,11 @@ NS_METHOD nsDataFlavor::GetHumanPresentableName(nsString & aHumanPresentableName * * */ -NS_METHOD nsDataFlavor::GetNativeData(void ** aData) +NS_METHOD nsDataFlavor::Equals(const nsIDataFlavor * aDataFlavor) { - return NS_OK; -} - -/** - * - * - */ -NS_METHOD nsDataFlavor::SetNativeData(void * aData) -{ - return NS_OK; + nsString mimeInQues; + aDataFlavor->GetMimeType(mimeInQues); + + return (mMimeType.Equals(mimeInQues)?NS_OK:NS_ERROR_FAILURE); } diff --git a/widget/src/xpwidgets/nsDataFlavor.h b/widget/src/xpwidgets/nsDataFlavor.h index 36ef462bc06..8f83dfcd1d8 100644 --- a/widget/src/xpwidgets/nsDataFlavor.h +++ b/widget/src/xpwidgets/nsDataFlavor.h @@ -41,22 +41,14 @@ public: //nsIDataFlavor NS_IMETHOD Init(const nsString & aMimeType, const nsString & aHumanPresentableName); - NS_IMETHOD GetMimeType(nsString & aMimeStr); - NS_IMETHOD GetHumanPresentableName(nsString & aReadableStr); - - NS_IMETHOD GetNativeData(void ** aData); - NS_IMETHOD SetNativeData(void * aData); - - - // Native Methods - PRUint32 GetFormat() { return mNativeClipboardFormat; } + NS_IMETHOD GetMimeType(nsString & aMimeStr) const; + NS_IMETHOD GetHumanPresentableName(nsString & aReadableStr) const; + NS_IMETHOD Equals(const nsIDataFlavor * aDataFlavor); protected: nsString mMimeType; nsString mHumanPresentableName; - PRUint32 mNativeClipboardFormat; - }; #endif // nsDataFlavor_h__