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 28 #include "accessibility/extended/AccessibleBrowseBoxTable.hxx" 29 #include <svtools/accessibletableprovider.hxx> 30 31 // ============================================================================ 32 33 using ::rtl::OUString; 34 35 using ::com::sun::star::uno::Reference; 36 using ::com::sun::star::uno::Sequence; 37 using ::com::sun::star::uno::Any; 38 39 using namespace ::com::sun::star; 40 using namespace ::com::sun::star::accessibility; 41 using namespace ::svt; 42 43 // ============================================================================ 44 45 namespace accessibility { 46 47 // ============================================================================ 48 49 // Ctor/Dtor/disposing -------------------------------------------------------- 50 51 DBG_NAME( AccessibleBrowseBoxTable ) 52 53 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable( 54 const Reference< XAccessible >& rxParent, 55 IAccessibleTableProvider& rBrowseBox ) : 56 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, BBTYPE_TABLE ) 57 { 58 DBG_CTOR( AccessibleBrowseBoxTable, NULL ); 59 } 60 61 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable() 62 { 63 DBG_DTOR( AccessibleBrowseBoxTable, NULL ); 64 } 65 66 // XAccessibleContext --------------------------------------------------------- 67 68 Reference< XAccessible > SAL_CALL 69 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex ) 70 { 71 BBSolarGuard aSolarGuard; 72 ::osl::MutexGuard aGuard( getOslMutex() ); 73 ensureIsAlive(); 74 ensureIsValidIndex( nChildIndex ); 75 return mpBrowseBox->CreateAccessibleCell( 76 implGetRow( nChildIndex ), (sal_Int16)implGetColumn( nChildIndex ) ); 77 } 78 79 sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent() 80 { 81 ensureIsAlive(); 82 return BBINDEX_TABLE; 83 } 84 85 // XAccessibleComponent ------------------------------------------------------- 86 87 Reference< XAccessible > SAL_CALL 88 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint ) 89 { 90 BBSolarGuard aSolarGuard; 91 ::osl::MutexGuard aGuard( getOslMutex() ); 92 ensureIsAlive(); 93 94 Reference< XAccessible > xChild; 95 sal_Int32 nRow = 0; 96 sal_uInt16 nColumnPos = 0; 97 if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) ) 98 xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos ); 99 100 return xChild; 101 } 102 103 void SAL_CALL AccessibleBrowseBoxTable::grabFocus() 104 { 105 BBSolarGuard aSolarGuard; 106 ::osl::MutexGuard aGuard( getOslMutex() ); 107 ensureIsAlive(); 108 mpBrowseBox->GrabTableFocus(); 109 } 110 111 Any SAL_CALL AccessibleBrowseBoxTable::getAccessibleKeyBinding() 112 { 113 ensureIsAlive(); 114 return Any(); // no special key bindings for data table 115 } 116 117 // XAccessibleTable ----------------------------------------------------------- 118 119 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow ) 120 { 121 BBSolarGuard aSolarGuard; 122 ::osl::MutexGuard aGuard( getOslMutex() ); 123 ensureIsAlive(); 124 ensureIsValidRow( nRow ); 125 return mpBrowseBox->GetRowDescription( nRow ); 126 } 127 128 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn ) 129 { 130 BBSolarGuard aSolarGuard; 131 ::osl::MutexGuard aGuard( getOslMutex() ); 132 ensureIsAlive(); 133 ensureIsValidColumn( nColumn ); 134 return mpBrowseBox->GetColumnDescription( (sal_uInt16)nColumn ); 135 } 136 137 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders() 138 { 139 ::osl::MutexGuard aGuard( getOslMutex() ); 140 ensureIsAlive(); 141 return implGetHeaderBar( BBINDEX_ROWHEADERBAR ); 142 } 143 144 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders() 145 { 146 ::osl::MutexGuard aGuard( getOslMutex() ); 147 ensureIsAlive(); 148 return implGetHeaderBar( BBINDEX_COLUMNHEADERBAR ); 149 } 150 151 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows() 152 { 153 BBSolarGuard aSolarGuard; 154 ::osl::MutexGuard aGuard( getOslMutex() ); 155 ensureIsAlive(); 156 157 Sequence< sal_Int32 > aSelSeq; 158 implGetSelectedRows( aSelSeq ); 159 return aSelSeq; 160 } 161 162 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns() 163 { 164 BBSolarGuard aSolarGuard; 165 ::osl::MutexGuard aGuard( getOslMutex() ); 166 ensureIsAlive(); 167 168 Sequence< sal_Int32 > aSelSeq; 169 implGetSelectedColumns( aSelSeq ); 170 return aSelSeq; 171 } 172 173 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow ) 174 { 175 BBSolarGuard aSolarGuard; 176 ::osl::MutexGuard aGuard( getOslMutex() ); 177 ensureIsAlive(); 178 ensureIsValidRow( nRow ); 179 return implIsRowSelected( nRow ); 180 } 181 182 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn ) 183 { 184 BBSolarGuard aSolarGuard; 185 ::osl::MutexGuard aGuard( getOslMutex() ); 186 ensureIsAlive(); 187 ensureIsValidColumn( nColumn ); 188 return implIsColumnSelected( nColumn ); 189 } 190 191 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt( 192 sal_Int32 nRow, sal_Int32 nColumn ) 193 { 194 BBSolarGuard aSolarGuard; 195 ::osl::MutexGuard aGuard( getOslMutex() ); 196 ensureIsAlive(); 197 ensureIsValidAddress( nRow, nColumn ); 198 return mpBrowseBox->CreateAccessibleCell( nRow, (sal_Int16)nColumn ); 199 } 200 201 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected( 202 sal_Int32 nRow, sal_Int32 nColumn ) 203 { 204 BBSolarGuard aSolarGuard; 205 ::osl::MutexGuard aGuard( getOslMutex() ); 206 ensureIsAlive(); 207 ensureIsValidAddress( nRow, nColumn ); 208 return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn ); 209 } 210 211 // XServiceInfo --------------------------------------------------------------- 212 213 OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName() 214 { 215 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" ) ); 216 } 217 218 // internal virtual methods --------------------------------------------------- 219 220 Rectangle AccessibleBrowseBoxTable::implGetBoundingBox() 221 { 222 return mpBrowseBox->calcTableRect(sal_False); 223 } 224 225 Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen() 226 { 227 return mpBrowseBox->calcTableRect(); 228 } 229 230 // internal helper methods ---------------------------------------------------- 231 232 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar( 233 sal_Int32 nChildIndex ) 234 { 235 Reference< XAccessible > xRet; 236 Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY ); 237 if( xContext.is() ) 238 { 239 try 240 { 241 xRet = xContext->getAccessibleChild( nChildIndex ); 242 } 243 catch( lang::IndexOutOfBoundsException& ) 244 { 245 DBG_ERROR( "implGetHeaderBar - wrong child index" ); 246 } 247 // RuntimeException goes to caller 248 } 249 return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY ); 250 } 251 252 // ============================================================================ 253 } // namespace accessibility 254 // ============================================================================ 255