OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Prevent user from using impress presentation window

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
berry120
General User
General User


Joined: 12 Mar 2012
Posts: 8

PostPosted: Wed Mar 21, 2012 3:55 pm    Post subject: Prevent user from using impress presentation window Reply with quote

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
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Thu Mar 22, 2012 9:53 am    Post subject: Reply with quote

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
View user's profile Send private message
berry120
General User
General User


Joined: 12 Mar 2012
Posts: 8

PostPosted: Thu Mar 22, 2012 4:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Thu Mar 22, 2012 9:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
berry120
General User
General User


Joined: 12 Mar 2012
Posts: 8

PostPosted: Fri Mar 23, 2012 7:06 am    Post subject: Reply with quote

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
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Fri Mar 23, 2012 8:04 am    Post subject: Reply with quote

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
View user's profile Send private message
berry120
General User
General User


Joined: 12 Mar 2012
Posts: 8

PostPosted: Fri Mar 23, 2012 8:16 am    Post subject: Reply with quote

Ah, yes that was indeed the issue! Thanks for your help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group