1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "accessibility/extended/accessiblelistboxentry.hxx"
21 #include <svtools/treelistbox.hxx>
22 #include <svtools/stringtransfer.hxx>
23 #include <com/sun/star/awt/Point.hpp>
24 #include <com/sun/star/awt/Rectangle.hpp>
25 #include <com/sun/star/awt/Size.hpp>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
28 #include <com/sun/star/accessibility/AccessibleRole.hpp>
29 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30 #include <vcl/svapp.hxx>
31 #include <vcl/controllayout.hxx>
32 #include <toolkit/awt/vclxwindow.hxx>
33 #include <toolkit/helper/convert.hxx>
34 #include <unotools/accessiblestatesethelper.hxx>
35 #include <unotools/accessiblerelationsethelper.hxx>
36 #include <cppuhelper/supportsservice.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <comphelper/sequence.hxx>
39 #include <comphelper/accessibleeventnotifier.hxx>
40 #include <toolkit/helper/vclunohelper.hxx>
42 #define ACCESSIBLE_ACTION_COUNT 1
46 void checkActionIndex_Impl( sal_Int32 _nIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
)
48 if ( _nIndex
< 0 || _nIndex
>= ACCESSIBLE_ACTION_COUNT
)
50 throw ::com::sun::star::lang::IndexOutOfBoundsException();
54 //........................................................................
55 namespace accessibility
57 // class AccessibleListBoxEntry -----------------------------------------------------
59 using namespace ::com::sun::star::accessibility
;
60 using namespace ::com::sun::star::uno
;
61 using namespace ::com::sun::star::lang
;
62 using namespace ::com::sun::star
;
64 // -----------------------------------------------------------------------------
66 // -----------------------------------------------------------------------------
67 AccessibleListBoxEntry::AccessibleListBoxEntry( SvTreeListBox
& _rListBox
,
68 SvTreeListEntry
* _pEntry
,
69 const Reference
< XAccessible
>& _xParent
) :
71 AccessibleListBoxEntry_BASE ( m_aMutex
),
72 ListBoxAccessibleBase( _rListBox
),
75 m_aParent ( _xParent
)
78 _rListBox
.FillEntryPath( _pEntry
, m_aEntryPath
);
80 // -----------------------------------------------------------------------------
81 AccessibleListBoxEntry::~AccessibleListBoxEntry()
85 // increment ref count to prevent double call of Dtor
86 osl_atomic_increment( &m_refCount
);
91 // -----------------------------------------------------------------------------
92 Rectangle
AccessibleListBoxEntry::GetBoundingBox_Impl() const
95 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
98 aRect
= getListBox()->GetBoundingRect( pEntry
);
99 SvTreeListEntry
* pParent
= getListBox()->GetParent( pEntry
);
102 // position relative to parent entry
103 Point aTopLeft
= aRect
.TopLeft();
104 aTopLeft
-= getListBox()->GetBoundingRect( pParent
).TopLeft();
105 aRect
= Rectangle( aTopLeft
, aRect
.GetSize() );
111 // -----------------------------------------------------------------------------
112 Rectangle
AccessibleListBoxEntry::GetBoundingBoxOnScreen_Impl() const
115 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
118 aRect
= getListBox()->GetBoundingRect( pEntry
);
119 Point aTopLeft
= aRect
.TopLeft();
120 aTopLeft
+= getListBox()->GetWindowExtentsRelative( NULL
).TopLeft();
121 aRect
= Rectangle( aTopLeft
, aRect
.GetSize() );
126 // -----------------------------------------------------------------------------
127 sal_Bool
AccessibleListBoxEntry::IsAlive_Impl() const
129 return ( !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
&& isAlive() );
131 // -----------------------------------------------------------------------------
132 sal_Bool
AccessibleListBoxEntry::IsShowing_Impl() const
134 Reference
< XAccessible
> xParent
= implGetParentAccessible( );
136 sal_Bool bShowing
= sal_False
;
137 Reference
< XAccessibleContext
> m_xParentContext
=
138 xParent
.is() ? xParent
->getAccessibleContext() : Reference
< XAccessibleContext
>();
139 if( m_xParentContext
.is() )
141 Reference
< XAccessibleComponent
> xParentComp( m_xParentContext
, uno::UNO_QUERY
);
142 if( xParentComp
.is() )
143 bShowing
= GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp
->getBounds() ) );
148 // -----------------------------------------------------------------------------
149 Rectangle
AccessibleListBoxEntry::GetBoundingBox() throw ( lang::DisposedException
)
151 SolarMutexGuard aSolarGuard
;
152 ::osl::MutexGuard
aGuard( m_aMutex
);
155 return GetBoundingBox_Impl();
157 // -----------------------------------------------------------------------------
158 Rectangle
AccessibleListBoxEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException
)
160 SolarMutexGuard aSolarGuard
;
161 ::osl::MutexGuard
aGuard( m_aMutex
);
164 return GetBoundingBoxOnScreen_Impl();
166 // -----------------------------------------------------------------------------
167 void AccessibleListBoxEntry::EnsureIsAlive() const throw ( lang::DisposedException
)
169 if ( !IsAlive_Impl() )
170 throw lang::DisposedException();
172 // -----------------------------------------------------------------------------
173 OUString
AccessibleListBoxEntry::implGetText()
176 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
178 sRet
= getListBox()->SearchEntryText( pEntry
);
181 // -----------------------------------------------------------------------------
182 Locale
AccessibleListBoxEntry::implGetLocale()
185 aLocale
= Application::GetSettings().GetUILanguageTag().getLocale();
189 void AccessibleListBoxEntry::implGetSelection( sal_Int32
& nStartIndex
, sal_Int32
& nEndIndex
)
194 // -----------------------------------------------------------------------------
196 // -----------------------------------------------------------------------------
197 // -----------------------------------------------------------------------------
198 Sequence
< sal_Int8
> AccessibleListBoxEntry::getImplementationId() throw (RuntimeException
)
200 static ::cppu::OImplementationId
* pId
= NULL
;
204 ::osl::Guard
< ::osl::Mutex
> aGuard( m_aMutex
);
208 static ::cppu::OImplementationId aId
;
212 return pId
->getImplementationId();
215 // -----------------------------------------------------------------------------
216 // XComponent/ListBoxAccessibleBase
217 // -----------------------------------------------------------------------------
218 void SAL_CALL
AccessibleListBoxEntry::dispose() throw ( uno::RuntimeException
)
220 AccessibleListBoxEntry_BASE::dispose();
223 // -----------------------------------------------------------------------------
225 // -----------------------------------------------------------------------------
226 void SAL_CALL
AccessibleListBoxEntry::disposing()
229 ::osl::MutexGuard
aGuard( m_aMutex
);
231 Reference
< XAccessible
> xKeepAlive( this );
233 // Send a disposing to all listeners.
236 ::comphelper::AccessibleEventNotifier::TClientId nId
= m_nClientId
;
238 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId
, *this );
244 ListBoxAccessibleBase::disposing();
246 m_aParent
= WeakReference
< XAccessible
>();
248 // -----------------------------------------------------------------------------
250 // -----------------------------------------------------------------------------
251 OUString SAL_CALL
AccessibleListBoxEntry::getImplementationName() throw(RuntimeException
)
253 return getImplementationName_Static();
255 // -----------------------------------------------------------------------------
256 Sequence
< OUString
> SAL_CALL
AccessibleListBoxEntry::getSupportedServiceNames() throw(RuntimeException
)
258 return getSupportedServiceNames_Static();
260 // -----------------------------------------------------------------------------
261 sal_Bool SAL_CALL
AccessibleListBoxEntry::supportsService( const OUString
& _rServiceName
) throw (RuntimeException
)
263 return cppu::supportsService(this, _rServiceName
);
265 // -----------------------------------------------------------------------------
266 // XServiceInfo - static methods
267 // -----------------------------------------------------------------------------
268 Sequence
< OUString
> AccessibleListBoxEntry::getSupportedServiceNames_Static(void) throw( RuntimeException
)
270 Sequence
< OUString
> aSupported(3);
271 aSupported
[0] = "com.sun.star.accessibility.AccessibleContext";
272 aSupported
[1] = "com.sun.star.accessibility.AccessibleComponent";
273 aSupported
[2] = "com.sun.star.awt.AccessibleTreeListBoxEntry";
276 // -----------------------------------------------------------------------------
277 OUString
AccessibleListBoxEntry::getImplementationName_Static(void) throw( RuntimeException
)
279 return OUString( "com.sun.star.comp.svtools.AccessibleTreeListBoxEntry" );
281 // -----------------------------------------------------------------------------
283 // -----------------------------------------------------------------------------
284 Reference
< XAccessibleContext
> SAL_CALL
AccessibleListBoxEntry::getAccessibleContext( ) throw (RuntimeException
)
289 // -----------------------------------------------------------------------------
290 // XAccessibleContext
291 // -----------------------------------------------------------------------------
292 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getAccessibleChildCount( ) throw (RuntimeException
)
294 SolarMutexGuard aSolarGuard
;
295 ::osl::MutexGuard
aGuard( m_aMutex
);
298 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
299 sal_Int32 nCount
= 0;
301 nCount
= getListBox()->GetLevelChildCount( pEntry
);
305 // -----------------------------------------------------------------------------
306 Reference
< XAccessible
> SAL_CALL
AccessibleListBoxEntry::getAccessibleChild( sal_Int32 i
) throw (IndexOutOfBoundsException
,RuntimeException
)
308 SolarMutexGuard aSolarGuard
;
309 ::osl::MutexGuard
aGuard( m_aMutex
);
312 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
313 SvTreeListEntry
* pEntry
= pParent
? getListBox()->GetEntry( pParent
, i
) : NULL
;
315 throw IndexOutOfBoundsException();
317 return new AccessibleListBoxEntry( *getListBox(), pEntry
, this );
320 // -----------------------------------------------------------------------------
321 Reference
< XAccessible
> AccessibleListBoxEntry::implGetParentAccessible( ) const
323 Reference
< XAccessible
> xParent
= (Reference
< XAccessible
>)m_aParent
;
326 OSL_ENSURE( m_aEntryPath
.size(), "AccessibleListBoxEntry::getAccessibleParent: invalid path!" );
327 if ( 1 == m_aEntryPath
.size() )
328 { // we're a top level entry
329 // -> our parent is the tree listbox itself
331 xParent
= getListBox()->GetAccessible( );
334 { // we have a entry as parent -> get it's accessible
336 // shorten our access path by one
337 ::std::deque
< sal_Int32
> aParentPath( m_aEntryPath
);
338 aParentPath
.pop_back();
340 // get the entry for this shortened access path
341 SvTreeListEntry
* pParentEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
342 OSL_ENSURE( pParentEntry
, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" );
345 xParent
= new AccessibleListBoxEntry( *getListBox(), pParentEntry
, NULL
);
346 // note that we pass NULL here as parent-accessible:
347 // this is allowed, as the AccessibleListBoxEntry class will create it's parent
355 // -----------------------------------------------------------------------------
356 Reference
< XAccessible
> SAL_CALL
AccessibleListBoxEntry::getAccessibleParent( ) throw (RuntimeException
)
358 SolarMutexGuard aSolarGuard
;
359 ::osl::MutexGuard
aGuard( m_aMutex
);
362 return implGetParentAccessible( );
364 // -----------------------------------------------------------------------------
365 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getAccessibleIndexInParent( ) throw (RuntimeException
)
367 ::osl::MutexGuard
aGuard( m_aMutex
);
369 OSL_ENSURE( !m_aEntryPath
.empty(), "empty path" );
370 return m_aEntryPath
.empty() ? -1 : m_aEntryPath
.back();
372 // -----------------------------------------------------------------------------
373 sal_Int16 SAL_CALL
AccessibleListBoxEntry::getAccessibleRole( ) throw (RuntimeException
)
375 return AccessibleRole::LABEL
;
377 // -----------------------------------------------------------------------------
378 OUString SAL_CALL
AccessibleListBoxEntry::getAccessibleDescription( ) throw (RuntimeException
)
380 // no description for every item
383 // -----------------------------------------------------------------------------
384 OUString SAL_CALL
AccessibleListBoxEntry::getAccessibleName( ) throw (RuntimeException
)
386 ::osl::MutexGuard
aGuard( m_aMutex
);
389 return implGetText();
391 // -----------------------------------------------------------------------------
392 Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleListBoxEntry::getAccessibleRelationSet( ) throw (RuntimeException
)
394 Reference
< XAccessibleRelationSet
> xRelSet
;
395 Reference
< XAccessible
> xParent
;
396 if ( m_aEntryPath
.size() > 1 ) // not a root entry
397 xParent
= implGetParentAccessible();
400 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
401 Sequence
< Reference
< XInterface
> > aSequence(1);
402 aSequence
[0] = xParent
;
403 pRelationSetHelper
->AddRelation(
404 AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF
, aSequence
) );
405 xRelSet
= pRelationSetHelper
;
409 // -----------------------------------------------------------------------------
410 Reference
< XAccessibleStateSet
> SAL_CALL
AccessibleListBoxEntry::getAccessibleStateSet( ) throw (RuntimeException
)
412 ::osl::MutexGuard
aGuard( m_aMutex
);
414 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
415 Reference
< XAccessibleStateSet
> xStateSet
= pStateSetHelper
;
417 if ( IsAlive_Impl() )
419 pStateSetHelper
->AddState( AccessibleStateType::TRANSIENT
);
420 pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
421 pStateSetHelper
->AddState( AccessibleStateType::ENABLED
);
422 pStateSetHelper
->AddState( AccessibleStateType::SENSITIVE
);
423 if ( getListBox()->IsInplaceEditingEnabled() )
424 pStateSetHelper
->AddState( AccessibleStateType::EDITABLE
);
425 if ( IsShowing_Impl() )
426 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
427 getListBox()->FillAccessibleEntryStateSet(
428 getListBox()->GetEntryFromPath( m_aEntryPath
), *pStateSetHelper
);
431 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
435 // -----------------------------------------------------------------------------
436 Locale SAL_CALL
AccessibleListBoxEntry::getLocale( ) throw (IllegalAccessibleComponentStateException
, RuntimeException
)
438 SolarMutexGuard aSolarGuard
;
439 ::osl::MutexGuard
aGuard( m_aMutex
);
441 return implGetLocale();
443 // -----------------------------------------------------------------------------
444 // XAccessibleComponent
445 // -----------------------------------------------------------------------------
446 sal_Bool SAL_CALL
AccessibleListBoxEntry::containsPoint( const awt::Point
& rPoint
) throw (RuntimeException
)
448 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint
) );
450 // -----------------------------------------------------------------------------
451 Reference
< XAccessible
> SAL_CALL
AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point
& _aPoint
) throw (RuntimeException
)
453 SolarMutexGuard aSolarGuard
;
454 ::osl::MutexGuard
aGuard( m_aMutex
);
457 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( VCLPoint( _aPoint
) );
459 throw RuntimeException();
461 Reference
< XAccessible
> xAcc
;
462 AccessibleListBoxEntry
* pAccEntry
= new AccessibleListBoxEntry( *getListBox(), pEntry
, this );
463 Rectangle aRect
= pAccEntry
->GetBoundingBox_Impl();
464 if ( aRect
.IsInside( VCLPoint( _aPoint
) ) )
468 // -----------------------------------------------------------------------------
469 awt::Rectangle SAL_CALL
AccessibleListBoxEntry::getBounds( ) throw (RuntimeException
)
471 return AWTRectangle( GetBoundingBox() );
473 // -----------------------------------------------------------------------------
474 awt::Point SAL_CALL
AccessibleListBoxEntry::getLocation( ) throw (RuntimeException
)
476 return AWTPoint( GetBoundingBox().TopLeft() );
478 // -----------------------------------------------------------------------------
479 awt::Point SAL_CALL
AccessibleListBoxEntry::getLocationOnScreen( ) throw (RuntimeException
)
481 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
483 // -----------------------------------------------------------------------------
484 awt::Size SAL_CALL
AccessibleListBoxEntry::getSize( ) throw (RuntimeException
)
486 return AWTSize( GetBoundingBox().GetSize() );
488 // -----------------------------------------------------------------------------
489 void SAL_CALL
AccessibleListBoxEntry::grabFocus( ) throw (RuntimeException
)
491 // do nothing, because no focus for each item
493 // -----------------------------------------------------------------------------
494 sal_Int32
AccessibleListBoxEntry::getForeground( ) throw (RuntimeException
)
496 SolarMutexGuard aSolarGuard
;
497 ::osl::MutexGuard
aGuard( m_aMutex
);
499 sal_Int32 nColor
= 0;
500 Reference
< XAccessible
> xParent
= getAccessibleParent();
503 Reference
< XAccessibleComponent
> xParentComp( xParent
->getAccessibleContext(), UNO_QUERY
);
504 if ( xParentComp
.is() )
505 nColor
= xParentComp
->getForeground();
510 // -----------------------------------------------------------------------------
511 sal_Int32
AccessibleListBoxEntry::getBackground( ) throw (RuntimeException
)
513 SolarMutexGuard aSolarGuard
;
514 ::osl::MutexGuard
aGuard( m_aMutex
);
516 sal_Int32 nColor
= 0;
517 Reference
< XAccessible
> xParent
= getAccessibleParent();
520 Reference
< XAccessibleComponent
> xParentComp( xParent
->getAccessibleContext(), UNO_QUERY
);
521 if ( xParentComp
.is() )
522 nColor
= xParentComp
->getBackground();
527 // -----------------------------------------------------------------------------
529 // -----------------------------------------------------------------------------
530 // -----------------------------------------------------------------------------
531 awt::Rectangle SAL_CALL
AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
533 SolarMutexGuard aSolarGuard
;
534 ::osl::MutexGuard
aGuard( m_aMutex
);
538 if ( !implIsValidIndex( nIndex
, implGetText().getLength() ) )
539 throw IndexOutOfBoundsException();
541 awt::Rectangle
aBounds( 0, 0, 0, 0 );
542 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
545 ::vcl::ControlLayoutData aLayoutData
;
546 Rectangle aItemRect
= GetBoundingBox();
547 getListBox()->RecordLayoutData( &aLayoutData
, aItemRect
);
548 Rectangle aCharRect
= aLayoutData
.GetCharacterBounds( nIndex
);
549 aCharRect
.Move( -aItemRect
.Left(), -aItemRect
.Top() );
550 aBounds
= AWTRectangle( aCharRect
);
555 // -----------------------------------------------------------------------------
556 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getIndexAtPoint( const awt::Point
& aPoint
) throw (RuntimeException
)
558 SolarMutexGuard aSolarGuard
;
559 ::osl::MutexGuard
aGuard( m_aMutex
);
562 sal_Int32 nIndex
= -1;
563 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
566 ::vcl::ControlLayoutData aLayoutData
;
567 Rectangle aItemRect
= GetBoundingBox();
568 getListBox()->RecordLayoutData( &aLayoutData
, aItemRect
);
569 Point
aPnt( VCLPoint( aPoint
) );
570 aPnt
+= aItemRect
.TopLeft();
571 nIndex
= aLayoutData
.GetIndexForPoint( aPnt
);
576 // -----------------------------------------------------------------------------
577 sal_Bool SAL_CALL
AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
579 SolarMutexGuard aSolarGuard
;
580 ::osl::MutexGuard
aGuard( m_aMutex
);
583 String sText
= getText();
584 if ( ( 0 > nStartIndex
) || ( sText
.Len() <= nStartIndex
)
585 || ( 0 > nEndIndex
) || ( sText
.Len() <= nEndIndex
) )
586 throw IndexOutOfBoundsException();
588 sal_Int32 nLen
= nEndIndex
- nStartIndex
+ 1;
589 ::svt::OStringTransfer::CopyString( sText
.Copy( (sal_uInt16
)nStartIndex
, (sal_uInt16
)nLen
), getListBox() );
593 // -----------------------------------------------------------------------------
594 // XAccessibleEventBroadcaster
595 // -----------------------------------------------------------------------------
596 void SAL_CALL
AccessibleListBoxEntry::addAccessibleEventListener( const Reference
< XAccessibleEventListener
>& xListener
) throw (RuntimeException
)
600 ::osl::MutexGuard
aGuard( m_aMutex
);
602 m_nClientId
= comphelper::AccessibleEventNotifier::registerClient( );
603 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId
, xListener
);
606 // -----------------------------------------------------------------------------
607 void SAL_CALL
AccessibleListBoxEntry::removeAccessibleEventListener( const Reference
< XAccessibleEventListener
>& xListener
) throw (RuntimeException
)
611 ::osl::MutexGuard
aGuard( m_aMutex
);
613 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId
, xListener
);
614 if ( !nListenerCount
)
616 // no listeners anymore
617 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
618 // and at least to us not firing any events anymore, in case somebody calls
619 // NotifyAccessibleEvent, again
620 sal_Int32 nId
= m_nClientId
;
622 comphelper::AccessibleEventNotifier::revokeClient( nId
);
627 // -----------------------------------------------------------------------------
629 // -----------------------------------------------------------------------------
630 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getAccessibleActionCount( ) throw (RuntimeException
)
632 ::osl::MutexGuard
aGuard( m_aMutex
);
634 // three actions supported
635 return ACCESSIBLE_ACTION_COUNT
;
637 // -----------------------------------------------------------------------------
638 sal_Bool SAL_CALL
AccessibleListBoxEntry::doAccessibleAction( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
640 SolarMutexGuard aSolarGuard
;
641 ::osl::MutexGuard
aGuard( m_aMutex
);
643 sal_Bool bRet
= sal_False
;
644 checkActionIndex_Impl( nIndex
);
647 SvTreeListEntry
* pEntry
= getListBox()->GetEntryFromPath( m_aEntryPath
);
650 if ( getListBox()->IsExpanded( pEntry
) )
651 getListBox()->Collapse( pEntry
);
653 getListBox()->Expand( pEntry
);
659 // -----------------------------------------------------------------------------
660 OUString SAL_CALL
AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
662 SolarMutexGuard aSolarGuard
;
663 ::osl::MutexGuard
aGuard( m_aMutex
);
665 checkActionIndex_Impl( nIndex
);
668 static const OUString
sActionDesc( "toggleExpand" );
671 // -----------------------------------------------------------------------------
672 Reference
< XAccessibleKeyBinding
> AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
674 ::osl::MutexGuard
aGuard( m_aMutex
);
676 Reference
< XAccessibleKeyBinding
> xRet
;
677 checkActionIndex_Impl( nIndex
);
681 // -----------------------------------------------------------------------------
682 // XAccessibleSelection
683 // -----------------------------------------------------------------------------
684 void SAL_CALL
AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
686 SolarMutexGuard aSolarGuard
;
687 ::osl::MutexGuard
aGuard( m_aMutex
);
691 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
692 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, nChildIndex
);
694 throw IndexOutOfBoundsException();
696 getListBox()->Select( pEntry
, sal_True
);
698 // -----------------------------------------------------------------------------
699 sal_Bool SAL_CALL
AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
701 SolarMutexGuard aSolarGuard
;
702 ::osl::MutexGuard
aGuard( m_aMutex
);
706 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
707 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, nChildIndex
);
709 throw IndexOutOfBoundsException();
711 return getListBox()->IsSelected( pEntry
);
713 // -----------------------------------------------------------------------------
714 void SAL_CALL
AccessibleListBoxEntry::clearAccessibleSelection( ) throw (RuntimeException
)
716 SolarMutexGuard aSolarGuard
;
717 ::osl::MutexGuard
aGuard( m_aMutex
);
721 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
723 throw RuntimeException();
724 sal_Int32 nCount
= getListBox()->GetLevelChildCount( pParent
);
725 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
727 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, i
);
728 if ( getListBox()->IsSelected( pEntry
) )
729 getListBox()->Select( pEntry
, sal_False
);
732 // -----------------------------------------------------------------------------
733 void SAL_CALL
AccessibleListBoxEntry::selectAllAccessibleChildren( ) throw (RuntimeException
)
735 SolarMutexGuard aSolarGuard
;
736 ::osl::MutexGuard
aGuard( m_aMutex
);
740 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
742 throw RuntimeException();
743 sal_Int32 nCount
= getListBox()->GetLevelChildCount( pParent
);
744 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
746 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, i
);
747 if ( !getListBox()->IsSelected( pEntry
) )
748 getListBox()->Select( pEntry
, sal_True
);
751 // -----------------------------------------------------------------------------
752 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
754 SolarMutexGuard aSolarGuard
;
755 ::osl::MutexGuard
aGuard( m_aMutex
);
759 sal_Int32 i
, nSelCount
= 0, nCount
= 0;
761 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
763 throw RuntimeException();
764 nCount
= getListBox()->GetLevelChildCount( pParent
);
765 for ( i
= 0; i
< nCount
; ++i
)
767 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, i
);
768 if ( getListBox()->IsSelected( pEntry
) )
774 // -----------------------------------------------------------------------------
775 Reference
< XAccessible
> SAL_CALL
AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
777 SolarMutexGuard aSolarGuard
;
778 ::osl::MutexGuard
aGuard( m_aMutex
);
782 if ( nSelectedChildIndex
< 0 || nSelectedChildIndex
>= getSelectedAccessibleChildCount() )
783 throw IndexOutOfBoundsException();
785 Reference
< XAccessible
> xChild
;
786 sal_Int32 i
, nSelCount
= 0, nCount
= 0;
788 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
790 throw RuntimeException();
791 nCount
= getListBox()->GetLevelChildCount( pParent
);
792 for ( i
= 0; i
< nCount
; ++i
)
794 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, i
);
795 if ( getListBox()->IsSelected( pEntry
) )
798 if ( nSelCount
== ( nSelectedChildIndex
+ 1 ) )
800 xChild
= new AccessibleListBoxEntry( *getListBox(), pEntry
, this );
807 // -----------------------------------------------------------------------------
808 void SAL_CALL
AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
810 SolarMutexGuard aSolarGuard
;
811 ::osl::MutexGuard
aGuard( m_aMutex
);
815 SvTreeListEntry
* pParent
= getListBox()->GetEntryFromPath( m_aEntryPath
);
816 SvTreeListEntry
* pEntry
= getListBox()->GetEntry( pParent
, nSelectedChildIndex
);
818 throw IndexOutOfBoundsException();
820 getListBox()->Select( pEntry
, sal_False
);
822 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException
)
826 sal_Bool SAL_CALL
AccessibleListBoxEntry::setCaretPosition ( sal_Int32 nIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
)
828 SolarMutexGuard aSolarGuard
;
829 ::osl::MutexGuard
aGuard( m_aMutex
);
832 if ( !implIsValidRange( nIndex
, nIndex
, implGetText().getLength() ) )
833 throw IndexOutOfBoundsException();
837 sal_Unicode SAL_CALL
AccessibleListBoxEntry::getCharacter( sal_Int32 nIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
)
839 SolarMutexGuard aSolarGuard
;
840 ::osl::MutexGuard
aGuard( m_aMutex
);
842 return OCommonAccessibleText::getCharacter( nIndex
);
844 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
AccessibleListBoxEntry::getCharacterAttributes( sal_Int32 nIndex
, const ::com::sun::star::uno::Sequence
< OUString
>& ) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
)
846 SolarMutexGuard aSolarGuard
;
847 ::osl::MutexGuard
aGuard( m_aMutex
);
850 OUString
sText( implGetText() );
852 if ( !implIsValidIndex( nIndex
, sText
.getLength() ) )
853 throw IndexOutOfBoundsException();
855 return ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>();
857 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException
)
859 SolarMutexGuard aSolarGuard
;
860 ::osl::MutexGuard
aGuard( m_aMutex
);
862 return OCommonAccessibleText::getCharacterCount( );
865 OUString SAL_CALL
AccessibleListBoxEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException
)
867 SolarMutexGuard aSolarGuard
;
868 ::osl::MutexGuard
aGuard( m_aMutex
);
870 return OCommonAccessibleText::getSelectedText( );
872 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException
)
874 SolarMutexGuard aSolarGuard
;
875 ::osl::MutexGuard
aGuard( m_aMutex
);
877 return OCommonAccessibleText::getSelectionStart( );
879 sal_Int32 SAL_CALL
AccessibleListBoxEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException
)
881 SolarMutexGuard aSolarGuard
;
882 ::osl::MutexGuard
aGuard( m_aMutex
);
884 return OCommonAccessibleText::getSelectionEnd( );
886 sal_Bool SAL_CALL
AccessibleListBoxEntry::setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
)
888 SolarMutexGuard aSolarGuard
;
889 ::osl::MutexGuard
aGuard( m_aMutex
);
892 if ( !implIsValidRange( nStartIndex
, nEndIndex
, implGetText().getLength() ) )
893 throw IndexOutOfBoundsException();
897 OUString SAL_CALL
AccessibleListBoxEntry::getText( ) throw (::com::sun::star::uno::RuntimeException
)
899 SolarMutexGuard aSolarGuard
;
900 ::osl::MutexGuard
aGuard( m_aMutex
);
902 return OCommonAccessibleText::getText( );
904 OUString SAL_CALL
AccessibleListBoxEntry::getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
)
906 SolarMutexGuard aSolarGuard
;
907 ::osl::MutexGuard
aGuard( m_aMutex
);
909 return OCommonAccessibleText::getTextRange( nStartIndex
, nEndIndex
);
911 ::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
)
913 SolarMutexGuard aSolarGuard
;
914 ::osl::MutexGuard
aGuard( m_aMutex
);
916 return OCommonAccessibleText::getTextAtIndex( nIndex
,aTextType
);
918 ::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
)
920 SolarMutexGuard aSolarGuard
;
921 ::osl::MutexGuard
aGuard( m_aMutex
);
923 return OCommonAccessibleText::getTextBeforeIndex( nIndex
,aTextType
);
925 ::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
)
927 SolarMutexGuard aSolarGuard
;
928 ::osl::MutexGuard
aGuard( m_aMutex
);
931 return OCommonAccessibleText::getTextBehindIndex( nIndex
,aTextType
);
933 //........................................................................
934 }// namespace accessibility
935 //........................................................................
937 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */