Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
Oliver Brinzing wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Mathias, What means without success? What exactly did you do and what exactly happened? that means, the preview is not closed, if i open a message box directly after the excecuteDispatch(), it does not matter if i use the SynchronMode or not ... the message box is shown in preview mode, after closing it, preview mode is still active ... without showMessageBox() the preview is closed ... This shows that closing is not done synchronously and so it is prevented by the dialog box that is opened before the view can be exchanged. Of course you can't close a view that contains a modal dialog! Obviously there is an additional asynchronity in the code that executes the ClosePreview command, it's not the dispatcher that works asynchronously. I had a look into the Writer code and indeed this is what happens. The closing of the preview is done by creating a new view and replacing the preview in the same window by it, and this is done asynchronously. I assume this is done to protect against possible crashes in case execution of the dispatch calls is requested by an object inside the view that can't cope with being killed itself before the call returns. So at least currently you can't do anything against it, except writing an issue of course asking the Writer developers for switching to a synchronous exchange of the View (though I don't know if this is feasible). Best regards, Mathias Bauer -- 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]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
Oliver Brinzing wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Mathias, The name of the property is SynchronMode and of course its value must be set to True in case you want to have synchronous execution. I tried it, without success, it seems, it's not possible to close the preview from java ... What means without success? What exactly did you do and what exactly happened? 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]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Mathias, What means without success? What exactly did you do and what exactly happened? that means, the preview is not closed, if i open a message box directly after the excecuteDispatch(), it does not matter if i use the SynchronMode or not ... the message box is shown in preview mode, after closing it, preview mode is still active ... without showMessageBox() the preview is closed ... here is a snippet of my code: PropertyValue[] xProps = new PropertyValue[1]; xProps[0] = new PropertyValue(); xProps[0].Name = SynchronMode; xProps[0].Value = Boolean.TRUE; executeDispatch(getModel().getCurrentController().getFrame(), .uno:ClosePreview, xProps); showMessageBox(); public Object executeDispatch(XFrame xFrame, String sUrl, PropertyValue xProp[]) { Object dispatchHelper = null; try { dispatchHelper = xComponentContext.getServiceManager() .createInstanceWithContext(com.sun.star.frame.DispatchHelper, xComponentContext); } catch (Exception e) { return null; } XDispatchHelper xDispatch = (XDispatchHelper) UnoRuntime .queryInterface(XDispatchHelper.class, dispatchHelper); XDispatchProvider xProvider = (XDispatchProvider) UnoRuntime .queryInterface(XDispatchProvider.class, xFrame); Object oDispatch = xDispatch.executeDispatch(xProvider, sUrl, , 0, xProp); return oDispatch; } public void showMessageBox() { XWindow xParent = null; XFrame xFrame = xController.getFrame(); XToolkit xToolkit = null; if (xFrame != null) xParent = xFrame.getContainerWindow(); try { xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, xComponentContext.getServiceManager() .createInstanceWithContext( com.sun.star.awt.Toolkit, xComponentContext)); } catch (Exception e) { e.printStackTrace(); } Oliver - -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE7atbTiyrQM/QSkURAp3RAJ0azSb+i4rboSD9ymm58sSGwA5l/ACePnYJ aoXXQSB/o85j7PPL9UQKTd8= =J1QP -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Mathias, The name of the property is SynchronMode and of course its value must be set to True in case you want to have synchronous execution. I tried it, without success, it seems, it's not possible to close the preview from java ... regards Oliver - -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE6VEjTiyrQM/QSkURAje2AKCd35SfCnSCL08eLm0C2EG9ig1/5QCgkdp+ NovSq7qZNyf5XIy225PjavM= =7Bbi -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
Oliver Brinzing wrote: Am 07.08.2006 08:41 schrieb Andreas Schlüns: If you wish to force a synchronous execution of your dispatch you should try the argument Asynchron as [bool] with a valud false. are you sure, this works ? I can see no difference ... the preview is not closed even if I use xProps[0] = new PropertyValue(); xProps[0].Name = Asynchron; xProps[0].Value = Boolean.FALSE; Object oDispatch = xDispatch.executeDispatch(xProvider, .uno:ClosePreviewl, , 0, xProps); The name of the property is SynchronMode and of course its value must be set to True in case you want to have synchronous execution. Closing a view synchronously is a little bit risky. If the code is executed from a call stack that was started somewhere inside a VCL resource (e.g. a toolbar) it *could* lead to a crash. So you have to try out if it works. 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]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
Oliver Brinzing wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Andreas, thanks for the detailed explanation ... I always try to avoid using dispatches ... Next possible solutions: a) close these preview using another API but I can not find an api for closing the calc preview ... There exists only an API to close the whole document/frame ... switching from one view to another one can be reached currently only by the dispatch ... if I'm not wrong .-( Did you try the XNotifyingDispatch solution ? If your listener will be called before the operation was realy done, it seams to be a bug. Oliver - -- Regards Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Andreas, thanks for the detailed explanation ... I always try to avoid using dispatches ... Next possible solutions: a) close these preview using another API but I can not find an api for closing the calc preview ... Oliver - -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE2hOATiyrQM/QSkURAm0bAKCYwz9ErcRiQYW1yCUMFHhYUxFslQCfZu2H 05ziXich0cBX9vq4lEYhNI4= =hc0q -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
Oliver Brinzing wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, 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]
Re: [api-dev] how to dispatch .uno:ClosePreview from java ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Andreas, Am 07.08.2006 08:41 schrieb Andreas Schlüns: If you wish to force a synchronous execution of your dispatch you should try the argument Asynchron as [bool] with a valud false. are you sure, this works ? I can see no difference ... the preview is not closed even if I use xProps[0] = new PropertyValue(); xProps[0].Name = Asynchron; xProps[0].Value = Boolean.FALSE; Object oDispatch = xDispatch.executeDispatch(xProvider, .uno:ClosePreviewl, , 0, xProps); Oliver - -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE13C+TiyrQM/QSkURAvx/AKCEoZChxyQqIRHG/uLM2Ysq0JUILQCgxX6J NiTJarJ+ikr96ToxHO5zqmk= =+nMh -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]