UNO Java API event listeners and source objects

The Application Programming Interface and the OASIS Open Document Format

UNO Java API event listeners and source objects

Postby waynemot » Tue Aug 07, 2012 8:34 pm

I've inherited a Java app that uses the UNO API's to launch an instance of swriter and then listens for actions of the user to form a record/playback behavior. My problem is when an action is detected by the window listener's notifyEvent() method I'm unable to get the XModel/XControl classes by the UnoRuntime.queryInterface() mechanism, at least using any of the examples I've found so far. From what it seems to me, the event source should be an AccessibleEventObject.Source and I'm doing things like UnoRuntime.queryInterface(XControl.class, accessibleEventObject.Source) but I'm not getting anything back doing that so I'm asking for a little help on how to expose the underlying document object (particularly the XText).

Any pointers on how to expose the document and it's text content via the AccessibleEventObject data passed to the notifyEvent() method? The listener class extends XAccessibleEventListener and XTopWindowListener.
Posts: 2
Joined: Tue Aug 07, 2012 6:37 pm

Re: UNO Java API event listeners and source objects

Postby pitonyak » Tue Sep 11, 2012 7:30 am

Does the event include a reference to the object that caused the event to be fired?

I expect that it does. The difficult part (from my perspective), is to then walk back to the sending document from the object that caused the event. This is easier in Basic I think (to inspect the objects and understand what you received).
Andrew Pitonyak
LO and AOO on Fedora
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: UNO Java API event listeners and source objects

Postby waynemot » Tue Sep 11, 2012 3:08 pm

I've made some level of progress/understanding about the Source object packaged within the keyEvent, which seemingly is not being documented in later revisions of the man page, or may be destined for the deprecation bin (hopefully not...)

The Source object points to a FRAME (role) object which contains one child which is a MENU of all the drop-down menus of the 'swriter' application. I'll probably end up caching the captured chars and/or grabbing the XText in the notifyEvent(), since I'm extending both the XKeyHandler and XAccessibleEventListener (as well as a XTopWindowListener) with this class, I can put in a field to save the string or state if I intend to capture the data from the subsequent event.

What I'm trying to do is extend the GUITAR framework and now I'm tackling the problem of key capture into the GUITAR scripts.
Since the 'Select All' keyboard action of Control-A only is seen by keyPressed() and keyReleased(), and the GUITAR framework wants an object that has an XAction object embedded that contains the keyCode/keyModifier/etc. The object I've got at the keyPressed(), neither the KeyEvent nor it's hidden/lost-documented Source object gives me this kind of embedded XAction object. My hunt goes on...
Thanks for the reply!
Col. P
OpenOffice 3.4 on Win 7
Posts: 2
Joined: Tue Aug 07, 2012 6:37 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest