Oliver Brinzing wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1Hi, at the moment I am trying to convert some of my basic macros into a java component :-) but get stuck with the following problem: dispatching ".uno:ClosePreview" from java seems not to work in all cases, if I open a message box directly after the "xDispatch.executeDispatch" the message box will be displayed in the preview mode ... after closing the message box, we are still in the preview mode ... the dispatch got lost ??? I think this i caused due to the async behaviour of the dispatching framwork ... I also tried xNotifyingDispatcher.dispatchWithNotification() without success ... :-( In Basic I used the following: Function ClosePreview() Dim oView as Object Dim oDispatcher as Object Dim mNoArgs() Dim i as Integer oView = ThisComponent.getCurrentController() If Not hasUnoInterfaces(oView, "com.sun.star.sheet.XSpreadsheetView") Then oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper") oDispatcher.executeDispatch(ThisComponent.getCurrentController().Frame, ".uno:ClosePreview", "", 0, mNoArgs()) While Not hasUnoInterfaces(oView, "com.sun.star.sheet.XSpreadsheetView") and i < 10 Wait(0) oView = ThisComponent.getCurrentController() i = i + 1 Wend EndIf MsgBox "Hello World..." & CStr(i) End Function Any hints ?
Using of the interface XNotifyingDispatch does not make the dispatch itself synchron ... it guarantees only, that the given listener will be called. Becausde normal XStatusListener used for a XDispatch call are not guaranteed to be used !
If you wish to force a synchronous execution of your dispatch you should try the argument "Asynchron" as [bool] with a valud "false". But note: Forcing the synchron mode for an asnychronous operation can make trouble. E.g. closing of such preview will destroy resources, which are used by your own java code. In such case Disposed- or RuntimeExcception can occure, which of course must be handled by your code. You have to make sure that all references to these preview was released by yourself
/Hint: GarbageCollector .-)
Oliver - --
Regards Andreas --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
