1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 import com.sun.star.accessibility.*; 23 import com.sun.star.lang.EventObject; 24 import com.sun.star.uno.*; 25 import com.sun.star.accessibility.*; 26 27 import java.util.LinkedList; 28 29 class QueuedListener 30 implements XAccessibleEventListener 31 { QueuedListener(EventListener aListener)32 public QueuedListener (EventListener aListener) 33 { 34 maListener = aListener; 35 } 36 37 disposing( final EventObject aEvent)38 public void disposing( final EventObject aEvent) 39 { 40 XAccessibleContext xContext = (XAccessibleContext)UnoRuntime.queryInterface( 41 XAccessibleContext.class, aEvent.Source); 42 if (xContext == null) 43 { 44 XAccessible xAccessible = (XAccessible)UnoRuntime.queryInterface( 45 XAccessible.class, aEvent.Source); 46 if (xAccessible != null) 47 xContext = xAccessible.getAccessibleContext(); 48 } 49 final XAccessibleContext xSource = xContext; 50 EventQueue.Instance().addDisposingEvent (new Runnable() 51 { 52 public void run() 53 { 54 if (QueuedListener.this.maListener != null) 55 QueuedListener.this.maListener.disposing (xSource); 56 } 57 } 58 ); 59 } 60 notifyEvent( final AccessibleEventObject aEvent )61 public void notifyEvent( final AccessibleEventObject aEvent ) 62 { 63 EventQueue.Instance().addEvent (new Runnable() 64 { 65 public void run() 66 { 67 QueuedListener.this.maListener.notifyEvent( aEvent ); 68 } 69 } 70 ); 71 } 72 73 private EventListener maListener; 74 } 75 76 77