Created attachment 54847 [details]
A document with the macro attached !
The first time I start a macro with a dialog, a message error appears.
Steps to reproduce:
1. Enable the macros on Libre Office
2. Open the attached document
3. Click on the logo on the to left of the document
4. The first time you click on the logo, you get the following error message :
5. Click a second time on the logo, and now the Dialog appears without error and the macro works normally !
The first time, the Macro Dialog is not starting. Instead an error message appears.
The Dialog should always start, without error message !
Platform (if different from the browser):
Tested on :
Browser: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:220.127.116.11) Gecko/20110324 Firefox/3.6.16
In fact, the problem is that the behavior is not the same if the library is stored in a library of Libre Office or it it is attached to a document.
The code that I sent is working as is if you add it to the Standard Library of Libre Office. For getting it work attached to the document, I have justto add the following line of code before the CreateUnoDialog instruction :
DialogLibraries.LoadLibrary( "Standard" )
The behavior should be the same, independently if the library is attached to a document or not !!!
Reproduced in 3.3.4 and 3.5.3 on Fedora 64 bit,
but not reproduced on Windows 7 32 bit
IMHO Unix specific bug
Changing platform to Linux because can not find Unix.
Changing version to 3.3.4 as most early reproducible
Before a dialog can be used it's library needs to be loaded that means that most of the time DialogLibraries.LoadLibrary( "Standard" ) is needed. And if you provide that line of code then you should not get the error you are referring to.
I did a test with LibreOffice 4.0.4 (Windows 7) and LibreOffice 3.5.7 (Ubuntu) and added a dialog to Standard in My Macros on my computer. I hooked it up to the image in your document, restarted my LibreOffice instance so the Standard library of My Macros gets unloaded. When I reopen the document and click the image I get a LibraryNotLoadedException, as expected and just as I get if the dialog is in the document.
Everything in your bug description is expected behavior (maybe not that obvious though). The reason that it works the second time is that the Basic IDE loads the dialog library when it opens the basic code to show you the offending line.
You could possibly argue that the function CreateUnoDialog should be extended to load the dialog library before it tries to execute it. I do not know what impact that might have on performance etc.
Please feel free to file an enhancement request to extend CreateUnoDialog if you feel strongly about it.