cocoa: updating OpenDocument api to handle URLs as well (similar to Win32)

git-svn-id: trunk@61175 -
This commit is contained in:
dmitry 2019-05-07 21:03:26 +00:00
parent 7bee5358e4
commit 17928418c1

View File

@ -21,10 +21,13 @@ var
begin
Result := False;
if AURL = '' then
Exit(False);
url := NSURL.URLWithString(NSStr(@AURL[1]));
if not Assigned(url) then
Exit(False);
Exit;
url := NSURL.URLWithString(NSString.stringWithUTF8String(@AURL[1]));
// scheme is checking for "protocol" specifier.
// if no protocol specifier exist - do not consider it as URL and fail
if not Assigned(url) or (url.scheme.length = 0) then
Exit;
ws := NSWorkspace.sharedWorkspace;
Result := ws.openURL(url);
end;
@ -33,9 +36,14 @@ end;
function OpenDocument(APath: String): Boolean;
var
ResultingPath: string;
lpath: string;
begin
Result := True;
if not FileExistsUTF8(APath) then exit(false);
if not FileExistsUTF8(APath) then begin
// Windows OpenDocument handles URLs as well
Result := OpenURL(Apath);
Exit;
end;
// Paths with spaces need to be quoted, see bug 21651
if (APath<>'') and (APath[1]<>'''') then
ResultingPath:=QuotedStr(APath)