xref: /AOO41X/main/unotools/inc/unotools/accessiblestatesethelper.hxx (revision bae3752ec30c258ca902793e4eea3c818b0bcaad)
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 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
24 #define _UTL_ACCESSIBLESTATESETHELPER_HXX_
25 
26 #include "unotools/unotoolsdllapi.h"
27 
28 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESSTATESET_HPP_
29 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
30 #endif
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <cppuhelper/weak.hxx>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/lang/XTypeProvider.hpp>
35 #include <com/sun/star/lang/XServiceName.hpp>
36 #include <vos/mutex.hxx>
37 #include <cppuhelper/implbase1.hxx>
38 #include <comphelper/servicehelper.hxx>
39 
40 class AccessibleStateSetHelperImpl;
41 
42 //=========================================================================
43 //= XAccessibleStateSet helper classes
44 //=========================================================================
45 
46 //... namespace utl .......................................................
47 namespace utl
48 {
49 //.........................................................................
50 
51 /** @descr
52         This base class provides an implementation of the
53         <code>AccessibleStateSet</code> service.
54 */
55 class UNOTOOLS_DLLPUBLIC AccessibleStateSetHelper
56     :   public cppu::WeakImplHelper1<
57         ::com::sun::star::accessibility::XAccessibleStateSet
58         >
59 {
60 public:
61     //=====  internal  ========================================================
62 
63     AccessibleStateSetHelper ();
64     /** constructs an object with some states initially set
65 
66         <p>This ctor is compatible with
67         <method scope="comphelper">OAccessibleImplementationAccess::implGetForeignControlledStates</method></p>
68 
69         @param _nInitialStates
70             is a bit mask. Every bit 2^n means that the state number n (as got from the
71             AccessibleStateType constants) should be set initially.
72     */
73     AccessibleStateSetHelper ( const sal_Int64 _nInitialStates );
74 
75     AccessibleStateSetHelper ( const AccessibleStateSetHelper& rHelper );
76 protected:
77     virtual ~AccessibleStateSetHelper   (void);
78 public:
79 
80     //=====  XAccessibleStateSet  ==============================================
81 
82     /** Checks whether the current state set is empty.
83 
84         @return
85             Returns <TRUE/> if there is no state in this state set and
86             <FALSE/> if there is at least one state set in it.
87     */
88     virtual sal_Bool SAL_CALL isEmpty ()
89         throw (::com::sun::star::uno::RuntimeException);
90 
91     /** Checks if the given state is a member of the state set of this
92         object.
93 
94         @param aState
95             The state for which to check membership.  This has to be one of
96             the constants of <type>AccessibleStateType</type>.
97 
98         @return
99             Returns <TRUE/> if the given state is a memeber of this object's
100             state set and <FALSE/> otherwise.
101     */
102     virtual sal_Bool SAL_CALL contains (sal_Int16 aState)
103         throw (::com::sun::star::uno::RuntimeException);
104 
105     /** Checks if all of the given states are in this object's state
106         set.
107 
108         @param aStateSet
109             This sequence of states is interpreted as set and every of its
110             members, duplicates are ignored, is checked for membership in
111             this object's state set.  Each state has to be one of the
112             constants of <type>AccessibleStateType</type>.
113 
114         @return
115             Returns <TRUE/> if all states of the given state set are members
116             of this object's state set.  <FALSE/> is returned if at least
117             one of the states in the given state is not a member of this
118             object's state set.
119     */
120     virtual sal_Bool SAL_CALL containsAll (
121         const ::com::sun::star::uno::Sequence<sal_Int16>& rStateSet)
122         throw (::com::sun::star::uno::RuntimeException);
123 
124     /** Returns a sequence of all states.
125     */
126     virtual com::sun::star::uno::Sequence<sal_Int16> SAL_CALL getStates()
127         throw (::com::sun::star::uno::RuntimeException);
128 
129     /** Adds a state to the set.
130     */
131     void    AddState(sal_Int16 aState)
132         throw (::com::sun::star::uno::RuntimeException);
133 
134     /** Removes a state from the set if the set contains the state, otherwise nothing is done.
135     */
136     void    RemoveState(sal_Int16 aState)
137         throw (::com::sun::star::uno::RuntimeException);
138 
139     /** Compares the set with the set given by rComparativeValue and puts the results
140         into rOldStates and rNewStates.
141 
142         rOldStates contains after call all states which are in the own set and
143         not in the comparative set.
144 
145         rNewStates contains after call all states which are in the comparative
146         set and not in the own set.
147     */
148     sal_Bool Compare(const AccessibleStateSetHelper& rComparativeValue,
149                         AccessibleStateSetHelper& rOldStates,
150                         AccessibleStateSetHelper& rNewStates)
151         throw (::com::sun::star::uno::RuntimeException);
152 
153     //=====  XTypeProvider  ===================================================
154 
155     /** Returns a sequence of all supported interfaces.
156     */
157     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
158         getTypes (void)
159         throw (::com::sun::star::uno::RuntimeException);
160 
161     /** Returns a implementation id.
162     */
163     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
164         getImplementationId (void)
165         throw (::com::sun::star::uno::RuntimeException);
166 
167 protected:
168     /// Mutex guarding this object.
169     ::vos::OMutex maMutex;
170 
171 private:
172     /// The implementation of this helper interface.
173     AccessibleStateSetHelperImpl*   mpHelperImpl;
174 };
175 
176 //.........................................................................
177 }
178 //... namespace utl .......................................................
179 #endif
180