Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / include / unotools / accessiblestatesethelper.hxx
blobe8277f6489036752502577ae08c4ab0af33d3fec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_UNOTOOLS_ACCESSIBLESTATESETHELPER_HXX
20 #define INCLUDED_UNOTOOLS_ACCESSIBLESTATESETHELPER_HXX
22 #include <unotools/unotoolsdllapi.h>
24 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
25 #include <osl/mutex.hxx>
26 #include <cppuhelper/implbase.hxx>
27 #include <memory>
29 class AccessibleStateSetHelperImpl;
31 //= XAccessibleStateSet helper classes
33 //... namespace utl .......................................................
34 namespace utl
37 /** @descr
38 This base class provides an implementation of the
39 <code>AccessibleStateSet</code> service.
41 class UNOTOOLS_DLLPUBLIC AccessibleStateSetHelper final
42 : public cppu::WeakImplHelper< css::accessibility::XAccessibleStateSet >
44 public:
45 //===== internal ========================================================
47 AccessibleStateSetHelper ();
48 /** constructs an object with some states initially set
50 <p>This ctor is compatible with
51 <method scope="comphelper">OAccessibleImplementationAccess::implGetForeignControlledStates</method></p>
53 @param _nInitialStates
54 is a bit mask. Every bit 2^n means that the state number n (as got from the
55 AccessibleStateType constants) should be set initially.
57 AccessibleStateSetHelper ( const sal_Int64 _nInitialStates );
59 AccessibleStateSetHelper ( const AccessibleStateSetHelper& rHelper );
60 private:
61 virtual ~AccessibleStateSetHelper() override;
62 public:
64 //===== XAccessibleStateSet ==============================================
66 /** Checks whether the current state set is empty.
68 @return
69 Returns <TRUE/> if there is no state in this state set and
70 <FALSE/> if there is at least one state set in it.
72 virtual sal_Bool SAL_CALL isEmpty () override;
74 /** Checks if the given state is a member of the state set of this
75 object.
77 @param aState
78 The state for which to check membership. This has to be one of
79 the constants of AccessibleStateType.
81 @return
82 Returns <TRUE/> if the given state is a member of this object's
83 state set and <FALSE/> otherwise.
85 virtual sal_Bool SAL_CALL contains (sal_Int16 aState) override;
87 /** Checks if all of the given states are in this object's state
88 set.
90 @param aStateSet
91 This sequence of states is interpreted as set and every of its
92 members, duplicates are ignored, is checked for membership in
93 this object's state set. Each state has to be one of the
94 constants of AccessibleStateType.
96 @return
97 Returns <TRUE/> if all states of the given state set are members
98 of this object's state set. <FALSE/> is returned if at least
99 one of the states in the given state is not a member of this
100 object's state set.
102 virtual sal_Bool SAL_CALL containsAll (
103 const css::uno::Sequence<sal_Int16>& rStateSet) override;
105 /** Returns a sequence of all states.
107 virtual css::uno::Sequence<sal_Int16> SAL_CALL getStates() override;
109 /** Adds a state to the set.
111 @throws css::uno::RuntimeException
113 void AddState(sal_Int16 aState);
115 /** Removes a state from the set if the set contains the state, otherwise nothing is done.
117 @throws css::uno::RuntimeException
119 void RemoveState(sal_Int16 aState);
121 //===== XTypeProvider ===================================================
123 /** Returns a sequence of all supported interfaces.
125 virtual css::uno::Sequence< css::uno::Type> SAL_CALL
126 getTypes() override;
128 /** Returns an implementation id.
130 virtual css::uno::Sequence<sal_Int8> SAL_CALL
131 getImplementationId() override;
133 private:
134 /// Mutex guarding this object.
135 ::osl::Mutex maMutex;
136 /// The implementation of this helper interface.
137 std::unique_ptr<AccessibleStateSetHelperImpl> mpHelperImpl;
141 //... namespace utl .......................................................
142 #endif
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */