Issue 20964 - xStorable.storeAsURL has problems with relative URL
Summary: xStorable.storeAsURL has problems with relative URL
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2003-10-09 16:23 UTC by svante.schubert
Modified: 2017-05-20 11:27 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Zip including easy test scenario (58.50 KB, application/octet-stream)
2005-10-04 13:42 UTC, svante.schubert
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description svante.schubert 2003-10-09 16:23:05 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.
Comment 1 andreas.schluens 2003-10-13 07:40:19 UTC
AS->MAV: Seem to be your area ...
Comment 2 mikhail.voytenko 2003-10-20 08:12:32 UTC
.
Comment 3 Mathias_Bauer 2004-02-06 09:55:00 UTC
There is no documentation that relative URLs are allowed here, and to my
knowledge we also didn't intend to allow this.

Comment 4 svante.schubert 2004-02-06 10:05:41 UTC
Might be a good opportunity to enhance the documentation towards this. ;)
Comment 5 svante.schubert 2004-03-25 09:39:14 UTC
Has the documentation being updated?
Comment 6 mikhail.voytenko 2004-04-23 16:32:42 UTC
set target to "OOo Later".
Comment 7 christianjunker 2005-08-01 09:56:11 UTC
In the Dev Guide it is clearly said that the office does not support relate 
path names. THis can be closed in my opinion.
Comment 8 mikhail.voytenko 2005-09-30 11:01:28 UTC
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.
Comment 9 svante.schubert 2005-10-04 13:42:23 UTC
Created attachment 30113 [details]
Zip including easy test scenario
Comment 10 svante.schubert 2005-10-04 13:50:22 UTC
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"
Comment 11 Marcus 2017-05-20 11:27:28 UTC
Reset assigne to the default "issues@openoffice.apache.org".