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 23 24 package org.openoffice.java.accessibility; 25 26 import com.sun.star.accessibility.*; 27 28 class AccessibleSelectionImpl implements javax.accessibility.AccessibleSelection { 29 XAccessibleSelection unoAccessibleSelection; 30 AccessibleSelectionImpl(XAccessibleSelection xAccessibleSelection)31 AccessibleSelectionImpl(XAccessibleSelection xAccessibleSelection) { 32 unoAccessibleSelection = xAccessibleSelection; 33 } 34 35 /** Returns an Accessible representing the specified selected child of the object */ getAccessibleSelection(int i)36 public javax.accessibility.Accessible getAccessibleSelection(int i) { 37 try { 38 return (javax.accessibility.Accessible) AccessibleObjectFactory.getAccessibleComponent( 39 unoAccessibleSelection.getSelectedAccessibleChild(i)); 40 } catch (com.sun.star.uno.Exception e) { 41 return null; 42 } 43 } 44 45 /** Adds the specified Accessible child of the object to the object's selection */ addAccessibleSelection(int i)46 public void addAccessibleSelection(int i) { 47 try { 48 unoAccessibleSelection.selectAccessibleChild(i); 49 } catch (com.sun.star.uno.Exception e) { 50 } 51 } 52 53 /** Clears the selection in the object, so that no children in the object are selected */ clearAccessibleSelection()54 public void clearAccessibleSelection() { 55 try { 56 unoAccessibleSelection.clearAccessibleSelection(); 57 } catch (com.sun.star.uno.RuntimeException e) { 58 } 59 } 60 61 /** Returns the number of Accessible children currently selected */ getAccessibleSelectionCount()62 public int getAccessibleSelectionCount() { 63 try { 64 return unoAccessibleSelection.getSelectedAccessibleChildCount(); 65 } catch (com.sun.star.uno.RuntimeException e) { 66 return 0; 67 } 68 } 69 70 /** Determines if the current child of this object is selected */ isAccessibleChildSelected(int i)71 public boolean isAccessibleChildSelected(int i) { 72 try { 73 return unoAccessibleSelection.isAccessibleChildSelected(i); 74 } catch (com.sun.star.uno.Exception e) { 75 return false; 76 } 77 } 78 79 /** Removes the specified child of the object from the object's selection */ removeAccessibleSelection(int i)80 public void removeAccessibleSelection(int i) { 81 try { 82 unoAccessibleSelection.deselectAccessibleChild(i); 83 } catch (com.sun.star.uno.Exception e) { 84 } 85 } 86 87 /** Causes every child of the object to be selected if the object supports multiple selection */ selectAllAccessibleSelection()88 public void selectAllAccessibleSelection() { 89 try { 90 unoAccessibleSelection.selectAllAccessibleChildren(); 91 } catch (com.sun.star.uno.RuntimeException e) { 92 } 93 } 94 95 } 96