Running with macro:// URL

Oduvan
2007-11-15
2013-04-26
  • Oduvan
    Oduvan
    2007-11-15

    Hi!

    Is it possible to run Groovy macros via a macro:// URL from the command line?

    By analogy to macros in Basic the command should look like this:

    > "c:\Program Files\OpenOffice.org 2.3\program\soffice.exe" macro:///Mylib.mymodule.foo.groovy(bar)

    One problem could be that when organizing macros one can create a library but cannot create a module within it: when doing "create" on a library already a macro is being created, not a module.

    So Groovy macros are contained "in the library itself". So I try:

    > "c:\Program Files\OpenOffice.org 2.3\program\soffice.exe" macro:///Mylib.foo.groovy(bar)

    Nothing seems to happen, no visible activity at all. May be this is interpreted as macro named "groovy" in the module named "foo"? Anyway, no diagnostic message appears..

    Any ideas will be greatly apreciated!
    By the way - how are the arguments passed to the script from the comand line? (args[]?)

    Thanks!
    Petr

     
    • Jim White
      Jim White
      2007-11-15

      I don't how to run macros from the command line, although I'm interested to find out.

      AFAIK the extension does have a library & module structure.  Internally the libraries are "user" and "share" (we'll not address macros in documents for the time being).  I would expect the separators to be "/" in a URL, not ".".

      There are two debug switches in the extension:

      For a few messages around actual Groovy macro execution:

      -Dorg.ifcx.oo.GroovyScriptDebug=true

      For extensive dump of content processing (including many URLs):

      -DScriptJavaRuntimeDebug=true

      You set those in the "Java" panel of your OpenOffice Preferences.

      But I've looked at the output and don't see much helpful right off the bat, but I haven't tried the command line invocation because I only have my PowerBook handy at the moment (I'm on the road in Austin at the ACL2 Workshop).

      It will probably take a fair bit of digging to find out how that is supposed to work (and it is possible the the "macro:" protocol only works for OOoBASIC macros).  The OOo Framework forum would be a better place to ask this question (as it isn't specific to Groovy macros which will work, if at all, in the same way as Java/JavaScript/Python).

      http://framework.openoffice.org/

      Jim

       
      • Oduvan
        Oduvan
        2007-11-15

        Hi Jim,

        just a thought about the library/module/macro hierarchy:

        in StarBasic a Module is a script, and a Macro is a subroutine in that script.

        Maybe the same can be done with Groovy? that is, a script is a Module, and a method is a Macro?
        Or may be each class with a method "run" should be a macro.. Or..

        Petr

         
      • Oduvan
        Oduvan
        2007-11-15

        Hi Jim,

        i've found another way of running macros from the command line (http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml#1_6_1_Scripting_Framework_URI_Specification)

        >"c:\Program Files\OpenOffice.org 2.3\program\soffice.exe" "vnd.sun.star.script:MyLibrary.MyScript.groovy?language=Groovy&location=user"

        It works better in that it gives good diagnostics, and it just works for any language, for Groovy in particular.
        The only problem here is that apparently there is no official way to pass arguments to the macro.
        But, they say that the language provider is responsible to map the macro reference (in this case "MyLibrary.MyScript.groovy") to a macro.
        Depending on the implementation of this mapping mechanism which I don't know, it could be possible for your extension to handle macro references with arguments, like "MyLibrary.MyScript.groovy(aaa,bbb)". this would be groovy, I think.
        This is used perhaps in Python extension to specify "entry point" after the macro name like "macro.py$doIt".

        Petr

         
    • Oduvan
      Oduvan
      2007-11-15

      Jim, thanks for the reply!

      I think 'share' and 'user' are a level higher than libraries. They appear as "OpenOffice.org Macros" and "My Macros" in the GUI. I judge from comparing to StarBasic macros.

      I also expected slashes to separate libraries, modules and macros - but apparently what is written before the last slash is considered to point to a document - I conclude that from http://www.pitonyak.org/AndrewMacro.odt.

      Well, it all seems to have a flavor of undocumented magic and calls for an investigation.

      I would think command line invocation should work for PowerBook as well - from a terminal window..

      Setting parameters for Java did not add any diagnostics with command line..

      Thanks again!
      Petr