I am trying to use python macros as cell functions with Basic wrappers.
My python function, stored in the document (returns the working directory):
Code: Select all
import os
def getWorkingDirectory():
return os.getcwd()
g_exportedScripts = (getWorkingDirectory,)
Code: Select all
function getWorkingDirectory()
GlobalScope.BasicLibraries.LoadLibrary("XrayTool")
oScriptProvider = ThisComponent.getScriptProvider()
' xray oScriptProvider.ChildNodes
oScript = oScriptProvider.getScript("vnd.sun.star.script:getCwd.py$getWorkingDirectory?language=Python&location=document")
getWorkingDirectory = oScript.invoke(array(), array(), array())
End function
Code: Select all
=GETWORKINGDIRECTORY()
Same behavior on AO and LO.
With the xray line, you can see that at the first call the beanshell / javascript / python script providers are not yet loaded ...
Do I do something wrong here?
ms777