Hi,
Sevastian `seva` Foglia wrote:
Hi all.
How can I give arguments to a java macro?
I try to modify the tag functionname on parcel-descriptor.xml and the
URL properties on Addons.xcu, but I can't retrieve the parameters.
Anyone did some similar?
In general it is not really supported to use parameters. How you want
assign the parameters to the macro function? Anyway, some parameters are
implicitly used. The first parameter is always the XScriptContext and
depending on the event which is used to bind the macro to a control you
get an event object as second parameter. Binding the macro in a toolbar
you got a short as second parameter (i haven't found yet where this
value comes from). Whereas the event object make sense i have no idea
for what the short value is good for.
All this seems to be a little bit confusing, especially when you check
the documentation in the DevGuide
(http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml#1_3_3_Handling_arguments_passed_to_macros).
Parameters are handled as
public void mymacrofunction(XScriptContext xScriptContext, Object[] args)
But the current implementation looks a little bit different. No Object[]
is used but the objects directly (e.g. short, MouseEvent, KeyEvent).
This is a bug and it limits the usage of the macros. I have played a
little bit with the whole stuff for a scripting integration in Netbeans
which is coming soon. The bug will be fixed for one of the next versions
(probably 2.3). The interesting point is that a commercial solution for
Eclipse is available and i ask myself how they handle this bug and of
course if i fix the bug as it is documented their macros won't run in
the future. I have to check, how we can handle it best.
Currently you have to implement the exact macro function for each use
case (not really usable) because the implementation search the right
function via reflection. That means for example if you have a macro with
a MouseEvent and nothing else you can't use this macro for a key event
:-( Well, typed macro functions can be useful and i will probably fix
the bug to support it either way.
The good news is that if the bug get fixed and we use Object[] for
additional parameters we are open to extend the Java script provider to
handle at least simple parameter types which can submitted in a macro
Url as for Basic macros.
Juergen
Thanks
Seva
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]