xref: /trunk/main/unotools/inc/unotools/accessiblestatesethelper.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
90     /** Checks if the given state is a member of the state set of this
91         object.
92 
93         @param aState
94             The state for which to check membership.  This has to be one of
95             the constants of <type>AccessibleStateType</type>.
96 
97         @return
98             Returns <TRUE/> if the given state is a member of this object's
99             state set and <FALSE/> otherwise.
100     */
101     virtual sal_Bool SAL_CALL contains (sal_Int16 aState);
102 
103     /** Checks if all of the given states are in this object's state
104         set.
105 
106         @param aStateSet
107             This sequence of states is interpreted as set and every of its
108             members, duplicates are ignored, is checked for membership in
109             this object's state set.  Each state has to be one of the
110             constants of <type>AccessibleStateType</type>.
111 
112         @return
113             Returns <TRUE/> if all states of the given state set are members
114             of this object's state set.  <FALSE/> is returned if at least
115             one of the states in the given state is not a member of this
116             object's state set.
117     */
118     virtual sal_Bool SAL_CALL containsAll (
119         const ::com::sun::star::uno::Sequence<sal_Int16>& rStateSet);
120 
121     /** Returns a sequence of all states.
122     */
123     virtual com::sun::star::uno::Sequence<sal_Int16> SAL_CALL getStates();
124 
125     /** Adds a state to the set.
126     */
127     void    AddState(sal_Int16 aState);
128 
129     /** Removes a state from the set if the set contains the state, otherwise nothing is done.
130     */
131     void    RemoveState(sal_Int16 aState);
132 
133     /** Compares the set with the set given by rComparativeValue and puts the results
134         into rOldStates and rNewStates.
135 
136         rOldStates contains after call all states which are in the own set and
137         not in the comparative set.
138 
139         rNewStates contains after call all states which are in the comparative
140         set and not in the own set.
141     */
142     sal_Bool Compare(const AccessibleStateSetHelper& rComparativeValue,
143                         AccessibleStateSetHelper& rOldStates,
144                         AccessibleStateSetHelper& rNewStates);
145 
146     //=====  XTypeProvider  ===================================================
147 
148     /** Returns a sequence of all supported interfaces.
149     */
150     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
151         getTypes (void);
152 
153     /** Returns a implementation id.
154     */
155     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
156         getImplementationId (void);
157 
158 protected:
159     /// Mutex guarding this object.
160     ::vos::OMutex maMutex;
161 
162 private:
163     /// The implementation of this helper interface.
164     AccessibleStateSetHelperImpl*   mpHelperImpl;
165 };
166 
167 //.........................................................................
168 }
169 //... namespace utl .......................................................
170 #endif
171