mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 23:00:27 +02:00
Cocoa: normalize NSPasteboardType
This commit is contained in:
parent
b55c816aa8
commit
1efcbc5377
@ -42,6 +42,20 @@ const // NSImageScaling values
|
||||
NSImageScaleNone = 2;
|
||||
NSImageScaleProportionallyUpOrDown = 3;
|
||||
|
||||
type
|
||||
NSPasteboardType = NSString;
|
||||
var
|
||||
NSPasteboardTypeString: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypePNG: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeTIFF: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypePDF: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeHTML: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeRTF: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeColor: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeFont: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeRuler: NSPasteboardType; cvar; external;
|
||||
NSPasteboardTypeSound: NSPasteboardType; cvar; external;
|
||||
|
||||
type
|
||||
NSMenuFix = objccategory external (NSMenu)
|
||||
function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:';
|
||||
|
@ -24,7 +24,7 @@ uses
|
||||
// fcl-image
|
||||
,fpreadpng, fpwritepng, fpimage, fpreadbmp, fpwritebmp
|
||||
,LCLType
|
||||
,CocoaUtils;
|
||||
,CocoaUtils, Cocoa_Extra;
|
||||
|
||||
type
|
||||
TCocoaClipboardDataType = (ccdtText,
|
||||
@ -81,22 +81,8 @@ type
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
// these constants are available starting MacOSX 10.6
|
||||
// thus for earlier systems must be redeclared
|
||||
_NSPasteboardTypeString : NSString = nil;
|
||||
_NSPasteboardTypePNG : NSString = nil;
|
||||
_NSPasteboardTypeTiff : NSString = nil;
|
||||
|
||||
implementation
|
||||
|
||||
procedure InitConst;
|
||||
begin
|
||||
_NSPasteboardTypeString := NSSTR('public.utf8-plain-text');
|
||||
_NSPasteboardTypePNG := NSSTR('public.png');
|
||||
_NSPasteboardTypeTiff := NSSTR('public.tiff');
|
||||
end;
|
||||
|
||||
{ TCocoaWSClipboard }
|
||||
|
||||
constructor TCocoaWSClipboard.Create;
|
||||
@ -433,20 +419,17 @@ begin
|
||||
case AMimeType of
|
||||
'text/plain':
|
||||
begin
|
||||
//hack: the name of constants is a hack
|
||||
// should be replaced with either weaklinking
|
||||
// or dynamic loading (dlsym)
|
||||
lNSStr := NSSTR('public.utf8-plain-text'); // NSPasteboardTypeString; // commented out for OSX < 10.6 see #33672
|
||||
lNSStr := NSPasteboardTypeString;
|
||||
lDataType := ccdtText;
|
||||
end;
|
||||
'image/png':
|
||||
begin
|
||||
lNSStr := NSSTR('public.png'); // NSPasteboardTypePNG
|
||||
lNSStr := NSPasteboardTypePNG;
|
||||
lDataType := ccdtCocoaStandard;
|
||||
end;
|
||||
'image/bmp':
|
||||
begin
|
||||
lNSStr := NSSTR('public.png'); // NSPasteboardTypePNG
|
||||
lNSStr := NSPasteboardTypePNG;
|
||||
lDataType := ccdtBitmap;
|
||||
end;
|
||||
else
|
||||
@ -470,7 +453,7 @@ end;
|
||||
function TCocoaWSClipboard.CocoaTypeToMimeType(AType: NSString): string;
|
||||
begin
|
||||
// "default" types must be mapped to a default LCL mime-type
|
||||
if AType.isEqualToString(_NSPasteboardTypeString) then
|
||||
if AType.isEqualToString(NSPasteboardTypeString) then
|
||||
Result := 'text/plain'
|
||||
else
|
||||
Result := NSStringToString(AType);
|
||||
@ -490,8 +473,4 @@ begin
|
||||
CocoaFormat.release;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
InitConst;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user