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 #include "precompiled_sd.hxx"
26
27 #include "AccessibleScrollPanel.hxx"
28
29 #include "taskpane/ScrollPanel.hxx"
30 #include "taskpane/ControlContainer.hxx"
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33 #include <unotools/accessiblestatesethelper.hxx>
34
35 #include <vos/mutex.hxx>
36 #include <vcl/svapp.hxx>
37
38 using ::rtl::OUString;
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::accessibility;
41 using namespace ::com::sun::star::uno;
42 using namespace ::sd::toolpanel;
43
44 namespace accessibility {
45
AccessibleScrollPanel(::sd::toolpanel::ScrollPanel & rScrollPanel,const::rtl::OUString & rsName,const::rtl::OUString & rsDescription)46 AccessibleScrollPanel::AccessibleScrollPanel (
47 ::sd::toolpanel::ScrollPanel& rScrollPanel,
48 const ::rtl::OUString& rsName,
49 const ::rtl::OUString& rsDescription)
50 : AccessibleTreeNode(
51 rScrollPanel,
52 rsName,
53 rsDescription,
54 AccessibleRole::PANEL)
55 {
56 }
57
58
59
60
~AccessibleScrollPanel(void)61 AccessibleScrollPanel::~AccessibleScrollPanel (void)
62 {
63 }
64
65
66
67
68 //===== XAccessibleContext ==================================================
69
70 sal_Int32 SAL_CALL
getAccessibleChildCount(void)71 AccessibleScrollPanel::getAccessibleChildCount (void)
72 {
73 ThrowIfDisposed();
74 const vos::OGuard aSolarGuard (Application::GetSolarMutex());
75
76 sal_Int32 nChildCount (mrTreeNode.GetControlContainer().GetControlCount());
77 if (GetScrollPanel().IsVerticalScrollBarVisible())
78 ++nChildCount;
79 if (GetScrollPanel().IsHorizontalScrollBarVisible())
80 ++nChildCount;
81
82 return nChildCount;
83 }
84
85
86
87
88 Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)89 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex)
90 {
91 ThrowIfDisposed();
92 const vos::OGuard aSolarGuard (Application::GetSolarMutex());
93
94 Reference<XAccessible> xChild;
95
96 ScrollPanel& rPanel (GetScrollPanel());
97
98 sal_uInt32 nControlCount (mrTreeNode.GetControlContainer().GetControlCount());
99
100 // The children of this accessible object include the tree node children
101 // and the two scroll bars (when they are visible).
102 if (nIndex < 0)
103 throw lang::IndexOutOfBoundsException();
104 else if ((sal_uInt32)nIndex < nControlCount)
105 xChild = AccessibleTreeNode::getAccessibleChild(nIndex);
106 else if ((sal_uInt32)nIndex == nControlCount)
107 {
108 if (rPanel.IsVerticalScrollBarVisible())
109 xChild = rPanel.GetVerticalScrollBar().GetAccessible();
110 else if (rPanel.IsHorizontalScrollBarVisible())
111 xChild = rPanel.GetHorizontalScrollBar().GetAccessible();
112 }
113 else if ((sal_uInt32)nIndex == nControlCount+1)
114 {
115 if (rPanel.IsVerticalScrollBarVisible() && rPanel.IsHorizontalScrollBarVisible())
116 xChild = rPanel.GetHorizontalScrollBar().GetAccessible();
117 }
118 else
119 throw lang::IndexOutOfBoundsException();
120
121 return xChild;
122 }
123
124
125
126
127 //===== XServiceInfo ========================================================
128
129 OUString SAL_CALL
getImplementationName(void)130 AccessibleScrollPanel::getImplementationName (void)
131 {
132 return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleScrollPanel"));
133 }
134
135
136
137
GetScrollPanel(void) const138 ScrollPanel& AccessibleScrollPanel::GetScrollPanel (void) const
139 {
140 return static_cast<ScrollPanel&>(mrTreeNode);
141 }
142
143 } // end of namespace accessibility
144