Bug 44181 - Macros: Macro library attached to document : LibraryNotLoadException
Summary: Macros: Macro library attached to document : LibraryNotLoadException
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected)
3.3.4 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
Whiteboard: BSA
Depends on:
Reported: 2011-12-27 05:45 UTC by Tribunal Federal
Modified: 2013-08-12 14:03 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:

A document with the macro attached ! (23.46 KB, application/vnd.oasis.opendocument.text-template)
2011-12-27 05:45 UTC, Tribunal Federal

Note You need to log in before you can comment on or make changes to this bug.
Description Tribunal Federal 2011-12-27 05:45:03 UTC
Created attachment 54847 [details]
A document with the macro attached !

Problem description: 
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 !

Current behavior:
The first time, the Macro Dialog is not starting. Instead an error message appears.

Expected behavior:
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: Gecko/20110324 Firefox/3.6.16
Comment 1 Tribunal Federal 2011-12-27 06:57:34 UTC
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 !!!
Comment 2 sasha.libreoffice 2012-05-03 01:50:59 UTC
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
Comment 3 Niklas Johansson 2013-08-12 14:03:47 UTC
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.