https://bugs.documentfoundation.org/show_bug.cgi?id=172532
Bug ID: 172532
Summary: The script browser interface can’t be used from Python
due to its design
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: sdk
Assignee: [email protected]
Reporter: [email protected]
The BrowseNodeFactory service provides a way to get access to the hierarchy of
macros available in the installation of LibreOffice. The tree is accessed by
the XBrowseNode interface which is implemented by a provider for each scripting
language. It contains methods such as “getChildren” to get access to the
children of each node in the tree. Once you find the macro you are interested
in you can use the XInvocation interface on a node to do a sort of duck-typing
and access optional methods such as “Editable” and “Creatable”.
The problem arises because pyuno uses the com.sun.star.script.Invocation
service to introspect UNO objects and determine what methods they implement. If
an object implements XInvocation then the Invocation service treats it
differently and uses that interface directly to determine what methods the
object has instead of using the com.sun.star.beans.Introspection service. In
practice this ends up throwing a runtime exception whenever pyuno encounters an
XBrowseNode because it wants the introspected objects to implement XInvocation2
but the browse node objects only implement XInvocation. But even if they were
changed to implement XInvocation2 then it still wouldn’t work because then
python would only be able get access to the duck-typed methods like “Editable”
and not the rest of the methods in XBrowseNode such as “getChildren”.
This means that for example you can’t implement an extension to manage macros
in Python. The popular APSO extension works around this by directly importing
the pythonscript Python file to get access to the node tree instead of using
the UNO interface. This wouldn’t work if the extension wanted to manage scripts
in other languages too.
It looks like XInvocation is meant as a way for an UNO object to override the
introspection mechanism and I think using it for the script browser mechanism
is a bad choice. I think it would be better to replace this with concrete
optional interfaces that the browse nodes can implement such as something like
XEditableBrowseNode which would just have an “editable” method. This would also
make it much easier to implement a script provider. When you implement the
XInvocation interface you also have to implement lots of methods that aren’t
used such as getValue, setValue and getIntrospection. I think it would be
possible to implement this in such a way that both the new and the old way
could be used in parallel for a while so that changing the design won’t break
existing script provider extensions such as Luno.
--
You are receiving this mail because:
You are the assignee for the bug.