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.XAccessible;
23 import com.sun.star.accessibility.AccessibleEventObject;
24 import com.sun.star.accessibility.AccessibleEventId;
25 import com.sun.star.uno.UnoRuntime;
26 import com.sun.star.uno.AnyConverter;
27 
28 import java.io.PrintStream;
29 
30 import tools.NameProvider;
31 
32 class ContextEventHandler
33     extends EventHandler
34 {
ContextEventHandler(AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)35     public ContextEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
36     {
37         super (aEvent, aTreeModel);
38     }
39 
PrintOldAndNew(PrintStream out)40     public void PrintOldAndNew (PrintStream out)
41     {
42         switch (mnEventId)
43         {
44             case AccessibleEventId.STATE_CHANGED:
45                 try
46                 {
47                     int nOldValue = AnyConverter.toInt (maEvent.OldValue);
48                     out.println ("    turning off state " + nOldValue + " ("
49                         + NameProvider.getStateName (nOldValue) + ")");
50                 }
51                 catch (com.sun.star.lang.IllegalArgumentException e)
52                 {}
53                 try
54                 {
55                     int nNewValue = AnyConverter.toInt (maEvent.NewValue);
56                     out.println ("    turning on state " + nNewValue + " ("
57                         + NameProvider.getStateName (nNewValue) + ")");
58                 }
59                 catch (com.sun.star.lang.IllegalArgumentException e)
60                 {}
61                 break;
62 
63             default:
64                 super.PrintOldAndNew (out);
65         }
66 
67     }
68 
Process()69     public void Process ()
70     {
71         maTreeModel.updateNode (mxEventSource, AccessibleContextHandler.class);
72     }
73 }
74