OK here goes -
In main unit
var
libreMgr, libreDsk, libreDoc: OleVariant;
libreEvents: ILibreOfficeEvents;
...
libreMgr := CreateOleObject('com.sun.star.ServiceManager');
libreDsk := LibreMgr.createInstance('com.sun.star.frame.Desktop');
libreDoc := libreDsk.loadComponentFromFile(filename etc...);
libreEvents := TLibreOfficeEvents.Create;
libreEvents.OnPrepareUnload := event handler method
libreDoc.addEventListener(libreEvents);
See attached units
LibreOfficeEventListener - implementation of TLibreOfficeEvents with internal ILibreOfficeEvents declaration
LibreOfficeEventListener_TLB - imported LO type library, declaration of LO ILibreOfficeEventListener interface
ActiveXConnectionPoints - custom implementation of IConnectionPointContainer
ComServNoRegisterLaz - override default FPC TComServer implementation to remove registry updates
I am not sure where my original Delphi implementation came from (back in 2011), I must have found some hints online, as I am pretty sure I did not work this all out for myself.
The LO type library must be loaded as a resource in the exe, but does not need to be added to the registry. This allows the app to run without admin privileges, hence the overrides of the default TComServer and TAutoObjectFactory to remove registry updates.
This all compiles OK in Lazarus, but the events do not fire at all after the LO document is opened and the event listener is added, and there are no runtime errors.