1*0841af79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0841af79SAndrew Rist * distributed with this work for additional information 6*0841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0841af79SAndrew Rist * "License"); you may not use this file except in compliance 9*0841af79SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*0841af79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0841af79SAndrew Rist * software distributed under the License is distributed on an 15*0841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0841af79SAndrew Rist * KIND, either express or implied. See the License for the 17*0841af79SAndrew Rist * specific language governing permissions and limitations 18*0841af79SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*0841af79SAndrew Rist *************************************************************/ 21*0841af79SAndrew Rist 22*0841af79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_accessibility.hxx" 26cdf0e10cSrcweir #include "accessibility/extended/accessiblelistboxentry.hxx" 27cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 28cdf0e10cSrcweir #include <svtools/stringtransfer.hxx> 29cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 30cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir #include <vcl/svapp.hxx> 38cdf0e10cSrcweir #include <vcl/controllayout.hxx> 39cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 40cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 41cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 42cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 43cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 44cdf0e10cSrcweir #include <comphelper/sequence.hxx> 45cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 46cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #define ACCESSIBLE_ACTION_COUNT 1 49cdf0e10cSrcweir 50cdf0e10cSrcweir namespace 51cdf0e10cSrcweir { 52cdf0e10cSrcweir void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT ) 55cdf0e10cSrcweir // only three actions 56cdf0e10cSrcweir throw ::com::sun::star::lang::IndexOutOfBoundsException(); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir //........................................................................ 61cdf0e10cSrcweir namespace accessibility 62cdf0e10cSrcweir { 63cdf0e10cSrcweir //........................................................................ 64cdf0e10cSrcweir // class ALBSolarGuard --------------------------------------------------------- 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** Aquire the solar mutex. */ 67cdf0e10cSrcweir class ALBSolarGuard : public ::vos::OGuard 68cdf0e10cSrcweir { 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir inline ALBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {} 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir 73cdf0e10cSrcweir // class AccessibleListBoxEntry ----------------------------------------------------- 74cdf0e10cSrcweir 75cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 76cdf0e10cSrcweir using namespace ::com::sun::star::uno; 77cdf0e10cSrcweir using namespace ::com::sun::star::lang; 78cdf0e10cSrcweir using namespace ::com::sun::star; 79cdf0e10cSrcweir 80cdf0e10cSrcweir DBG_NAME(AccessibleListBoxEntry) 81cdf0e10cSrcweir 82cdf0e10cSrcweir // ----------------------------------------------------------------------------- 83cdf0e10cSrcweir // Ctor() and Dtor() 84cdf0e10cSrcweir // ----------------------------------------------------------------------------- 85cdf0e10cSrcweir AccessibleListBoxEntry::AccessibleListBoxEntry( SvTreeListBox& _rListBox, 86cdf0e10cSrcweir SvLBoxEntry* _pEntry, 87cdf0e10cSrcweir const Reference< XAccessible >& _xParent ) : 88cdf0e10cSrcweir 89cdf0e10cSrcweir AccessibleListBoxEntry_BASE ( m_aMutex ), 90cdf0e10cSrcweir ListBoxAccessibleBase( _rListBox ), 91cdf0e10cSrcweir 92cdf0e10cSrcweir m_nClientId ( 0 ), 93cdf0e10cSrcweir m_aParent ( _xParent ) 94cdf0e10cSrcweir 95cdf0e10cSrcweir { 96cdf0e10cSrcweir DBG_CTOR( AccessibleListBoxEntry, NULL ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir _rListBox.FillEntryPath( _pEntry, m_aEntryPath ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir // ----------------------------------------------------------------------------- 101cdf0e10cSrcweir AccessibleListBoxEntry::~AccessibleListBoxEntry() 102cdf0e10cSrcweir { 103cdf0e10cSrcweir DBG_DTOR( AccessibleListBoxEntry, NULL ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir if ( IsAlive_Impl() ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir // increment ref count to prevent double call of Dtor 108cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 109cdf0e10cSrcweir dispose(); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir // ----------------------------------------------------------------------------- 114cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBox_Impl() const 115cdf0e10cSrcweir { 116cdf0e10cSrcweir Rectangle aRect; 117cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 118cdf0e10cSrcweir if ( pEntry ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir aRect = getListBox()->GetBoundingRect( pEntry ); 121cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetParent( pEntry ); 122cdf0e10cSrcweir if ( pParent ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir // position relative to parent entry 125cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft(); 126cdf0e10cSrcweir aTopLeft -= getListBox()->GetBoundingRect( pParent ).TopLeft(); 127cdf0e10cSrcweir aRect = Rectangle( aTopLeft, aRect.GetSize() ); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir return aRect; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir // ----------------------------------------------------------------------------- 134cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen_Impl() const 135cdf0e10cSrcweir { 136cdf0e10cSrcweir Rectangle aRect; 137cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 138cdf0e10cSrcweir if ( pEntry ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir aRect = getListBox()->GetBoundingRect( pEntry ); 141cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft(); 142cdf0e10cSrcweir aTopLeft += getListBox()->GetWindowExtentsRelative( NULL ).TopLeft(); 143cdf0e10cSrcweir aRect = Rectangle( aTopLeft, aRect.GetSize() ); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir return aRect; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir // ----------------------------------------------------------------------------- 149cdf0e10cSrcweir sal_Bool AccessibleListBoxEntry::IsAlive_Impl() const 150cdf0e10cSrcweir { 151cdf0e10cSrcweir return ( !rBHelper.bDisposed && !rBHelper.bInDispose && isAlive() ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir // ----------------------------------------------------------------------------- 154cdf0e10cSrcweir sal_Bool AccessibleListBoxEntry::IsShowing_Impl() const 155cdf0e10cSrcweir { 156cdf0e10cSrcweir Reference< XAccessible > xParent = implGetParentAccessible( ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir sal_Bool bShowing = sal_False; 159cdf0e10cSrcweir Reference< XAccessibleContext > m_xParentContext = 160cdf0e10cSrcweir xParent.is() ? xParent->getAccessibleContext() : Reference< XAccessibleContext >(); 161cdf0e10cSrcweir if( m_xParentContext.is() ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY ); 164cdf0e10cSrcweir if( xParentComp.is() ) 165cdf0e10cSrcweir bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) ); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir return bShowing; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir // ----------------------------------------------------------------------------- 171cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBox() throw ( lang::DisposedException ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 174cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir EnsureIsAlive(); 177cdf0e10cSrcweir return GetBoundingBox_Impl(); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir // ----------------------------------------------------------------------------- 180cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 183cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir EnsureIsAlive(); 186cdf0e10cSrcweir return GetBoundingBoxOnScreen_Impl(); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir // ----------------------------------------------------------------------------- 189cdf0e10cSrcweir void AccessibleListBoxEntry::EnsureIsAlive() const throw ( lang::DisposedException ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir if ( !IsAlive_Impl() ) 192cdf0e10cSrcweir throw lang::DisposedException(); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195cdf0e10cSrcweir ::rtl::OUString AccessibleListBoxEntry::implGetText() 196cdf0e10cSrcweir { 197cdf0e10cSrcweir ::rtl::OUString sRet; 198cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 199cdf0e10cSrcweir if ( pEntry ) 200cdf0e10cSrcweir sRet = getListBox()->SearchEntryText( pEntry ); 201cdf0e10cSrcweir return sRet; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir // ----------------------------------------------------------------------------- 204cdf0e10cSrcweir Locale AccessibleListBoxEntry::implGetLocale() 205cdf0e10cSrcweir { 206cdf0e10cSrcweir Locale aLocale; 207cdf0e10cSrcweir aLocale = Application::GetSettings().GetUILocale(); 208cdf0e10cSrcweir 209cdf0e10cSrcweir return aLocale; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir void AccessibleListBoxEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir nStartIndex = 0; 214cdf0e10cSrcweir nEndIndex = 0; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir // ----------------------------------------------------------------------------- 217cdf0e10cSrcweir // XTypeProvider 218cdf0e10cSrcweir // ----------------------------------------------------------------------------- 219cdf0e10cSrcweir // ----------------------------------------------------------------------------- 220cdf0e10cSrcweir Sequence< sal_Int8 > AccessibleListBoxEntry::getImplementationId() throw (RuntimeException) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir static ::cppu::OImplementationId* pId = NULL; 223cdf0e10cSrcweir 224cdf0e10cSrcweir if ( !pId ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir if ( !pId ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir static ::cppu::OImplementationId aId; 231cdf0e10cSrcweir pId = &aId; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir return pId->getImplementationId(); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir // ----------------------------------------------------------------------------- 238cdf0e10cSrcweir // XComponent/ListBoxAccessibleBase 239cdf0e10cSrcweir // ----------------------------------------------------------------------------- 240cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::dispose() throw ( uno::RuntimeException ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir AccessibleListBoxEntry_BASE::dispose(); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir // ----------------------------------------------------------------------------- 246cdf0e10cSrcweir // XComponent 247cdf0e10cSrcweir // ----------------------------------------------------------------------------- 248cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::disposing() 249cdf0e10cSrcweir { 250cdf0e10cSrcweir ALBSolarGuard(); 251cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir Reference< XAccessible > xKeepAlive( this ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir // Send a disposing to all listeners. 256cdf0e10cSrcweir if ( m_nClientId ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::TClientId nId = m_nClientId; 259cdf0e10cSrcweir m_nClientId = 0; 260cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir // clean up 264cdf0e10cSrcweir { 265cdf0e10cSrcweir 266cdf0e10cSrcweir ListBoxAccessibleBase::disposing(); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir m_aParent = WeakReference< XAccessible >(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir // ----------------------------------------------------------------------------- 271cdf0e10cSrcweir // XServiceInfo 272cdf0e10cSrcweir // ----------------------------------------------------------------------------- 273cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getImplementationName() throw(RuntimeException) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir return getImplementationName_Static(); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir // ----------------------------------------------------------------------------- 278cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL AccessibleListBoxEntry::getSupportedServiceNames() throw(RuntimeException) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir return getSupportedServiceNames_Static(); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir // ----------------------------------------------------------------------------- 283cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 286cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 287cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 288cdf0e10cSrcweir for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 289cdf0e10cSrcweir ; 290cdf0e10cSrcweir 291cdf0e10cSrcweir return pSupported != pEnd; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir // ----------------------------------------------------------------------------- 294cdf0e10cSrcweir // XServiceInfo - static methods 295cdf0e10cSrcweir // ----------------------------------------------------------------------------- 296cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleListBoxEntry::getSupportedServiceNames_Static(void) throw( RuntimeException ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(3); 299cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 300cdf0e10cSrcweir aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 301cdf0e10cSrcweir aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleTreeListBoxEntry") ); 302cdf0e10cSrcweir return aSupported; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir // ----------------------------------------------------------------------------- 305cdf0e10cSrcweir ::rtl::OUString AccessibleListBoxEntry::getImplementationName_Static(void) throw( RuntimeException ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleTreeListBoxEntry") ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir // ----------------------------------------------------------------------------- 310cdf0e10cSrcweir // XAccessible 311cdf0e10cSrcweir // ----------------------------------------------------------------------------- 312cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleListBoxEntry::getAccessibleContext( ) throw (RuntimeException) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir EnsureIsAlive(); 315cdf0e10cSrcweir return this; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir // ----------------------------------------------------------------------------- 318cdf0e10cSrcweir // XAccessibleContext 319cdf0e10cSrcweir // ----------------------------------------------------------------------------- 320cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount( ) throw (RuntimeException) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 323cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 324cdf0e10cSrcweir 325cdf0e10cSrcweir EnsureIsAlive(); 326cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 327cdf0e10cSrcweir sal_Int32 nCount = 0; 328cdf0e10cSrcweir if ( pEntry ) 329cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pEntry ); 330cdf0e10cSrcweir 331cdf0e10cSrcweir return nCount; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir // ----------------------------------------------------------------------------- 334cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 337cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 338cdf0e10cSrcweir EnsureIsAlive(); 339cdf0e10cSrcweir 340cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 341cdf0e10cSrcweir SvLBoxEntry* pEntry = pParent ? getListBox()->GetEntry( pParent, i ) : NULL; 342cdf0e10cSrcweir if ( !pEntry ) 343cdf0e10cSrcweir throw IndexOutOfBoundsException(); 344cdf0e10cSrcweir 345cdf0e10cSrcweir return new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir // ----------------------------------------------------------------------------- 349cdf0e10cSrcweir Reference< XAccessible > AccessibleListBoxEntry::implGetParentAccessible( ) const 350cdf0e10cSrcweir { 351cdf0e10cSrcweir Reference< XAccessible > xParent = (Reference< XAccessible >)m_aParent; 352cdf0e10cSrcweir if ( !xParent.is() ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir DBG_ASSERT( m_aEntryPath.size(), "AccessibleListBoxEntry::getAccessibleParent: invalid path!" ); 355cdf0e10cSrcweir if ( 1 == m_aEntryPath.size() ) 356cdf0e10cSrcweir { // we're a top level entry 357cdf0e10cSrcweir // -> our parent is the tree listbox itself 358cdf0e10cSrcweir if ( getListBox() ) 359cdf0e10cSrcweir xParent = getListBox()->GetAccessible( ); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir else 362cdf0e10cSrcweir { // we have a entry as parent -> get it's accessible 363cdf0e10cSrcweir 364cdf0e10cSrcweir // shorten our access path by one 365cdf0e10cSrcweir ::std::deque< sal_Int32 > aParentPath( m_aEntryPath ); 366cdf0e10cSrcweir aParentPath.pop_back(); 367cdf0e10cSrcweir 368cdf0e10cSrcweir // get the entry for this shortened access path 369cdf0e10cSrcweir SvLBoxEntry* pParentEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 370cdf0e10cSrcweir DBG_ASSERT( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" ); 371cdf0e10cSrcweir 372cdf0e10cSrcweir if ( pParentEntry ) 373cdf0e10cSrcweir xParent = new AccessibleListBoxEntry( *getListBox(), pParentEntry, NULL ); 374cdf0e10cSrcweir // note that we pass NULL here as parent-accessible: 375cdf0e10cSrcweir // this is allowed, as the AccessibleListBoxEntry class will create it's parent 376cdf0e10cSrcweir // when needed 377cdf0e10cSrcweir } 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir return xParent; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir // ----------------------------------------------------------------------------- 384cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleParent( ) throw (RuntimeException) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 387cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 388cdf0e10cSrcweir EnsureIsAlive(); 389cdf0e10cSrcweir 390cdf0e10cSrcweir return implGetParentAccessible( ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir // ----------------------------------------------------------------------------- 393cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleIndexInParent( ) throw (RuntimeException) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir DBG_ASSERT( !m_aEntryPath.empty(), "empty path" ); 398cdf0e10cSrcweir return m_aEntryPath.empty() ? -1 : m_aEntryPath.back(); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir // ----------------------------------------------------------------------------- 401cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleListBoxEntry::getAccessibleRole( ) throw (RuntimeException) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir return AccessibleRole::LABEL; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir // ----------------------------------------------------------------------------- 406cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleDescription( ) throw (RuntimeException) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir // no description for every item 409cdf0e10cSrcweir return ::rtl::OUString(); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir // ----------------------------------------------------------------------------- 412cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleName( ) throw (RuntimeException) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 415cdf0e10cSrcweir 416cdf0e10cSrcweir EnsureIsAlive(); 417cdf0e10cSrcweir return implGetText(); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir // ----------------------------------------------------------------------------- 420cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleListBoxEntry::getAccessibleRelationSet( ) throw (RuntimeException) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir Reference< XAccessibleRelationSet > xRelSet; 423cdf0e10cSrcweir Reference< XAccessible > xParent; 424cdf0e10cSrcweir if ( m_aEntryPath.size() > 1 ) // not a root entry 425cdf0e10cSrcweir xParent = implGetParentAccessible(); 426cdf0e10cSrcweir if ( xParent.is() ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 429cdf0e10cSrcweir Sequence< Reference< XInterface > > aSequence(1); 430cdf0e10cSrcweir aSequence[0] = xParent; 431cdf0e10cSrcweir pRelationSetHelper->AddRelation( 432cdf0e10cSrcweir AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF, aSequence ) ); 433cdf0e10cSrcweir xRelSet = pRelationSetHelper; 434cdf0e10cSrcweir } 435cdf0e10cSrcweir return xRelSet; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir // ----------------------------------------------------------------------------- 438cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet( ) throw (RuntimeException) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 441cdf0e10cSrcweir 442cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 443cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = pStateSetHelper; 444cdf0e10cSrcweir 445cdf0e10cSrcweir if ( IsAlive_Impl() ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 448cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 449cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 450cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 451cdf0e10cSrcweir if ( getListBox()->IsInplaceEditingEnabled() ) 452cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::EDITABLE ); 453cdf0e10cSrcweir if ( IsShowing_Impl() ) 454cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 455cdf0e10cSrcweir getListBox()->FillAccessibleEntryStateSet( 456cdf0e10cSrcweir getListBox()->GetEntryFromPath( m_aEntryPath ), *pStateSetHelper ); 457cdf0e10cSrcweir } 458cdf0e10cSrcweir else 459cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 460cdf0e10cSrcweir 461cdf0e10cSrcweir return xStateSet; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir // ----------------------------------------------------------------------------- 464cdf0e10cSrcweir Locale SAL_CALL AccessibleListBoxEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 467cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 468cdf0e10cSrcweir 469cdf0e10cSrcweir return implGetLocale(); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir // ----------------------------------------------------------------------------- 472cdf0e10cSrcweir // XAccessibleComponent 473cdf0e10cSrcweir // ----------------------------------------------------------------------------- 474cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir // ----------------------------------------------------------------------------- 479cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 482cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir EnsureIsAlive(); 485cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( VCLPoint( _aPoint ) ); 486cdf0e10cSrcweir if ( !pEntry ) 487cdf0e10cSrcweir throw RuntimeException(); 488cdf0e10cSrcweir 489cdf0e10cSrcweir Reference< XAccessible > xAcc; 490cdf0e10cSrcweir AccessibleListBoxEntry* pAccEntry = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 491cdf0e10cSrcweir Rectangle aRect = pAccEntry->GetBoundingBox_Impl(); 492cdf0e10cSrcweir if ( aRect.IsInside( VCLPoint( _aPoint ) ) ) 493cdf0e10cSrcweir xAcc = pAccEntry; 494cdf0e10cSrcweir return xAcc; 495cdf0e10cSrcweir } 496cdf0e10cSrcweir // ----------------------------------------------------------------------------- 497cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds( ) throw (RuntimeException) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir return AWTRectangle( GetBoundingBox() ); 500cdf0e10cSrcweir } 501cdf0e10cSrcweir // ----------------------------------------------------------------------------- 502cdf0e10cSrcweir awt::Point SAL_CALL AccessibleListBoxEntry::getLocation( ) throw (RuntimeException) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir return AWTPoint( GetBoundingBox().TopLeft() ); 505cdf0e10cSrcweir } 506cdf0e10cSrcweir // ----------------------------------------------------------------------------- 507cdf0e10cSrcweir awt::Point SAL_CALL AccessibleListBoxEntry::getLocationOnScreen( ) throw (RuntimeException) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir // ----------------------------------------------------------------------------- 512cdf0e10cSrcweir awt::Size SAL_CALL AccessibleListBoxEntry::getSize( ) throw (RuntimeException) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir return AWTSize( GetBoundingBox().GetSize() ); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir // ----------------------------------------------------------------------------- 517cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::grabFocus( ) throw (RuntimeException) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir // do nothing, because no focus for each item 520cdf0e10cSrcweir } 521cdf0e10cSrcweir // ----------------------------------------------------------------------------- 522cdf0e10cSrcweir sal_Int32 AccessibleListBoxEntry::getForeground( ) throw (RuntimeException) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 525cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 526cdf0e10cSrcweir 527cdf0e10cSrcweir sal_Int32 nColor = 0; 528cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 529cdf0e10cSrcweir if ( xParent.is() ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 532cdf0e10cSrcweir if ( xParentComp.is() ) 533cdf0e10cSrcweir nColor = xParentComp->getForeground(); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir return nColor; 537cdf0e10cSrcweir } 538cdf0e10cSrcweir // ----------------------------------------------------------------------------- 539cdf0e10cSrcweir sal_Int32 AccessibleListBoxEntry::getBackground( ) throw (RuntimeException) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 542cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 543cdf0e10cSrcweir 544cdf0e10cSrcweir sal_Int32 nColor = 0; 545cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 546cdf0e10cSrcweir if ( xParent.is() ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 549cdf0e10cSrcweir if ( xParentComp.is() ) 550cdf0e10cSrcweir nColor = xParentComp->getBackground(); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir return nColor; 554cdf0e10cSrcweir } 555cdf0e10cSrcweir // ----------------------------------------------------------------------------- 556cdf0e10cSrcweir // XAccessibleText 557cdf0e10cSrcweir // ----------------------------------------------------------------------------- 558cdf0e10cSrcweir // ----------------------------------------------------------------------------- 559cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 562cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 563cdf0e10cSrcweir 564cdf0e10cSrcweir EnsureIsAlive(); 565cdf0e10cSrcweir 566cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, implGetText().getLength() ) ) 567cdf0e10cSrcweir throw IndexOutOfBoundsException(); 568cdf0e10cSrcweir 569cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 570cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 571cdf0e10cSrcweir if ( pEntry ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir ::vcl::ControlLayoutData aLayoutData; 574cdf0e10cSrcweir Rectangle aItemRect = GetBoundingBox(); 575cdf0e10cSrcweir getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 576cdf0e10cSrcweir Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex ); 577cdf0e10cSrcweir aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 578cdf0e10cSrcweir aBounds = AWTRectangle( aCharRect ); 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir return aBounds; 582cdf0e10cSrcweir } 583cdf0e10cSrcweir // ----------------------------------------------------------------------------- 584cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 587cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 588cdf0e10cSrcweir EnsureIsAlive(); 589cdf0e10cSrcweir 590cdf0e10cSrcweir sal_Int32 nIndex = -1; 591cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 592cdf0e10cSrcweir if ( pEntry ) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir ::vcl::ControlLayoutData aLayoutData; 595cdf0e10cSrcweir Rectangle aItemRect = GetBoundingBox(); 596cdf0e10cSrcweir getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 597cdf0e10cSrcweir Point aPnt( VCLPoint( aPoint ) ); 598cdf0e10cSrcweir aPnt += aItemRect.TopLeft(); 599cdf0e10cSrcweir nIndex = aLayoutData.GetIndexForPoint( aPnt ); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602cdf0e10cSrcweir return nIndex; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir // ----------------------------------------------------------------------------- 605cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 608cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 609cdf0e10cSrcweir EnsureIsAlive(); 610cdf0e10cSrcweir 611cdf0e10cSrcweir String sText = getText(); 612cdf0e10cSrcweir if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex ) 613cdf0e10cSrcweir || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) ) 614cdf0e10cSrcweir throw IndexOutOfBoundsException(); 615cdf0e10cSrcweir 616cdf0e10cSrcweir sal_Int32 nLen = nEndIndex - nStartIndex + 1; 617cdf0e10cSrcweir ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), getListBox() ); 618cdf0e10cSrcweir 619cdf0e10cSrcweir return sal_True; 620cdf0e10cSrcweir } 621cdf0e10cSrcweir // ----------------------------------------------------------------------------- 622cdf0e10cSrcweir // XAccessibleEventBroadcaster 623cdf0e10cSrcweir // ----------------------------------------------------------------------------- 624cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 625cdf0e10cSrcweir { 626cdf0e10cSrcweir if (xListener.is()) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 629cdf0e10cSrcweir if (!m_nClientId) 630cdf0e10cSrcweir m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); 631cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); 632cdf0e10cSrcweir } 633cdf0e10cSrcweir } 634cdf0e10cSrcweir // ----------------------------------------------------------------------------- 635cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir if (xListener.is()) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 640cdf0e10cSrcweir 641cdf0e10cSrcweir sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); 642cdf0e10cSrcweir if ( !nListenerCount ) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir // no listeners anymore 645cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 646cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 647cdf0e10cSrcweir // NotifyAccessibleEvent, again 648cdf0e10cSrcweir sal_Int32 nId = m_nClientId; 649cdf0e10cSrcweir m_nClientId = 0; 650cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClient( nId ); 651cdf0e10cSrcweir 652cdf0e10cSrcweir } 653cdf0e10cSrcweir } 654cdf0e10cSrcweir } 655cdf0e10cSrcweir // ----------------------------------------------------------------------------- 656cdf0e10cSrcweir // XAccessibleAction 657cdf0e10cSrcweir // ----------------------------------------------------------------------------- 658cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleActionCount( ) throw (RuntimeException) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 661cdf0e10cSrcweir 662cdf0e10cSrcweir // three actions supported 663cdf0e10cSrcweir return ACCESSIBLE_ACTION_COUNT; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir // ----------------------------------------------------------------------------- 666cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 669cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 670cdf0e10cSrcweir 671cdf0e10cSrcweir sal_Bool bRet = sal_False; 672cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 673cdf0e10cSrcweir EnsureIsAlive(); 674cdf0e10cSrcweir 675cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 676cdf0e10cSrcweir if ( pEntry ) 677cdf0e10cSrcweir { 678cdf0e10cSrcweir if ( getListBox()->IsExpanded( pEntry ) ) 679cdf0e10cSrcweir getListBox()->Collapse( pEntry ); 680cdf0e10cSrcweir else 681cdf0e10cSrcweir getListBox()->Expand( pEntry ); 682cdf0e10cSrcweir bRet = sal_True; 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir return bRet; 686cdf0e10cSrcweir } 687cdf0e10cSrcweir // ----------------------------------------------------------------------------- 688cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 691cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 692cdf0e10cSrcweir 693cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 694cdf0e10cSrcweir EnsureIsAlive(); 695cdf0e10cSrcweir 696cdf0e10cSrcweir static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "toggleExpand" ) ); 697cdf0e10cSrcweir return sActionDesc; 698cdf0e10cSrcweir } 699cdf0e10cSrcweir // ----------------------------------------------------------------------------- 700cdf0e10cSrcweir Reference< XAccessibleKeyBinding > AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 703cdf0e10cSrcweir 704cdf0e10cSrcweir Reference< XAccessibleKeyBinding > xRet; 705cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 706cdf0e10cSrcweir // ... which key? 707cdf0e10cSrcweir return xRet; 708cdf0e10cSrcweir } 709cdf0e10cSrcweir // ----------------------------------------------------------------------------- 710cdf0e10cSrcweir // XAccessibleSelection 711cdf0e10cSrcweir // ----------------------------------------------------------------------------- 712cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 715cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 716cdf0e10cSrcweir 717cdf0e10cSrcweir EnsureIsAlive(); 718cdf0e10cSrcweir 719cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 720cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex ); 721cdf0e10cSrcweir if ( !pEntry ) 722cdf0e10cSrcweir throw IndexOutOfBoundsException(); 723cdf0e10cSrcweir 724cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir // ----------------------------------------------------------------------------- 727cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 730cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 731cdf0e10cSrcweir 732cdf0e10cSrcweir EnsureIsAlive(); 733cdf0e10cSrcweir 734cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 735cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex ); 736cdf0e10cSrcweir if ( !pEntry ) 737cdf0e10cSrcweir throw IndexOutOfBoundsException(); 738cdf0e10cSrcweir 739cdf0e10cSrcweir return getListBox()->IsSelected( pEntry ); 740cdf0e10cSrcweir } 741cdf0e10cSrcweir // ----------------------------------------------------------------------------- 742cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::clearAccessibleSelection( ) throw (RuntimeException) 743cdf0e10cSrcweir { 744cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 745cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 746cdf0e10cSrcweir 747cdf0e10cSrcweir EnsureIsAlive(); 748cdf0e10cSrcweir 749cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 750cdf0e10cSrcweir if ( !pParent ) 751cdf0e10cSrcweir throw RuntimeException(); 752cdf0e10cSrcweir sal_Int32 i, nCount = 0; 753cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 754cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 757cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 758cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 759cdf0e10cSrcweir } 760cdf0e10cSrcweir } 761cdf0e10cSrcweir // ----------------------------------------------------------------------------- 762cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::selectAllAccessibleChildren( ) throw (RuntimeException) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 765cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 766cdf0e10cSrcweir 767cdf0e10cSrcweir EnsureIsAlive(); 768cdf0e10cSrcweir 769cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 770cdf0e10cSrcweir if ( !pParent ) 771cdf0e10cSrcweir throw RuntimeException(); 772cdf0e10cSrcweir sal_Int32 i, nCount = 0; 773cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 774cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 777cdf0e10cSrcweir if ( !getListBox()->IsSelected( pEntry ) ) 778cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 779cdf0e10cSrcweir } 780cdf0e10cSrcweir } 781cdf0e10cSrcweir // ----------------------------------------------------------------------------- 782cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount( ) throw (RuntimeException) 783cdf0e10cSrcweir { 784cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 785cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 786cdf0e10cSrcweir 787cdf0e10cSrcweir EnsureIsAlive(); 788cdf0e10cSrcweir 789cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 790cdf0e10cSrcweir 791cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 792cdf0e10cSrcweir if ( !pParent ) 793cdf0e10cSrcweir throw RuntimeException(); 794cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 795cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 798cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 799cdf0e10cSrcweir ++nSelCount; 800cdf0e10cSrcweir } 801cdf0e10cSrcweir 802cdf0e10cSrcweir return nSelCount; 803cdf0e10cSrcweir } 804cdf0e10cSrcweir // ----------------------------------------------------------------------------- 805cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 808cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 809cdf0e10cSrcweir 810cdf0e10cSrcweir EnsureIsAlive(); 811cdf0e10cSrcweir 812cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 813cdf0e10cSrcweir throw IndexOutOfBoundsException(); 814cdf0e10cSrcweir 815cdf0e10cSrcweir Reference< XAccessible > xChild; 816cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 817cdf0e10cSrcweir 818cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 819cdf0e10cSrcweir if ( !pParent ) 820cdf0e10cSrcweir throw RuntimeException(); 821cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 822cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 825cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 826cdf0e10cSrcweir ++nSelCount; 827cdf0e10cSrcweir 828cdf0e10cSrcweir if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 831cdf0e10cSrcweir break; 832cdf0e10cSrcweir } 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir return xChild; 836cdf0e10cSrcweir } 837cdf0e10cSrcweir // ----------------------------------------------------------------------------- 838cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 841cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 842cdf0e10cSrcweir 843cdf0e10cSrcweir EnsureIsAlive(); 844cdf0e10cSrcweir 845cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 846cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nSelectedChildIndex ); 847cdf0e10cSrcweir if ( !pEntry ) 848cdf0e10cSrcweir throw IndexOutOfBoundsException(); 849cdf0e10cSrcweir 850cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 851cdf0e10cSrcweir } 852cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir return -1; 855cdf0e10cSrcweir } 856cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 857cdf0e10cSrcweir { 858cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 859cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 860cdf0e10cSrcweir EnsureIsAlive(); 861cdf0e10cSrcweir 862cdf0e10cSrcweir if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 863cdf0e10cSrcweir throw IndexOutOfBoundsException(); 864cdf0e10cSrcweir 865cdf0e10cSrcweir return sal_False; 866cdf0e10cSrcweir } 867cdf0e10cSrcweir sal_Unicode SAL_CALL AccessibleListBoxEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 870cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 871cdf0e10cSrcweir EnsureIsAlive(); 872cdf0e10cSrcweir return OCommonAccessibleText::getCharacter( nIndex ); 873cdf0e10cSrcweir } 874cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleListBoxEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 877cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 878cdf0e10cSrcweir EnsureIsAlive(); 879cdf0e10cSrcweir 880cdf0e10cSrcweir ::rtl::OUString sText( implGetText() ); 881cdf0e10cSrcweir 882cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 883cdf0e10cSrcweir throw IndexOutOfBoundsException(); 884cdf0e10cSrcweir 885cdf0e10cSrcweir return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(); 886cdf0e10cSrcweir } 887cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 890cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 891cdf0e10cSrcweir EnsureIsAlive(); 892cdf0e10cSrcweir return OCommonAccessibleText::getCharacterCount( ); 893cdf0e10cSrcweir } 894cdf0e10cSrcweir 895cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 898cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 899cdf0e10cSrcweir EnsureIsAlive(); 900cdf0e10cSrcweir return OCommonAccessibleText::getSelectedText( ); 901cdf0e10cSrcweir } 902cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 905cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 906cdf0e10cSrcweir EnsureIsAlive(); 907cdf0e10cSrcweir return OCommonAccessibleText::getSelectionStart( ); 908cdf0e10cSrcweir } 909cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 912cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 913cdf0e10cSrcweir EnsureIsAlive(); 914cdf0e10cSrcweir return OCommonAccessibleText::getSelectionEnd( ); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 919cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 920cdf0e10cSrcweir EnsureIsAlive(); 921cdf0e10cSrcweir 922cdf0e10cSrcweir if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 923cdf0e10cSrcweir throw IndexOutOfBoundsException(); 924cdf0e10cSrcweir 925cdf0e10cSrcweir return sal_False; 926cdf0e10cSrcweir } 927cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getText( ) throw (::com::sun::star::uno::RuntimeException) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 930cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 931cdf0e10cSrcweir EnsureIsAlive(); 932cdf0e10cSrcweir return OCommonAccessibleText::getText( ); 933cdf0e10cSrcweir } 934cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 937cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 938cdf0e10cSrcweir EnsureIsAlive(); 939cdf0e10cSrcweir return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ); 940cdf0e10cSrcweir } 941cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 942cdf0e10cSrcweir { 943cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 944cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 945cdf0e10cSrcweir EnsureIsAlive(); 946cdf0e10cSrcweir return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 949cdf0e10cSrcweir { 950cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 951cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 952cdf0e10cSrcweir EnsureIsAlive(); 953cdf0e10cSrcweir return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType); 954cdf0e10cSrcweir } 955cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 956cdf0e10cSrcweir { 957cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 958cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 959cdf0e10cSrcweir EnsureIsAlive(); 960cdf0e10cSrcweir 961cdf0e10cSrcweir return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType); 962cdf0e10cSrcweir } 963cdf0e10cSrcweir //........................................................................ 964cdf0e10cSrcweir }// namespace accessibility 965cdf0e10cSrcweir //........................................................................ 966cdf0e10cSrcweir 967