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