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 throw (RuntimeException)
73 {
74 ThrowIfDisposed();
75 const vos::OGuard aSolarGuard (Application::GetSolarMutex());
76
77 sal_Int32 nChildCount (mrTreeNode.GetControlContainer().GetControlCount());
78 if (GetScrollPanel().IsVerticalScrollBarVisible())
79 ++nChildCount;
80 if (GetScrollPanel().IsHorizontalScrollBarVisible())
81 ++nChildCount;
82
83 return nChildCount;
84 }
85
86
87
88
89 Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)90 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex)
91 throw (lang::IndexOutOfBoundsException,
92 RuntimeException)
93 {
94 ThrowIfDisposed();
95 const vos::OGuard aSolarGuard (Application::GetSolarMutex());
96
97 Reference<XAccessible> xChild;
98
99 ScrollPanel& rPanel (GetScrollPanel());
100
101 sal_uInt32 nControlCount (mrTreeNode.GetControlContainer().GetControlCount());
102
103 // The children of this accessible object include the tree node children
104 // and the two scroll bars (when they are visible).
105 if (nIndex < 0)
106 throw lang::IndexOutOfBoundsException();
107 else if ((sal_uInt32)nIndex < nControlCount)
108 xChild = AccessibleTreeNode::getAccessibleChild(nIndex);
109 else if ((sal_uInt32)nIndex == nControlCount)
110 {
111 if (rPanel.IsVerticalScrollBarVisible())
112 xChild = rPanel.GetVerticalScrollBar().GetAccessible();
113 else if (rPanel.IsHorizontalScrollBarVisible())
114 xChild = rPanel.GetHorizontalScrollBar().GetAccessible();
115 }
116 else if ((sal_uInt32)nIndex == nControlCount+1)
117 {
118 if (rPanel.IsVerticalScrollBarVisible() && rPanel.IsHorizontalScrollBarVisible())
119 xChild = rPanel.GetHorizontalScrollBar().GetAccessible();
120 }
121 else
122 throw lang::IndexOutOfBoundsException();
123
124 return xChild;
125 }
126
127
128
129
130 //===== XServiceInfo ========================================================
131
132 OUString SAL_CALL
getImplementationName(void)133 AccessibleScrollPanel::getImplementationName (void)
134 throw (RuntimeException)
135 {
136 return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleScrollPanel"));
137 }
138
139
140
141
GetScrollPanel(void) const142 ScrollPanel& AccessibleScrollPanel::GetScrollPanel (void) const
143 {
144 return static_cast<ScrollPanel&>(mrTreeNode);
145 }
146
147 } // end of namespace accessibility
148