diff --git a/lcl/interfaces/cocoa/cocoa_extra.pas b/lcl/interfaces/cocoa/cocoa_extra.pas index 0942d80b69..1bae1b467e 100644 --- a/lcl/interfaces/cocoa/cocoa_extra.pas +++ b/lcl/interfaces/cocoa/cocoa_extra.pas @@ -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:'; diff --git a/lcl/interfaces/cocoa/cocoawsclipboard.pas b/lcl/interfaces/cocoa/cocoawsclipboard.pas index b47813d698..f131c48244 100644 --- a/lcl/interfaces/cocoa/cocoawsclipboard.pas +++ b/lcl/interfaces/cocoa/cocoawsclipboard.pas @@ -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.