15900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 55900e8ecSAndrew Rist * distributed with this work for additional information 65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 145900e8ecSAndrew Rist * software distributed under the License is distributed on an 155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 175900e8ecSAndrew Rist * specific language governing permissions and limitations 185900e8ecSAndrew Rist * under the License. 19cdf0e10cSrcweir * 205900e8ecSAndrew Rist *************************************************************/ 215900e8ecSAndrew Rist 225900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir #include <svtools/brwbox.hxx> 27cdf0e10cSrcweir #include <svtools/AccessibleBrowseBoxObjType.hxx> 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #include <tools/multisel.hxx> 30cdf0e10cSrcweir #include "datwin.hxx" 31cdf0e10cSrcweir #include "brwimpl.hxx" 32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 34cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir // Accessibility ============================================================== 37cdf0e10cSrcweir 38cdf0e10cSrcweir using ::rtl::OUString; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using ::com::sun::star::accessibility::XAccessible; 41cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 42cdf0e10cSrcweir 43cdf0e10cSrcweir // ============================================================================ 44cdf0e10cSrcweir namespace svt 45cdf0e10cSrcweir { 46cdf0e10cSrcweir using namespace ::com::sun::star::lang; 47cdf0e10cSrcweir using namespace utl; 48cdf0e10cSrcweir 49cdf0e10cSrcweir Reference< XAccessible > getHeaderCell( BrowseBoxImpl::THeaderCellMap& _raHeaderCells, 50cdf0e10cSrcweir sal_Int32 _nPos, 51cdf0e10cSrcweir AccessibleBrowseBoxObjType _eType, 52cdf0e10cSrcweir const Reference< XAccessible >& _rParent, 53cdf0e10cSrcweir BrowseBox& _rBrowseBox, 54cdf0e10cSrcweir IAccessibleFactory& rFactory 55cdf0e10cSrcweir ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir Reference< XAccessible > xRet; 58cdf0e10cSrcweir BrowseBoxImpl::THeaderCellMap::iterator aFind = _raHeaderCells.find( _nPos ); 59cdf0e10cSrcweir if ( aFind == _raHeaderCells.end() ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell( 62cdf0e10cSrcweir _nPos, 63cdf0e10cSrcweir _rParent, 64cdf0e10cSrcweir _rBrowseBox, 65cdf0e10cSrcweir NULL, 66cdf0e10cSrcweir _eType 67cdf0e10cSrcweir ); 68cdf0e10cSrcweir aFind = _raHeaderCells.insert( BrowseBoxImpl::THeaderCellMap::value_type( _nPos, xAccessible ) ).first; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir if ( aFind != _raHeaderCells.end() ) 71cdf0e10cSrcweir xRet = aFind->second; 72cdf0e10cSrcweir return xRet; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir // ============================================================================ 76cdf0e10cSrcweir // ---------------------------------------------------------------------------- 77cdf0e10cSrcweir Reference< XAccessible > BrowseBoxImpl::getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir if ( m_pAccessible && m_pAccessible->isAlive() ) 80cdf0e10cSrcweir return m_pAccessible->getHeaderBar( _eObjType ); 81cdf0e10cSrcweir return NULL; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir // ---------------------------------------------------------------------------- 85cdf0e10cSrcweir Reference< XAccessible > BrowseBoxImpl::getAccessibleTable( ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir if ( m_pAccessible && m_pAccessible->isAlive() ) 88cdf0e10cSrcweir return m_pAccessible->getTable( ); 89cdf0e10cSrcweir return NULL; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir // ============================================================================ 94cdf0e10cSrcweir 95cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessible() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir Window* pParent = GetAccessibleParentWindow(); 98cdf0e10cSrcweir DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir if( pParent && !m_pImpl->m_pAccessible) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir Reference< XAccessible > xAccParent = pParent->GetAccessible(); 103cdf0e10cSrcweir if( xAccParent.is() ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir m_pImpl->m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox( 106cdf0e10cSrcweir xAccParent, *this 107cdf0e10cSrcweir ); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir Reference< XAccessible > xAccessible; 112cdf0e10cSrcweir if ( m_pImpl->m_pAccessible ) 113cdf0e10cSrcweir xAccessible = m_pImpl->m_pAccessible->getMyself(); 114cdf0e10cSrcweir 115cdf0e10cSrcweir return xAccessible; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir // ----------------------------------------------------------------------------- 118cdf0e10cSrcweir 119cdf0e10cSrcweir // Children ------------------------------------------------------------------- 120cdf0e10cSrcweir 121cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir // BBINDEX_TABLE must be the table 124cdf0e10cSrcweir OSL_ENSURE(m_pImpl->m_pAccessible,"Invalid call: Accessible is null"); 125cdf0e10cSrcweir 126cdf0e10cSrcweir return m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell( 127cdf0e10cSrcweir m_pImpl->getAccessibleTable(), 128cdf0e10cSrcweir *this, 129cdf0e10cSrcweir NULL, 130cdf0e10cSrcweir _nRow, 131cdf0e10cSrcweir _nColumnPos, 132cdf0e10cSrcweir OFFSET_DEFAULT 133cdf0e10cSrcweir ); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir // ----------------------------------------------------------------------------- 136cdf0e10cSrcweir 137cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir return svt::getHeaderCell( 140cdf0e10cSrcweir m_pImpl->m_aRowHeaderCellMap, 141cdf0e10cSrcweir _nRow, 142cdf0e10cSrcweir svt::BBTYPE_ROWHEADERCELL, 143cdf0e10cSrcweir m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_ROWHEADERBAR), 144cdf0e10cSrcweir *this, 145cdf0e10cSrcweir m_pImpl->m_aFactoryAccess.getFactory() 146cdf0e10cSrcweir ); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir // ----------------------------------------------------------------------------- 149cdf0e10cSrcweir 150cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir return svt::getHeaderCell( 153cdf0e10cSrcweir m_pImpl->m_aColHeaderCellMap, 154cdf0e10cSrcweir _nColumnPos, 155cdf0e10cSrcweir svt::BBTYPE_COLUMNHEADERCELL, 156cdf0e10cSrcweir m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_COLUMNHEADERBAR), 157cdf0e10cSrcweir *this, 158cdf0e10cSrcweir m_pImpl->m_aFactoryAccess.getFactory() 159cdf0e10cSrcweir ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir // ----------------------------------------------------------------------------- 162cdf0e10cSrcweir 163cdf0e10cSrcweir sal_Int32 BrowseBox::GetAccessibleControlCount() const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir return 0; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir // ----------------------------------------------------------------------------- 168cdf0e10cSrcweir 169cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleControl( sal_Int32 ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir DBG_ASSERT( sal_False, "BrowseBox::CreateAccessibleControl: to be overwritten!" ); 172cdf0e10cSrcweir return NULL; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir // ----------------------------------------------------------------------------- 175cdf0e10cSrcweir 176cdf0e10cSrcweir // Conversions ---------------------------------------------------------------- 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToCellAddress( 179cdf0e10cSrcweir sal_Int32& rnRow, sal_uInt16& rnColumnPos, const Point& rPoint ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir //! TODO has to be checked 182cdf0e10cSrcweir rnRow = GetRowAtYPosPixel(rPoint.Y()); 183cdf0e10cSrcweir rnColumnPos = GetColumnAtXPosPixel(rPoint.X()); 184cdf0e10cSrcweir return rnRow != BROWSER_INVALIDID && rnColumnPos != BROWSER_INVALIDID; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir // ----------------------------------------------------------------------------- 187cdf0e10cSrcweir 188cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir rnRow = GetRowAtYPosPixel(rPoint.Y()); 191cdf0e10cSrcweir // sal_uInt16 nColumnId = GetColumnAtXPosPixel(rPoint.X()); 192cdf0e10cSrcweir return rnRow != BROWSER_INVALIDID;// && nColumnId == 0; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195cdf0e10cSrcweir 196cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToColumnHeader( sal_uInt16& _rnColumnPos, const Point& _rPoint ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir _rnColumnPos = GetColumnAtXPosPixel(_rPoint.X()); 199cdf0e10cSrcweir return _rnColumnPos != BROWSER_INVALIDID; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir // ----------------------------------------------------------------------------- 202cdf0e10cSrcweir 203cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir //! TODO has to be checked 206cdf0e10cSrcweir sal_Int32 nRow = 0; 207cdf0e10cSrcweir sal_uInt16 nColumn = 0; 208cdf0e10cSrcweir sal_Bool bRet = ConvertPointToCellAddress(nRow,nColumn,_rPoint); 209cdf0e10cSrcweir if ( bRet ) 210cdf0e10cSrcweir _rnIndex = nRow * ColCount() + nColumn; 211cdf0e10cSrcweir 212cdf0e10cSrcweir return bRet; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir // ----------------------------------------------------------------------------- 215cdf0e10cSrcweir 216cdf0e10cSrcweir // Object data and state ------------------------------------------------------ 217cdf0e10cSrcweir 218*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009----- 219*2bfcd321SSteve Yin OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const 220*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009 221cdf0e10cSrcweir { 222cdf0e10cSrcweir OUString aRetText; 223cdf0e10cSrcweir switch( eObjType ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX: 226cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox" ) ); 227cdf0e10cSrcweir break; 228cdf0e10cSrcweir case ::svt::BBTYPE_TABLE: 229cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ); 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR: 232cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) ); 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR: 235cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); 236cdf0e10cSrcweir break; 237cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL: 238*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009----- 239*2bfcd321SSteve Yin if( ColCount() !=0 && GetRowCount()!=0) 240*2bfcd321SSteve Yin { 241*2bfcd321SSteve Yin 242*2bfcd321SSteve Yin sal_Int32 columnId = _nPosition % ColCount() +1; 243*2bfcd321SSteve Yin aRetText = OUString( GetColumnDescription( sal_Int16( columnId ) ) ); 244*2bfcd321SSteve Yin sal_Int32 rowId = _nPosition / GetRowCount() + 1; 245*2bfcd321SSteve Yin aRetText += OUString::valueOf(rowId); 246*2bfcd321SSteve Yin } 247*2bfcd321SSteve Yin else 248*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009 249cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TableCell" ) ); 250cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 251cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); 252cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow())); 253cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); 254cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); 255cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); 256cdf0e10cSrcweir #endif 257cdf0e10cSrcweir break; 258cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL: 259*2bfcd321SSteve Yin { 260*2bfcd321SSteve Yin sal_Int32 rowId = _nPosition + 1; 261*2bfcd321SSteve Yin aRetText = OUString::valueOf( rowId ); 262*2bfcd321SSteve Yin } 263*2bfcd321SSteve Yin //aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderCell" ) ); 264cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 265cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); 266cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow())); 267cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); 268cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); 269cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); 270cdf0e10cSrcweir #endif 271cdf0e10cSrcweir break; 272cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL: 273*2bfcd321SSteve Yin //aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderCell" ) ); 274*2bfcd321SSteve Yin aRetText = OUString( GetColumnDescription( sal_Int16( _nPosition ) ) ); 275cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 276cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); 277cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow())); 278cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); 279cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); 280cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); 281cdf0e10cSrcweir #endif 282cdf0e10cSrcweir break; 283cdf0e10cSrcweir default: 284cdf0e10cSrcweir OSL_ENSURE(0,"BrowseBox::GetAccessibleName: invalid enum!"); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir return aRetText; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir // ----------------------------------------------------------------------------- 289cdf0e10cSrcweir 290cdf0e10cSrcweir OUString BrowseBox::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const 291cdf0e10cSrcweir { 292cdf0e10cSrcweir OUString aRetText; 293cdf0e10cSrcweir switch( eObjType ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX: 296cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox description" ) ); 297cdf0e10cSrcweir break; 298cdf0e10cSrcweir case ::svt::BBTYPE_TABLE: 299cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); 300cdf0e10cSrcweir break; 301cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR: 302cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) ); 303cdf0e10cSrcweir break; 304cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR: 305cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); 306cdf0e10cSrcweir break; 307cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL: 308cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); 309cdf0e10cSrcweir break; 310cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL: 311cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); 312cdf0e10cSrcweir break; 313cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL: 314cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) ); 315cdf0e10cSrcweir break; 316cdf0e10cSrcweir case ::svt::BBTYPE_CHECKBOXCELL: 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir return aRetText; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir // ----------------------------------------------------------------------------- 322cdf0e10cSrcweir 323cdf0e10cSrcweir OUString BrowseBox::GetRowDescription( sal_Int32 ) const 324cdf0e10cSrcweir { 325cdf0e10cSrcweir return OUString(); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir // ----------------------------------------------------------------------------- 328cdf0e10cSrcweir 329cdf0e10cSrcweir OUString BrowseBox::GetColumnDescription( sal_uInt16 _nColumn ) const 330cdf0e10cSrcweir { 331cdf0e10cSrcweir return OUString( GetColumnTitle( GetColumnId( _nColumn ) ) ); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir // ----------------------------------------------------------------------------- 335cdf0e10cSrcweir 336cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSet( 337cdf0e10cSrcweir ::utl::AccessibleStateSetHelper& rStateSet, 338cdf0e10cSrcweir ::svt::AccessibleBrowseBoxObjType eObjType ) const 339cdf0e10cSrcweir { 340cdf0e10cSrcweir switch( eObjType ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX: 343cdf0e10cSrcweir case ::svt::BBTYPE_TABLE: 344cdf0e10cSrcweir 345cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 346cdf0e10cSrcweir if ( HasFocus() ) 347cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED ); 348cdf0e10cSrcweir if ( IsActive() ) 349cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ACTIVE ); 350cdf0e10cSrcweir if ( GetUpdateMode() ) 351cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::EDITABLE ); 352cdf0e10cSrcweir if ( IsEnabled() ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ENABLED ); 355cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SENSITIVE ); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir if ( IsReallyVisible() ) 358cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 359cdf0e10cSrcweir if ( eObjType == ::svt::BBTYPE_TABLE ) 360cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 361cdf0e10cSrcweir 362cdf0e10cSrcweir break; 363cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR: 364cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 365cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 366cdf0e10cSrcweir if ( GetSelectRowCount() ) 367cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED ); 368cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 369cdf0e10cSrcweir break; 370cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR: 371cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 372cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 373cdf0e10cSrcweir if ( GetSelectColumnCount() ) 374cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED ); 375cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 376cdf0e10cSrcweir break; 377cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL: 378cdf0e10cSrcweir { 379cdf0e10cSrcweir sal_Int32 nRow = GetCurRow(); 380cdf0e10cSrcweir sal_uInt16 nColumn = GetCurColumnId(); 381cdf0e10cSrcweir if ( IsFieldVisible(nRow,nColumn) ) 382cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 383cdf0e10cSrcweir if ( !IsFrozen( nColumn ) ) 384cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 385cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::TRANSIENT ); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir break; 388cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL: 389cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL: 390cdf0e10cSrcweir case ::svt::BBTYPE_CHECKBOXCELL: 391cdf0e10cSrcweir OSL_ENSURE(0,"Illegal call here!"); 392cdf0e10cSrcweir break; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir // ----------------------------------------------------------------------- 396cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, 397cdf0e10cSrcweir sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const 398cdf0e10cSrcweir { 399cdf0e10cSrcweir //! TODO check if the state is valid for table cells 400cdf0e10cSrcweir if ( IsCellVisible( _nRow, _nColumnPos ) ) 401cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::VISIBLE ); 402cdf0e10cSrcweir if ( GetCurrRow() == _nRow && GetCurrColumn() == _nColumnPos ) 403cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::FOCUSED ); 404cdf0e10cSrcweir else // only transient when column is not focused 405cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::TRANSIENT ); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir // ----------------------------------------------------------------------------- 408cdf0e10cSrcweir 409cdf0e10cSrcweir void BrowseBox::GrabTableFocus() 410cdf0e10cSrcweir { 411cdf0e10cSrcweir GrabFocus(); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir // ----------------------------------------------------------------------------- 414cdf0e10cSrcweir String BrowseBox::GetCellText(long, sal_uInt16 ) const 415cdf0e10cSrcweir { 416cdf0e10cSrcweir DBG_ASSERT(0,"This method has to be implemented by the derived classes! BUG!!"); 417cdf0e10cSrcweir return String(); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 420cdf0e10cSrcweir // ----------------------------------------------------------------------------- 421cdf0e10cSrcweir void BrowseBox::commitHeaderBarEvent(sal_Int16 nEventId, 422cdf0e10cSrcweir const Any& rNewValue, const Any& rOldValue, sal_Bool _bColumnHeaderBar ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir if ( isAccessibleAlive() ) 425cdf0e10cSrcweir m_pImpl->m_pAccessible->commitHeaderBarEvent( nEventId, 426cdf0e10cSrcweir rNewValue, rOldValue, _bColumnHeaderBar ); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir // ----------------------------------------------------------------------------- 430cdf0e10cSrcweir void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir if ( isAccessibleAlive() ) 433cdf0e10cSrcweir m_pImpl->m_pAccessible->commitTableEvent( _nEventId, _rNewValue, _rOldValue ); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir // ----------------------------------------------------------------------------- 436cdf0e10cSrcweir void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir if ( isAccessibleAlive() ) 439cdf0e10cSrcweir m_pImpl->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir // ----------------------------------------------------------------------------- 443cdf0e10cSrcweir ::svt::IAccessibleFactory& BrowseBox::getAccessibleFactory() 444cdf0e10cSrcweir { 445cdf0e10cSrcweir return m_pImpl->m_aFactoryAccess.getFactory(); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir // ----------------------------------------------------------------------------- 449cdf0e10cSrcweir sal_Bool BrowseBox::isAccessibleAlive( ) const 450cdf0e10cSrcweir { 451cdf0e10cSrcweir return ( NULL != m_pImpl->m_pAccessible ) && m_pImpl->m_pAccessible->isAlive(); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir // ----------------------------------------------------------------------------- 454cdf0e10cSrcweir // IAccessibleTableProvider 455cdf0e10cSrcweir // ----------------------------------------------------------------------------- 456cdf0e10cSrcweir sal_Int32 BrowseBox::GetCurrRow() const 457cdf0e10cSrcweir { 458cdf0e10cSrcweir return GetCurRow(); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir // ----------------------------------------------------------------------------- 461cdf0e10cSrcweir sal_uInt16 BrowseBox::GetCurrColumn() const 462cdf0e10cSrcweir { 463cdf0e10cSrcweir return GetColumnPos( GetCurColumnId() ); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir // ----------------------------------------------------------------------------- 466cdf0e10cSrcweir sal_Bool BrowseBox::HasRowHeader() const 467cdf0e10cSrcweir { 468cdf0e10cSrcweir return ( GetColumnId( 0 ) == 0 ); // HandleColumn == RowHeader 469cdf0e10cSrcweir } 470cdf0e10cSrcweir // ----------------------------------------------------------------------------- 471cdf0e10cSrcweir sal_Bool BrowseBox::IsCellFocusable() const 472cdf0e10cSrcweir { 473cdf0e10cSrcweir return sal_True; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir // ----------------------------------------------------------------------------- 476cdf0e10cSrcweir sal_Bool BrowseBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir return GoToRowColumnId( _nRow, GetColumnId( _nColumn ) ); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir // ----------------------------------------------------------------------------- 481cdf0e10cSrcweir void BrowseBox::SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir SelectColumnPos( _nColumn, _bSelect ); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir // ----------------------------------------------------------------------------- 486cdf0e10cSrcweir sal_Bool BrowseBox::IsColumnSelected( long _nColumn ) const 487cdf0e10cSrcweir { 488cdf0e10cSrcweir return ( pColSel && (0 <= _nColumn) && (_nColumn <= 0xFFF) ) ? 489cdf0e10cSrcweir pColSel->IsSelected( static_cast< sal_uInt16 >( _nColumn ) ) : 490cdf0e10cSrcweir sal_False; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir // ----------------------------------------------------------------------------- 493cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedRowCount() const 494cdf0e10cSrcweir { 495cdf0e10cSrcweir return GetSelectRowCount(); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir // ----------------------------------------------------------------------------- 498cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedColumnCount() const 499cdf0e10cSrcweir { 500cdf0e10cSrcweir const MultiSelection* pColumnSel = GetColumnSelection(); 501cdf0e10cSrcweir return pColumnSel ? pColumnSel->GetSelectCount() : 0; 502cdf0e10cSrcweir } 503cdf0e10cSrcweir // ----------------------------------------------------------------------------- 504cdf0e10cSrcweir void BrowseBox::GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const 505cdf0e10cSrcweir { 506cdf0e10cSrcweir sal_Int32 nCount = GetSelectRowCount(); 507cdf0e10cSrcweir if( nCount ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir _rRows.realloc( nCount ); 510cdf0e10cSrcweir _rRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow(); 511cdf0e10cSrcweir for( sal_Int32 nIndex = 1; nIndex < nCount; ++nIndex ) 512cdf0e10cSrcweir _rRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow(); 513cdf0e10cSrcweir DBG_ASSERT( const_cast< BrowseBox* >( this )->NextSelectedRow() == BROWSER_ENDOFSELECTION, 514cdf0e10cSrcweir "BrowseBox::GetAllSelectedRows - too many selected rows found" ); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir } 517cdf0e10cSrcweir // ----------------------------------------------------------------------------- 518cdf0e10cSrcweir void BrowseBox::GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const 519cdf0e10cSrcweir { 520cdf0e10cSrcweir const MultiSelection* pColumnSel = GetColumnSelection(); 521cdf0e10cSrcweir sal_Int32 nCount = GetSelectedColumnCount(); 522cdf0e10cSrcweir if( pColumnSel && nCount ) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir _rColumns.realloc( nCount ); 525cdf0e10cSrcweir 526cdf0e10cSrcweir sal_Int32 nIndex = 0; 527cdf0e10cSrcweir sal_uInt32 nRangeCount = pColumnSel->GetRangeCount(); 528cdf0e10cSrcweir for( sal_uInt32 nRange = 0; nRange < nRangeCount; ++nRange ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir const Range& rRange = pColumnSel->GetRange( nRange ); 531cdf0e10cSrcweir // loop has to include aRange.Max() 532cdf0e10cSrcweir for( sal_Int32 nCol = rRange.Min(); nCol <= rRange.Max(); ++nCol ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir DBG_ASSERT( nIndex < nCount, 535cdf0e10cSrcweir "GetAllSelectedColumns - range overflow" ); 536cdf0e10cSrcweir _rColumns[ nIndex ] = nCol; 537cdf0e10cSrcweir ++nIndex; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir } 542cdf0e10cSrcweir // ----------------------------------------------------------------------------- 543cdf0e10cSrcweir sal_Bool BrowseBox::IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const 544cdf0e10cSrcweir { 545cdf0e10cSrcweir return IsFieldVisible( _nRow, GetColumnId( _nColumnPos ) ); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir // ----------------------------------------------------------------------------- 548cdf0e10cSrcweir String BrowseBox::GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const 549cdf0e10cSrcweir { 550cdf0e10cSrcweir return GetCellText( _nRow, GetColumnId( _nColPos ) ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir // ----------------------------------------------------------------------------- 554cdf0e10cSrcweir sal_Bool BrowseBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector ); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir // ----------------------------------------------------------------------------- 559cdf0e10cSrcweir Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const 560cdf0e10cSrcweir { 561cdf0e10cSrcweir return Control::GetWindowExtentsRelative( pRelativeWindow ); 562cdf0e10cSrcweir } 563cdf0e10cSrcweir // ----------------------------------------------------------------------------- 564cdf0e10cSrcweir void BrowseBox::GrabFocus() 565cdf0e10cSrcweir { 566cdf0e10cSrcweir Control::GrabFocus(); 567cdf0e10cSrcweir } 568cdf0e10cSrcweir // ----------------------------------------------------------------------------- 569cdf0e10cSrcweir Reference< XAccessible > BrowseBox::GetAccessible( sal_Bool bCreate ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir return Control::GetAccessible( bCreate ); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir // ----------------------------------------------------------------------------- 574cdf0e10cSrcweir Window* BrowseBox::GetAccessibleParentWindow() const 575cdf0e10cSrcweir { 576cdf0e10cSrcweir return Control::GetAccessibleParentWindow(); 577cdf0e10cSrcweir } 578cdf0e10cSrcweir // ----------------------------------------------------------------------------- 579cdf0e10cSrcweir Window* BrowseBox::GetWindowInstance() 580cdf0e10cSrcweir { 581cdf0e10cSrcweir return this; 582cdf0e10cSrcweir } 583