by FJCC » Tue May 26, 2009 2:18 am
Looking into the information in the post I referenced previously, the basic method is easy. This code does the minimal task.
- Code: Select all Expand viewCollapse view
MSPF = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
scriptPro = MSPF.createScriptProvider("")
xScript = scriptPro.getScript("vnd.sun.star.script:PythonTest6.py$ProcessArray?language=Python&location=user")
ReturnVal = xScript.Invoke(Array(arg1()), Array(), Array())
The python file PythonTest6.py is stored as a script for an Ooo macro, but it needn't have anything to do with Ooo other than handle whatever gets passed to it. The array arg1() contains the arguments passed to the python script. I've read in the API documentation about the other two arrays that are arguments for xScript.invoke, but it made my head swim. Maybe I'll try that again later.
ReturnVal is whatever you put in the return statement of the python function. Remember that objects passed to and from python scripts by Ooo will be in the form of tuples on the python side.
Thanks to Villeroy for doing all the heavy lifting on this years ago.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.