Hi Paolo, Paolo Mantovani wrote:
> Just a small addition: > Of course, holding a reference of the listener into a global variable is a > good thing, (especially when you need to de-register it at latter time), > anyway, the listener survives even if you don't store it in a global var: > > AFAIK a registered listener is not disposed by the Basic engine while the > broadcaster still holds a reference to it: > f.e. with the following code you will be bothered by the msgbox whenever you > change selection, and to kill the listener you must close the document: > > ------------------ > Sub testListener() > oListener = createUnoListener("Doc_", _ > "com.sun.star.view.XSelectionChangeListener") > ThisComponent.CurrentController.addSelectionChangeListener(oListener) > End Sub > > Sub Doc_selectionChanged(oEvent) > msgbox "ciao" > End Sub > > Sub Document_disposing(oEvent) > 'nothing to do > End Sub > ------------------ That sounds like a clear sign that listeners implemented in Basic will work as long as their library code is not swapped out. So I think the listener approach would be the way to go because it solves the problem of handing over objects to the basic code quite easily. This morning I had another idea that might solve the other problems: if we use a dispatch object service as a "relay" between the UI elements and the basic code as I proposed we also can use this object as a storage for data associated to this connection, e.g. by providing a property container (that is used from Basic quite easily!). This way you don't need to use global variables. And if we want to send status updates to the UI element we can do this based on the data stored at the object and by calling a forwarding method of the object. The only problem then will be to identify the dispatch object amongst the bunch of them that might have been created, but as we can make frame and command URL accessible to the listener (implemented in Basic) we can use the combination of both as a unique identifier for searching for the dispatch object in a global container of such objects. I will draw up this in a more detailed manner. Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]