1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include "AccessibleScrollPanel.hxx" 32 33 #include "taskpane/ScrollPanel.hxx" 34 #include "taskpane/ControlContainer.hxx" 35 #include <com/sun/star/accessibility/AccessibleRole.hpp> 36 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37 #include <unotools/accessiblestatesethelper.hxx> 38 39 #include <vos/mutex.hxx> 40 #include <vcl/svapp.hxx> 41 42 using ::rtl::OUString; 43 using namespace ::com::sun::star; 44 using namespace ::com::sun::star::accessibility; 45 using namespace ::com::sun::star::uno; 46 using namespace ::sd::toolpanel; 47 48 namespace accessibility { 49 50 AccessibleScrollPanel::AccessibleScrollPanel ( 51 ::sd::toolpanel::ScrollPanel& rScrollPanel, 52 const ::rtl::OUString& rsName, 53 const ::rtl::OUString& rsDescription) 54 : AccessibleTreeNode( 55 rScrollPanel, 56 rsName, 57 rsDescription, 58 AccessibleRole::PANEL) 59 { 60 } 61 62 63 64 65 AccessibleScrollPanel::~AccessibleScrollPanel (void) 66 { 67 } 68 69 70 71 72 //===== XAccessibleContext ================================================== 73 74 sal_Int32 SAL_CALL 75 AccessibleScrollPanel::getAccessibleChildCount (void) 76 throw (RuntimeException) 77 { 78 ThrowIfDisposed(); 79 const vos::OGuard aSolarGuard (Application::GetSolarMutex()); 80 81 sal_Int32 nChildCount (mrTreeNode.GetControlContainer().GetControlCount()); 82 if (GetScrollPanel().IsVerticalScrollBarVisible()) 83 ++nChildCount; 84 if (GetScrollPanel().IsHorizontalScrollBarVisible()) 85 ++nChildCount; 86 87 return nChildCount; 88 } 89 90 91 92 93 Reference<XAccessible> SAL_CALL 94 AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex) 95 throw (lang::IndexOutOfBoundsException, 96 RuntimeException) 97 { 98 ThrowIfDisposed(); 99 const vos::OGuard aSolarGuard (Application::GetSolarMutex()); 100 101 Reference<XAccessible> xChild; 102 103 ScrollPanel& rPanel (GetScrollPanel()); 104 105 sal_uInt32 nControlCount (mrTreeNode.GetControlContainer().GetControlCount()); 106 107 // The children of this accessible object include the tree node children 108 // and the two scroll bars (when they are visible). 109 if (nIndex < 0) 110 throw lang::IndexOutOfBoundsException(); 111 else if ((sal_uInt32)nIndex < nControlCount) 112 xChild = AccessibleTreeNode::getAccessibleChild(nIndex); 113 else if ((sal_uInt32)nIndex == nControlCount) 114 { 115 if (rPanel.IsVerticalScrollBarVisible()) 116 xChild = rPanel.GetVerticalScrollBar().GetAccessible(); 117 else if (rPanel.IsHorizontalScrollBarVisible()) 118 xChild = rPanel.GetHorizontalScrollBar().GetAccessible(); 119 } 120 else if ((sal_uInt32)nIndex == nControlCount+1) 121 { 122 if (rPanel.IsVerticalScrollBarVisible() && rPanel.IsHorizontalScrollBarVisible()) 123 xChild = rPanel.GetHorizontalScrollBar().GetAccessible(); 124 } 125 else 126 throw lang::IndexOutOfBoundsException(); 127 128 return xChild; 129 } 130 131 132 133 134 //===== XServiceInfo ======================================================== 135 136 OUString SAL_CALL 137 AccessibleScrollPanel::getImplementationName (void) 138 throw (RuntimeException) 139 { 140 return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleScrollPanel")); 141 } 142 143 144 145 146 ScrollPanel& AccessibleScrollPanel::GetScrollPanel (void) const 147 { 148 return static_cast<ScrollPanel&>(mrTreeNode); 149 } 150 151 } // end of namespace accessibility 152