1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "AccessibleScrollPanel.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "taskpane/ScrollPanel.hxx" 30cdf0e10cSrcweir #include "taskpane/ControlContainer.hxx" 31cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 33cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <vos/mutex.hxx> 36cdf0e10cSrcweir #include <vcl/svapp.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir using ::rtl::OUString; 39cdf0e10cSrcweir using namespace ::com::sun::star; 40cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 41cdf0e10cSrcweir using namespace ::com::sun::star::uno; 42cdf0e10cSrcweir using namespace ::sd::toolpanel; 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace accessibility { 45cdf0e10cSrcweir 46cdf0e10cSrcweir AccessibleScrollPanel::AccessibleScrollPanel ( 47cdf0e10cSrcweir ::sd::toolpanel::ScrollPanel& rScrollPanel, 48cdf0e10cSrcweir const ::rtl::OUString& rsName, 49cdf0e10cSrcweir const ::rtl::OUString& rsDescription) 50cdf0e10cSrcweir : AccessibleTreeNode( 51cdf0e10cSrcweir rScrollPanel, 52cdf0e10cSrcweir rsName, 53cdf0e10cSrcweir rsDescription, 54cdf0e10cSrcweir AccessibleRole::PANEL) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir AccessibleScrollPanel::~AccessibleScrollPanel (void) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir 66cdf0e10cSrcweir 67cdf0e10cSrcweir 68cdf0e10cSrcweir //===== XAccessibleContext ================================================== 69cdf0e10cSrcweir 70cdf0e10cSrcweir sal_Int32 SAL_CALL 71cdf0e10cSrcweir AccessibleScrollPanel::getAccessibleChildCount (void) 72cdf0e10cSrcweir throw (RuntimeException) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ThrowIfDisposed(); 75cdf0e10cSrcweir const vos::OGuard aSolarGuard (Application::GetSolarMutex()); 76cdf0e10cSrcweir 77cdf0e10cSrcweir sal_Int32 nChildCount (mrTreeNode.GetControlContainer().GetControlCount()); 78cdf0e10cSrcweir if (GetScrollPanel().IsVerticalScrollBarVisible()) 79cdf0e10cSrcweir ++nChildCount; 80cdf0e10cSrcweir if (GetScrollPanel().IsHorizontalScrollBarVisible()) 81cdf0e10cSrcweir ++nChildCount; 82cdf0e10cSrcweir 83cdf0e10cSrcweir return nChildCount; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir Reference<XAccessible> SAL_CALL 90cdf0e10cSrcweir AccessibleScrollPanel::getAccessibleChild (sal_Int32 nIndex) 91cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, 92cdf0e10cSrcweir RuntimeException) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir ThrowIfDisposed(); 95cdf0e10cSrcweir const vos::OGuard aSolarGuard (Application::GetSolarMutex()); 96cdf0e10cSrcweir 97cdf0e10cSrcweir Reference<XAccessible> xChild; 98cdf0e10cSrcweir 99cdf0e10cSrcweir ScrollPanel& rPanel (GetScrollPanel()); 100cdf0e10cSrcweir 101cdf0e10cSrcweir sal_uInt32 nControlCount (mrTreeNode.GetControlContainer().GetControlCount()); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // The children of this accessible object include the tree node children 104cdf0e10cSrcweir // and the two scroll bars (when they are visible). 105cdf0e10cSrcweir if (nIndex < 0) 106cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 107cdf0e10cSrcweir else if ((sal_uInt32)nIndex < nControlCount) 108cdf0e10cSrcweir xChild = AccessibleTreeNode::getAccessibleChild(nIndex); 109cdf0e10cSrcweir else if ((sal_uInt32)nIndex == nControlCount) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir if (rPanel.IsVerticalScrollBarVisible()) 112cdf0e10cSrcweir xChild = rPanel.GetVerticalScrollBar().GetAccessible(); 113cdf0e10cSrcweir else if (rPanel.IsHorizontalScrollBarVisible()) 114cdf0e10cSrcweir xChild = rPanel.GetHorizontalScrollBar().GetAccessible(); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir else if ((sal_uInt32)nIndex == nControlCount+1) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir if (rPanel.IsVerticalScrollBarVisible() && rPanel.IsHorizontalScrollBarVisible()) 119cdf0e10cSrcweir xChild = rPanel.GetHorizontalScrollBar().GetAccessible(); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir else 122cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 123cdf0e10cSrcweir 124cdf0e10cSrcweir return xChild; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir //===== XServiceInfo ======================================================== 131cdf0e10cSrcweir 132cdf0e10cSrcweir OUString SAL_CALL 133cdf0e10cSrcweir AccessibleScrollPanel::getImplementationName (void) 134cdf0e10cSrcweir throw (RuntimeException) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleScrollPanel")); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir 140cdf0e10cSrcweir 141cdf0e10cSrcweir 142cdf0e10cSrcweir ScrollPanel& AccessibleScrollPanel::GetScrollPanel (void) const 143cdf0e10cSrcweir { 144cdf0e10cSrcweir return static_cast<ScrollPanel&>(mrTreeNode); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir } // end of namespace accessibility 148