1 import com.sun.star.accessibility.XAccessible;
2 import com.sun.star.accessibility.AccessibleEventObject;
3 import com.sun.star.accessibility.AccessibleEventId;
4 import com.sun.star.uno.UnoRuntime;
5 import com.sun.star.uno.AnyConverter;
6 
7 import java.io.PrintStream;
8 
9 import tools.NameProvider;
10 
11 class ContextEventHandler
12     extends EventHandler
13 {
14     public ContextEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
15     {
16         super (aEvent, aTreeModel);
17     }
18 
19     public void PrintOldAndNew (PrintStream out)
20     {
21         switch (mnEventId)
22         {
23             case AccessibleEventId.STATE_CHANGED:
24                 try
25                 {
26                     int nOldValue = AnyConverter.toInt (maEvent.OldValue);
27                     out.println ("    turning off state " + nOldValue + " ("
28                         + NameProvider.getStateName (nOldValue) + ")");
29                 }
30                 catch (com.sun.star.lang.IllegalArgumentException e)
31                 {}
32                 try
33                 {
34                     int nNewValue = AnyConverter.toInt (maEvent.NewValue);
35                     out.println ("    turning on state " + nNewValue + " ("
36                         + NameProvider.getStateName (nNewValue) + ")");
37                 }
38                 catch (com.sun.star.lang.IllegalArgumentException e)
39                 {}
40                 break;
41 
42             default:
43                 super.PrintOldAndNew (out);
44         }
45 
46     }
47 
48     public void Process ()
49     {
50         maTreeModel.updateNode (mxEventSource, AccessibleContextHandler.class);
51     }
52 }
53