Option Explicit PUBLIC Event disposing(Source) PUBLIC Event terminate(Source) PUBLIC Event notifyevent(eventname, Source) PRIVATE interfaces(0) As string PUBLIC Property Get Bridge_ImplementedInterfaces() As Variant Bridge_ImplementedInterfaces = interfaces END Property PRIVATE Sub Class_Initialize() interfaces(0) = "com.sun.star.document.XEventListener" 'document level END Sub 'create A sub FOR EACH OOoevent TO be trapped PUBLIC Sub disposing(ByVal Source As object) MsgBox "disposing call" RaiseEvent disposing(Source) END Sub 'these two dont appear TO work odd! PUBLIC Sub terminate(ByVal Source As object) RaiseEvent terminate(Source) END Sub 'IF this worked would solve ALL problems PUBLIC Sub notifyevent(ByVal eventname As string, ByVal Source As object) MsgBox "notifyevent" RaiseEvent notifyevent(eventname, Source) END Sub
DocEventListener est un objet OLE dynamique DocEventListener = allouer un objet OLE("OOoevent.Listener") oDocument>>AddEventListener(DocEventListener)
'create a Public Event Matching the OOoevent sub below 'so it gets passed back to calling program 'To fire this event, use RaiseEvent with the following syntax:
'RaiseEvent xxxxxx[(arg1, arg2, ... , argn)] in the 'corresponding Sub below 'Event can be trapped in calling prog by 'objEventListener:enable-events("OOoEvents").
'and creating int proc called OOoevents.xxxxx
Public Event disposing(source)
Public Event terminate(source)
Public Event notifyevent(eventname, source)
Private interfaces(0) As String
Public Property Get Bridge_ImplementedInterfaces() As Variant
Bridge_ImplementedInterfaces = interfaces End Property
Private Sub Class_Initialize()
'interfaces(0) = "com.sun.star.lang.XEventListener" 'works good in OOo
V2
interfaces(0) = "com.sun.star.document.XEventListener"
End Sub
'create a sub for each OOoevent to be trapped Public Sub disposing(ByVal source As Object)
RaiseEvent disposing(source)
End Sub
Public Sub terminate(ByVal source As Object)
RaiseEvent terminate(source)
End Sub
Public Sub notifyevent(ByVal eventname As String, ByVal source As Object)
RaiseEvent notifyevent(eventname, source) End Sub
This will fire on the notifyevent so it passes across the event and the source of the event then you can handle the notify event in youre program as you did for the disposing .