Hi Steffen,
it is no specific problem of the bean. The bean calls internally
loadComponentFromURL(...) and there is no difference. The behaviour
sounds indeed strange and maybe somebody can comment it.
Anyway using a valid and correct Url is always a good idea.
Juergen
Steffen Boersig wrote:
Hey guys,
OOoBean.loadFromURL() is acting strange for different URL formats.
//fileURL = E:\Test.ods
String fileURL = file.getAbsolutePath();
URL = Tools.convertToFileURL(fileURL);
try
{
PropertyValue[] loadProperties = new PropertyValue[1];
loadProperties[0] = new PropertyValue("ReadOnly", 0, new
Boolean(false), PropertyState.DIRECT_VALUE);
aBean.loadFromURL(URL, loadProperties);
In this snippet, a valid fileURL is created by a method of mine to
ensure there are no backslashes in the file URL. ( E:\Test.ods ==>
E:/Test.ods )
If I'm exectuing the code, all works fine and i can work with the document.
If I'm changing the code to
//fileURL = E:\Test.ods
String fileURL = file.getAbsolutePath();
URL = file:/// + fileURL;
try
{
PropertyValue[] loadProperties = new PropertyValue[1];
loadProperties[0] = new PropertyValue("ReadOnly", 0, new
Boolean(false), PropertyState.DIRECT_VALUE);
aBean.loadFromURL(URL, loadProperties);
the document will be loaded as well. That's some nice feature of the
loadFromURL() function to not enforce converting backslashes. BUT it is
then opened in read only mode. Which in my opinion is strange and not
intuitive for users of the api.
At first I had the second snippet implemented and everything was fine,
because I worked with templates only, but after opening normal documents
that read-only error occured. After some rewriting I found the problem,
but I think this should be documented at least. If not fixed.
Except someone can explain me, why OOoBean should open fileUrls which
aren't correct but prevent modifiying.
Regards,
Steffen Börsig
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org