|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
OOoBean: possible Bug with OOoBean.loadFromURL()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-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean: possible Bug with OOoBean.loadFromURL()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-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean: possible Bug with OOoBean.loadFromURL()On 10/29/09 13:14, Steffen Boersig wrote:
> 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. <file:///E:\Test.ods> is not a valid URL to denote Windows pathname E:\Test.ods (<file:///E:/Test.ods> would be correct). I vaguely remember that the implementation of loadComponentFromURL indeed does somewhat strange things upon such invalid input (which would explain the read-only status; maybe there is already an issue for this?). (By the way, <E:/Test.ods> is also not a valid URL to denote Windows pathname E:\Test.ods; it is an URL of the---unknown---schema "e". That loadFromURL happens to work "as expected" for such invalid input is a sad consequence of "try to guess what the client wants" software.) -Stephan --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean: possible Bug with OOoBean.loadFromURL()Stephan Bergmann schrieb:
> <file:///E:\Test.ods> is not a valid URL to denote Windows pathname > E:\Test.ods (<file:///E:/Test.ods> would be correct). I vaguely > remember that the implementation of loadComponentFromURL indeed does > somewhat strange things upon such invalid input (which would explain > the read-only status; maybe there is already an issue for this?). > > (By the way, <E:/Test.ods> is also not a valid URL to denote Windows > pathname E:\Test.ods; it is an URL of the---unknown---schema "e". > That loadFromURL happens to work "as expected" for such invalid input > is a sad consequence of "try to guess what the client wants" software.) > > -Stephan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > converting function adds file:/// and gets rid of backslashes to get a valid file URL ( file:///E:/Test.ods ). But tested it and at least there it throws an error and does not open in read only mode or sth. like that. An error on ALL kinds of invalid urls would be great. Would make debugging easier. Steffen Börsig --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean: possible Bug with OOoBean.loadFromURL()On 10/29/09 14:59, Steffen Boersig wrote:
> I didn't know if loadFromURL can handle E:/Test.ods as well since my > converting function adds file:/// and gets rid of backslashes to get a > valid file URL ( file:///E:/Test.ods ). But tested it and at least there > it throws an error and does not open in read only mode or sth. like that. I see. > An error on ALL kinds of invalid urls would be great. Would make > debugging easier. Yes, I agree. The problem, however, is probably along the lines that loadComponentFromURL is also used to load whatever the user types on the command line or in the file open dialog etc., where the "smart logic" to understand that "E:\Test.ods" is a Windows pathname while "file:///E:/Test.ods" is a URL is called for. (Not that all this could not probably be disentangled in a sane way, but just to give some context why things are the way they are...) -Stephan --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |