This is a general question but I have provided the context to explain how this could be useful and also to invite completely different solutions to my immediate problem.dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(ThisComponent.CurrentController.Frame, "macro:///" & LibModuleFunctionString, "", 0, Array())
Indirect macro invocation with object argument
-
- Posts: 44
- Joined: Tue Apr 10, 2018 6:15 am
Indirect macro invocation with object argument
I have registered a function to be invoked whenever any document is opened. Since only one macro can be assigned to this event, I want my function to play nicely by invoking macros specified by a user-defined list of similar functions in other libraries. Obviously, these functions cannot be embedded in mine and must, therefore, be invoked indirectly, i.e. by name as string. This "indirect" invocation is not difficult if no arguments or only string arguments are needed but the argument to this function is an object. Not passing the argument, the indirect invocation of each chained function is:
W10 Libre 6.1.5.2 and Ubuntu-Mate 18.04 Libre 6.0.7.3
Re: Indirect macro invocation with object argument
PLease upload more samples (the code of the macros to call, and a sample document where you want to to call the macros from.)
You can call your own (user defined) macros by their name and by the passed parameters, not needed the Dispacther.
The Dispatcher is excellent (for example) to call the Calc Cell functions from a macro.
You can assingn the My_main_routine to the document event. It will call all of others routines and functions.
It can call the subs and functions from the MyMacros Standard library and/or from the Standard library of the actual document.
These libraries (the Standard ones) will be loaded into the memory, automatically. You must load-in the other libraries before you call a routine/function from them:
You can call your own (user defined) macros by their name and by the passed parameters, not needed the Dispacther.
The Dispatcher is excellent (for example) to call the Calc Cell functions from a macro.
Code: Select all
sub My_main_routine
my_routine1("constant string parameter", sStringVariable)
floatResult = my_function2(floatNumberVariable1; floatNumberVariable2)
my_routine3(floatResult, floatNumberVariable3)
end sub
It can call the subs and functions from the MyMacros Standard library and/or from the Standard library of the actual document.
These libraries (the Standard ones) will be loaded into the memory, automatically. You must load-in the other libraries before you call a routine/function from them:
Code: Select all
...
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("MyLibrary1")) Then
GlobalScope.BasicLibraries.LoadLibrary("MyLibrary1")
End If
...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
-
- Posts: 44
- Joined: Tue Apr 10, 2018 6:15 am
Re: Indirect macro invocation with object argument
Thank you Zizi64 for your quick reply. Unfortunately, my situation is more complex than that. Indeed, my "on document open" macro does call several others, as you suggest, but they are all known at compile time and can be invoked directly. If the macro is not known until run time it must be invoked by reference. In C/C++ this is done with a pointer, in LISP with a delayed dereference operator. In BASIC I think it can only be done with a string passed to a mechanism that will interpret the string as a reference to a macro. Dispatcher is the only means that I have found. It does work but I can't find a way to pass an object argument to the macro. I'm hoping that someone either knows how to do that or can suggest an alternative means of invoking a macro that is not known until run time.
W10 Libre 6.1.5.2 and Ubuntu-Mate 18.04 Libre 6.0.7.3
- JohnSUN-Pensioner
- Volunteer
- Posts: 876
- Joined: Fri Jan 14, 2011 1:21 pm
- Location: Kyiv, Ukraine
Re: Indirect macro invocation with object argument
Perhaps this solution will help you move on.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Re: Indirect macro invocation with object argument
The stupid StarBasic language ignores any parameters as long as they remain unreferenced. Install the MRI extension and read [Tutorial] Introduction into object inspection with MRI
Bind your event to MyMacros>MriLib>Module1.Mri
This will show an object inspection window with all properties of the passed event struct, including the "Source" element which is the calling object.
Bind your event to MyMacros>MriLib>Module1.Mri
This will show an object inspection window with all properties of the passed event struct, including the "Source" element which is the calling object.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice