1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 // MARKER(update_precomp.py): autogen include statement, do not remove 24 #include "precompiled_svtools.hxx" 25 26 #ifndef _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_ 27 #include <svtools/vclxaccessibleheaderbar.hxx> 28 #endif 29 #ifndef _SVTOOLS_VCLACCESSIBLEHEADBARITEM_HXX_ 30 #include <svtools/vclxaccessibleheaderbaritem.hxx> 31 #endif 32 33 #ifndef _TOOLKIT_AWT_VCLXWINDOWS_HXX_ 34 #include <toolkit/awt/vclxwindows.hxx> 35 #endif 36 #ifndef _HEADBAR_HXX 37 #include <headbar.hxx> 38 #endif 39 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_ 40 #include <unotools/accessiblestatesethelper.hxx> 41 #endif 42 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 43 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 44 #endif 45 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 46 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 47 #endif 48 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ 49 #include <cppuhelper/typeprovider.hxx> 50 #endif 51 #ifndef _COMPHELPER_SEQUENCE_HXX_ 52 #include <comphelper/sequence.hxx> 53 #endif 54 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ 55 #include <com/sun/star/accessibility/AccessibleRole.hpp> 56 #endif 57 58 using namespace ::com::sun::star; 59 using namespace ::com::sun::star::uno; 60 using namespace ::com::sun::star::awt; 61 using namespace ::com::sun::star::lang; 62 using namespace ::com::sun::star::beans; 63 using namespace ::com::sun::star::accessibility; 64 using namespace ::comphelper; 65 VCLXHeaderBar(Window * pHeaderBar)66VCLXHeaderBar::VCLXHeaderBar(Window* pHeaderBar) 67 { 68 SetWindow(pHeaderBar); 69 } 70 ~VCLXHeaderBar()71VCLXHeaderBar::~VCLXHeaderBar() 72 { 73 } 74 CreateAccessibleContext()75::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext() 76 { 77 return new VCLXAccessibleHeaderBar(this); 78 } 79 80 VCLXAccessibleHeaderBar(VCLXWindow * pVCLWindow)81VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar( VCLXWindow* pVCLWindow ) 82 :VCLXAccessibleComponent( pVCLWindow ) 83 ,m_pHeadBar(NULL) 84 { 85 m_pHeadBar = static_cast< HeaderBar* >( GetWindow() ); 86 } 87 88 // ----------------------------------------------------------------------------- 89 ~VCLXAccessibleHeaderBar()90VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar() 91 { 92 } 93 94 // ----------------------------------------------------------------------------- 95 ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)96void VCLXAccessibleHeaderBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 97 { 98 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); 99 } 100 101 // ----------------------------------------------------------------------------- 102 FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)103void VCLXAccessibleHeaderBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 104 { 105 VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); 106 } 107 108 // ----------------------------------------------------------------------------- 109 // XServiceInfo 110 // ----------------------------------------------------------------------------- 111 getImplementationName()112::rtl::OUString VCLXAccessibleHeaderBar::getImplementationName() 113 { 114 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleHeaderBar" ); 115 } 116 117 // ----------------------------------------------------------------------------- 118 getSupportedServiceNames()119Sequence< ::rtl::OUString > VCLXAccessibleHeaderBar::getSupportedServiceNames() 120 { 121 Sequence< ::rtl::OUString > aNames(1); 122 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBar" ); 123 return aNames; 124 } 125 126 // =======XAccessibleContext======= 127 getAccessibleChildCount()128sal_Int32 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount( ) 129 { 130 sal_Int32 nCount = 0; 131 if ( m_pHeadBar ) 132 nCount = m_pHeadBar->GetItemCount(); 133 134 return nCount; 135 } 136 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i)137 VCLXAccessibleHeaderBar::getAccessibleChild( sal_Int32 i ) 138 { 139 if ( i < 0 || i >= getAccessibleChildCount() ) 140 throw IndexOutOfBoundsException(); 141 142 Reference< XAccessible > xChild; 143 // search for the child 144 if ( static_cast<sal_uInt16>(i) >= m_aAccessibleChildren.size() ) 145 xChild = CreateChild (i); 146 else 147 { 148 xChild = m_aAccessibleChildren[i]; 149 if ( !xChild.is() ) 150 xChild = CreateChild (i); 151 } 152 return xChild; 153 } 154 getAccessibleRole()155sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole( ) 156 { 157 return com::sun::star::accessibility::AccessibleRole::LIST; 158 } 159 disposing(void)160void SAL_CALL VCLXAccessibleHeaderBar::disposing (void) 161 { 162 ListItems().swap(m_aAccessibleChildren); 163 VCLXAccessibleComponent::disposing(); 164 } 165 CreateChild(sal_Int32 i)166::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > VCLXAccessibleHeaderBar::CreateChild (sal_Int32 i) 167 { 168 Reference<XAccessible> xChild; 169 170 sal_uInt16 nPos = static_cast<sal_uInt16>(i); 171 if ( nPos >= m_aAccessibleChildren.size() ) 172 { 173 m_aAccessibleChildren.resize(nPos + 1); 174 175 // insert into the container 176 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); 177 m_aAccessibleChildren[nPos] = xChild; 178 } 179 else 180 { 181 xChild = m_aAccessibleChildren[nPos]; 182 // check if position is empty and can be used else we have to adjust all entries behind this 183 if ( !xChild.is() ) 184 { 185 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); 186 m_aAccessibleChildren[nPos] = xChild; 187 } 188 } 189 return xChild; 190 } 191