10841af79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 30841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file 50841af79SAndrew Rist * distributed with this work for additional information 60841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 70841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the 80841af79SAndrew Rist * "License"); you may not use this file except in compliance 90841af79SAndrew Rist * with the License. You may obtain a copy of the License at 100841af79SAndrew Rist * 110841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 120841af79SAndrew Rist * 130841af79SAndrew Rist * Unless required by applicable law or agreed to in writing, 140841af79SAndrew Rist * software distributed under the License is distributed on an 150841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160841af79SAndrew Rist * KIND, either express or implied. See the License for the 170841af79SAndrew Rist * specific language governing permissions and limitations 180841af79SAndrew Rist * under the License. 190841af79SAndrew Rist * 200841af79SAndrew Rist *************************************************************/ 210841af79SAndrew Rist 220841af79SAndrew 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> 2821075d77SSteve Yin #include <accessibility/helper/accresmgr.hxx> 29cdf0e10cSrcweir #include <svtools/stringtransfer.hxx> 30cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37cdf0e10cSrcweir #include <tools/debug.hxx> 38cdf0e10cSrcweir #include <vcl/svapp.hxx> 39cdf0e10cSrcweir #include <vcl/controllayout.hxx> 40cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 41cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 42cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 43cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 44cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 45cdf0e10cSrcweir #include <comphelper/sequence.hxx> 46cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 47cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 4821075d77SSteve Yin #include <accessibility/helper/accessiblestrings.hrc> 4921075d77SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEVALUE_HPP_ 5021075d77SSteve Yin #include <com/sun/star/accessibility/XAccessibleValue.hpp> 5121075d77SSteve Yin #endif 52cdf0e10cSrcweir #define ACCESSIBLE_ACTION_COUNT 1 53cdf0e10cSrcweir 54cdf0e10cSrcweir namespace 55cdf0e10cSrcweir { checkActionIndex_Impl(sal_Int32 _nIndex)56cdf0e10cSrcweir void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT ) 59cdf0e10cSrcweir // only three actions 60cdf0e10cSrcweir throw ::com::sun::star::lang::IndexOutOfBoundsException(); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir //........................................................................ 65cdf0e10cSrcweir namespace accessibility 66cdf0e10cSrcweir { 67cdf0e10cSrcweir //........................................................................ 68cdf0e10cSrcweir // class ALBSolarGuard --------------------------------------------------------- 69cdf0e10cSrcweir 7007a3d7f1SPedro Giffuni /** Acquire the solar mutex. */ 71cdf0e10cSrcweir class ALBSolarGuard : public ::vos::OGuard 72cdf0e10cSrcweir { 73cdf0e10cSrcweir public: ALBSolarGuard()74cdf0e10cSrcweir inline ALBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {} 75cdf0e10cSrcweir }; 76cdf0e10cSrcweir 77cdf0e10cSrcweir // class AccessibleListBoxEntry ----------------------------------------------------- 78cdf0e10cSrcweir 79cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 80cdf0e10cSrcweir using namespace ::com::sun::star::uno; 81cdf0e10cSrcweir using namespace ::com::sun::star::lang; 82cdf0e10cSrcweir using namespace ::com::sun::star; 8321075d77SSteve Yin using namespace ::comphelper; DBG_NAME(AccessibleListBoxEntry)84cdf0e10cSrcweir DBG_NAME(AccessibleListBoxEntry) 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ----------------------------------------------------------------------------- 87cdf0e10cSrcweir // Ctor() and Dtor() 88cdf0e10cSrcweir // ----------------------------------------------------------------------------- 89cdf0e10cSrcweir AccessibleListBoxEntry::AccessibleListBoxEntry( SvTreeListBox& _rListBox, 90cdf0e10cSrcweir SvLBoxEntry* _pEntry, 91cdf0e10cSrcweir const Reference< XAccessible >& _xParent ) : 92cdf0e10cSrcweir 93cdf0e10cSrcweir AccessibleListBoxEntry_BASE ( m_aMutex ), 94cdf0e10cSrcweir ListBoxAccessibleBase( _rListBox ), 95cdf0e10cSrcweir 9621075d77SSteve Yin m_pSvLBoxEntry ( _pEntry ), 97cdf0e10cSrcweir m_nClientId ( 0 ), 98cdf0e10cSrcweir m_aParent ( _xParent ) 99cdf0e10cSrcweir 100cdf0e10cSrcweir { 101cdf0e10cSrcweir DBG_CTOR( AccessibleListBoxEntry, NULL ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir _rListBox.FillEntryPath( _pEntry, m_aEntryPath ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir // ----------------------------------------------------------------------------- ~AccessibleListBoxEntry()106cdf0e10cSrcweir AccessibleListBoxEntry::~AccessibleListBoxEntry() 107cdf0e10cSrcweir { 108cdf0e10cSrcweir DBG_DTOR( AccessibleListBoxEntry, NULL ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir if ( IsAlive_Impl() ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir // increment ref count to prevent double call of Dtor 113cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 114cdf0e10cSrcweir dispose(); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir } 11721075d77SSteve Yin NotifyAccessibleEvent(sal_Int16 _nEventId,const::com::sun::star::uno::Any & _aOldValue,const::com::sun::star::uno::Any & _aNewValue)11821075d77SSteve Yin void AccessibleListBoxEntry::NotifyAccessibleEvent( sal_Int16 _nEventId, 11921075d77SSteve Yin const ::com::sun::star::uno::Any& _aOldValue, 12021075d77SSteve Yin const ::com::sun::star::uno::Any& _aNewValue ) 12121075d77SSteve Yin { 12221075d77SSteve Yin Reference< uno::XInterface > xSource( *this ); 12321075d77SSteve Yin AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue ); 12421075d77SSteve Yin 12521075d77SSteve Yin if (m_nClientId) 12621075d77SSteve Yin comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj ); 12721075d77SSteve Yin } 12821075d77SSteve Yin 129cdf0e10cSrcweir 130cdf0e10cSrcweir // ----------------------------------------------------------------------------- GetBoundingBox_Impl() const131cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBox_Impl() const 132cdf0e10cSrcweir { 133cdf0e10cSrcweir Rectangle aRect; 134cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 135cdf0e10cSrcweir if ( pEntry ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir aRect = getListBox()->GetBoundingRect( pEntry ); 138cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetParent( pEntry ); 139cdf0e10cSrcweir if ( pParent ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir // position relative to parent entry 142cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft(); 143cdf0e10cSrcweir aTopLeft -= getListBox()->GetBoundingRect( pParent ).TopLeft(); 144cdf0e10cSrcweir aRect = Rectangle( aTopLeft, aRect.GetSize() ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir return aRect; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir // ----------------------------------------------------------------------------- GetBoundingBoxOnScreen_Impl() const151cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen_Impl() const 152cdf0e10cSrcweir { 153cdf0e10cSrcweir Rectangle aRect; 154cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 155cdf0e10cSrcweir if ( pEntry ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir aRect = getListBox()->GetBoundingRect( pEntry ); 158cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft(); 159cdf0e10cSrcweir aTopLeft += getListBox()->GetWindowExtentsRelative( NULL ).TopLeft(); 160cdf0e10cSrcweir aRect = Rectangle( aTopLeft, aRect.GetSize() ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir return aRect; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir // ----------------------------------------------------------------------------- IsAlive_Impl() const166cdf0e10cSrcweir sal_Bool AccessibleListBoxEntry::IsAlive_Impl() const 167cdf0e10cSrcweir { 168cdf0e10cSrcweir return ( !rBHelper.bDisposed && !rBHelper.bInDispose && isAlive() ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir // ----------------------------------------------------------------------------- IsShowing_Impl() const171cdf0e10cSrcweir sal_Bool AccessibleListBoxEntry::IsShowing_Impl() const 172cdf0e10cSrcweir { 173cdf0e10cSrcweir Reference< XAccessible > xParent = implGetParentAccessible( ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Bool bShowing = sal_False; 176cdf0e10cSrcweir Reference< XAccessibleContext > m_xParentContext = 177cdf0e10cSrcweir xParent.is() ? xParent->getAccessibleContext() : Reference< XAccessibleContext >(); 178cdf0e10cSrcweir if( m_xParentContext.is() ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY ); 181cdf0e10cSrcweir if( xParentComp.is() ) 182cdf0e10cSrcweir bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) ); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir return bShowing; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir // ----------------------------------------------------------------------------- GetBoundingBox()188cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBox() throw ( lang::DisposedException ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 191cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir EnsureIsAlive(); 194cdf0e10cSrcweir return GetBoundingBox_Impl(); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir // ----------------------------------------------------------------------------- GetBoundingBoxOnScreen()197cdf0e10cSrcweir Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 200cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir EnsureIsAlive(); 203cdf0e10cSrcweir return GetBoundingBoxOnScreen_Impl(); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir // ----------------------------------------------------------------------------- EnsureIsAlive() const206cdf0e10cSrcweir void AccessibleListBoxEntry::EnsureIsAlive() const throw ( lang::DisposedException ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir if ( !IsAlive_Impl() ) 209cdf0e10cSrcweir throw lang::DisposedException(); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir // ----------------------------------------------------------------------------- implGetText()212cdf0e10cSrcweir ::rtl::OUString AccessibleListBoxEntry::implGetText() 213cdf0e10cSrcweir { 214cdf0e10cSrcweir ::rtl::OUString sRet; 215cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 216cdf0e10cSrcweir if ( pEntry ) 21721075d77SSteve Yin sRet = getListBox()->SearchEntryTextWithHeadTitle( pEntry ); 218cdf0e10cSrcweir return sRet; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir // ----------------------------------------------------------------------------- implGetLocale()221cdf0e10cSrcweir Locale AccessibleListBoxEntry::implGetLocale() 222cdf0e10cSrcweir { 223cdf0e10cSrcweir Locale aLocale; 224cdf0e10cSrcweir aLocale = Application::GetSettings().GetUILocale(); 225cdf0e10cSrcweir 226cdf0e10cSrcweir return aLocale; 227cdf0e10cSrcweir } implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)228cdf0e10cSrcweir void AccessibleListBoxEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir nStartIndex = 0; 231cdf0e10cSrcweir nEndIndex = 0; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir // ----------------------------------------------------------------------------- 234cdf0e10cSrcweir // XTypeProvider 235cdf0e10cSrcweir // ----------------------------------------------------------------------------- 236cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationId()237cdf0e10cSrcweir Sequence< sal_Int8 > AccessibleListBoxEntry::getImplementationId() throw (RuntimeException) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir static ::cppu::OImplementationId* pId = NULL; 240cdf0e10cSrcweir 241cdf0e10cSrcweir if ( !pId ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); 244cdf0e10cSrcweir 245cdf0e10cSrcweir if ( !pId ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir static ::cppu::OImplementationId aId; 248cdf0e10cSrcweir pId = &aId; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir return pId->getImplementationId(); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir // ----------------------------------------------------------------------------- 255cdf0e10cSrcweir // XComponent/ListBoxAccessibleBase 256cdf0e10cSrcweir // ----------------------------------------------------------------------------- dispose()257cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::dispose() throw ( uno::RuntimeException ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir AccessibleListBoxEntry_BASE::dispose(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // ----------------------------------------------------------------------------- 263cdf0e10cSrcweir // XComponent 264cdf0e10cSrcweir // ----------------------------------------------------------------------------- disposing()265cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::disposing() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir ALBSolarGuard(); 268cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir Reference< XAccessible > xKeepAlive( this ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir // Send a disposing to all listeners. 273cdf0e10cSrcweir if ( m_nClientId ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::TClientId nId = m_nClientId; 276cdf0e10cSrcweir m_nClientId = 0; 277cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir // clean up 281cdf0e10cSrcweir { 282cdf0e10cSrcweir 283cdf0e10cSrcweir ListBoxAccessibleBase::disposing(); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir m_aParent = WeakReference< XAccessible >(); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir // ----------------------------------------------------------------------------- 288cdf0e10cSrcweir // XServiceInfo 289cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName()290cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getImplementationName() throw(RuntimeException) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir return getImplementationName_Static(); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSupportedServiceNames()295cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL AccessibleListBoxEntry::getSupportedServiceNames() throw(RuntimeException) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir return getSupportedServiceNames_Static(); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir // ----------------------------------------------------------------------------- supportsService(const::rtl::OUString & _rServiceName)300cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 303cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 304cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 305cdf0e10cSrcweir for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 306cdf0e10cSrcweir ; 307cdf0e10cSrcweir 308cdf0e10cSrcweir return pSupported != pEnd; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir // ----------------------------------------------------------------------------- 311cdf0e10cSrcweir // XServiceInfo - static methods 312cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSupportedServiceNames_Static(void)313cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleListBoxEntry::getSupportedServiceNames_Static(void) throw( RuntimeException ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(3); 316cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 317cdf0e10cSrcweir aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 318cdf0e10cSrcweir aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleTreeListBoxEntry") ); 319cdf0e10cSrcweir return aSupported; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName_Static(void)322cdf0e10cSrcweir ::rtl::OUString AccessibleListBoxEntry::getImplementationName_Static(void) throw( RuntimeException ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleTreeListBoxEntry") ); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir // ----------------------------------------------------------------------------- 327cdf0e10cSrcweir // XAccessible 328cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleContext()329cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleListBoxEntry::getAccessibleContext( ) throw (RuntimeException) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir EnsureIsAlive(); 332cdf0e10cSrcweir return this; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir // ----------------------------------------------------------------------------- 335cdf0e10cSrcweir // XAccessibleContext 336cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChildCount()337cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount( ) throw (RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 340cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 341cdf0e10cSrcweir 342cdf0e10cSrcweir EnsureIsAlive(); 343cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 344cdf0e10cSrcweir sal_Int32 nCount = 0; 345cdf0e10cSrcweir if ( pEntry ) 346cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pEntry ); 347cdf0e10cSrcweir 348cdf0e10cSrcweir return nCount; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChild(sal_Int32 i)351cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 354cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 355cdf0e10cSrcweir EnsureIsAlive(); 356cdf0e10cSrcweir 35721075d77SSteve Yin // SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 35821075d77SSteve Yin // SvLBoxEntry* pEntry = pParent ? getListBox()->GetEntry( pParent, i ) : NULL; 35921075d77SSteve Yin SvLBoxEntry* pEntry =GetRealChild(i); 360cdf0e10cSrcweir if ( !pEntry ) 361cdf0e10cSrcweir throw IndexOutOfBoundsException(); 362cdf0e10cSrcweir 363cdf0e10cSrcweir return new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir // ----------------------------------------------------------------------------- implGetParentAccessible() const367cdf0e10cSrcweir Reference< XAccessible > AccessibleListBoxEntry::implGetParentAccessible( ) const 368cdf0e10cSrcweir { 369cdf0e10cSrcweir Reference< XAccessible > xParent = (Reference< XAccessible >)m_aParent; 370cdf0e10cSrcweir if ( !xParent.is() ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir DBG_ASSERT( m_aEntryPath.size(), "AccessibleListBoxEntry::getAccessibleParent: invalid path!" ); 373cdf0e10cSrcweir if ( 1 == m_aEntryPath.size() ) 374cdf0e10cSrcweir { // we're a top level entry 375cdf0e10cSrcweir // -> our parent is the tree listbox itself 376cdf0e10cSrcweir if ( getListBox() ) 377cdf0e10cSrcweir xParent = getListBox()->GetAccessible( ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir else 380cdf0e10cSrcweir { // we have a entry as parent -> get it's accessible 381cdf0e10cSrcweir 382cdf0e10cSrcweir // shorten our access path by one 383cdf0e10cSrcweir ::std::deque< sal_Int32 > aParentPath( m_aEntryPath ); 384cdf0e10cSrcweir aParentPath.pop_back(); 385cdf0e10cSrcweir 386cdf0e10cSrcweir // get the entry for this shortened access path 387cdf0e10cSrcweir SvLBoxEntry* pParentEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 388cdf0e10cSrcweir DBG_ASSERT( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" ); 389cdf0e10cSrcweir 39021075d77SSteve Yin if ( pParentEntry ) 39121075d77SSteve Yin pParentEntry = getListBox()->GetParent(pParentEntry); 392cdf0e10cSrcweir if ( pParentEntry ) 393cdf0e10cSrcweir xParent = new AccessibleListBoxEntry( *getListBox(), pParentEntry, NULL ); 394cdf0e10cSrcweir // note that we pass NULL here as parent-accessible: 395cdf0e10cSrcweir // this is allowed, as the AccessibleListBoxEntry class will create it's parent 396cdf0e10cSrcweir // when needed 397cdf0e10cSrcweir } 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir return xParent; 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleParent()404cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleParent( ) throw (RuntimeException) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 407cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 408cdf0e10cSrcweir EnsureIsAlive(); 409cdf0e10cSrcweir 410cdf0e10cSrcweir return implGetParentAccessible( ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleIndexInParent()413cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleIndexInParent( ) throw (RuntimeException) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 416cdf0e10cSrcweir 417cdf0e10cSrcweir DBG_ASSERT( !m_aEntryPath.empty(), "empty path" ); 418cdf0e10cSrcweir return m_aEntryPath.empty() ? -1 : m_aEntryPath.back(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir // ----------------------------------------------------------------------------- getRoleType()42121075d77SSteve Yin sal_Int32 SAL_CALL AccessibleListBoxEntry::getRoleType() 42221075d77SSteve Yin { 42321075d77SSteve Yin sal_Int32 nCase = 0; 42421075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntry(0); 42521075d77SSteve Yin if ( pEntry ) 42621075d77SSteve Yin { 42721075d77SSteve Yin if( pEntry->HasChildsOnDemand() || getListBox()->GetChildCount(pEntry) > 0 ) 42821075d77SSteve Yin { 42921075d77SSteve Yin nCase = 1; 43021075d77SSteve Yin return nCase; 43121075d77SSteve Yin } 43221075d77SSteve Yin } 43321075d77SSteve Yin 43421075d77SSteve Yin sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 43521075d77SSteve Yin if( !(getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN) ) 43621075d77SSteve Yin { 43721075d77SSteve Yin if( bHasButtons ) 43821075d77SSteve Yin nCase = 1; 43921075d77SSteve Yin } 44021075d77SSteve Yin else 44121075d77SSteve Yin { 44221075d77SSteve Yin if( bHasButtons ) 44321075d77SSteve Yin nCase = 2; 44421075d77SSteve Yin else 44521075d77SSteve Yin nCase = 3; 44621075d77SSteve Yin } 44721075d77SSteve Yin return nCase; 44821075d77SSteve Yin } getAccessibleRole()449cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleListBoxEntry::getAccessibleRole( ) throw (RuntimeException) 450cdf0e10cSrcweir { 45121075d77SSteve Yin SvTreeListBox* pBox = getListBox(); 45221075d77SSteve Yin if(pBox) 45321075d77SSteve Yin { 45421075d77SSteve Yin short nType = pBox->GetAllEntriesAccessibleRoleType(); 45521075d77SSteve Yin if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_TREE) 45621075d77SSteve Yin return AccessibleRole::TREE_ITEM; 45721075d77SSteve Yin else if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_LIST) 45821075d77SSteve Yin return AccessibleRole::LIST_ITEM; 45921075d77SSteve Yin } 46021075d77SSteve Yin 46121075d77SSteve Yin sal_uInt16 treeFlag = pBox->GetTreeFlags(); 46221075d77SSteve Yin if(treeFlag & TREEFLAG_CHKBTN ) 46321075d77SSteve Yin { 46421075d77SSteve Yin SvLBoxEntry* pEntry = pBox->GetEntryFromPath( m_aEntryPath ); 46521075d77SSteve Yin SvButtonState eState = pBox->GetCheckButtonState( pEntry ); 46621075d77SSteve Yin switch( eState ) 46721075d77SSteve Yin { 46821075d77SSteve Yin case SV_BUTTON_CHECKED: 46921075d77SSteve Yin case SV_BUTTON_UNCHECKED: 47021075d77SSteve Yin return AccessibleRole::CHECK_BOX; 47121075d77SSteve Yin case SV_BUTTON_TRISTATE: 47221075d77SSteve Yin default: 47321075d77SSteve Yin return AccessibleRole::LABEL; 47421075d77SSteve Yin } 47521075d77SSteve Yin } 47621075d77SSteve Yin else 47721075d77SSteve Yin { 47821075d77SSteve Yin 47921075d77SSteve Yin if(getRoleType() == 0) 48021075d77SSteve Yin return AccessibleRole::LIST_ITEM; 48121075d77SSteve Yin else 48221075d77SSteve Yin //o is: return AccessibleRole::LABEL; 48321075d77SSteve Yin return AccessibleRole::TREE_ITEM; 48421075d77SSteve Yin } 485cdf0e10cSrcweir } 486cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleDescription()487cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleDescription( ) throw (RuntimeException) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir // no description for every item 49021075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 49121075d77SSteve Yin if( getAccessibleRole() == AccessibleRole::TREE_ITEM ) 49221075d77SSteve Yin { 49321075d77SSteve Yin return getListBox()->GetEntryLongDescription( pEntry ); 49421075d77SSteve Yin } 495*c34b68abSJohn Bampton //want to cout the real column number in the list box. 49621075d77SSteve Yin sal_uInt16 iRealItemCount = 0; 49721075d77SSteve Yin sal_uInt16 iCount = 0; 49821075d77SSteve Yin sal_uInt16 iTotleItemCount = pEntry->ItemCount(); 49921075d77SSteve Yin SvLBoxItem* pItem; 50021075d77SSteve Yin while( iCount < iTotleItemCount ) 50121075d77SSteve Yin { 50221075d77SSteve Yin pItem = pEntry->GetItem( iCount ); 50321075d77SSteve Yin if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && 50421075d77SSteve Yin static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 ) 50521075d77SSteve Yin { 50621075d77SSteve Yin iRealItemCount++; 50721075d77SSteve Yin } 50821075d77SSteve Yin iCount++; 50921075d77SSteve Yin } 51021075d77SSteve Yin if(iRealItemCount<=1 ) 51121075d77SSteve Yin { 51221075d77SSteve Yin return ::rtl::OUString(); 51321075d77SSteve Yin } 51421075d77SSteve Yin else 51521075d77SSteve Yin { 51621075d77SSteve Yin return getListBox()->SearchEntryTextWithHeadTitle( pEntry ); 51721075d77SSteve Yin } 51821075d77SSteve Yin 519cdf0e10cSrcweir } 520cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleName()521cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleName( ) throw (RuntimeException) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 524cdf0e10cSrcweir 525cdf0e10cSrcweir EnsureIsAlive(); 52621075d77SSteve Yin 52721075d77SSteve Yin ::rtl::OUString sRet; 52821075d77SSteve Yin sRet = implGetText(); 52921075d77SSteve Yin 53021075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 53121075d77SSteve Yin 53221075d77SSteve Yin String altText = getListBox()->GetEntryAltText( pEntry ); 53321075d77SSteve Yin if( altText.Len() > 0 ) 53421075d77SSteve Yin { 53521075d77SSteve Yin sRet += ::rtl::OUString(' '); 53621075d77SSteve Yin sRet += altText; 53721075d77SSteve Yin } 53821075d77SSteve Yin 53921075d77SSteve Yin // IA2 CWS. Removed for now - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this 54021075d77SSteve Yin // if ( pEntry && pEntry->IsMarked()) 54121075d77SSteve Yin // sRet = sRet + ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_LISTENTRY_SELCTED_STATE)); 54221075d77SSteve Yin 54321075d77SSteve Yin return sRet; 544cdf0e10cSrcweir } 545cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleRelationSet()546cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleListBoxEntry::getAccessibleRelationSet( ) throw (RuntimeException) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir Reference< XAccessibleRelationSet > xRelSet; 549cdf0e10cSrcweir Reference< XAccessible > xParent; 550cdf0e10cSrcweir if ( m_aEntryPath.size() > 1 ) // not a root entry 551cdf0e10cSrcweir xParent = implGetParentAccessible(); 552cdf0e10cSrcweir if ( xParent.is() ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 555cdf0e10cSrcweir Sequence< Reference< XInterface > > aSequence(1); 556cdf0e10cSrcweir aSequence[0] = xParent; 557cdf0e10cSrcweir pRelationSetHelper->AddRelation( 558cdf0e10cSrcweir AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF, aSequence ) ); 559cdf0e10cSrcweir xRelSet = pRelationSetHelper; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir return xRelSet; 562cdf0e10cSrcweir } 563cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleStateSet()564cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet( ) throw (RuntimeException) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 567cdf0e10cSrcweir 568cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 569cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = pStateSetHelper; 570cdf0e10cSrcweir 571cdf0e10cSrcweir if ( IsAlive_Impl() ) 572cdf0e10cSrcweir { 57321075d77SSteve Yin switch(getAccessibleRole()) 57421075d77SSteve Yin { 57521075d77SSteve Yin case AccessibleRole::LABEL: 57621075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 57721075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 57821075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 57921075d77SSteve Yin if ( getListBox()->IsInplaceEditingEnabled() ) 58021075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::EDITABLE ); 58121075d77SSteve Yin if ( IsShowing_Impl() ) 58221075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 58321075d77SSteve Yin break; 58421075d77SSteve Yin case AccessibleRole::CHECK_BOX: 58521075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 58621075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 58721075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 58821075d77SSteve Yin if ( IsShowing_Impl() ) 58921075d77SSteve Yin pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 59021075d77SSteve Yin break; 59121075d77SSteve Yin } 592cdf0e10cSrcweir getListBox()->FillAccessibleEntryStateSet( 593cdf0e10cSrcweir getListBox()->GetEntryFromPath( m_aEntryPath ), *pStateSetHelper ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir else 596cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 597cdf0e10cSrcweir 598cdf0e10cSrcweir return xStateSet; 599cdf0e10cSrcweir } 600cdf0e10cSrcweir // ----------------------------------------------------------------------------- getLocale()601cdf0e10cSrcweir Locale SAL_CALL AccessibleListBoxEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 604cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 605cdf0e10cSrcweir 606cdf0e10cSrcweir return implGetLocale(); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir // ----------------------------------------------------------------------------- 609cdf0e10cSrcweir // XAccessibleComponent 610cdf0e10cSrcweir // ----------------------------------------------------------------------------- containsPoint(const awt::Point & rPoint)611cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleAtPoint(const awt::Point & _aPoint)616cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 619cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 620cdf0e10cSrcweir 621cdf0e10cSrcweir EnsureIsAlive(); 622cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( VCLPoint( _aPoint ) ); 623cdf0e10cSrcweir if ( !pEntry ) 624cdf0e10cSrcweir throw RuntimeException(); 625cdf0e10cSrcweir 626cdf0e10cSrcweir Reference< XAccessible > xAcc; 627cdf0e10cSrcweir AccessibleListBoxEntry* pAccEntry = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 628cdf0e10cSrcweir Rectangle aRect = pAccEntry->GetBoundingBox_Impl(); 629cdf0e10cSrcweir if ( aRect.IsInside( VCLPoint( _aPoint ) ) ) 630cdf0e10cSrcweir xAcc = pAccEntry; 631cdf0e10cSrcweir return xAcc; 632cdf0e10cSrcweir } 633cdf0e10cSrcweir // ----------------------------------------------------------------------------- getBounds()634cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds( ) throw (RuntimeException) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir return AWTRectangle( GetBoundingBox() ); 637cdf0e10cSrcweir } 638cdf0e10cSrcweir // ----------------------------------------------------------------------------- getLocation()639cdf0e10cSrcweir awt::Point SAL_CALL AccessibleListBoxEntry::getLocation( ) throw (RuntimeException) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir return AWTPoint( GetBoundingBox().TopLeft() ); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir // ----------------------------------------------------------------------------- getLocationOnScreen()644cdf0e10cSrcweir awt::Point SAL_CALL AccessibleListBoxEntry::getLocationOnScreen( ) throw (RuntimeException) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSize()649cdf0e10cSrcweir awt::Size SAL_CALL AccessibleListBoxEntry::getSize( ) throw (RuntimeException) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir return AWTSize( GetBoundingBox().GetSize() ); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir // ----------------------------------------------------------------------------- grabFocus()654cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::grabFocus( ) throw (RuntimeException) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir // do nothing, because no focus for each item 657cdf0e10cSrcweir } 658cdf0e10cSrcweir // ----------------------------------------------------------------------------- getForeground()659cdf0e10cSrcweir sal_Int32 AccessibleListBoxEntry::getForeground( ) throw (RuntimeException) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 662cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 663cdf0e10cSrcweir 664cdf0e10cSrcweir sal_Int32 nColor = 0; 665cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 666cdf0e10cSrcweir if ( xParent.is() ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 669cdf0e10cSrcweir if ( xParentComp.is() ) 670cdf0e10cSrcweir nColor = xParentComp->getForeground(); 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir return nColor; 674cdf0e10cSrcweir } 675cdf0e10cSrcweir // ----------------------------------------------------------------------------- getBackground()676cdf0e10cSrcweir sal_Int32 AccessibleListBoxEntry::getBackground( ) throw (RuntimeException) 677cdf0e10cSrcweir { 678cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 679cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 680cdf0e10cSrcweir 681cdf0e10cSrcweir sal_Int32 nColor = 0; 682cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 683cdf0e10cSrcweir if ( xParent.is() ) 684cdf0e10cSrcweir { 685cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 686cdf0e10cSrcweir if ( xParentComp.is() ) 687cdf0e10cSrcweir nColor = xParentComp->getBackground(); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir 690cdf0e10cSrcweir return nColor; 691cdf0e10cSrcweir } 692cdf0e10cSrcweir // ----------------------------------------------------------------------------- 693cdf0e10cSrcweir // XAccessibleText 694cdf0e10cSrcweir // ----------------------------------------------------------------------------- 695cdf0e10cSrcweir // ----------------------------------------------------------------------------- getCharacterBounds(sal_Int32 nIndex)696cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 699cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 700cdf0e10cSrcweir 701cdf0e10cSrcweir EnsureIsAlive(); 702cdf0e10cSrcweir 703cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, implGetText().getLength() ) ) 704cdf0e10cSrcweir throw IndexOutOfBoundsException(); 705cdf0e10cSrcweir 706cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 707cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 708cdf0e10cSrcweir if ( pEntry ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir ::vcl::ControlLayoutData aLayoutData; 711cdf0e10cSrcweir Rectangle aItemRect = GetBoundingBox(); 712cdf0e10cSrcweir getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 713cdf0e10cSrcweir Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex ); 714cdf0e10cSrcweir aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 715cdf0e10cSrcweir aBounds = AWTRectangle( aCharRect ); 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir return aBounds; 719cdf0e10cSrcweir } 720cdf0e10cSrcweir // ----------------------------------------------------------------------------- getIndexAtPoint(const awt::Point & aPoint)721cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 724cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 725cdf0e10cSrcweir EnsureIsAlive(); 72621075d77SSteve Yin if(aPoint.X==0 && aPoint.Y==0) return 0; 727cdf0e10cSrcweir 728cdf0e10cSrcweir sal_Int32 nIndex = -1; 729cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 730cdf0e10cSrcweir if ( pEntry ) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir ::vcl::ControlLayoutData aLayoutData; 733cdf0e10cSrcweir Rectangle aItemRect = GetBoundingBox(); 734cdf0e10cSrcweir getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 735cdf0e10cSrcweir Point aPnt( VCLPoint( aPoint ) ); 736cdf0e10cSrcweir aPnt += aItemRect.TopLeft(); 737cdf0e10cSrcweir nIndex = aLayoutData.GetIndexForPoint( aPnt ); 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir return nIndex; 741cdf0e10cSrcweir } 742cdf0e10cSrcweir // ----------------------------------------------------------------------------- copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)743cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 746cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 747cdf0e10cSrcweir EnsureIsAlive(); 748cdf0e10cSrcweir 749cdf0e10cSrcweir String sText = getText(); 750cdf0e10cSrcweir if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex ) 751cdf0e10cSrcweir || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) ) 752cdf0e10cSrcweir throw IndexOutOfBoundsException(); 753cdf0e10cSrcweir 754cdf0e10cSrcweir sal_Int32 nLen = nEndIndex - nStartIndex + 1; 755cdf0e10cSrcweir ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), getListBox() ); 756cdf0e10cSrcweir 757cdf0e10cSrcweir return sal_True; 758cdf0e10cSrcweir } 759cdf0e10cSrcweir // ----------------------------------------------------------------------------- 760cdf0e10cSrcweir // XAccessibleEventBroadcaster 761cdf0e10cSrcweir // ----------------------------------------------------------------------------- addEventListener(const Reference<XAccessibleEventListener> & xListener)762cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir if (xListener.is()) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 767cdf0e10cSrcweir if (!m_nClientId) 768cdf0e10cSrcweir m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); 769cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir } 772cdf0e10cSrcweir // ----------------------------------------------------------------------------- removeEventListener(const Reference<XAccessibleEventListener> & xListener)773cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir if (xListener.is()) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 778cdf0e10cSrcweir 779cdf0e10cSrcweir sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); 780cdf0e10cSrcweir if ( !nListenerCount ) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir // no listeners anymore 783cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 784cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 785cdf0e10cSrcweir // NotifyAccessibleEvent, again 786cdf0e10cSrcweir sal_Int32 nId = m_nClientId; 787cdf0e10cSrcweir m_nClientId = 0; 788cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClient( nId ); 789cdf0e10cSrcweir 790cdf0e10cSrcweir } 791cdf0e10cSrcweir } 792cdf0e10cSrcweir } 793cdf0e10cSrcweir // ----------------------------------------------------------------------------- 794cdf0e10cSrcweir // XAccessibleAction 795cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleActionCount()796cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleActionCount( ) throw (RuntimeException) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 799cdf0e10cSrcweir 800cdf0e10cSrcweir // three actions supported 80121075d77SSteve Yin SvTreeListBox* pBox = getListBox(); 80221075d77SSteve Yin sal_uInt16 treeFlag = pBox->GetTreeFlags(); 80321075d77SSteve Yin sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 80421075d77SSteve Yin if( (treeFlag & TREEFLAG_CHKBTN) && !bHasButtons) 80521075d77SSteve Yin { 80621075d77SSteve Yin sal_Int16 role = getAccessibleRole(); 80721075d77SSteve Yin if ( role == AccessibleRole::CHECK_BOX ) 80821075d77SSteve Yin return 2; 80921075d77SSteve Yin else if ( role == AccessibleRole::LABEL ) 81021075d77SSteve Yin return 0; 81121075d77SSteve Yin } 81221075d77SSteve Yin else 81321075d77SSteve Yin return ACCESSIBLE_ACTION_COUNT; 81421075d77SSteve Yin return 0; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir // ----------------------------------------------------------------------------- doAccessibleAction(sal_Int32 nIndex)817cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 818cdf0e10cSrcweir { 819cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 820cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 821cdf0e10cSrcweir 822cdf0e10cSrcweir sal_Bool bRet = sal_False; 823cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 824cdf0e10cSrcweir EnsureIsAlive(); 82521075d77SSteve Yin sal_uInt16 treeFlag = getListBox()->GetTreeFlags(); 82621075d77SSteve Yin if( nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN) ) 827cdf0e10cSrcweir { 82821075d77SSteve Yin if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 82921075d77SSteve Yin { 83021075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 83121075d77SSteve Yin SvButtonState state = getListBox()->GetCheckButtonState( pEntry ); 83221075d77SSteve Yin if ( state == SV_BUTTON_CHECKED ) 83321075d77SSteve Yin getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BMP_UNCHECKED); 83421075d77SSteve Yin else if (state == SV_BMP_UNCHECKED) 83521075d77SSteve Yin getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BUTTON_CHECKED); 83621075d77SSteve Yin } 83721075d77SSteve Yin }else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN) ) || (nIndex == 0) ) 83821075d77SSteve Yin { 83921075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 84021075d77SSteve Yin if ( pEntry ) 84121075d77SSteve Yin { 84221075d77SSteve Yin if ( getListBox()->IsExpanded( pEntry ) ) 84321075d77SSteve Yin getListBox()->Collapse( pEntry ); 84421075d77SSteve Yin else 84521075d77SSteve Yin getListBox()->Expand( pEntry ); 84621075d77SSteve Yin bRet = sal_True; 84721075d77SSteve Yin } 848cdf0e10cSrcweir } 849cdf0e10cSrcweir return bRet; 850cdf0e10cSrcweir } 851cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleActionDescription(sal_Int32 nIndex)852cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 855cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 856cdf0e10cSrcweir 857cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 858cdf0e10cSrcweir EnsureIsAlive(); 859cdf0e10cSrcweir 860cdf0e10cSrcweir static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "toggleExpand" ) ); 86121075d77SSteve Yin static const ::rtl::OUString sActionDesc1( RTL_CONSTASCII_USTRINGPARAM( "Check" ) ); 86221075d77SSteve Yin static const ::rtl::OUString sActionDesc2( RTL_CONSTASCII_USTRINGPARAM( "UnCheck" ) ); 86321075d77SSteve Yin // sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 86421075d77SSteve Yin SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 86521075d77SSteve Yin SvButtonState state = getListBox()->GetCheckButtonState( pEntry ); 86621075d77SSteve Yin sal_uInt16 treeFlag = getListBox()->GetTreeFlags(); 86721075d77SSteve Yin if(nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN)) 86821075d77SSteve Yin { 86921075d77SSteve Yin if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 87021075d77SSteve Yin { 87121075d77SSteve Yin if ( state == SV_BUTTON_CHECKED ) 87221075d77SSteve Yin return sActionDesc2; 87321075d77SSteve Yin else if (state == SV_BMP_UNCHECKED) 87421075d77SSteve Yin return sActionDesc1; 87521075d77SSteve Yin } 87621075d77SSteve Yin else 87721075d77SSteve Yin { 87821075d77SSteve Yin //Sometimes, a List or Tree may have both checkbox and label at the same time 87921075d77SSteve Yin return ::rtl::OUString(); 88021075d77SSteve Yin } 88121075d77SSteve Yin }else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN)) || nIndex == 0 ) 88221075d77SSteve Yin { 88321075d77SSteve Yin if( pEntry->HasChilds() || pEntry->HasChildsOnDemand() ) 88421075d77SSteve Yin return getListBox()->IsExpanded( pEntry ) ? \ 88521075d77SSteve Yin ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_COLLAPSE)) : 88621075d77SSteve Yin ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_EXPAND)); 88721075d77SSteve Yin return ::rtl::OUString(); 88821075d77SSteve Yin 88921075d77SSteve Yin } 89021075d77SSteve Yin throw IndexOutOfBoundsException(); 891cdf0e10cSrcweir } 892cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleActionKeyBinding(sal_Int32 nIndex)893cdf0e10cSrcweir Reference< XAccessibleKeyBinding > AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 894cdf0e10cSrcweir { 895cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 896cdf0e10cSrcweir 897cdf0e10cSrcweir Reference< XAccessibleKeyBinding > xRet; 898cdf0e10cSrcweir checkActionIndex_Impl( nIndex ); 899cdf0e10cSrcweir // ... which key? 900cdf0e10cSrcweir return xRet; 901cdf0e10cSrcweir } 902cdf0e10cSrcweir // ----------------------------------------------------------------------------- 903cdf0e10cSrcweir // XAccessibleSelection 904cdf0e10cSrcweir // ----------------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)905cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 906cdf0e10cSrcweir { 907cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 908cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 909cdf0e10cSrcweir 910cdf0e10cSrcweir EnsureIsAlive(); 9113ea0c3d5SHerbert Dürr SvLBoxEntry* pEntry = GetRealChild(nChildIndex); 912cdf0e10cSrcweir if ( !pEntry ) 913cdf0e10cSrcweir throw IndexOutOfBoundsException(); 914cdf0e10cSrcweir 915cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir // ----------------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)918cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 921cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 922cdf0e10cSrcweir 923cdf0e10cSrcweir EnsureIsAlive(); 924cdf0e10cSrcweir 925cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 926cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex ); 927cdf0e10cSrcweir if ( !pEntry ) 928cdf0e10cSrcweir throw IndexOutOfBoundsException(); 929cdf0e10cSrcweir 930cdf0e10cSrcweir return getListBox()->IsSelected( pEntry ); 931cdf0e10cSrcweir } 932cdf0e10cSrcweir // ----------------------------------------------------------------------------- clearAccessibleSelection()933cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::clearAccessibleSelection( ) throw (RuntimeException) 934cdf0e10cSrcweir { 935cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 936cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 937cdf0e10cSrcweir 938cdf0e10cSrcweir EnsureIsAlive(); 939cdf0e10cSrcweir 940cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 941cdf0e10cSrcweir if ( !pParent ) 942cdf0e10cSrcweir throw RuntimeException(); 943cdf0e10cSrcweir sal_Int32 i, nCount = 0; 944cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 945cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 948cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 949cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 950cdf0e10cSrcweir } 951cdf0e10cSrcweir } 952cdf0e10cSrcweir // ----------------------------------------------------------------------------- selectAllAccessibleChildren()953cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::selectAllAccessibleChildren( ) throw (RuntimeException) 954cdf0e10cSrcweir { 955cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 956cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 957cdf0e10cSrcweir 958cdf0e10cSrcweir EnsureIsAlive(); 959cdf0e10cSrcweir 960cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 961cdf0e10cSrcweir if ( !pParent ) 962cdf0e10cSrcweir throw RuntimeException(); 963cdf0e10cSrcweir sal_Int32 i, nCount = 0; 964cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 965cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 966cdf0e10cSrcweir { 967cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 968cdf0e10cSrcweir if ( !getListBox()->IsSelected( pEntry ) ) 969cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 970cdf0e10cSrcweir } 971cdf0e10cSrcweir } 972cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSelectedAccessibleChildCount()973cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount( ) throw (RuntimeException) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 976cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 977cdf0e10cSrcweir 978cdf0e10cSrcweir EnsureIsAlive(); 979cdf0e10cSrcweir 980cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 981cdf0e10cSrcweir 982cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 983cdf0e10cSrcweir if ( !pParent ) 984cdf0e10cSrcweir throw RuntimeException(); 985cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 986cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 987cdf0e10cSrcweir { 988cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 989cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 990cdf0e10cSrcweir ++nSelCount; 991cdf0e10cSrcweir } 992cdf0e10cSrcweir 993cdf0e10cSrcweir return nSelCount; 994cdf0e10cSrcweir } 995cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)996cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 999cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1000cdf0e10cSrcweir 1001cdf0e10cSrcweir EnsureIsAlive(); 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 1004cdf0e10cSrcweir throw IndexOutOfBoundsException(); 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir Reference< XAccessible > xChild; 1007cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 1010cdf0e10cSrcweir if ( !pParent ) 1011cdf0e10cSrcweir throw RuntimeException(); 1012cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( pParent ); 1013cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 1016cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 1017cdf0e10cSrcweir ++nSelCount; 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 1022cdf0e10cSrcweir break; 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir return xChild; 1027cdf0e10cSrcweir } 1028cdf0e10cSrcweir // ----------------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)1029cdf0e10cSrcweir void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1032cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir EnsureIsAlive(); 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 1037cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nSelectedChildIndex ); 1038cdf0e10cSrcweir if ( !pEntry ) 1039cdf0e10cSrcweir throw IndexOutOfBoundsException(); 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 1042cdf0e10cSrcweir } getCaretPosition()1043cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException) 1044cdf0e10cSrcweir { 1045cdf0e10cSrcweir return -1; 1046cdf0e10cSrcweir } setCaretPosition(sal_Int32 nIndex)1047cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1050cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1051cdf0e10cSrcweir EnsureIsAlive(); 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 1054cdf0e10cSrcweir throw IndexOutOfBoundsException(); 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir return sal_False; 1057cdf0e10cSrcweir } getCharacter(sal_Int32 nIndex)1058cdf0e10cSrcweir sal_Unicode SAL_CALL AccessibleListBoxEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1059cdf0e10cSrcweir { 1060cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1061cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1062cdf0e10cSrcweir EnsureIsAlive(); 1063cdf0e10cSrcweir return OCommonAccessibleText::getCharacter( nIndex ); 1064cdf0e10cSrcweir } getCharacterAttributes(sal_Int32 nIndex,const::com::sun::star::uno::Sequence<::rtl::OUString> &)1065cdf0e10cSrcweir ::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) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1068cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1069cdf0e10cSrcweir EnsureIsAlive(); 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir ::rtl::OUString sText( implGetText() ); 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 1074cdf0e10cSrcweir throw IndexOutOfBoundsException(); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(); 1077cdf0e10cSrcweir } getCharacterCount()1078cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException) 1079cdf0e10cSrcweir { 1080cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1081cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1082cdf0e10cSrcweir EnsureIsAlive(); 1083cdf0e10cSrcweir return OCommonAccessibleText::getCharacterCount( ); 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir getSelectedText()1086cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException) 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1089cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1090cdf0e10cSrcweir EnsureIsAlive(); 1091cdf0e10cSrcweir return OCommonAccessibleText::getSelectedText( ); 1092cdf0e10cSrcweir } getSelectionStart()1093cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1096cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1097cdf0e10cSrcweir EnsureIsAlive(); 1098cdf0e10cSrcweir return OCommonAccessibleText::getSelectionStart( ); 1099cdf0e10cSrcweir } getSelectionEnd()1100cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException) 1101cdf0e10cSrcweir { 1102cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1103cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1104cdf0e10cSrcweir EnsureIsAlive(); 1105cdf0e10cSrcweir return OCommonAccessibleText::getSelectionEnd( ); 1106cdf0e10cSrcweir } setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)1107cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBoxEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1108cdf0e10cSrcweir { 1109cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1110cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1111cdf0e10cSrcweir EnsureIsAlive(); 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 1114cdf0e10cSrcweir throw IndexOutOfBoundsException(); 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir return sal_False; 1117cdf0e10cSrcweir } getText()1118cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getText( ) throw (::com::sun::star::uno::RuntimeException) 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1121cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1122cdf0e10cSrcweir EnsureIsAlive(); 1123cdf0e10cSrcweir return OCommonAccessibleText::getText( ); 1124cdf0e10cSrcweir } getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)1125cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1126cdf0e10cSrcweir { 1127cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1128cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1129cdf0e10cSrcweir EnsureIsAlive(); 1130cdf0e10cSrcweir return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ); 1131cdf0e10cSrcweir } getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)1132cdf0e10cSrcweir ::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) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1135cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1136cdf0e10cSrcweir EnsureIsAlive(); 1137cdf0e10cSrcweir return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType); 1138cdf0e10cSrcweir } getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)1139cdf0e10cSrcweir ::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) 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1142cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1143cdf0e10cSrcweir EnsureIsAlive(); 1144cdf0e10cSrcweir return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType); 1145cdf0e10cSrcweir } getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)1146cdf0e10cSrcweir ::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) 1147cdf0e10cSrcweir { 1148cdf0e10cSrcweir ALBSolarGuard aSolarGuard; 1149cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1150cdf0e10cSrcweir EnsureIsAlive(); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType); 1153cdf0e10cSrcweir } 115421075d77SSteve Yin // ----------------------------------------------------------------------------- 115521075d77SSteve Yin // XAccessibleValue 115621075d77SSteve Yin // ----------------------------------------------------------------------------- 115721075d77SSteve Yin getCurrentValue()115821075d77SSteve Yin Any AccessibleListBoxEntry::getCurrentValue( ) throw (RuntimeException) 115921075d77SSteve Yin { 116021075d77SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 116121075d77SSteve Yin Any aValue; 116221075d77SSteve Yin sal_Int32 level = ((sal_Int32) m_aEntryPath.size() - 1); 116321075d77SSteve Yin level = level < 0 ? 0: level; 116421075d77SSteve Yin aValue <<= level; 116521075d77SSteve Yin return aValue; 116621075d77SSteve Yin } 116721075d77SSteve Yin 116821075d77SSteve Yin // ----------------------------------------------------------------------------- 116921075d77SSteve Yin setCurrentValue(const Any & aNumber)117021075d77SSteve Yin sal_Bool AccessibleListBoxEntry::setCurrentValue( const Any& aNumber ) throw (RuntimeException) 117121075d77SSteve Yin { 117221075d77SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 117321075d77SSteve Yin 117421075d77SSteve Yin 117521075d77SSteve Yin sal_Bool bReturn = sal_False; 117621075d77SSteve Yin SvTreeListBox* pBox = getListBox(); 117721075d77SSteve Yin if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 117821075d77SSteve Yin { 117921075d77SSteve Yin SvLBoxEntry* pEntry = pBox->GetEntryFromPath( m_aEntryPath ); 118021075d77SSteve Yin if ( pEntry ) 118121075d77SSteve Yin { 11823e60c8baSPavel Janík sal_Int32 nValue(0), nValueMin(0), nValueMax(0); 118321075d77SSteve Yin aNumber >>= nValue; 118421075d77SSteve Yin getMinimumValue() >>= nValueMin; 118521075d77SSteve Yin getMaximumValue() >>= nValueMax; 118621075d77SSteve Yin 118721075d77SSteve Yin if ( nValue < nValueMin ) 118821075d77SSteve Yin nValue = nValueMin; 118921075d77SSteve Yin else if ( nValue > nValueMax ) 119021075d77SSteve Yin nValue = nValueMax; 119121075d77SSteve Yin 119221075d77SSteve Yin pBox->SetCheckButtonState(pEntry, (SvButtonState) nValue ); 119321075d77SSteve Yin bReturn = sal_True; 119421075d77SSteve Yin } 119521075d77SSteve Yin } 119621075d77SSteve Yin 119721075d77SSteve Yin return bReturn; 119821075d77SSteve Yin } 119921075d77SSteve Yin 120021075d77SSteve Yin // ----------------------------------------------------------------------------- 120121075d77SSteve Yin getMaximumValue()120221075d77SSteve Yin Any AccessibleListBoxEntry::getMaximumValue( ) throw (RuntimeException) 120321075d77SSteve Yin { 120421075d77SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 120521075d77SSteve Yin 120621075d77SSteve Yin Any aValue; 120721075d77SSteve Yin // SvTreeListBox* pBox = getListBox(); 120821075d77SSteve Yin switch(getAccessibleRole()) 120921075d77SSteve Yin { 121021075d77SSteve Yin case AccessibleRole::CHECK_BOX: 121121075d77SSteve Yin aValue <<= (sal_Int32)1; 121221075d77SSteve Yin break; 121321075d77SSteve Yin case AccessibleRole::LABEL: 121421075d77SSteve Yin default: 121521075d77SSteve Yin break; 121621075d77SSteve Yin } 121721075d77SSteve Yin 121821075d77SSteve Yin return aValue; 121921075d77SSteve Yin } 122021075d77SSteve Yin 122121075d77SSteve Yin // ----------------------------------------------------------------------------- 122221075d77SSteve Yin getMinimumValue()122321075d77SSteve Yin Any AccessibleListBoxEntry::getMinimumValue( ) throw (RuntimeException) 122421075d77SSteve Yin { 122521075d77SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 122621075d77SSteve Yin 122721075d77SSteve Yin Any aValue; 122821075d77SSteve Yin // SvTreeListBox* pBox = getListBox(); 122921075d77SSteve Yin switch(getAccessibleRole()) 123021075d77SSteve Yin { 123121075d77SSteve Yin case AccessibleRole::CHECK_BOX: 123221075d77SSteve Yin aValue <<= (sal_Int32)0; 123321075d77SSteve Yin break; 123421075d77SSteve Yin case AccessibleRole::LABEL: 123521075d77SSteve Yin default: 123621075d77SSteve Yin break; 123721075d77SSteve Yin } 123821075d77SSteve Yin 123921075d77SSteve Yin return aValue; 124021075d77SSteve Yin } 124121075d77SSteve Yin 124221075d77SSteve Yin // ----------------------------------------------------------------------------- 124321075d77SSteve Yin GetRealChild(sal_Int32 nIndex)124421075d77SSteve Yin SvLBoxEntry * AccessibleListBoxEntry::GetRealChild(sal_Int32 nIndex) 124521075d77SSteve Yin { 124621075d77SSteve Yin SvLBoxEntry* pEntry =NULL; 124721075d77SSteve Yin SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 124821075d77SSteve Yin if (pParent) 124921075d77SSteve Yin { 125021075d77SSteve Yin pEntry = getListBox()->GetEntry( pParent, nIndex ); 125121075d77SSteve Yin if ( !pEntry && getAccessibleChildCount() > 0 ) 125221075d77SSteve Yin { 125321075d77SSteve Yin getListBox()->RequestingChilds(pParent); 125421075d77SSteve Yin pEntry = getListBox()->GetEntry( pParent, nIndex ); 125521075d77SSteve Yin } 125621075d77SSteve Yin } 125721075d77SSteve Yin return pEntry; 125821075d77SSteve Yin } 1259cdf0e10cSrcweir //........................................................................ 1260cdf0e10cSrcweir }// namespace accessibility 1261cdf0e10cSrcweir //........................................................................ 1262cdf0e10cSrcweir 1263