On Sat, Jan 25, 2020 at 1:38 PM Matthias Seidel <matthias.sei...@hamburg.de> wrote:
> Hi Damjan, Hi Pedro, > > Thank you for your work and the helpful explanation. > > Pleasure :) > BTW: I could make the "edit" button clickable for Python scripts by > setting ENABLE_EDIT_DIALOG to TRUE in [1], but it never brought up an > editor or something similar. > > Yes I saw that too. If I wrap the contents of ScriptBrowseNode.invoke() in a try/except, and log the contents, I get: <class 'pythonscript.com.sun.star.lang.WrappedTargetRuntimeException'>: /openoffice-git/main/instsetoo_native/unxfbsdx/Apache_OpenOffice/installed/install/en-US/openoffice4/program/pythonscript.py:520 in function invoke() ["vnd.sun.star.script:" +] with the code involved being: 519 self.editor = dlgprov.createDialog( 520 "vnd.sun.star.script:" + 521 "ScriptBindingLibrary.MacroEditor?location=application") and I am not sure what's making it unhappy there. > Regards, > > Matthias > > [1] > > https://github.com/apache/openoffice/blob/trunk/main/scripting/source/pyprov/pythonscript.py > > Am 25.01.20 um 10:56 schrieb Damjan Jovanovic: > > Hi > > > > With Python 2 EOL as of 1 January 2020, we have little choice but to move > > to Python 3. > > > > After a lot of hard work by me and Pedro, both of us relatively > unfamiliar > > with Python, I am happy to report that using a system-provided Python 3 > in > > Apache OpenOffice now works. > > > > The UNO/Python bridge and the Python script provider have been patched to > > support both Python 2 and 3, and all 3 sample Python macros that ship > with > > AOO work with Python 3 too. More extensive testing (eg. main/pyuno/demo) > > has not been performed, but isn't in the build anyway and might be broken > > with Python 2 as well. > > > > It certainly works on FreeBSD and probably on Linux, please test other > > platforms. > > > > As I said only system-provided Python 3 works as this stage. Building an > > internal Python 3, as is required on Windows, does not work yet, and is > > extremely difficult to implement, as Python 3 requires a new Windows > > Platform SDK with MSVC >= 14 in order to build, which will probably lead > to > > numerous build-related changes to all modules. This does need to happen > at > > some stage anyway though. > > > > Also as per https://bz.apache.org/ooo/show_bug.cgi?id=123975#c9 > > we also need to release AOO 5.0 (a new major release) for an incompatible > > change of this nature. > > > > Along the way, I also looked at what it would take to improve the Python > > macro dialog, which never allowed creating, renaming, deleting or editing > > Python scripts, only running them (and to add them to an .odt file, you > > have to edit the ZIP file and add them manually). There are at least 3 > > separate implementations of scripting providers: the StarBasic one, the > > Java one (used for Java, BeanShell and Rhino (Javascript)), and the > Python > > one. It's the Python one in main/scripting/source/pyprov/pythonscript.py > > that is missing features. By comparing it against the Java provider I > > managed to patch DirBrowseNode to implement XPropertySet and add a > > getPropertyValue() method which checks for the "Creatable" property and > > returns true, and this enables the (otherwise grayed out) "Create" button > > in the dialog, but then to implement the "Creatable" action in invoke() > > when the button is clicked seems rather difficult, and requires a > low-level > > understanding of script URLs and content brokers and various other > > infrastructure. > > > > Damjan > > > >