1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "AccessibleScrollPanel.hxx"
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>
29 #include <osl/mutex.hxx>
30 #include <vcl/svapp.hxx>
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
;
37 namespace accessibility
{
39 AccessibleScrollPanel::AccessibleScrollPanel (
40 ::sd::toolpanel::ScrollPanel
& rScrollPanel
,
41 const OUString
& rsName
,
42 const OUString
& rsDescription
)
47 AccessibleRole::PANEL
)
54 AccessibleScrollPanel::~AccessibleScrollPanel (void)
61 //===== XAccessibleContext ==================================================
64 AccessibleScrollPanel::getAccessibleChildCount (void)
65 throw (RuntimeException
)
68 const SolarMutexGuard aSolarGuard
;
70 sal_Int32
nChildCount (mrTreeNode
.GetControlContainer().GetControlCount());
71 if (GetScrollPanel().IsVerticalScrollBarVisible())
73 if (GetScrollPanel().IsHorizontalScrollBarVisible())
82 Reference
<XAccessible
> SAL_CALL
83 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex
)
84 throw (lang::IndexOutOfBoundsException
,
88 const SolarMutexGuard aSolarGuard
;
90 Reference
<XAccessible
> xChild
;
92 ScrollPanel
& rPanel (GetScrollPanel());
94 sal_uInt32
nControlCount (mrTreeNode
.GetControlContainer().GetControlCount());
96 // The children of this accessible object include the tree node children
97 // and the two scroll bars (when they are visible).
99 throw lang::IndexOutOfBoundsException();
100 else if ((sal_uInt32
)nIndex
< nControlCount
)
101 xChild
= AccessibleTreeNode::getAccessibleChild(nIndex
);
102 else if ((sal_uInt32
)nIndex
== nControlCount
)
104 if (rPanel
.IsVerticalScrollBarVisible())
105 xChild
= rPanel
.GetVerticalScrollBar().GetAccessible();
106 else if (rPanel
.IsHorizontalScrollBarVisible())
107 xChild
= rPanel
.GetHorizontalScrollBar().GetAccessible();
109 else if ((sal_uInt32
)nIndex
== nControlCount
+1)
111 if (rPanel
.IsVerticalScrollBarVisible() && rPanel
.IsHorizontalScrollBarVisible())
112 xChild
= rPanel
.GetHorizontalScrollBar().GetAccessible();
115 throw lang::IndexOutOfBoundsException();
123 //===== XServiceInfo ========================================================
126 AccessibleScrollPanel::getImplementationName (void)
127 throw (RuntimeException
)
129 return OUString("AccessibleScrollPanel");
135 ScrollPanel
& AccessibleScrollPanel::GetScrollPanel (void) const
137 return static_cast<ScrollPanel
&>(mrTreeNode
);
140 } // end of namespace accessibility
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */