/src/libreoffice/comphelper/source/misc/accessibleselectionhelper.cxx
Line | Count | Source (jump to first uncovered line) |
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 <comphelper/accessiblecontexthelper.hxx> |
21 | | #include <comphelper/accessibleselectionhelper.hxx> |
22 | | |
23 | | namespace comphelper |
24 | | { |
25 | | using namespace ::com::sun::star::uno; |
26 | | using namespace ::com::sun::star::accessibility; |
27 | | |
28 | 0 | OCommonAccessibleSelection::OCommonAccessibleSelection() {} |
29 | | |
30 | 0 | OCommonAccessibleSelection::~OCommonAccessibleSelection() {} |
31 | | |
32 | | void OCommonAccessibleSelection::selectAccessibleChild(sal_Int64 nChildIndex) |
33 | 0 | { |
34 | 0 | implSelect(nChildIndex, true); |
35 | 0 | } |
36 | | |
37 | | bool OCommonAccessibleSelection::isAccessibleChildSelected(sal_Int64 nChildIndex) |
38 | 0 | { |
39 | 0 | return implIsSelected(nChildIndex); |
40 | 0 | } |
41 | | |
42 | | void OCommonAccessibleSelection::clearAccessibleSelection() |
43 | 0 | { |
44 | 0 | implSelect(ACCESSIBLE_SELECTION_CHILD_ALL, false); |
45 | 0 | } |
46 | | |
47 | | void OCommonAccessibleSelection::selectAllAccessibleChildren() |
48 | 0 | { |
49 | 0 | implSelect(ACCESSIBLE_SELECTION_CHILD_ALL, true); |
50 | 0 | } |
51 | | |
52 | | sal_Int64 OCommonAccessibleSelection::getSelectedAccessibleChildCount() |
53 | 0 | { |
54 | 0 | sal_Int64 nRet = 0; |
55 | 0 | Reference<XAccessibleContext> xParentContext(implGetAccessibleContext()); |
56 | |
|
57 | 0 | OSL_ENSURE(xParentContext.is(), |
58 | 0 | "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!"); |
59 | |
|
60 | 0 | if (xParentContext.is()) |
61 | 0 | { |
62 | 0 | for (sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); |
63 | 0 | i < nChildCount; i++) |
64 | 0 | if (implIsSelected(i)) |
65 | 0 | ++nRet; |
66 | 0 | } |
67 | |
|
68 | 0 | return nRet; |
69 | 0 | } |
70 | | |
71 | | Reference<XAccessible> |
72 | | OCommonAccessibleSelection::getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) |
73 | 0 | { |
74 | 0 | Reference<XAccessible> xRet; |
75 | 0 | Reference<XAccessibleContext> xParentContext(implGetAccessibleContext()); |
76 | |
|
77 | 0 | OSL_ENSURE(xParentContext.is(), |
78 | 0 | "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!"); |
79 | |
|
80 | 0 | if (xParentContext.is()) |
81 | 0 | { |
82 | 0 | for (sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; |
83 | 0 | (i < nChildCount) && !xRet.is(); i++) |
84 | 0 | if (implIsSelected(i) && (nPos++ == nSelectedChildIndex)) |
85 | 0 | xRet = xParentContext->getAccessibleChild(i); |
86 | 0 | } |
87 | |
|
88 | 0 | return xRet; |
89 | 0 | } |
90 | | |
91 | | void OCommonAccessibleSelection::deselectAccessibleChild(sal_Int64 nSelectedChildIndex) |
92 | 0 | { |
93 | 0 | implSelect(nSelectedChildIndex, false); |
94 | 0 | } |
95 | | |
96 | 0 | OAccessibleSelectionHelper::OAccessibleSelectionHelper() {} |
97 | | |
98 | | Reference<XAccessibleContext> OAccessibleSelectionHelper::implGetAccessibleContext() |
99 | 0 | { |
100 | 0 | return this; |
101 | 0 | } |
102 | | |
103 | | void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild(sal_Int64 nChildIndex) |
104 | 0 | { |
105 | 0 | OExternalLockGuard aGuard(this); |
106 | 0 | OCommonAccessibleSelection::selectAccessibleChild(nChildIndex); |
107 | 0 | } |
108 | | |
109 | | sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected(sal_Int64 nChildIndex) |
110 | 0 | { |
111 | 0 | OExternalLockGuard aGuard(this); |
112 | 0 | return OCommonAccessibleSelection::isAccessibleChildSelected(nChildIndex); |
113 | 0 | } |
114 | | |
115 | | void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection() |
116 | 0 | { |
117 | 0 | OExternalLockGuard aGuard(this); |
118 | 0 | OCommonAccessibleSelection::clearAccessibleSelection(); |
119 | 0 | } |
120 | | |
121 | | void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren() |
122 | 0 | { |
123 | 0 | OExternalLockGuard aGuard(this); |
124 | 0 | OCommonAccessibleSelection::selectAllAccessibleChildren(); |
125 | 0 | } |
126 | | |
127 | | sal_Int64 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount() |
128 | 0 | { |
129 | 0 | OExternalLockGuard aGuard(this); |
130 | 0 | return OCommonAccessibleSelection::getSelectedAccessibleChildCount(); |
131 | 0 | } |
132 | | |
133 | | Reference<XAccessible> |
134 | | SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) |
135 | 0 | { |
136 | 0 | OExternalLockGuard aGuard(this); |
137 | 0 | return OCommonAccessibleSelection::getSelectedAccessibleChild(nSelectedChildIndex); |
138 | 0 | } |
139 | | |
140 | | void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild(sal_Int64 nSelectedChildIndex) |
141 | 0 | { |
142 | 0 | OExternalLockGuard aGuard(this); |
143 | 0 | OCommonAccessibleSelection::deselectAccessibleChild(nSelectedChildIndex); |
144 | 0 | } |
145 | | |
146 | | } // namespace comphelper |
147 | | |
148 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |