2006-10-03 00:28:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-10-03 00:28:40 +04:00
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#ifndef nsClipboard_h_
|
|
|
|
#define nsClipboard_h_
|
2006-10-03 00:28:40 +04:00
|
|
|
|
2016-08-11 23:43:32 +03:00
|
|
|
#include "nsIClipboard.h"
|
2017-08-17 08:29:03 +03:00
|
|
|
#include "nsString.h"
|
2016-07-08 18:21:43 +03:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2006-10-03 00:28:40 +04:00
|
|
|
|
2007-06-27 09:26:18 +04:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2006-10-03 00:28:40 +04:00
|
|
|
class nsITransferable;
|
|
|
|
|
2017-05-23 07:23:38 +03:00
|
|
|
@interface UTIHelper : NSObject
|
|
|
|
+ (NSString*)stringFromPboardType:(NSString*)aType;
|
|
|
|
@end
|
|
|
|
|
2016-08-11 23:43:32 +03:00
|
|
|
class nsClipboard : public nsIClipboard {
|
2006-10-03 00:28:40 +04:00
|
|
|
public:
|
|
|
|
nsClipboard();
|
|
|
|
|
2016-08-11 23:43:32 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICLIPBOARD
|
2006-10-03 00:28:40 +04:00
|
|
|
|
2016-07-08 18:21:43 +03:00
|
|
|
// On macOS, cache the transferable of the current selection (chrome/content)
|
|
|
|
// in the parent process. This is needed for the services menu which
|
|
|
|
// requires synchronous access to the current selection.
|
|
|
|
static mozilla::StaticRefPtr<nsITransferable> sSelectionCache;
|
|
|
|
|
2007-06-27 09:26:18 +04:00
|
|
|
// Helper methods, used also by nsDragService
|
|
|
|
static NSDictionary* PasteboardDictFromTransferable(nsITransferable* aTransferable);
|
2017-05-23 07:23:38 +03:00
|
|
|
// aPasteboardType is being retained and needs to be released by the caller.
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsStringType(const nsCString& aMIMEType, NSString** aPasteboardType);
|
2009-01-01 17:26:16 +03:00
|
|
|
static NSString* WrapHtmlForSystemPasteboard(NSString* aString);
|
2010-01-11 04:45:45 +03:00
|
|
|
static nsresult TransferableFromPasteboard(nsITransferable* aTransferable, NSPasteboard* pboard);
|
2006-10-03 00:28:40 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// impelement the native clipboard behavior
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD SetNativeClipboardData(int32_t aWhichClipboard);
|
|
|
|
NS_IMETHOD GetNativeClipboardData(nsITransferable* aTransferable, int32_t aWhichClipboard);
|
2016-06-08 21:11:39 +03:00
|
|
|
void ClearSelectionCache();
|
2016-07-08 18:21:43 +03:00
|
|
|
void SetSelectionCache(nsITransferable* aTransferable);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-07-03 11:16:19 +04:00
|
|
|
private:
|
2016-08-11 23:43:32 +03:00
|
|
|
virtual ~nsClipboard();
|
2014-06-26 05:29:50 +04:00
|
|
|
int32_t mCachedClipboard;
|
|
|
|
int32_t mChangeCount; // Set to the native change count after any modification of the clipboard.
|
2016-08-11 23:43:32 +03:00
|
|
|
|
|
|
|
bool mIgnoreEmptyNotification;
|
|
|
|
nsCOMPtr<nsIClipboardOwner> mClipboardOwner;
|
|
|
|
nsCOMPtr<nsITransferable> mTransferable;
|
2006-10-03 00:28:40 +04:00
|
|
|
};
|
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#endif // nsClipboard_h_
|