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_ACCIMPLACCESS_HXX 25 #define COMPHELPER_ACCIMPLACCESS_HXX 26 27 #include <cppuhelper/implbase1.hxx> 28 #include <com/sun/star/lang/XUnoTunnel.hpp> 29 #include "comphelper/comphelperdllapi.h" 30 31 // forward declaration 32 namespace com { namespace sun { namespace star { namespace accessibility { 33 class XAccessible; 34 class XAccessibleContext; 35 }}}} 36 37 //......................................................................... 38 namespace comphelper 39 { 40 //......................................................................... 41 42 //===================================================================== 43 //= OAccessibleImplementationAccess 44 //===================================================================== 45 typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XUnoTunnel 46 > OAccImpl_Base; 47 struct OAccImpl_Impl; 48 49 /** This is a helper class which allows accessing several aspects of the the implementation 50 of an AccessibleContext. 51 52 <p>For instance, when you want to implement a context which can be re-parented, you: 53 <ul><li>derive your class from <type>OAccessibleImplementationAccess</type></li> 54 <li>use <code>setAccessibleParent( <em>component</em>, <em>new_parent</em> )</code> 55 </ul> 56 </p> 57 58 <p>Another aspect which can be controlled from the outside are states. If you have a class which 59 has only partial control over it's states, you may consider deriving from OAccessibleImplementationAccess.<br/> 60 For instance, say you have an implementation (say component A) which is <em>unable</em> to know or to 61 determine if the represented object is selected, but another component (say B) which uses A (and integrates 62 it into a tree of accessibility components) is.<br/> 63 In this case, if A is derived from OAccessibleImplementationAccess, B can manipulate this 64 foreign-controlled state flag "SELECTED" by using the static helper methods on this class.</p> 65 66 <p>Please note that the support for foreign controlled states is rather restrictive: You can't have states 67 which <em>may be</em> controlled by a foreign instances. This is implied by the fact that a derived 68 class can ask for states which are <em>set</em> only, not for the ones which are <em>reset</em> currently. 69 </p> 70 */ 71 class COMPHELPER_DLLPUBLIC OAccessibleImplementationAccess : public OAccImpl_Base 72 { 73 private: 74 OAccImpl_Impl* m_pImpl; 75 76 protected: 77 /// retrieves the parent previously set via <method>setAccessibleParent</method> 78 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 79 implGetForeignControlledParent( ) const; 80 81 /** retrieves the set of currently set states which are controlled by a foreign instance 82 @return 83 a bit mask, where a set bit 2^n means that the AccessibleStateType n has been set 84 */ 85 sal_Int64 implGetForeignControlledStates( ) const; 86 87 /// sets the accessible parent component 88 virtual void setAccessibleParent( 89 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxAccParent ); 90 91 /// sets or resets a bit of the foreign controlled states 92 virtual void setStateBit( const sal_Int16 _nState, const sal_Bool _bSet ); 93 94 protected: 95 OAccessibleImplementationAccess( ); 96 virtual ~OAccessibleImplementationAccess( ); 97 98 // XUnoTunnel 99 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& _rIdentifier ) throw (::com::sun::star::uno::RuntimeException); 100 101 public: 102 /** tries to access the implementation of an OAccessibleImplementationAccess derivee which is known as 103 interface only. 104 105 @param _rxComponent 106 is the component which should be examined. 107 @return 108 the pointer to the implementation, if successfull. The only known error condition so far 109 is an invalid context (which means it is <NULL/>, or the implementation is not derived 110 from <type>OAccessibleImplementationAccess</type>, or retrieving the implementation failed). 111 */ 112 static OAccessibleImplementationAccess* getImplementation( 113 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxComponent 114 ); 115 116 117 /** sets the parent for a derived implementation 118 119 @param _rxComponent 120 is the component which's new parent should be set 121 @param _rxNewParent 122 is the new parent of the component 123 @return 124 <TRUE/> in case of success, <FALSE/> otherwise. For error condition please look at 125 <method>getImplementation</method>. 126 */ 127 static sal_Bool setAccessibleParent( 128 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxComponent, 129 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxNewParent 130 ); 131 132 /** sets or resets a state bit in the set of foreign-controlled states of the component. 133 134 @param _rxComponent 135 is the component which's state is to be (re)set 136 @param _nState 137 the state bit which should be affected. This should be one of the respective UNO constants. 138 @param _bSet 139 <TRUE/> if the bit should be set, <FALSE/> otherwise 140 @return 141 <TRUE/> in case of success, <FALSE/> otherwise. For error condition please look at 142 <method>getImplementation</method>. 143 */ 144 static sal_Bool setForeignControlledState( 145 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxComponent, 146 const sal_Int16 _nState, 147 const sal_Bool _bSet 148 ); 149 150 151 private: 152 COMPHELPER_DLLPRIVATE static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId(); 153 }; 154 155 //......................................................................... 156 } // namespace comphelper 157 //......................................................................... 158 159 160 #endif // COMPHELPER_ACCIMPLACCESS_HXX 161 162 163