I am searching some example VB.NET/C# code to raise OnLoad & OnSave events for LibreOffice Writer document.
So referring the below code from the link ‘https://ask.libreoffice.org/en/question/136735/how-do-we-import-the-listener-events-of-libreoffice-writer-in-visual-basic-6/#’. Here please anyone can tell how to get object and assign to variable ‘Dim xContainer As XContainer =’
Imports unoidl.com.sun.star.container
Imports unoidl.com.sun.star.lang
Module Module1 Sub Main()
Dim oSM
Dim oDesk, oDoc As Object
Dim arg(-1)
oSM = CreateObject("com.sun.star.ServiceManager")
oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, arg)
oDoc.getText().setString("Hello!")
Dim xContainer As XContainer = REM # TODO: Get object you want to listen to
Dim myListener As MyListener = New MyListener()
xContainer.addContainerListener(myListener)
End Sub
Class MyListener
Implements XContainerListener
Sub disposing(oEvent As EventObject) Implements XEventListener.disposing
MsgBox("disposing")
End Sub
Sub XContainerListener_elementInserted([Event] As ContainerEvent) Implements XContainerListener.elementInserted
MsgBox("elementInserted")
End Sub
Sub XContainerListener_elementRemoved([Event] As ContainerEvent) Implements XContainerListener.elementRemoved
MsgBox("elementRemoved")
End Sub
Sub XContainerListener_elementReplaced([Event] As ContainerEvent) Implements XContainerListener.elementReplaced
MsgBox("elementReplaced")
End Sub
End Class
End Module