1*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 2*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleEventObject; 3*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 4*cdf0e10cSrcweir 5*cdf0e10cSrcweir import java.io.PrintStream; 6*cdf0e10cSrcweir 7*cdf0e10cSrcweir class ChildEventHandler 8*cdf0e10cSrcweir extends EventHandler 9*cdf0e10cSrcweir { 10*cdf0e10cSrcweir public ChildEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel) 11*cdf0e10cSrcweir { 12*cdf0e10cSrcweir super (aEvent, aTreeModel); 13*cdf0e10cSrcweir mxOldChild = (XAccessible)UnoRuntime.queryInterface( 14*cdf0e10cSrcweir XAccessible.class, aEvent.OldValue); 15*cdf0e10cSrcweir mxNewChild = (XAccessible)UnoRuntime.queryInterface( 16*cdf0e10cSrcweir XAccessible.class, aEvent.NewValue); 17*cdf0e10cSrcweir } 18*cdf0e10cSrcweir 19*cdf0e10cSrcweir public void PrintOldAndNew (PrintStream out) 20*cdf0e10cSrcweir { 21*cdf0e10cSrcweir if (mxOldChild != null) 22*cdf0e10cSrcweir out.println (" removing child " + mxOldChild); 23*cdf0e10cSrcweir if (mxNewChild != null) 24*cdf0e10cSrcweir out.println (" adding child " + mxNewChild); 25*cdf0e10cSrcweir } 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir public void Process () 28*cdf0e10cSrcweir { 29*cdf0e10cSrcweir // Insertion and removal of children should be mutually exclusive. 30*cdf0e10cSrcweir // But this is a test tool and should take everything into account. 31*cdf0e10cSrcweir if (mxOldChild != null) 32*cdf0e10cSrcweir { 33*cdf0e10cSrcweir maTreeModel.removeNode (mxOldChild.getAccessibleContext()); 34*cdf0e10cSrcweir maTreeModel.updateNode (mxEventSource, AccessibleTreeHandler.class); 35*cdf0e10cSrcweir } 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir if (mxNewChild != null) 38*cdf0e10cSrcweir { 39*cdf0e10cSrcweir maTreeModel.addChild (mxEventSource, mxNewChild); 40*cdf0e10cSrcweir } 41*cdf0e10cSrcweir } 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir private XAccessible mxOldChild; 45*cdf0e10cSrcweir private XAccessible mxNewChild; 46*cdf0e10cSrcweir } 47