Bug 134896 - No documentation about proper conversion of system file names into URLs in Calc
Summary: No documentation about proper conversion of system file names into URLs in Calc
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-17 09:56 UTC by Mike Kaganski
Modified: 2021-01-11 07:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2020-07-17 09:56:59 UTC
There is HYPERLINK function in Calc, that is documented [1] [2] to take URL/IRI. There's also ENCODEURL [3] to properly URL-encode various strings. Yet, the latter function is not enough to convert random system filepath into proper file: URL on all platforms. E.g., on Windows, the conversion also includes replacing backslashes '\' with forward-slashes '/'. A naive attempt to concatenate "file://" with "c:\path to\file.ext" would result in invalid URL; also concatenating "file://" with ENCODEURL("c:\path to\file.ext") is not correct.

But in fact, LibreOffice does the magic of proper conversion of system filepaths into URLs: clicking on a cell with

> =HYPERLINK("c:\path to\file.ext")

would result in attempt to open proper "file:///c:/path%20to/file.ext". The magic happens in ScGlobal::OpenURL calling ScGlobal::GetAbsDocName.

I suppose it's worth mentioning that on HYPERLINK help page, to avoid users trying to create file URLs in various wrong ways.

Refs: https://ask.libreoffice.org/en/question/255719/, https://ask.libreoffice.org/en/question/142052/

[1] https://help.libreoffice.org/6.4/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id9959410
[2] docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#__RefHeading__1018226_715980110
[3] https://help.libreoffice.org/6.4/en-US/text/scalc/01/func_webservice.html?DbPAR=CALC#bm_id811517136840444