CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / windows / nsClipboard.h
blobd58c5c88301e29a75e5f0f2f1d3a468a4e7aefe9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsClipboard_h__
39 #define nsClipboard_h__
41 #include "nsBaseClipboard.h"
42 #include "nsIURI.h"
43 #include <windows.h>
45 class nsITransferable;
46 class nsIClipboardOwner;
47 class nsIWidget;
48 class nsILocalFile;
49 struct IDataObject;
51 /**
52 * Native Win32 Clipboard wrapper
55 class nsClipboard : public nsBaseClipboard
58 public:
59 nsClipboard();
60 virtual ~nsClipboard();
62 // nsIClipboard
63 NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength,
64 PRInt32 aWhichClipboard, PRBool *_retval);
66 // Internal Native Routines
67 static nsresult CreateNativeDataObject(nsITransferable * aTransferable,
68 IDataObject ** aDataObj,
69 nsIURI * uri);
70 static nsresult SetupNativeDataObject(nsITransferable * aTransferable,
71 IDataObject * aDataObj);
72 static nsresult GetDataFromDataObject(IDataObject * aDataObject,
73 UINT anIndex,
74 nsIWidget * aWindow,
75 nsITransferable * aTransferable);
76 static nsresult GetNativeDataOffClipboard(nsIWidget * aWindow, UINT aIndex, UINT aFormat, void ** aData, PRUint32 * aLen);
77 static nsresult GetNativeDataOffClipboard(IDataObject * aDataObject, UINT aIndex, UINT aFormat, const char * aMIMEImageFormat, void ** aData, PRUint32 * aLen);
78 static nsresult GetGlobalData(HGLOBAL aHGBL, void ** aData, PRUint32 * aLen);
79 static UINT GetFormat(const char* aMimeStr);
81 static UINT CF_HTML;
83 protected:
84 NS_IMETHOD SetNativeClipboardData ( PRInt32 aWhichClipboard );
85 NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 aWhichClipboard );
87 static PRBool IsInternetShortcut ( const nsAString& inFileName ) ;
88 static PRBool FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen ) ;
89 static PRBool FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen ) ;
90 static PRBool FindUnicodeFromPlainText ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen ) ;
91 static PRBool FindPlatformHTML ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen );
92 static void ResolveShortcut ( nsILocalFile* inFileName, nsACString& outURL ) ;
94 nsIWidget * mWindow;
98 #define SET_FORMATETC(fe, cf, td, asp, li, med) \
100 (fe).cfFormat=cf;\
101 (fe).ptd=td;\
102 (fe).dwAspect=asp;\
103 (fe).lindex=li;\
104 (fe).tymed=med;\
108 #endif // nsClipboard_h__