mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 09:42:12 +01:00
carbon: report image/bmp format available on clipboard, if any image available
git-svn-id: trunk@25955 -
This commit is contained in:
parent
2a48de77e0
commit
0f2d6c94a9
@ -448,6 +448,7 @@ var
|
|||||||
C: ItemCount;
|
C: ItemCount;
|
||||||
ID: PasteboardItemID;
|
ID: PasteboardItemID;
|
||||||
Formats: TList;
|
Formats: TList;
|
||||||
|
isImageFormat: Boolean;
|
||||||
const
|
const
|
||||||
SName = 'GetFormats';
|
SName = 'GetFormats';
|
||||||
begin
|
begin
|
||||||
@ -460,6 +461,7 @@ begin
|
|||||||
'PasteboardGetItemCount') then Exit;
|
'PasteboardGetItemCount') then Exit;
|
||||||
if C < 1 then Exit;
|
if C < 1 then Exit;
|
||||||
|
|
||||||
|
isImageFormat:=False;
|
||||||
Formats := TList.Create;
|
Formats := TList.Create;
|
||||||
try
|
try
|
||||||
for I := 1 to C do
|
for I := 1 to C do
|
||||||
@ -473,14 +475,15 @@ begin
|
|||||||
for J := 0 to FlavorCount - 1 do
|
for J := 0 to FlavorCount - 1 do
|
||||||
begin
|
begin
|
||||||
UTI := CFArrayGetValueAtIndex(Flavors, J);
|
UTI := CFArrayGetValueAtIndex(Flavors, J);
|
||||||
|
isImageFormat:=isImageFormat or UTTypeConformsTo(UTI, kUTTypePICT);
|
||||||
//DebugLn('TCarbonClipboard.GetFormats ' + CFStringToStr(UTI));
|
//DebugLn('TCarbonClipboard.GetFormats ' + CFStringToStr(UTI));
|
||||||
|
|
||||||
FormatID := FindFormat(UTI);
|
FormatID := FindFormat(UTI);
|
||||||
if FormatID = 0 then
|
if FormatID = 0 then
|
||||||
FormatID := FFormats.Add(UTI);
|
FormatID := FFormats.Add(UTI)
|
||||||
if FormatID < 4 then // if it is text format, add plain text format
|
else
|
||||||
if Formats.IndexOf(Pointer(1)) = -1 then Formats.Add(Pointer(1));
|
// reserved text format!
|
||||||
|
if FormatID < 4 then FormatID:=1;
|
||||||
|
|
||||||
if Formats.IndexOf(Pointer(FormatID)) = -1 then
|
if Formats.IndexOf(Pointer(FormatID)) = -1 then
|
||||||
begin
|
begin
|
||||||
@ -491,6 +494,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if isImageFormat then
|
||||||
|
begin
|
||||||
|
// there's an image format in the clipboard, it can be converted
|
||||||
|
// to Bitmap. Since most of the delphi software is using CF_Bitmap as
|
||||||
|
// a common format, it's necessary to "emulate" bitmap presence!
|
||||||
|
FormatID:=FindFormat(kUTTypeBMP);
|
||||||
|
if (FormatID>0) and (Formats.IndexOf(Pointer(FormatID))=-1) then
|
||||||
|
Formats.Add(Pointer(FormatID));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Count := Formats.Count;
|
Count := Formats.Count;
|
||||||
GetMem(List, Count * SizeOf(TClipboardFormat));
|
GetMem(List, Count * SizeOf(TClipboardFormat));
|
||||||
for I := 0 to Count - 1 do List[i] := TClipboardFormat(Formats[I]);
|
for I := 0 to Count - 1 do List[i] := TClipboardFormat(Formats[I]);
|
||||||
@ -604,6 +618,10 @@ function GetLCLPredefinedUTI(const LCLMimeType: String): CFStringRef;
|
|||||||
begin
|
begin
|
||||||
if (LCLMimeType='image/bmp') or (LCLMimeType='image/delphi.bitmap') then
|
if (LCLMimeType='image/bmp') or (LCLMimeType='image/delphi.bitmap') then
|
||||||
Result:=kUTTypeBMP
|
Result:=kUTTypeBMP
|
||||||
|
else if (LCLMimeType='image/png') then
|
||||||
|
Result:=kUTTypePNG
|
||||||
|
else if (LCLMimeType='image/jpeg') then
|
||||||
|
Result:=kUTTypeJPEG
|
||||||
else
|
else
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user