fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / EventListener.java
blob66fe5da5de67484dd51d9ba594e8fe23a2038205
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.*;
21 /** Objects of this class (usually one, singleton?) listen to accessible
22 events of all objects in all trees.
24 public class EventListener
26 public boolean mbVerbose = false;
28 public EventListener (AccessibilityTreeModel aTreeModel)
30 maTreeModel = aTreeModel;
34 private static String objectToString(Object aObject)
36 if (aObject == null)
37 return null;
38 else
39 return aObject.toString();
44 /** This method handles accessibility objects that are being disposed.
46 public void disposing (XAccessibleContext xContext)
48 if (mbVerbose)
49 System.out.println("disposing " + xContext);
50 maTreeModel.removeNode (xContext);
53 /** This method is called from accessible objects that broadcast
54 modifications of themselves or from their children. The event is
55 processed only, except printing some messages, if the tree is not
56 locked. It should be locked during changes to its internal
57 structure like expanding nodes.
59 public void notifyEvent (AccessibleEventObject aEvent)
61 EventHandler aHandler;
63 switch (aEvent.EventId)
65 case AccessibleEventId.CHILD:
66 aHandler = new ChildEventHandler (aEvent, maTreeModel);
67 break;
69 case AccessibleEventId.BOUNDRECT_CHANGED:
70 case AccessibleEventId.VISIBLE_DATA_CHANGED:
71 aHandler = new GeometryEventHandler (aEvent, maTreeModel);
72 break;
75 case AccessibleEventId.NAME_CHANGED:
76 case AccessibleEventId.DESCRIPTION_CHANGED:
77 case AccessibleEventId.STATE_CHANGED:
78 case AccessibleEventId.SELECTION_CHANGED:
79 aHandler = new ContextEventHandler (aEvent, maTreeModel);
80 break;
82 case AccessibleEventId.TABLE_MODEL_CHANGED:
83 case AccessibleEventId.TABLE_CAPTION_CHANGED:
84 case AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED:
85 case AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED:
86 case AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED:
87 case AccessibleEventId.TABLE_ROW_HEADER_CHANGED:
88 case AccessibleEventId.TABLE_SUMMARY_CHANGED:
89 aHandler = new TableEventHandler (aEvent, maTreeModel);
90 break;
92 case AccessibleEventId.ACTION_CHANGED:
93 aHandler = new EventHandler (aEvent, maTreeModel);
94 break;
96 case AccessibleEventId.HYPERTEXT_CHANGED:
97 aHandler = new EventHandler (aEvent, maTreeModel);
98 break;
100 case AccessibleEventId.ACTIVE_DESCENDANT_CHANGED:
101 case AccessibleEventId.CARET_CHANGED:
102 case AccessibleEventId.TEXT_CHANGED:
103 case AccessibleEventId.VALUE_CHANGED:
104 aHandler = new EventHandler (aEvent, maTreeModel);
105 break;
107 default:
108 aHandler = null;
109 break;
112 if (aHandler == null)
113 System.out.println (" unhandled event");
114 else
116 if (mbVerbose)
117 aHandler.Print (System.out);
118 aHandler.Process ();
123 private AccessibilityTreeModel maTreeModel;