Hi,
As per OpenOffice specs, calling a Python extension macro from Basic is possible. I have been unable to do so and may surely be doing something wrong.
I am linking a Writer doc holding example code and instructions for anyone to x-check.
Thanks in advance for your assistance in that matter.
[Solved] Unable to call a Python extension macro from Basic
- LibreOfficiant
- Posts: 12
- Joined: Wed Jan 25, 2017 9:36 pm
[Solved] Unable to call a Python extension macro from Basic
Last edited by LibreOfficiant on Sat Oct 27, 2018 12:08 pm, edited 1 time in total.
libO 5.4 64bit, (PortableApps: libO 6.0, aOO 4.1, OOo 3.2 32bit) on Win7/Win10 x64 | aOO 4.1.x & libO 5.4.x on Mint 18 Sarah & OSX 10.9 Mavericks x64
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: Unable to call a Python extension macro from Basic
Hi,
When calling an embedded python script, you need to pass the document model as argument to the method createScriptProvider:This is needed as the program can't know in which document is stored the script.
When you want to call a script exposed from a package location, you need to pass the full path, which is not reflected in the organizer dialog :
Regards
When calling an embedded python script, you need to pass the document model as argument to the method createScriptProvider:
Code: Select all
doc = thiscomponent
uri = "vnd.sun.star.script:apso_utils.py$console?language=Python&location=document"
mspf = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
msp = mspf.createScriptProvider(doc)
script = msp.getScript(uri)
script.invoke(array(), array(), array())
When you want to call a script exposed from a package location, you need to pass the full path, which is not reflected in the organizer dialog :
Code: Select all
doc = thiscomponent
uri = "vnd.sun.star.script:apso.oxt|python|pythonpath|apso_utils.py$console?language=Python&location=user:uno_packages"
mspf = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
msp = mspf.createScriptProvider("")
script = msp.getScript(uri)
script.invoke(array(), array(), array())
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
- LibreOfficiant
- Posts: 12
- Joined: Wed Jan 25, 2017 9:36 pm
Re: Unable to call a Python extension macro from Basic
Hi,
Nice to have you back.
And « many thanks » by the way for solving this issue.
Cordially
Nice to have you back.
And « many thanks » by the way for solving this issue.
Cordially
libO 5.4 64bit, (PortableApps: libO 6.0, aOO 4.1, OOo 3.2 32bit) on Win7/Win10 x64 | aOO 4.1.x & libO 5.4.x on Mint 18 Sarah & OSX 10.9 Mavericks x64
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide