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_accessibility.hxx" 30 31 32 #include "accessibility/extended/AccessibleGridControlHeader.hxx" 33 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx" 34 #include "accessibility/extended/AccessibleGridControlTableCell.hxx" 35 #include <svtools/accessibletable.hxx> 36 37 38 // ============================================================================ 39 40 using ::rtl::OUString; 41 42 using ::com::sun::star::uno::Reference; 43 using ::com::sun::star::uno::Sequence; 44 using ::com::sun::star::uno::Any; 45 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star; 48 using namespace ::com::sun::star::lang; 49 using namespace ::com::sun::star::accessibility; 50 using namespace ::svt; 51 using namespace ::svt::table; 52 53 // ============================================================================ 54 55 namespace accessibility { 56 57 // ============================================================================ 58 59 DBG_NAME( AccessibleGridControlHeader ) 60 61 AccessibleGridControlHeader::AccessibleGridControlHeader( 62 const Reference< XAccessible >& rxParent, 63 ::svt::table::IAccessibleTable& rTable, 64 ::svt::table::AccessibleTableControlObjType eObjType): 65 AccessibleGridControlTableBase( rxParent, rTable, eObjType ) 66 { 67 DBG_ASSERT( isRowBar() || isColumnBar(), 68 "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" ); 69 } 70 71 AccessibleGridControlHeader::~AccessibleGridControlHeader() 72 { 73 } 74 75 // XAccessibleContext --------------------------------------------------------- 76 77 Reference< XAccessible > SAL_CALL 78 AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex ) 79 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 80 { 81 TCSolarGuard aSolarGuard; 82 ::osl::MutexGuard aGuard( getOslMutex() ); 83 84 if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount()) 85 throw IndexOutOfBoundsException(); 86 ensureIsAlive(); 87 Reference< XAccessible > xChild; 88 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR) 89 { 90 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL); 91 xChild = pColHeaderCell; 92 } 93 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR) 94 { 95 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL); 96 xChild = pRowHeaderCell; 97 } 98 return xChild; 99 } 100 101 sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent() 102 throw ( uno::RuntimeException ) 103 { 104 ensureIsAlive(); 105 if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader()) 106 return 1; 107 else 108 return 0; 109 } 110 111 // XAccessibleComponent ------------------------------------------------------- 112 113 Reference< XAccessible > SAL_CALL 114 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint ) 115 throw ( uno::RuntimeException ) 116 { 117 TCSolarGuard aSolarGuard; 118 ::osl::MutexGuard aGuard( getOslMutex() ); 119 ensureIsAlive(); 120 121 sal_Int32 nRow = 0; 122 sal_Int32 nColumnPos = 0; 123 sal_Bool bConverted = isRowBar() ? 124 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) : 125 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ); 126 127 return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >(); 128 } 129 130 void SAL_CALL AccessibleGridControlHeader::grabFocus() 131 throw ( uno::RuntimeException ) 132 { 133 ensureIsAlive(); 134 // focus on header not supported 135 } 136 137 Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding() 138 throw ( uno::RuntimeException ) 139 { 140 ensureIsAlive(); 141 return Any(); // no special key bindings for header 142 } 143 144 // XAccessibleTable ----------------------------------------------------------- 145 146 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow ) 147 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 148 { 149 TCSolarGuard aSolarGuard; 150 ::osl::MutexGuard aGuard( getOslMutex() ); 151 ensureIsAlive(); 152 ensureIsValidRow( nRow ); 153 return OUString(); // no headers in headers 154 } 155 156 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn ) 157 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 158 { 159 TCSolarGuard aSolarGuard; 160 ::osl::MutexGuard aGuard( getOslMutex() ); 161 ensureIsAlive(); 162 ensureIsValidColumn( nColumn ); 163 return OUString(); // no headers in headers 164 } 165 166 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders() 167 throw ( uno::RuntimeException ) 168 { 169 ensureIsAlive(); 170 return NULL; // no headers in headers 171 } 172 173 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders() 174 throw ( uno::RuntimeException ) 175 { 176 ensureIsAlive(); 177 return NULL; // no headers in headers 178 } 179 //not selectable 180 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows() 181 throw ( uno::RuntimeException ) 182 { 183 Sequence< sal_Int32 > aSelSeq(0); 184 return aSelSeq; 185 } 186 //columns aren't selectable 187 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns() 188 throw ( uno::RuntimeException ) 189 { 190 Sequence< sal_Int32 > aSelSeq(0); 191 return aSelSeq; 192 } 193 //row headers not selectable 194 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ ) 195 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 196 { 197 return sal_False; 198 } 199 //columns aren't selectable 200 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn ) 201 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 202 { 203 (void)nColumn; 204 return sal_False; 205 } 206 //not implemented 207 Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt( 208 sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) 209 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 210 { 211 return NULL; 212 } 213 // not selectable 214 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected( 215 sal_Int32 /*nRow*/, sal_Int32 /*nColumn */) 216 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) 217 { 218 return sal_False; 219 } 220 221 // XServiceInfo --------------------------------------------------------------- 222 223 OUString SAL_CALL AccessibleGridControlHeader::getImplementationName() 224 throw ( uno::RuntimeException ) 225 { 226 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeader" ) ); 227 } 228 229 Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId() 230 throw ( uno::RuntimeException ) 231 { 232 ::osl::MutexGuard aGuard( getOslGlobalMutex() ); 233 static Sequence< sal_Int8 > aId; 234 implCreateUuid( aId ); 235 return aId; 236 } 237 238 // internal virtual methods --------------------------------------------------- 239 240 Rectangle AccessibleGridControlHeader::implGetBoundingBox() 241 { 242 Window* pParent = m_aTable.GetAccessibleParentWindow(); 243 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) ); 244 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar())); 245 if(isColumnBar()) 246 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight())); 247 else 248 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight())); 249 250 } 251 252 Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen() 253 { 254 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) ); 255 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar())); 256 if(isColumnBar()) 257 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight())); 258 else 259 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight())); 260 } 261 262 sal_Int32 AccessibleGridControlHeader::implGetRowCount() const 263 { 264 return 1; 265 } 266 267 sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const 268 { 269 return 1; 270 } 271 272 // internal helper methods ---------------------------------------------------- 273 274 Reference< XAccessible > AccessibleGridControlHeader::implGetChild( 275 sal_Int32 nRow, sal_uInt32 nColumnPos ) 276 { 277 Reference< XAccessible > xChild; 278 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR) 279 { 280 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL); 281 xChild = pColHeaderCell; 282 } 283 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR) 284 { 285 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL); 286 xChild = pRowHeaderCell; 287 } 288 return xChild; 289 } 290 291 // ============================================================================ 292 293 } // namespace accessibility 294 295 // ============================================================================ 296 297