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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_accessibility.hxx" 26 27 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx" 28 #include <svtools/accessibletable.hxx> 29 #include "accessibility/extended/AccessibleGridControl.hxx" 30 31 namespace accessibility 32 { 33 using namespace ::com::sun::star::accessibility; 34 using namespace ::com::sun::star::lang; 35 using namespace ::com::sun::star::uno; 36 using namespace ::svt; 37 using namespace ::svt::table; 38 39 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId, 40 const Reference< XAccessible >& rxParent, 41 IAccessibleTable& rTable, 42 AccessibleTableControlObjType eObjType) 43 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType) 44 , m_nColumnRowId(_nColumnRowId) 45 { 46 } 47 /** Creates a new AccessibleStateSetHelper and fills it with states of the 48 current object. 49 @return 50 A filled AccessibleStateSetHelper. 51 */ 52 ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper() 53 { 54 ::osl::MutexGuard aGuard( getOslMutex() ); 55 ::utl::AccessibleStateSetHelper* 56 pStateSetHelper = new ::utl::AccessibleStateSetHelper; 57 58 if( isAlive() ) 59 { 60 // SHOWING done with mxParent 61 if( implIsShowing() ) 62 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 63 64 TCSolarGuard aSolarGuard; 65 pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 66 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 67 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 68 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 69 70 if ( m_aTable.IsRowSelected(m_nColumnRowId) ) 71 pStateSetHelper->AddState( AccessibleStateType::SELECTED ); 72 } 73 else 74 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 75 76 return pStateSetHelper; 77 } 78 // ----------------------------------------------------------------------------- 79 /** @return 80 The count of visible children. 81 */ 82 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount() 83 { 84 return 0; 85 } 86 // ----------------------------------------------------------------------------- 87 88 /** @return 89 The XAccessible interface of the specified child. 90 */ 91 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 ) 92 { 93 throw IndexOutOfBoundsException(); 94 } 95 // XInterface ------------------------------------------------------------- 96 97 /** Queries for a new interface. */ 98 ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( 99 const ::com::sun::star::uno::Type& rType ) 100 { 101 Any aRet = AccessibleGridControlCell::queryInterface(rType); 102 return aRet; 103 } 104 105 /** Aquires the object (calls acquire() on base class). */ 106 void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw () 107 { 108 AccessibleGridControlCell::acquire(); 109 } 110 111 /** Releases the object (calls release() on base class). */ 112 void SAL_CALL AccessibleGridControlHeaderCell::release() throw () 113 { 114 AccessibleGridControlCell::release(); 115 } 116 /** @return The XAccessibleContext interface of this object. */ 117 Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() 118 { 119 ensureIsAlive(); 120 return this; 121 } 122 123 // ----------------------------------------------------------------------------- 124 125 /** Grabs the focus to the column header. */ 126 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus() 127 { 128 } 129 // ----------------------------------------------------------------------------- 130 /** @return 131 The name of this class. 132 */ 133 ::rtl::OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName() 134 { 135 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" ) ); 136 } 137 // ----------------------------------------------------------------------------- 138 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox() 139 { 140 Window* pParent = m_aTable.GetAccessibleParentWindow(); 141 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) ); 142 sal_Int32 nIndex = getAccessibleIndexInParent(); 143 Rectangle aCellRect; 144 if(m_eObjType == TCTYPE_COLUMNHEADERCELL) 145 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex); 146 else 147 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex); 148 return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize()); 149 } 150 // ----------------------------------------------------------------------------- 151 152 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen() 153 { 154 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) ); 155 sal_Int32 nIndex = getAccessibleIndexInParent(); 156 Rectangle aCellRect; 157 if(m_eObjType == TCTYPE_COLUMNHEADERCELL) 158 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex); 159 else 160 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex); 161 return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize()); 162 } 163 // ----------------------------------------------------------------------------- 164 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent() 165 { 166 ::osl::MutexGuard aGuard( getOslMutex() ); 167 ensureIsAlive(); 168 sal_Int32 nIndex = m_nColumnRowId; 169 return nIndex; 170 } 171 // ----------------------------------------------------------------------------- 172 } // namespace accessibility 173 // ----------------------------------------------------------------------------- 174