Apache OpenOffice (AOO) Bugzilla – Issue 43544
getURL() return empty String while loading
Last modified: 2017-05-20 11:31:40 UTC
OpenOffice first loads and runs macros instead of load the document itself. This leads to many problems if a macro wants to access any type of information in the document.
Created attachment 23037 [details] Sample file that has a macro that returns document URL.
Running the attached file will return a NULL string to the very first cell in the sheet1, but just editing this cell or running again the macro will return the correct URL string.
np->ab reassign
confirm with m81
If I remember correctly, you've told me about a simlilar problem lately. This problem cannot be solved within Basic anyway.
But that's what the document wants: it obviously contains a macro call in the spreadsheet table, and Calc evaluates such macros while it loads the document. So this alone isn't a problem. If your macro does not work correctly (or what else should cause the empty cell?) it's something else. I assume that this is something a Calc expert should investigate.
The macro calls getURL (implemented in SfxBaseModel). I can't say if that is supposed to return a value during loading.
OK, so the question remains: should getURL() return something before loading has finished?! And should it be different to getLocation()?
I changed the title because it is misleading. It's absolutely correct to execute the macro before the loading has finished, only the behavior of a particular function must be clarified
In my opinion getURL is not supposed to return a value during loading time, but the real problem is that the cells calculation starts before the loading is finished.
Not only getURL() wont work, others API calls wont too.
Created attachment 25758 [details] For those who dont realize the real problem another sample.
I can provide many others samples that this problem occurs and the only way that i could make it work is disabling macros and then reload the document.
I found a strange workaround for this issue! Porting Obba (see http://www.obba.info) I came across this issue, because Obba provides a function to load an external library. In order to function with sheet-relative paths, this function (e.g. obAddJar) needs to use getURL. The function has a second argument being a boolean "isPathRelative". If you write "obAddJar("lib";TRUE())" the path not expanded. However if you write "obAddJar("lib";IF(TODAY();TRUE();TRUE()), then the function is evaluated at a later time and getURL is valid. Furthermore, try this on a sheet featuring a macro and set a breakpoint in your Java code. If you use the call without TODAY(), then your code will be called before the macro dialog appears. If you use the call with the TODAY() workaround, then the code will be called after the macro dialog appeared. You can check this behavior by downloading the Obba plugin from http://www.obba.info an use the Demo "Normal Distribution.odt". Regards Christian
Reset assigne to the default "issues@openoffice.apache.org".