Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "AccessibleGlobal.hxx"
21 :
22 : using ::com::sun::star::uno::RuntimeException;
23 : using ::com::sun::star::uno::Reference;
24 : using ::com::sun::star::uno::Sequence;
25 : using ::std::set;
26 :
27 0 : ScAccessibleStateSet::ScAccessibleStateSet()
28 : {
29 0 : }
30 :
31 0 : ScAccessibleStateSet::~ScAccessibleStateSet()
32 : {
33 0 : }
34 :
35 : // XAccessibleStateSet
36 :
37 0 : sal_Bool SAL_CALL ScAccessibleStateSet::isEmpty() throw (RuntimeException, std::exception)
38 : {
39 0 : return maStates.empty();
40 : }
41 :
42 0 : sal_Bool SAL_CALL ScAccessibleStateSet::contains(sal_Int16 nState)
43 : throw (RuntimeException, std::exception)
44 : {
45 0 : return maStates.count(nState) != 0;
46 : }
47 :
48 0 : sal_Bool SAL_CALL ScAccessibleStateSet::containsAll(
49 : const Sequence<sal_Int16>& aStateSet) throw (RuntimeException, std::exception)
50 : {
51 0 : sal_Int32 n = aStateSet.getLength();
52 0 : for (sal_Int32 i = 0; i < n; ++i)
53 : {
54 0 : if (!maStates.count(aStateSet[i]))
55 : // This state is not set.
56 0 : return false;
57 : }
58 : // All specified states are set.
59 0 : return true;
60 : }
61 :
62 0 : Sequence<sal_Int16> SAL_CALL ScAccessibleStateSet::getStates()
63 : throw (RuntimeException, std::exception)
64 : {
65 0 : Sequence<sal_Int16> aSeq(0);
66 0 : set<sal_Int16>::const_iterator itr = maStates.begin(), itrEnd = maStates.end();
67 0 : for (size_t i = 0; itr != itrEnd; ++itr, ++i)
68 : {
69 0 : aSeq.realloc(i+1);
70 0 : aSeq[i] = *itr;
71 : }
72 0 : return aSeq;
73 : }
74 :
75 0 : void ScAccessibleStateSet::insert(sal_Int16 nState)
76 : {
77 0 : maStates.insert(nState);
78 0 : }
79 :
80 0 : void ScAccessibleStateSet::clear()
81 : {
82 0 : maStates.clear();
83 0 : }
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|