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 _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
25 #define _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
26 
27 #include "unotools/unotoolsdllapi.h"
28 
29 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESSTATESET_HPP_
30 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
31 #endif
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/lang/XServiceName.hpp>
37 #include <vos/mutex.hxx>
38 #include <cppuhelper/implbase1.hxx>
39 #include <comphelper/servicehelper.hxx>
40 
41 class AccessibleRelationSetHelperImpl;
42 
43 //=========================================================================
44 //= XAccessibleRelationSet helper classes
45 //=========================================================================
46 
47 //... namespace utl .......................................................
48 namespace utl
49 {
50 //.........................................................................
51 
52 /**	@descr
53         This base class provides an implementation of the
54         <code>AccessibleRelationSet</code> service.
55 */
56 class UNOTOOLS_DLLPUBLIC AccessibleRelationSetHelper
57 	:	public cppu::WeakImplHelper1<
58 		::com::sun::star::accessibility::XAccessibleRelationSet
59         >
60 {
61 public:
62 	//=====  internal  ========================================================
63 	AccessibleRelationSetHelper ();
64 	AccessibleRelationSetHelper (const AccessibleRelationSetHelper& rHelper);
65 protected:
66 	virtual ~AccessibleRelationSetHelper	(void);
67 public:
68 
69 	//=====  XAccessibleRelationSet  ==========================================
70 
71 	/** Returns the number of relations in this relation set.
72 
73         @return
74             Returns the number of relations or zero if there are none.
75 	*/
76     virtual sal_Int32 SAL_CALL getRelationCount(  )
77 		throw (::com::sun::star::uno::RuntimeException);
78 
79 	/** Returns the relation of this relation set that is specified by
80         the given index.
81 
82         @param nIndex
83             This index specifies the relatio to return.
84 
85         @return
86             For a valid index, i.e. inside the range 0 to the number of
87             relations minus one, the returned value is the requested
88             relation.  If the index is invalid then the returned relation
89             has the type INVALID.
90 
91 	*/
92     virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL
93 		getRelation( sal_Int32 nIndex )
94 			throw (::com::sun::star::lang::IndexOutOfBoundsException,
95 					::com::sun::star::uno::RuntimeException);
96 
97 	/** Tests whether the relation set contains a relation matching the
98         specified key.
99 
100         @param aRelationType
101             The type of relation to look for in this set of relations.  This
102             has to be one of the constants of
103             <type>AccessibleRelationType</type>.
104 
105         @return
106             Returns <TRUE/> if there is a (at least one) relation of the
107             given type and <FALSE/> if there is no such relation in the set.
108 	*/
109     virtual sal_Bool SAL_CALL containsRelation( sal_Int16 aRelationType )
110 		throw (::com::sun::star::uno::RuntimeException);
111 
112 	/** Retrieve and return the relation with the given relation type.
113 
114         @param aRelationType
115             The type of the relation to return.  This has to be one of the
116             constants of <type>AccessibleRelationType</type>.
117 
118         @return
119             If a relation with the given type could be found than (a copy
120             of) this relation is returned.  Otherwise a relation with the
121             type INVALID is returned.
122 	*/
123     virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL
124 		getRelationByType( sal_Int16 aRelationType )
125 			throw (::com::sun::star::uno::RuntimeException);
126 
127 	void AddRelation(
128 		const ::com::sun::star::accessibility::AccessibleRelation& rRelation)
129 			throw (::com::sun::star::uno::RuntimeException);
130 
131 	//=====  XTypeProvider  ===================================================
132 
133     /**	Returns a sequence of all supported interfaces.
134     */
135 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
136 		getTypes (void)
137         throw (::com::sun::star::uno::RuntimeException);
138 
139     /**	Returns a implementation id.
140     */
141     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
142         getImplementationId (void)
143         throw (::com::sun::star::uno::RuntimeException);
144 
145 protected:
146 	///	Mutex guarding this object.
147     ::vos::OMutex maMutex;
148 
149 private:
150 	///	The implementation of this helper interface.
151 	AccessibleRelationSetHelperImpl*	mpHelperImpl;
152 };
153 
154 //.........................................................................
155 }
156 //... namespace utl .......................................................
157 #endif
158