xref: /AOO41X/main/sc/source/ui/Accessibility/AccessibleGlobal.cxx (revision b3f79822e811ac3493b185030a72c3c5a51f32d8)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "precompiled_sc.hxx"
27cdf0e10cSrcweir #include "AccessibleGlobal.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
30cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
31cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
32cdf0e10cSrcweir using ::std::set;
33cdf0e10cSrcweir 
ScAccessibleStateSet()34cdf0e10cSrcweir ScAccessibleStateSet::ScAccessibleStateSet()
35cdf0e10cSrcweir {
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
~ScAccessibleStateSet()38cdf0e10cSrcweir ScAccessibleStateSet::~ScAccessibleStateSet()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir }
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // XAccessibleStateSet
43cdf0e10cSrcweir 
isEmpty()44cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleStateSet::isEmpty() throw (RuntimeException)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     return maStates.empty();
47cdf0e10cSrcweir }
48cdf0e10cSrcweir 
contains(sal_Int16 nState)49cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleStateSet::contains(sal_Int16 nState)
50cdf0e10cSrcweir     throw (RuntimeException)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     return maStates.count(nState) != 0;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
containsAll(const Sequence<sal_Int16> & aStateSet)55cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleStateSet::containsAll(
56cdf0e10cSrcweir     const Sequence<sal_Int16>& aStateSet) throw (RuntimeException)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     sal_Int32 n = aStateSet.getLength();
59cdf0e10cSrcweir     for (sal_Int32 i = 0; i < n; ++i)
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         if (!maStates.count(aStateSet[i]))
62cdf0e10cSrcweir             // This state is not set.
63cdf0e10cSrcweir             return false;
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir     // All specified states are set.
66cdf0e10cSrcweir     return true;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
getStates()69cdf0e10cSrcweir Sequence<sal_Int16> SAL_CALL ScAccessibleStateSet::getStates()
70cdf0e10cSrcweir     throw (RuntimeException)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     Sequence<sal_Int16> aSeq(0);
73cdf0e10cSrcweir     set<sal_Int16>::const_iterator itr = maStates.begin(), itrEnd = maStates.end();
74cdf0e10cSrcweir     for (size_t i = 0; itr != itrEnd; ++itr, ++i)
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         aSeq.realloc(i+1);
77cdf0e10cSrcweir         aSeq[i] = *itr;
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir     return aSeq;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
insert(sal_Int16 nState)82cdf0e10cSrcweir void ScAccessibleStateSet::insert(sal_Int16 nState)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     maStates.insert(nState);
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
clear()87cdf0e10cSrcweir void ScAccessibleStateSet::clear()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     maStates.clear();
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92