Apache OpenOffice (AOO) Bugzilla – Issue 20964
xStorable.storeAsURL has problems with relative URL
Last modified: 2017-05-20 11:27:28 UTC
Code snipplet from SDK test framework "OfficeDocHelper.java": XStorable xStorable = null; xStorable = (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(com.sun.star.frame.XStorable.class, xComponent); if(xStorable == null) throw new Exception("com.sun.star.frame.XStorable could not be instantiated from the office."); PropertyValue pvFilterName = new PropertyValue("FilterName", -1, exportFilter, com.sun.star.beans.PropertyState.getDefault()); PropertyValue pvOverwrite = new PropertyValue("Overwrite", -1, new Boolean(true), com.sun.star.beans.PropertyState.getDefault()); xStorable.storeAsURL(resultURL, new PropertyValue[]{pvFilterName, pvOverwrite}); System.out.println("Saving XComponent as " + resultURL); Saving the results into the following URL file:///D:/sdk/m8-1/StarOffice7_SDK/../test_results/java/Text/GraphicsInserter/GraphicsInserter.sxw creates a relative link to the graphic D:\sdk\m8-1\StarOffice7_SDK\examples\java\Text\oo_smiley.gif Which is wrong in case of using the API: xlink:href="../../../../../examples/java/Text/oo_smiley.gif" or works in case of using the GUI: xlink:href="../../../../StarOffice7_SDK/examples/java/Text/oo_smiley.gif" On the other hand, saving with the API with the following URL "(file:///x:/sus/dummy.sxw" (without an included /../) works fine.
AS->MAV: Seem to be your area ...
.
There is no documentation that relative URLs are allowed here, and to my knowledge we also didn't intend to allow this.
Might be a good opportunity to enhance the documentation towards this. ;)
Has the documentation being updated?
set target to "OOo Later".
In the Dev Guide it is clearly said that the office does not support relate path names. THis can be closed in my opinion.
The office defenitly does not support relative URL's in API calls. But relative URL's are currently used in the result document to refer the links if it is specified so in the optioins dialog. And the URL that is provided to the API call in the original scenario file:///D:/sdk/m8-1/StarOffice7_SDK/../test_results/java/Text/GraphicsInserter/GraphicsInserter.sxw is not a relative URL, but a nonnormalized absolute one. Thus the scenario should work in case of API call the same way as in case of GUI call. I have tried to reproduce the problem in m124, and in my case the scenario seems to have a different problem, an absolut URL "/D:/..." is used in this case. That is much better than the broken URL but is still not so correct, since it seems to be possible to detect the relative URL in this case ( and settings request to use relative URL's when possible ). MAV->SUS: Could you please try the original test with the m124 to see whether the behaviour is really changed to using the absolut URL in such case. Thanks.
Created attachment 30113 [details] Zip including easy test scenario
The issue is not as severe as at the beginning, but the behavior is still odd. Saving with a non-normalized URL the graphic reference becomes absolute in the OpenDocument format, using an absolute URL results in an relative graphic reference. This seems to be inconsistent. Added a Basic Test Macro document as an zip. In detail: Using storeAsURL with unnormalized URL: ThisComponent.storetourl("file:///x:/sus/i20964/old/../test1/normalizeURL-i20964.odt", dimarray()) results in XML to an absolute link: xlink:href="/X:/sus/i20964/old/image/oo_smiley.gif" Using storeAsURL with absolute URL ThisComponent.storetourl("file:///x:/sus/i20964/test2/normalizeURL-i20964.odt", dimarray()) results in relative URL: xlink:href="../old/image/oo_smiley.gif"
Reset assigne to the default "issues@openoffice.apache.org".