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 #include "accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx" 32 #include <svtools/accessibletableprovider.hxx> 33 #include "accessibility/extended/AccessibleBrowseBox.hxx" 34 35 namespace accessibility 36 { 37 using namespace ::com::sun::star::accessibility; 38 using namespace ::com::sun::star::lang; 39 using namespace ::com::sun::star::uno; 40 using namespace ::svt; 41 42 AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId, 43 const Reference< XAccessible >& rxParent, 44 IAccessibleTableProvider& rBrowseBox, 45 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow, 46 AccessibleBrowseBoxObjType eObjType) 47 : BrowseBoxAccessibleElement(rxParent, 48 rBrowseBox, 49 _xFocusWindow, 50 eObjType, 51 rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId), 52 rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId)) 53 , m_nColumnRowId(_nColumnRowId) 54 { 55 } 56 /** Creates a new AccessibleStateSetHelper and fills it with states of the 57 current object. 58 @return 59 A filled AccessibleStateSetHelper. 60 */ 61 ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper() 62 { 63 ::osl::MutexGuard aGuard( getOslMutex() ); 64 ::utl::AccessibleStateSetHelper* 65 pStateSetHelper = new ::utl::AccessibleStateSetHelper; 66 67 if( isAlive() ) 68 { 69 // SHOWING done with mxParent 70 if( implIsShowing() ) 71 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 72 73 BBSolarGuard aSolarGuard; 74 pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 75 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 76 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 77 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 78 79 sal_Bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId); 80 if ( bSelected ) 81 pStateSetHelper->AddState( AccessibleStateType::SELECTED ); 82 } 83 else 84 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 85 86 return pStateSetHelper; 87 } 88 // ----------------------------------------------------------------------------- 89 /** @return 90 The count of visible children. 91 */ 92 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount() 93 throw ( RuntimeException ) 94 { 95 return 0; 96 } 97 // ----------------------------------------------------------------------------- 98 99 /** @return 100 The XAccessible interface of the specified child. 101 */ 102 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 ) 103 throw ( IndexOutOfBoundsException,RuntimeException ) 104 { 105 throw IndexOutOfBoundsException(); 106 } 107 // ----------------------------------------------------------------------------- 108 109 /** Grabs the focus to the column header. */ 110 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus() 111 throw ( ::com::sun::star::uno::RuntimeException ) 112 { 113 BBSolarGuard aSolarGuard; 114 ::osl::MutexGuard aGuard( getOslMutex() ); 115 ensureIsAlive(); 116 if ( isRowBarCell() ) 117 mpBrowseBox->SelectRow(m_nColumnRowId); 118 else 119 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!! 120 } 121 // ----------------------------------------------------------------------------- 122 /** @return 123 The name of this class. 124 */ 125 ::rtl::OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName() 126 throw ( ::com::sun::star::uno::RuntimeException ) 127 { 128 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" ) ); 129 } 130 // ----------------------------------------------------------------------------- 131 namespace 132 { 133 Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, sal_Bool _bOnScreen,sal_Bool _bRowBar) 134 { 135 sal_Int32 nRow = 0; 136 sal_uInt16 nCol = (sal_uInt16)_nRowColIndex; 137 if ( _bRowBar ) 138 { 139 nRow = _nRowColIndex + 1; 140 nCol = 0; 141 } 142 143 Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, sal_True, _bOnScreen)); 144 return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize()); 145 } 146 } 147 148 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox() 149 { 150 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_False,isRowBarCell()); 151 } 152 // ----------------------------------------------------------------------------- 153 154 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen() 155 { 156 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_True,isRowBarCell()); 157 } 158 // ----------------------------------------------------------------------------- 159 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent() 160 throw ( RuntimeException ) 161 { 162 ::osl::MutexGuard aGuard( getOslMutex() ); 163 ensureIsAlive(); 164 sal_Int32 nIndex = m_nColumnRowId; 165 if ( mpBrowseBox->HasRowHeader() ) 166 --nIndex; 167 return nIndex; 168 } 169 // ----------------------------------------------------------------------------- 170 } // namespace accessibility 171 // ----------------------------------------------------------------------------- 172 173 174