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