I have made a python script (strength_lib.py) with the following content:
Code: Select all
from math import *
def Element(p1,p2):
return pi*p1*p2
After that, I embed this python script by modifying the "META-INF/manifest.xml" and putting strength_lib.py in "Scripts/python" location inside the pseudo-zip ods file.
THe manifest.xml file is modified by adding this lines:
<manifest:file-entry manifest:media-type="" manifest:full-path="Scripts/python/strength_lib.py"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/python/"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/"/>
Then I open the OpenOffice Calc sheet (mySheet.ods) and create the following macro code in Basic language:
Code: Select all
Function Element(p1,p2)
sURL = "vnd.sun.star.script:strength_lib.py$Element?language=Python&location=document"
oMSP = ThisComponent.getScriptProvider()
oScript = oMSP.getScript(sURL)
Element = oScript.invoke(Array(p1,p2), Array(), Array())
End Function
So everything is OK and I save the file and close it.
However, everytime I re-open this file I get the following error message:
and also the function does not works:
See that it is written on the cell, but its result is not displayed.
Am I doing something wrong? Or is it a limitation of OpenOffice 3.2? I have to develop my work in this OO version..
Thanks.