1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * The Contents of this file are made available subject to the terms of 4*cdf0e10cSrcweir * the BSD license. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 7*cdf0e10cSrcweir * All rights reserved. 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * Redistribution and use in source and binary forms, with or without 10*cdf0e10cSrcweir * modification, are permitted provided that the following conditions 11*cdf0e10cSrcweir * are met: 12*cdf0e10cSrcweir * 1. Redistributions of source code must retain the above copyright 13*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer. 14*cdf0e10cSrcweir * 2. Redistributions in binary form must reproduce the above copyright 15*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer in the 16*cdf0e10cSrcweir * documentation and/or other materials provided with the distribution. 17*cdf0e10cSrcweir * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 18*cdf0e10cSrcweir * contributors may be used to endorse or promote products derived 19*cdf0e10cSrcweir * from this software without specific prior written permission. 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*cdf0e10cSrcweir * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*cdf0e10cSrcweir * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*cdf0e10cSrcweir * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*cdf0e10cSrcweir * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*cdf0e10cSrcweir * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*cdf0e10cSrcweir * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28*cdf0e10cSrcweir * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29*cdf0e10cSrcweir * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30*cdf0e10cSrcweir * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 31*cdf0e10cSrcweir * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*cdf0e10cSrcweir * 33*cdf0e10cSrcweir *************************************************************************/ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir import java.util.Vector; 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 38*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 39*cdf0e10cSrcweir import com.sun.star.uno.Type; 40*cdf0e10cSrcweir import com.sun.star.accessibility.*; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir /** Handle all the events send from accessibility objects. The events 43*cdf0e10cSrcweir denoting new or removed top windows are handled as well. 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir It does not implement any listener interface as does the 46*cdf0e10cSrcweir EventListenerProxy class because it is interested only in a sub set of 47*cdf0e10cSrcweir the event types. 48*cdf0e10cSrcweir */ 49*cdf0e10cSrcweir public class EventHandler 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir public EventHandler () 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir mnTopWindowCount = 0; 54*cdf0e10cSrcweir maListenerProxy = new EventListenerProxy (this); 55*cdf0e10cSrcweir maConnectionTask = new ConnectionTask (maListenerProxy); 56*cdf0e10cSrcweir maObjectDisplays = new Vector (); 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir public synchronized void addObjectDisplay (IAccessibleObjectDisplay aDisplay) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir maObjectDisplays.add (aDisplay); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir public void finalize () 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir // When it is running then cancel the timer that tries to connect to 68*cdf0e10cSrcweir // the Office. 69*cdf0e10cSrcweir if (maConnectionTask != null) 70*cdf0e10cSrcweir maConnectionTask.cancel(); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir public void disposing (com.sun.star.lang.EventObject aEvent) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir // Ignored: We are not holding references to accessibility objects. 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /** This method is called back when a new top level window has been opened. 84*cdf0e10cSrcweir */ 85*cdf0e10cSrcweir public void windowOpened (XAccessible xAccessible) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if (xAccessible != null) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir // Update the counter of currently open top level windows 90*cdf0e10cSrcweir // observed by this object. 91*cdf0e10cSrcweir mnTopWindowCount += 1; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir XAccessibleContext xContext = xAccessible.getAccessibleContext(); 94*cdf0e10cSrcweir if (xContext != null) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir MessageArea.println ("new top level window has accessible name " 97*cdf0e10cSrcweir + xContext.getAccessibleName()); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir // Register at all accessible objects of the new window. 100*cdf0e10cSrcweir new RegistrationThread ( 101*cdf0e10cSrcweir maListenerProxy, 102*cdf0e10cSrcweir xContext, 103*cdf0e10cSrcweir true, 104*cdf0e10cSrcweir true); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir else 107*cdf0e10cSrcweir MessageArea.println ("new top level window is not accessible."); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir MessageArea.println ("new top level window is not accessible."); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir public void windowClosed (XAccessible xAccessible) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir mnTopWindowCount -= 1; 119*cdf0e10cSrcweir MessageArea.println ("window closed, " + mnTopWindowCount + " still open"); 120*cdf0e10cSrcweir if (mnTopWindowCount == 0) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir // This was the last window. Wait for a new connection. 123*cdf0e10cSrcweir MessageArea.println ("lost connection to office"); 124*cdf0e10cSrcweir new ConnectionTask (maListenerProxy); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir if (xAccessible != null) 127*cdf0e10cSrcweir new RegistrationThread ( 128*cdf0e10cSrcweir maListenerProxy, 129*cdf0e10cSrcweir xAccessible.getAccessibleContext(), 130*cdf0e10cSrcweir false, 131*cdf0e10cSrcweir true); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /** Print a message that the given object just received the focus. Call 138*cdf0e10cSrcweir all accessible object diplays and tell them to update. 139*cdf0e10cSrcweir */ 140*cdf0e10cSrcweir private synchronized void focusGained (XAccessibleContext xContext) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir if (xContext != null) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir MessageArea.println ("focusGained: " + xContext.getAccessibleName() 145*cdf0e10cSrcweir + " with role " 146*cdf0e10cSrcweir + NameProvider.getRoleName (xContext.getAccessibleRole())); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // Tell the object displays to update their views. 149*cdf0e10cSrcweir for (int i=0; i<maObjectDisplays.size(); i++) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir IAccessibleObjectDisplay aDisplay = 152*cdf0e10cSrcweir (IAccessibleObjectDisplay)maObjectDisplays.get(i); 153*cdf0e10cSrcweir if (aDisplay != null) 154*cdf0e10cSrcweir aDisplay.setAccessibleObject (xContext); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // Remember the currently focused object. 158*cdf0e10cSrcweir mxFocusedObject = xContext; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir else 161*cdf0e10cSrcweir MessageArea.println ("focusGained: null"); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /** Print a message that the given object just lost the focus. Call 168*cdf0e10cSrcweir all accessible object diplays and tell them to update. 169*cdf0e10cSrcweir */ 170*cdf0e10cSrcweir private synchronized void focusLost (XAccessibleContext xContext) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir if (xContext != null) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir MessageArea.println ("focusLost: " 175*cdf0e10cSrcweir + xContext.getAccessibleName() 176*cdf0e10cSrcweir + " with role " 177*cdf0e10cSrcweir + NameProvider.getRoleName (xContext.getAccessibleRole())); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // Tell the object displays to update their views. 180*cdf0e10cSrcweir for (int i=0; i<maObjectDisplays.size(); i++) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir IAccessibleObjectDisplay aDisplay = 183*cdf0e10cSrcweir (IAccessibleObjectDisplay)maObjectDisplays.get(i); 184*cdf0e10cSrcweir if (aDisplay != null) 185*cdf0e10cSrcweir aDisplay.setAccessibleObject (null); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir mxFocusedObject = null; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir else 190*cdf0e10cSrcweir MessageArea.println ("focusLost: null"); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir /** Handle a change of the caret position. Ignore this on all objects 197*cdf0e10cSrcweir but the one currently focused. 198*cdf0e10cSrcweir */ 199*cdf0e10cSrcweir private void handleCaretEvent (XAccessibleContext xContext, 200*cdf0e10cSrcweir long nOldPosition, long nNewPosition) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if (xContext == mxFocusedObject) 203*cdf0e10cSrcweir MessageArea.println ("caret moved from " + nOldPosition + " to " + nNewPosition); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir /** Print a message that a state has been changed. 210*cdf0e10cSrcweir @param xContext 211*cdf0e10cSrcweir The accessible context of the object whose state has changed. 212*cdf0e10cSrcweir @param nOldState 213*cdf0e10cSrcweir When not zero then this value describes a state that has been reset. 214*cdf0e10cSrcweir @param nNewValue 215*cdf0e10cSrcweir When not zero then this value describes a state that has been set. 216*cdf0e10cSrcweir */ 217*cdf0e10cSrcweir private void handleStateChange (XAccessibleContext xContext, short nOldState, short nNewState) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir // Determine which state has changed and what is its new value. 220*cdf0e10cSrcweir short nState; 221*cdf0e10cSrcweir boolean aNewValue; 222*cdf0e10cSrcweir if (nOldState >= 0) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir nState = nOldState; 225*cdf0e10cSrcweir aNewValue = false; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir else 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir nState = nNewState; 230*cdf0e10cSrcweir aNewValue = true; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir // Print a message about the changed state. 234*cdf0e10cSrcweir MessageArea.print ("setting state " + NameProvider.getStateName(nState) 235*cdf0e10cSrcweir + " to " + aNewValue); 236*cdf0e10cSrcweir if (xContext != null) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir MessageArea.println (" at " + xContext.getAccessibleName() + " with role " 239*cdf0e10cSrcweir + NameProvider.getRoleName(xContext.getAccessibleRole())); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir MessageArea.println (" at null"); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // Further handling of some states 245*cdf0e10cSrcweir switch (nState) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir case AccessibleStateType.FOCUSED: 248*cdf0e10cSrcweir if (aNewValue) 249*cdf0e10cSrcweir focusGained (xContext); 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir focusLost (xContext); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir /** Handle a child event that describes the creation of removal of a 259*cdf0e10cSrcweir single child. 260*cdf0e10cSrcweir */ 261*cdf0e10cSrcweir private void handleChildEvent ( 262*cdf0e10cSrcweir XAccessibleContext aOldChild, 263*cdf0e10cSrcweir XAccessibleContext aNewChild) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir if (aOldChild != null) 266*cdf0e10cSrcweir // Remove event listener from the child and all of its descendants. 267*cdf0e10cSrcweir new RegistrationThread (maListenerProxy, aOldChild, false, false); 268*cdf0e10cSrcweir else if (aNewChild != null) 269*cdf0e10cSrcweir // Add event listener to the new child and all of its descendants. 270*cdf0e10cSrcweir new RegistrationThread (maListenerProxy, aNewChild, true, false); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir /** Handle the change of some visible data of an object. 277*cdf0e10cSrcweir */ 278*cdf0e10cSrcweir private void handleVisibleDataEvent (XAccessibleContext xContext) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir // The given object may affect the visible appearance of the focused 281*cdf0e10cSrcweir // object even when the two are not identical when the given object 282*cdf0e10cSrcweir // is an ancestor of the focused object. 283*cdf0e10cSrcweir // In order to not check this we simply call an update on the 284*cdf0e10cSrcweir // focused object. 285*cdf0e10cSrcweir if (mxFocusedObject != null) 286*cdf0e10cSrcweir for (int i=0; i<maObjectDisplays.size(); i++) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir IAccessibleObjectDisplay aDisplay = 289*cdf0e10cSrcweir (IAccessibleObjectDisplay)maObjectDisplays.get(i); 290*cdf0e10cSrcweir if (aDisplay != null) 291*cdf0e10cSrcweir aDisplay.updateAccessibleObject (mxFocusedObject); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir /** Print some information about an event that is not handled by any 299*cdf0e10cSrcweir more specialized handler. 300*cdf0e10cSrcweir */ 301*cdf0e10cSrcweir private void handleGenericEvent ( 302*cdf0e10cSrcweir int nEventId, 303*cdf0e10cSrcweir Object aSource, 304*cdf0e10cSrcweir Object aOldValue, 305*cdf0e10cSrcweir Object aNewValue) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir // Print event to message area. 308*cdf0e10cSrcweir MessageArea.print ("received event " 309*cdf0e10cSrcweir + NameProvider.getEventName (nEventId) + " from "); 310*cdf0e10cSrcweir XAccessibleContext xContext = objectToContext (aSource); 311*cdf0e10cSrcweir if (xContext != null) 312*cdf0e10cSrcweir MessageArea.print (xContext.getAccessibleName()); 313*cdf0e10cSrcweir else 314*cdf0e10cSrcweir MessageArea.print ("null"); 315*cdf0e10cSrcweir MessageArea.println (" / " 316*cdf0e10cSrcweir + NameProvider.getRoleName(xContext.getAccessibleRole())); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir /** This is the main method for handling accessibility events. It is 322*cdf0e10cSrcweir assumed that it is not called directly from the Office but from a 323*cdf0e10cSrcweir listener proxy that runs in a separate thread so that calls back to 324*cdf0e10cSrcweir the Office do not result in dead-locks. 325*cdf0e10cSrcweir */ 326*cdf0e10cSrcweir public void notifyEvent (com.sun.star.accessibility.AccessibleEventObject aEvent) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir try // Guard against disposed objects. 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir switch (aEvent.EventId) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir case AccessibleEventId.CHILD: 333*cdf0e10cSrcweir handleChildEvent ( 334*cdf0e10cSrcweir objectToContext (aEvent.OldValue), 335*cdf0e10cSrcweir objectToContext (aEvent.NewValue)); 336*cdf0e10cSrcweir break; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir case AccessibleEventId.STATE_CHANGED: 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir short nOldState = -1; 341*cdf0e10cSrcweir short nNewState = -1; 342*cdf0e10cSrcweir try 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir if (AnyConverter.isShort (aEvent.NewValue)) 345*cdf0e10cSrcweir nNewState = AnyConverter.toShort (aEvent.NewValue); 346*cdf0e10cSrcweir if (AnyConverter.isShort (aEvent.OldValue)) 347*cdf0e10cSrcweir nOldState = AnyConverter.toShort (aEvent.OldValue); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir catch (com.sun.star.lang.IllegalArgumentException e) 350*cdf0e10cSrcweir {} 351*cdf0e10cSrcweir handleStateChange ( 352*cdf0e10cSrcweir objectToContext (aEvent.Source), 353*cdf0e10cSrcweir nOldState, 354*cdf0e10cSrcweir nNewState); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir break; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir case AccessibleEventId.VISIBLE_DATA_CHANGED: 359*cdf0e10cSrcweir case AccessibleEventId.BOUNDRECT_CHANGED: 360*cdf0e10cSrcweir handleVisibleDataEvent (objectToContext (aEvent.Source)); 361*cdf0e10cSrcweir break; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir case AccessibleEventId.CARET_CHANGED: 364*cdf0e10cSrcweir try 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir handleCaretEvent ( 367*cdf0e10cSrcweir objectToContext (aEvent.Source), 368*cdf0e10cSrcweir AnyConverter.toLong(aEvent.OldValue), 369*cdf0e10cSrcweir AnyConverter.toLong(aEvent.NewValue)); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir catch (com.sun.star.lang.IllegalArgumentException e) 372*cdf0e10cSrcweir {} 373*cdf0e10cSrcweir break; 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir default: 376*cdf0e10cSrcweir handleGenericEvent (aEvent.EventId, 377*cdf0e10cSrcweir aEvent.Source, aEvent.OldValue, aEvent.NewValue); 378*cdf0e10cSrcweir break; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir catch (com.sun.star.lang.DisposedException e) 382*cdf0e10cSrcweir {} 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir /** Convert the given object into an accessible context. The object is 389*cdf0e10cSrcweir interpreted as UNO Any and may contain either an XAccessible or 390*cdf0e10cSrcweir XAccessibleContext reference. 391*cdf0e10cSrcweir @return 392*cdf0e10cSrcweir The returned value is null when the given object can not be 393*cdf0e10cSrcweir converted to an XAccessibleContext reference. 394*cdf0e10cSrcweir */ 395*cdf0e10cSrcweir private XAccessibleContext objectToContext (Object aObject) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir XAccessibleContext xContext = null; 398*cdf0e10cSrcweir XAccessible xAccessible = null; 399*cdf0e10cSrcweir try 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir xAccessible = (XAccessible)AnyConverter.toObject( 402*cdf0e10cSrcweir new Type(XAccessible.class), aObject); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir catch (com.sun.star.lang.IllegalArgumentException e) 405*cdf0e10cSrcweir {} 406*cdf0e10cSrcweir if (xAccessible != null) 407*cdf0e10cSrcweir xContext = xAccessible.getAccessibleContext(); 408*cdf0e10cSrcweir else 409*cdf0e10cSrcweir try 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir xContext = (XAccessibleContext)AnyConverter.toObject( 412*cdf0e10cSrcweir new Type(XAccessibleContext.class), aObject); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir catch (com.sun.star.lang.IllegalArgumentException e) 415*cdf0e10cSrcweir {} 416*cdf0e10cSrcweir return xContext; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir /** The proxy that runs in a seperate thread and allows to call back to 423*cdf0e10cSrcweir the Office without running into dead-locks. 424*cdf0e10cSrcweir */ 425*cdf0e10cSrcweir private EventListenerProxy maListenerProxy; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir /** The currently focused object. A value of null means that no object 428*cdf0e10cSrcweir has the focus. 429*cdf0e10cSrcweir */ 430*cdf0e10cSrcweir private XAccessibleContext mxFocusedObject; 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir /** Keep track of the currently open top windows to start a registration 433*cdf0e10cSrcweir loop when the last window (and the Office) is closed. 434*cdf0e10cSrcweir */ 435*cdf0e10cSrcweir private long mnTopWindowCount; 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir /** A list of objects that can display accessible objects in specific 438*cdf0e10cSrcweir ways such as showing a graphical representation or some textual 439*cdf0e10cSrcweir descriptions. 440*cdf0e10cSrcweir */ 441*cdf0e10cSrcweir private Vector maObjectDisplays; 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir /** The timer task that attempts in regular intervals to connect to a 444*cdf0e10cSrcweir running Office application. 445*cdf0e10cSrcweir */ 446*cdf0e10cSrcweir private ConnectionTask maConnectionTask; 447*cdf0e10cSrcweir } 448