I’m experimenting with the python ooodev project created by user “vib” here.
He/she hasn’t yet covered Base in any great depth, but this is the app I want to automate.
Tweaking one or two of his files and cobbling something together I have managed to open an .mdb file and then get a reference to a form in this dbase document.
with Lo.Loader(Lo.ConnectSocket()) as loader:
doc = Base.open_doc('test_db.odb', loader)
GUI.set_visible(is_visible=True, odoc=doc)
form_0 = doc.FormDocuments[0]
print(f'form_0 {form_0}')
But I’m struggling with how to implement a listener on the “open form” event (in fact the event is called “When loading” if you do it manually). The print command shows the UNO interfaces implemented:
form_0 pyuno object (com.sun.star.ucb.XContent)0x1eb77dc0c68{implementationName=com.sun.star.comp.sdb.Content, supportedServices={com.sun.star.ucb.Content}, supportedInterfaces={com.sun.star.ucb.XContent,com.sun.star.ucb.XCommandProcessor,com.sun.star.lang.XServiceInfo,com.sun.star.beans.XPropertiesChangeNotifier,com.sun.star.beans.XPropertyContainer,com.sun.star.lang.XInitialization,com.sun.star.lang.XUnoTunnel,com.sun.star.container.XChild,com.sun.star.sdbcx.XRename,com.sun.star.lang.XTypeProvider,com.sun.star.uno.XWeak,com.sun.star.lang.XComponent,com.sun.star.beans.XPropertySet,com.sun.star.beans.XMultiPropertySet,com.sun.star.beans.XFastPropertySet,com.sun.star.beans.XPropertyState,com.sun.star.lang.XTypeProvider,com.sun.star.embed.XComponentSupplier,com.sun.star.sdb.XSubDocument,com.sun.star.util.XCloseListener,com.sun.star.container.XHierarchicalName,com.sun.star.lang.XTypeProvider}}
… but none of these seems to contain a suitable addXXXListener method whose Listener class has a method which will fire when the form is opened (by user action or programmatically).
For that matter, I wanted to do this even previously, when using “standard” embedded macros: it got to be tiresome to have to connect up the events to the macros manually each time I changed my code and rebuilt the .odb file.
The closest answer I’ve found is this thread, which talks about firing events on form controls (which I’d also like to do and to be able to find listeners for)… but it all seems to be about VB, and I can’t understand what to do in Python.