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