| View previous topic :: View next topic |
| Author |
Message |
berry120 General User

Joined: 12 Mar 2012 Posts: 8
|
Posted: Wed Mar 21, 2012 3:55 pm Post subject: Prevent user from using impress presentation window |
|
|
I'm currently programmatically launching and controlling an impress presentation from my application, which seems to work well. However, I'd like to just allow control this way, and stop the user from being able to click on the presentation window itself or press keys etc. to interact with the presentation.
Is there a way to do this with the UNO API? I'm using Java if that affects things at all. |
|
| Back to top |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Thu Mar 22, 2012 9:53 am Post subject: |
|
|
| How about to disable the container window of the presentation? I tried it and it seemed work well anything I could not do it on. |
|
| Back to top |
|
 |
berry120 General User

Joined: 12 Mar 2012 Posts: 8
|
Posted: Thu Mar 22, 2012 4:07 pm Post subject: |
|
|
Perhaps I'm missing something with the way I'm trying to go about disabling the presentation's container window?
I was attempting to do this by the following:
| Code: |
XModel xPresModel = UnoRuntime.queryInterface(XModel.class, xPresentation);
xPresModel.getCurrentController().getFrame().getContainerWindow().setEnable(false);
|
However, xPresModel ends up being null so I can't find a way to retrieve the window in question. Am I querying the wrong object for the XModel (xPresentation is an instance of XPresentation) or do I need to look for something else entirely? |
|
| Back to top |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Thu Mar 22, 2012 9:49 pm Post subject: |
|
|
Here is a way to get full screen presentation window using event listener:
| Code: | Sub AddDocumentEventListener
listener = CreateUnoListener(_
"DocumentEvent_", "com.sun.star.document.XEventListener")
oDoc = ThisComponent
oDoc.com_sun_star_document_XEventBroadcaster_addEventListener(listener)
End Sub
Sub DocumentEvent_notifyEvent(ev)
If ev.EventName = "OnStartPresentation" Then
' FullScreenPresentation
oController = ev.Source.getCurrentController()
oContWin = oController.getFrame().getContainerWindow()
oContWin.setEnable(False)
End If
End Sub
Sub DocumentEvent_disposing(ev)
End Sub |
When the presentation is started on the document, another frame is created if full screen mode is choosen and slide show is shown in it. The document model is the same with the one of the original document but the document controller and the frame are different.
DocumentEvent_notifyEvent method is called when the presentation is started. If full screen mode is choosen, we can get the controller of the newly opened frame from the event object for the full screen presentation. |
|
| Back to top |
|
 |
berry120 General User

Joined: 12 Mar 2012 Posts: 8
|
Posted: Fri Mar 23, 2012 7:06 am Post subject: |
|
|
Thanks for the reply.
I've tried to replicate this in Java but without success using the following:
| Code: | doc = Helper.createDocument(xOfficeContext, sURL.toString(), "_blank", 0, props);
doc.addEventListener(new XEventListener() {
@Override
public void notifyEvent(com.sun.star.document.EventObject eo) {
System.out.println(eo.EventName);
}
@Override
public void disposing(EventObject eo) {
System.out.println("disposing");
}
}); |
The event listener in the above example never seems to get called when the presentation is started - nothing is printed out. Do I need to create the event listener some other way, through a "createunolistener()" function or similar? And if so, where do I look to find it?
Thanks for your help. |
|
| Back to top |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Fri Mar 23, 2012 8:04 am Post subject: |
|
|
The problem is not clear for me because the class name is not written in fully qualified name. Maybe your variable "doc" is css.lang.XComponent interface, if so, it should be css.document.XEventBroadcaster interface to register like as follows.
Here is my try as macro in Java and it worked like written in Basic.
| Code: | public static void test(XScriptContext xScriptContext) {
XModel xModel = xScriptContext.getDocument();
com.sun.star.document.XEventBroadcaster xDocEventBroadcaster =
UnoRuntime.queryInterface(com.sun.star.document.XEventBroadcaster.class, xModel);
xDocEventBroadcaster.addEventListener(new com.sun.star.document.XEventListener() {
@Override
public void disposing(EventObject ev) {
}
@Override
public void notifyEvent(com.sun.star.document.EventObject ev) {
System.out.println(ev.EventName);
XModel xModel = UnoRuntime.queryInterface(XModel.class, ev.Source);
XController xController = xModel.getCurrentController();
xController.getFrame().getContainerWindow().setEnable(false);
}
});
} |
|
|
| Back to top |
|
 |
berry120 General User

Joined: 12 Mar 2012 Posts: 8
|
Posted: Fri Mar 23, 2012 8:16 am Post subject: |
|
|
| Ah, yes that was indeed the issue! Thanks for your help. |
|
| Back to top |
|
 |
|