Branch libreoffice-5-0-4
[LibreOffice.git] / toolkit / test / accessibility / QueuedListener.java
bloba34b335497341c16cab20ccd984cc4307ff4a10c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import com.sun.star.accessibility.*;
20 import com.sun.star.lang.EventObject;
21 import com.sun.star.uno.*;
23 class QueuedListener
24 implements XAccessibleEventListener
26 public QueuedListener (EventListener aListener)
28 maListener = aListener;
32 public void disposing( final EventObject aEvent)
34 XAccessibleContext xContext = UnoRuntime.queryInterface(
35 XAccessibleContext.class, aEvent.Source);
36 if (xContext == null)
38 XAccessible xAccessible = UnoRuntime.queryInterface(
39 XAccessible.class, aEvent.Source);
40 if (xAccessible != null)
41 xContext = xAccessible.getAccessibleContext();
43 final XAccessibleContext xSource = xContext;
44 EventQueue.Instance().addDisposingEvent (new Runnable()
46 public void run()
48 if (QueuedListener.this.maListener != null)
49 QueuedListener.this.maListener.disposing (xSource);
55 public void notifyEvent( final AccessibleEventObject aEvent )
57 EventQueue.Instance().addEvent (new Runnable()
59 public void run()
61 QueuedListener.this.maListener.notifyEvent( aEvent );
67 private final EventListener maListener;