Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsClipboard_h__ |
michael@0 | 7 | #define nsClipboard_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsBaseClipboard.h" |
michael@0 | 10 | #include "nsIURI.h" |
michael@0 | 11 | #include <windows.h> |
michael@0 | 12 | |
michael@0 | 13 | class nsITransferable; |
michael@0 | 14 | class nsIClipboardOwner; |
michael@0 | 15 | class nsIWidget; |
michael@0 | 16 | class nsIFile; |
michael@0 | 17 | struct IDataObject; |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * Native Win32 Clipboard wrapper |
michael@0 | 21 | */ |
michael@0 | 22 | |
michael@0 | 23 | class nsClipboard : public nsBaseClipboard, |
michael@0 | 24 | public nsIObserver |
michael@0 | 25 | { |
michael@0 | 26 | |
michael@0 | 27 | public: |
michael@0 | 28 | nsClipboard(); |
michael@0 | 29 | virtual ~nsClipboard(); |
michael@0 | 30 | |
michael@0 | 31 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 32 | |
michael@0 | 33 | // nsIObserver |
michael@0 | 34 | NS_DECL_NSIOBSERVER |
michael@0 | 35 | |
michael@0 | 36 | // nsIClipboard |
michael@0 | 37 | NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength, |
michael@0 | 38 | int32_t aWhichClipboard, bool *_retval); |
michael@0 | 39 | NS_IMETHOD EmptyClipboard(int32_t aWhichClipboard); |
michael@0 | 40 | |
michael@0 | 41 | // Internal Native Routines |
michael@0 | 42 | static nsresult CreateNativeDataObject(nsITransferable * aTransferable, |
michael@0 | 43 | IDataObject ** aDataObj, |
michael@0 | 44 | nsIURI * uri); |
michael@0 | 45 | static nsresult SetupNativeDataObject(nsITransferable * aTransferable, |
michael@0 | 46 | IDataObject * aDataObj); |
michael@0 | 47 | static nsresult GetDataFromDataObject(IDataObject * aDataObject, |
michael@0 | 48 | UINT anIndex, |
michael@0 | 49 | nsIWidget * aWindow, |
michael@0 | 50 | nsITransferable * aTransferable); |
michael@0 | 51 | static nsresult GetNativeDataOffClipboard(nsIWidget * aWindow, UINT aIndex, UINT aFormat, void ** aData, uint32_t * aLen); |
michael@0 | 52 | static nsresult GetNativeDataOffClipboard(IDataObject * aDataObject, UINT aIndex, UINT aFormat, const char * aMIMEImageFormat, void ** aData, uint32_t * aLen); |
michael@0 | 53 | static nsresult GetGlobalData(HGLOBAL aHGBL, void ** aData, uint32_t * aLen); |
michael@0 | 54 | static UINT GetFormat(const char* aMimeStr); |
michael@0 | 55 | |
michael@0 | 56 | static UINT CF_HTML; |
michael@0 | 57 | |
michael@0 | 58 | protected: |
michael@0 | 59 | NS_IMETHOD SetNativeClipboardData ( int32_t aWhichClipboard ); |
michael@0 | 60 | NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, int32_t aWhichClipboard ); |
michael@0 | 61 | |
michael@0 | 62 | static bool IsInternetShortcut ( const nsAString& inFileName ) ; |
michael@0 | 63 | static bool FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, void** outData, uint32_t* outDataLen ) ; |
michael@0 | 64 | static bool FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, void** outData, uint32_t* outDataLen ) ; |
michael@0 | 65 | static bool FindUnicodeFromPlainText ( IDataObject* inDataObject, UINT inIndex, void** outData, uint32_t* outDataLen ) ; |
michael@0 | 66 | static bool FindPlatformHTML ( IDataObject* inDataObject, UINT inIndex, void** outData, uint32_t* outDataLen ); |
michael@0 | 67 | static void ResolveShortcut ( nsIFile* inFileName, nsACString& outURL ) ; |
michael@0 | 68 | |
michael@0 | 69 | nsIWidget * mWindow; |
michael@0 | 70 | |
michael@0 | 71 | }; |
michael@0 | 72 | |
michael@0 | 73 | #define SET_FORMATETC(fe, cf, td, asp, li, med) \ |
michael@0 | 74 | {\ |
michael@0 | 75 | (fe).cfFormat=cf;\ |
michael@0 | 76 | (fe).ptd=td;\ |
michael@0 | 77 | (fe).dwAspect=asp;\ |
michael@0 | 78 | (fe).lindex=li;\ |
michael@0 | 79 | (fe).tymed=med;\ |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | |
michael@0 | 83 | #endif // nsClipboard_h__ |
michael@0 | 84 |