1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleScrollPanel.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "AccessibleScrollPanel.hxx"
36 #include "taskpane/ScrollPanel.hxx"
37 #include "taskpane/ControlContainer.hxx"
38 #include <com/sun/star/accessibility/AccessibleRole.hpp>
39 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40 #include <unotools/accessiblestatesethelper.hxx>
42 #include <vos/mutex.hxx>
43 #include <vcl/svapp.hxx>
45 using ::rtl::OUString
;
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::accessibility
;
48 using namespace ::com::sun::star::uno
;
49 using namespace ::sd::toolpanel
;
51 namespace accessibility
{
53 AccessibleScrollPanel::AccessibleScrollPanel (
54 ::sd::toolpanel::ScrollPanel
& rScrollPanel
,
55 const ::rtl::OUString
& rsName
,
56 const ::rtl::OUString
& rsDescription
)
61 AccessibleRole::PANEL
)
68 AccessibleScrollPanel::~AccessibleScrollPanel (void)
75 //===== XAccessibleContext ==================================================
78 AccessibleScrollPanel::getAccessibleChildCount (void)
79 throw (RuntimeException
)
82 const vos::OGuard
aSolarGuard (Application::GetSolarMutex());
84 sal_Int32
nChildCount (mrTreeNode
.GetControlContainer().GetControlCount());
85 if (GetScrollPanel().IsVerticalScrollBarVisible())
87 if (GetScrollPanel().IsHorizontalScrollBarVisible())
96 Reference
<XAccessible
> SAL_CALL
97 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex
)
98 throw (lang::IndexOutOfBoundsException
,
102 const vos::OGuard
aSolarGuard (Application::GetSolarMutex());
104 Reference
<XAccessible
> xChild
;
106 ScrollPanel
& rPanel (GetScrollPanel());
108 sal_uInt32
nControlCount (mrTreeNode
.GetControlContainer().GetControlCount());
110 // The children of this accessible object include the tree node children
111 // and the two scroll bars (when they are visible).
113 throw lang::IndexOutOfBoundsException();
114 else if ((sal_uInt32
)nIndex
< nControlCount
)
115 xChild
= AccessibleTreeNode::getAccessibleChild(nIndex
);
116 else if ((sal_uInt32
)nIndex
== nControlCount
)
118 if (rPanel
.IsVerticalScrollBarVisible())
119 xChild
= rPanel
.GetVerticalScrollBar().GetAccessible();
120 else if (rPanel
.IsHorizontalScrollBarVisible())
121 xChild
= rPanel
.GetHorizontalScrollBar().GetAccessible();
123 else if ((sal_uInt32
)nIndex
== nControlCount
+1)
125 if (rPanel
.IsVerticalScrollBarVisible() && rPanel
.IsHorizontalScrollBarVisible())
126 xChild
= rPanel
.GetHorizontalScrollBar().GetAccessible();
129 throw lang::IndexOutOfBoundsException();
137 //===== XServiceInfo ========================================================
140 AccessibleScrollPanel::getImplementationName (void)
141 throw (RuntimeException
)
143 return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleScrollPanel"));
149 ScrollPanel
& AccessibleScrollPanel::GetScrollPanel (void) const
151 return static_cast<ScrollPanel
&>(mrTreeNode
);
154 } // end of namespace accessibility