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 #ifndef COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX 25 #define COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX 26 27 #include <comphelper/uno3.hxx> 28 #ifndef COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX 29 #include <comphelper/accessiblecomponenthelper.hxx> 30 #endif 31 #include <cppuhelper/implbase1.hxx> 32 #include <comphelper/uno3.hxx> 33 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 34 #include "comphelper/comphelperdllapi.h" 35 36 #define ACCESSIBLE_SELECTION_CHILD_ALL ((sal_Int32)-1) 37 #define ACCESSIBLE_SELECTION_CHILD_SELF ((sal_Int32)-2) 38 39 //......................................................................... 40 namespace comphelper 41 { 42 //......................................................................... 43 44 //===================================================================== 45 //= OCommonAccessibleSelection 46 //===================================================================== 47 /** base class encapsulating common functionality for the helper classes implementing 48 the XAccessibleSelection 49 */ 50 class COMPHELPER_DLLPUBLIC OCommonAccessibleSelection 51 { 52 protected: 53 54 OCommonAccessibleSelection(); 55 56 protected: 57 58 // access to context - still waiting to be overwritten 59 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 60 implGetAccessibleContext() = 0; 61 62 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) 63 virtual sal_Bool 64 implIsSelected( sal_Int32 nAccessibleChildIndex ) = 0; 65 66 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) 67 virtual void 68 implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) = 0; 69 70 protected: 71 72 /** non-virtual versions of the methods which can be implemented using <method>implIsSelected</method> and <method>implSelect</method> 73 */ 74 void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ); 75 sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ); 76 void SAL_CALL clearAccessibleSelection( ); 77 void SAL_CALL selectAllAccessibleChildren( ); 78 sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ); 79 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ); 80 void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ); 81 }; 82 83 //===================================================================== 84 //= OAccessibleSelectionHelper 85 //===================================================================== 86 87 typedef ::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleSelection > OAccessibleSelectionHelper_Base; 88 89 /** a helper class for implementing an AccessibleSelection which at the same time 90 supports an XAccessibleSelection interface. 91 */ 92 class COMPHELPER_DLLPUBLIC OAccessibleSelectionHelper : public OAccessibleComponentHelper, 93 public OCommonAccessibleSelection, 94 public OAccessibleSelectionHelper_Base 95 { 96 protected: 97 98 OAccessibleSelectionHelper( ); 99 100 /// see the respective base class ctor for an extensive comment on this, please 101 OAccessibleSelectionHelper( IMutex* _pExternalLock ); 102 103 // return ourself here by default 104 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > implGetAccessibleContext(); 105 106 public: 107 108 // XInterface 109 DECLARE_XINTERFACE( ) 110 DECLARE_XTYPEPROVIDER( ) 111 112 // XAccessibleSelection - default implementations 113 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ); 114 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ); 115 virtual void SAL_CALL clearAccessibleSelection( ); 116 virtual void SAL_CALL selectAllAccessibleChildren( ); 117 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ); 118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ); 119 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ); 120 }; 121 122 //......................................................................... 123 } // namespace comphelper 124 //......................................................................... 125 126 #endif // COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX 127