merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / accessibility / AccessibleScrollPanel.cxx
blobe2f0e1112f5274f0c03fbda652c5a618a55e85f7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleScrollPanel.cxx,v $
10 * $Revision: 1.5 $
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)
57 : AccessibleTreeNode(
58 rScrollPanel,
59 rsName,
60 rsDescription,
61 AccessibleRole::PANEL)
68 AccessibleScrollPanel::~AccessibleScrollPanel (void)
75 //===== XAccessibleContext ==================================================
77 sal_Int32 SAL_CALL
78 AccessibleScrollPanel::getAccessibleChildCount (void)
79 throw (RuntimeException)
81 ThrowIfDisposed();
82 const vos::OGuard aSolarGuard (Application::GetSolarMutex());
84 sal_Int32 nChildCount (mrTreeNode.GetControlContainer().GetControlCount());
85 if (GetScrollPanel().IsVerticalScrollBarVisible())
86 ++nChildCount;
87 if (GetScrollPanel().IsHorizontalScrollBarVisible())
88 ++nChildCount;
90 return nChildCount;
96 Reference<XAccessible> SAL_CALL
97 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex)
98 throw (lang::IndexOutOfBoundsException,
99 RuntimeException)
101 ThrowIfDisposed();
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).
112 if (nIndex < 0)
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();
128 else
129 throw lang::IndexOutOfBoundsException();
131 return xChild;
137 //===== XServiceInfo ========================================================
139 OUString SAL_CALL
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