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