In the case under discussion the bit of code I provided takes a pathname for a file as the OS shows it and passes it to the 'ConvertToURL()' method which returns the correct file-URL. The replacement of spaces by "%20" is part of the conversion.
(Of course, I also never create folders or files with spaces or other non-name characters in their names. However, Win has such a space even in "Program Files" where I cannot change it. Not to blame Win unjustly: If I remember correctly, the nonsense originated in the UNIX world decades ago.)
BTW @Villeroy: Do you know what is necessary to tell 'StarDesktop.LoadComponentFromURL()' that it should open a plain text file with any extension (in this case "xml") with Writer in
AOO. I tried the argument
Code: Select all
args(0).Name = "FilterName"
args(0).Value = "swriter"
(also slightly modified in different ways, "swriter:Text" e.g.) but did not succeed. AOO returns the intended document object as 'Null'. LibO opens the file as intended also without additional precautions, but accepts the argument described above.
=== Editing 2018-06-27 ===
In LibO the above shown argument definition (as well as similar ones) is simply ignored.
In AOO 4.1.5 neither the above shown attempt nor settings as descibed in Andrew Pitonyaks "Macro Document" nor the "generic_Text" as the value for a
FilterName argument suggested by Villeroy in his post below worked for me. The simple
FilterName-value "Text" did.
Of course this only helps to load a file with extension ".xml" (e.g.) with
Writer, and not to parse it for data based on the Xpath syntax as the FILTERXML() function of LibO does. I won't try to write user code based on the XXPathAPI interface to implement a similar function for AOO. (It should be possible, however.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München