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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 
26 #include "precompiled_sc.hxx"
27 #include "AccessibleGlobal.hxx"
28 
29 using ::com::sun::star::uno::RuntimeException;
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::uno::Sequence;
32 using ::std::set;
33 
ScAccessibleStateSet()34 ScAccessibleStateSet::ScAccessibleStateSet()
35 {
36 }
37 
~ScAccessibleStateSet()38 ScAccessibleStateSet::~ScAccessibleStateSet()
39 {
40 }
41 
42 // XAccessibleStateSet
43 
isEmpty()44 sal_Bool SAL_CALL ScAccessibleStateSet::isEmpty() throw (RuntimeException)
45 {
46     return maStates.empty();
47 }
48 
contains(sal_Int16 nState)49 sal_Bool SAL_CALL ScAccessibleStateSet::contains(sal_Int16 nState)
50     throw (RuntimeException)
51 {
52     return maStates.count(nState) != 0;
53 }
54 
containsAll(const Sequence<sal_Int16> & aStateSet)55 sal_Bool SAL_CALL ScAccessibleStateSet::containsAll(
56     const Sequence<sal_Int16>& aStateSet) throw (RuntimeException)
57 {
58     sal_Int32 n = aStateSet.getLength();
59     for (sal_Int32 i = 0; i < n; ++i)
60     {
61         if (!maStates.count(aStateSet[i]))
62             // This state is not set.
63             return false;
64     }
65     // All specified states are set.
66     return true;
67 }
68 
getStates()69 Sequence<sal_Int16> SAL_CALL ScAccessibleStateSet::getStates()
70     throw (RuntimeException)
71 {
72     Sequence<sal_Int16> aSeq(0);
73     set<sal_Int16>::const_iterator itr = maStates.begin(), itrEnd = maStates.end();
74     for (size_t i = 0; itr != itrEnd; ++itr, ++i)
75     {
76         aSeq.realloc(i+1);
77         aSeq[i] = *itr;
78     }
79     return aSeq;
80 }
81 
insert(sal_Int16 nState)82 void ScAccessibleStateSet::insert(sal_Int16 nState)
83 {
84     maStates.insert(nState);
85 }
86 
clear()87 void ScAccessibleStateSet::clear()
88 {
89     maStates.clear();
90 }
91 
92