Re: Calc scripts as worksheet functions in cell formulae
2020-01-03 revision per advice of Mike Kaganski.
Dear LO community:
There was a 2004 proposal for a feature as noted in the subject. The proposal was voted off per subsequent 2006 assessment. Much thought and deliberation by technical experts of the then OO development team was recorded in the link below. The discussion was thorough, and lengthy, containing both merits and counter arguments. Please refer to the link below for details, to minimize replication in this inquiry.
2004-01-26 Enable Calc to use Scripting Framework scripts as Calc functions
http://bz.apache.org/ooo/show_bug.cgi?id=24829
2004-01-26 Duncan Foster. Proposal.
2006-02-10 Mathias Bauer. Will not fix. (1) Low demand. (2) Slower than Basic.
Inquiry and discussion of this feature emerged in later years. Script languages included BeanShell, Java, Python, etc. Some references are provided for representation, not meant to overlook the vast contributors endeavoring in script development.
I am curious about the two main decision factors in the 2006 assessment.
(1) low demand → Does it remain true in 2020?
(2) slower than Basic → What might be the technical cause?
Info. or URL to the past relevant discussion is appreciated.
Sincerely,
[references]
2004-01-26 Enable Calc to use Scripting Framework scripts as Calc functions
http://bz.apache.org/ooo/show_bug.cgi?id=24829
2004-01-26 Duncan Foster. Proposal.
2006-02-10 Mathias Bauer. Will not fix. (1) Low demand. (2) Slower than Basic.
20080119 [BeanShell] OOo Calc macro example
http://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=1829
20080120 [Java] OOo Writer and Calc macro examples
http://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=1844
20151206 Interface-oriented programming in OpenOffice / LibreOffice : automate your office tasks with Python Macros
http://christopher5106.github.io/office/2015/12/06/openoffice-libreoffice-automate-your-office-tasks-with-python-macros.html
20110929 How can I call a Python macro in a cell formula in OpenOffice.Org Calc?
http://www.stackoverflow.com/questions/7591656
Outis citing Villeroy work on inactive oooforum.org → Python functions from OO.org Basic
20180221 Use a Python function as formula in LibreOffice Calc cells
http://www.superuser.com/questions/1297120
Jim K → no easy direct call to Python, need wrapper in Basic,
20180610 Define a LibreOffice Calc custom function in Python
http://www.stackoverflow.com/questions/50785510
Jim K → no easy direct call to Python
JLOP Java LibreOffice Programming
Prof./Dr. Andrew Davison
http://fivedots.coe.psu.ac.th/~ad/jlop
Part 01, Basics; Chapter 01, LibreOffice API Concepts
page 14, comparison, ease of Basic (or constraint)
Basic = easier access to service / component,
Basic API = script running inside documents, no need of the client component context
Basic code need = loader, service manager, desktop
Basic simplification
(1) Basic script outside OO document
Dim oSM, oDesk, oDoc as Object
Set oSM = CreateObject( “com.sun.star.ServiceManager” )
Set oDesk = oSM.createInstance( “com.sun.star.frame.Desktop” )
Set oDoc = oDesk.loadComponentFromURL( “file:///C:/tmp/testdoc.odt”, “_blank”, 0, noArgs() )
↓
(2) Basic script inside OO document
Set oSM = CreateObject( “com.sun.star.ServiceManager” )
Set oDesk = oSM.createInstance( “com.sun.star.frame.Desktop” )
Set oDoc = oDesk.CurrentComponent
↓
(3) default objects of service manager + desktop
Set oDoc = StarDesktop.CurrentComponent
Set oDoc = ThisComponent
↓
(4) add service
set oSFA = CreateUnoService( “com.sun.star.ucb.SimpleFileAccess” )
oSFA.CreateFolder( dirName )