Bug 45088

Summary: : Macros from other Calc documents aren't executed when called
Product: LibreOffice Reporter: Zarko Zivanov <zzarko>
Component: CalcAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED NOTABUG    
Severity: normal CC: markus.mohrhard
Priority: medium    
Version: 3.5.0 RC1   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard: BSA
Crash report or crash signature: Regression By:

Description Zarko Zivanov 2012-01-22 07:36:07 UTC
Problem description: 
I have a number of macros that open other calc documents, change them and call some macros in them. Other calc document is opened like this:

Dim aOdsProps(1) as new com.sun.star.beans.PropertyValue
aOdsProps(0).name = "MacroExecutionMode"
aOdsProps(0).Value = 0
frame = ThisComponent.CurrentController.Frame
MyDoc = frame.LoadComponentFromUrl(uPath, "_default", 0, aOdsProps())

After some manipulation, a macro from opened document is called (the document is called Pregled.ods, and the macro is FillIndexList):

uMacroUrl = "macro://Pregled/Standard.Module1.FillIndexList"
oDispatch = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatch.executeDispatch( StarDesktop, uMacroUrl, "", 0, Array() )

This works as expected in LO 3.3.3 and OpenOffice 3.3, but in LO 3.4.3, 3.4.4 and 3.4.5 simply nothing happens: macro isn't executed (macro should make some additional changes, but they aren't done, this is how I know that it isn't executed), and there isn't any error box that says that something is wrong.

Current behavior:
When called, macro from another document isn't executed.

Expected behavior:
After calling macro from another document, it should be executed.

Platform (if different from the browser):
Ubuntu 11.10, LO 3.4.5, 3.4.4, 3.4.3, Mint Debian, LO 3.3.3
              
Browser: Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
Comment 1 Zarko Zivanov 2012-01-22 08:17:52 UTC
I just tested LO 3.5.0rc1 (as part of QA/BugHunting Session 3.5.0.-2), and this is still a bug.
Comment 2 Markus Mohrhard 2012-01-22 21:46:02 UTC
There is a t least one little error in your macro.

It must be aOdsProps[0].Value = 4 for ALWAYS_EXECUTE_NO_WARN, see http://api.libreoffice.org/docs/common/ref/com/sun/star/document/MacroExecMode.html

And this can't block the release even if there is a bug in LibO. This is just a normal bug. See http://wiki.documentfoundation.org/Release_Criteria#Blocker_Bug_Definition
Comment 3 Zarko Zivanov 2012-01-26 22:58:08 UTC
Makcus,
Thanks for clarification, now it works. The code for opening ODS file I copied from elsewhere, and I didn't know about meaning of parameters. It worked well until LO 3.4 came out. But, this means that it was a bug in OO/LO 3.3 and earlier - macros shouldn't be executed at all when opening witn "0".

Just one more question, if you have the time. If I put this in my basic macro:

aOdsProps(0).Value = com.sun.star.document.ALWAYS_EXECUTE_NO_WARN

I get an error about unrecognised property ALWAYS_EXECUTE_NO_WARN

If I put this:

aOdsProps(0).Value = ALWAYS_EXECUTE_NO_WARN

then there are no errors, but macro isn't executed. Is there a way to use symbolic constant (ALWAYS_EXECUTE_NO_WARN) instead of it's value (4) in LO Basic?
Comment 4 Markus Mohrhard 2012-01-27 03:20:17 UTC
Honestly I don't know. I only know how to use uno in c++.