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/standard/vclxaccessiblelist.hxx>
21 #include <accessibility/standard/vclxaccessiblelistitem.hxx>
22 #include <accessibility/helper/listboxhelper.hxx>
24 #include <unotools/accessiblestatesethelper.hxx>
25 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #include <vcl/svapp.hxx>
29 #include <vcl/combobox.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <toolkit/helper/convert.hxx>
33 using namespace ::com::sun::star
;
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::lang
;
36 using namespace ::com::sun::star::beans
;
37 using namespace ::com::sun::star::accessibility
;
38 using namespace ::accessibility
;
42 void checkSelection_Impl( sal_Int32 _nIndex
, const IComboListBoxHelper
& _rListBox
, sal_Bool bSelected
)
43 throw (::com::sun::star::lang::IndexOutOfBoundsException
)
45 sal_Int32 nCount
= bSelected
? (sal_Int32
)_rListBox
.GetSelectEntryCount()
46 : (sal_Int32
)_rListBox
.GetEntryCount();
47 if ( _nIndex
< 0 || _nIndex
>= nCount
)
48 throw ::com::sun::star::lang::IndexOutOfBoundsException();
52 VCLXAccessibleList::VCLXAccessibleList (VCLXWindow
* pVCLWindow
, BoxType aBoxType
,
53 const Reference
< XAccessible
>& _xParent
)
54 : VCLXAccessibleComponent (pVCLWindow
),
55 m_aBoxType (aBoxType
),
57 m_nVisibleLineCount (0),
58 m_nIndexInParent (DEFAULT_INDEX_IN_PARENT
),
59 m_nLastTopEntry ( 0 ),
60 m_nLastSelectedPos ( LISTBOX_ENTRY_NOTFOUND
),
61 m_bDisableProcessEvent ( false ),
63 m_xParent ( _xParent
)
65 // Because combo boxes and list boxes don't have a common interface for
66 // methods with identical signature we have to write down twice the
72 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
74 m_pListBoxHelper
= new VCLListBoxHelper
<ComboBox
> (*pBox
);
80 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
82 m_pListBoxHelper
= new VCLListBoxHelper
<ListBox
> (*pBox
);
86 UpdateVisibleLineCount();
88 sal_uInt16 nCount
= static_cast<sal_uInt16
>(getAccessibleChildCount());
89 m_aAccessibleChildren
.reserve(nCount
);
91 // -----------------------------------------------------------------------------
93 VCLXAccessibleList::~VCLXAccessibleList (void)
95 delete m_pListBoxHelper
;
97 // -----------------------------------------------------------------------------
99 void VCLXAccessibleList::SetIndexInParent (sal_Int32 nIndex
)
101 m_nIndexInParent
= nIndex
;
103 // -----------------------------------------------------------------------------
105 void SAL_CALL
VCLXAccessibleList::disposing (void)
107 VCLXAccessibleComponent::disposing();
109 // Dispose all items in the list.
112 delete m_pListBoxHelper
;
113 m_pListBoxHelper
= NULL
;
115 // -----------------------------------------------------------------------------
117 void VCLXAccessibleList::clearItems()
119 // Clear the list itself and delete all the rest.
120 ListItems().swap(m_aAccessibleChildren
); // clear and minimize
122 // -----------------------------------------------------------------------------
124 void VCLXAccessibleList::FillAccessibleStateSet (utl::AccessibleStateSetHelper
& rStateSet
)
126 SolarMutexGuard aSolarGuard
;
128 VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet
);
129 // check if our list should be visible
130 if ( m_pListBoxHelper
131 && (m_pListBoxHelper
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
132 && !m_pListBoxHelper
->IsInDropDown() )
134 rStateSet
.RemoveState (AccessibleStateType::VISIBLE
);
135 rStateSet
.RemoveState (AccessibleStateType::SHOWING
);
139 // Both the combo box and list box are handled identical in the
140 // following but for some reason they don't have a common interface for
142 if ( m_pListBoxHelper
)
144 if ( m_pListBoxHelper
->IsMultiSelectionEnabled() )
145 rStateSet
.AddState( AccessibleStateType::MULTI_SELECTABLE
);
146 rStateSet
.AddState (AccessibleStateType::FOCUSABLE
);
147 // All children are transient.
148 rStateSet
.AddState (AccessibleStateType::MANAGES_DESCENDANTS
);
151 // -----------------------------------------------------------------------------
152 void VCLXAccessibleList::notifyVisibleStates(sal_Bool _bSetNew
)
154 m_bVisible
= _bSetNew
? true : false;
155 Any aOldValue
, aNewValue
;
156 (_bSetNew
? aNewValue
: aOldValue
) <<= AccessibleStateType::VISIBLE
;
157 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
158 (_bSetNew
? aNewValue
: aOldValue
) <<= AccessibleStateType::SHOWING
;
159 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
161 ListItems::iterator aIter
= m_aAccessibleChildren
.begin();
162 ListItems::iterator aEnd
= m_aAccessibleChildren
.end();
163 UpdateVisibleLineCount();
164 // adjust the index inside the VCLXAccessibleListItem
165 for (;aIter
!= aEnd
; ++aIter
)
167 Reference
< XAccessible
> xHold
= *aIter
;
168 VCLXAccessibleListItem
* pItem
= static_cast<VCLXAccessibleListItem
*>(xHold
.get());
171 sal_uInt16 nTopEntry
= 0;
172 if ( m_pListBoxHelper
)
173 nTopEntry
= m_pListBoxHelper
->GetTopEntry();
174 sal_uInt16 nPos
= (sal_uInt16
)(aIter
- m_aAccessibleChildren
.begin());
175 sal_Bool bVisible
= ( nPos
>=nTopEntry
&& nPos
<( nTopEntry
+ m_nVisibleLineCount
) );
176 pItem
->SetVisible( m_bVisible
&& bVisible
);
181 // -----------------------------------------------------------------------------
182 void VCLXAccessibleList::ProcessWindowEvent (const VclWindowEvent
& rVclWindowEvent
)
184 // Create a reference to this object to prevent an early release of the
185 // listbox (VCLEVENT_OBJECT_DYING).
186 Reference
< XAccessible
> xTemp
= this;
188 switch ( rVclWindowEvent
.GetId() )
190 case VCLEVENT_DROPDOWN_OPEN
:
191 notifyVisibleStates(sal_True
);
193 case VCLEVENT_DROPDOWN_CLOSE
:
194 notifyVisibleStates(sal_False
);
196 case VCLEVENT_LISTBOX_SCROLLED
:
197 case VCLEVENT_COMBOBOX_SCROLLED
:
198 UpdateEntryRange_Impl();
201 case VCLEVENT_LISTBOX_SELECT
:
202 if ( !m_bDisableProcessEvent
)
203 UpdateSelection_Impl();
205 // The selection events VCLEVENT_COMBOBOX_SELECT and
206 // VCLEVENT_COMBOBOX_DESELECT are not handled here because here we
207 // have no access to the edit field. Its text is necessary to
208 // identify the currently selected item.
210 case VCLEVENT_OBJECT_DYING
:
214 VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent
);
218 case VCLEVENT_LISTBOX_ITEMREMOVED
:
219 case VCLEVENT_COMBOBOX_ITEMREMOVED
:
220 HandleChangedItemList (false, reinterpret_cast<sal_IntPtr
>(
221 rVclWindowEvent
.GetData()));
224 case VCLEVENT_LISTBOX_ITEMADDED
:
225 case VCLEVENT_COMBOBOX_ITEMADDED
:
226 HandleChangedItemList (true, reinterpret_cast<sal_IntPtr
>(
227 rVclWindowEvent
.GetData()));
229 case VCLEVENT_CONTROL_GETFOCUS
:
230 VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent
);
231 if ( m_pListBoxHelper
)
235 sal_uInt16 nPos
= m_pListBoxHelper
->GetSelectEntryPos();
236 if ( nPos
== LISTBOX_ENTRY_NOTFOUND
)
237 nPos
= m_pListBoxHelper
->GetTopEntry();
238 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
239 aNewValue
<<= CreateChild(nPos
);
241 NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
,
248 VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent
);
251 // -----------------------------------------------------------------------------
253 /** To find out which item is currently selected and to update the SELECTED
254 state of the associated accessibility objects accordingly we exploit the
257 void VCLXAccessibleList::UpdateSelection (OUString sTextOfSelectedItem
)
259 if ( m_aBoxType
== COMBOBOX
)
261 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
264 // Find the index of the selected item inside the VCL control...
265 sal_uInt16 nIndex
= pBox
->GetEntryPos(sTextOfSelectedItem
);
266 // ...and then find the associated accessibility object.
267 if ( nIndex
== LISTBOX_ENTRY_NOTFOUND
)
269 UpdateSelection_Impl(nIndex
);
273 // -----------------------------------------------------------------------------
275 void VCLXAccessibleList::adjustEntriesIndexInParent(ListItems::iterator
& _aBegin
,::std::mem_fun_t
<bool,VCLXAccessibleListItem
>& _rMemFun
)
277 ListItems::iterator aIter
= _aBegin
;
278 ListItems::iterator aEnd
= m_aAccessibleChildren
.end();
279 // adjust the index inside the VCLXAccessibleListItem
280 for (;aIter
!= aEnd
; ++aIter
)
282 Reference
< XAccessible
> xHold
= *aIter
;
283 VCLXAccessibleListItem
* pItem
= static_cast<VCLXAccessibleListItem
*>(xHold
.get());
288 // -----------------------------------------------------------------------------
290 Reference
<XAccessible
> VCLXAccessibleList::CreateChild (sal_Int32 i
)
292 Reference
<XAccessible
> xChild
;
294 sal_uInt16 nPos
= static_cast<sal_uInt16
>(i
);
295 if ( nPos
>= m_aAccessibleChildren
.size() )
297 m_aAccessibleChildren
.resize(nPos
+ 1);
299 // insert into the container
300 xChild
= new VCLXAccessibleListItem(m_pListBoxHelper
, i
, this);
301 m_aAccessibleChildren
[nPos
] = xChild
;
305 xChild
= m_aAccessibleChildren
[nPos
];
306 // check if position is empty and can be used else we have to adjust all entries behind this
309 ListItems::iterator aIter
= m_aAccessibleChildren
.begin() + nPos
;
310 ::std::mem_fun_t
<bool, VCLXAccessibleListItem
> aTemp(&VCLXAccessibleListItem::IncrementIndexInParent
);
311 adjustEntriesIndexInParent( aIter
, aTemp
);
315 xChild
= new VCLXAccessibleListItem(m_pListBoxHelper
, i
, this);
316 m_aAccessibleChildren
[nPos
] = xChild
;
322 // Just add the SELECTED state.
323 bool bNowSelected
= false;
324 if ( m_pListBoxHelper
)
325 bNowSelected
= m_pListBoxHelper
->IsEntryPosSelected ((sal_uInt16
)i
);
326 VCLXAccessibleListItem
* pItem
= static_cast< VCLXAccessibleListItem
* >(xChild
.get());
327 pItem
->SetSelected( bNowSelected
);
329 // Set the child's VISIBLE state.
330 UpdateVisibleLineCount();
331 sal_uInt16 nTopEntry
= 0;
332 if ( m_pListBoxHelper
)
333 nTopEntry
= m_pListBoxHelper
->GetTopEntry();
334 bool bVisible
= ( nPos
>=nTopEntry
&& nPos
<( nTopEntry
+ m_nVisibleLineCount
) );
335 pItem
->SetVisible( m_bVisible
&& bVisible
);
340 // -----------------------------------------------------------------------------
342 void VCLXAccessibleList::HandleChangedItemList (bool bItemInserted
, sal_Int32 nIndex
)
344 if ( !bItemInserted
)
346 if ( nIndex
== -1 ) // special handling here
352 if ( nIndex
>= 0 && static_cast<sal_uInt16
>(nIndex
) < m_aAccessibleChildren
.size() )
354 ListItems::iterator aIter
= m_aAccessibleChildren
.erase(m_aAccessibleChildren
.begin()+nIndex
);
355 ::std::mem_fun_t
<bool, VCLXAccessibleListItem
> aTemp(&VCLXAccessibleListItem::DecrementIndexInParent
);
356 adjustEntriesIndexInParent( aIter
, aTemp
);
361 getAccessibleChild(nIndex
);
363 NotifyAccessibleEvent (
364 AccessibleEventId::INVALIDATE_ALL_CHILDREN
,
367 // -----------------------------------------------------------------------------
369 IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleList
, VCLXAccessibleComponent
, VCLXAccessibleList_BASE
)
370 IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleList
, VCLXAccessibleComponent
, VCLXAccessibleList_BASE
)
372 //===== XAccessible =========================================================
374 Reference
<XAccessibleContext
> SAL_CALL
375 VCLXAccessibleList::getAccessibleContext (void)
376 throw (RuntimeException
)
380 // -----------------------------------------------------------------------------
382 //===== XAccessibleContext ==================================================
384 sal_Int32 SAL_CALL
VCLXAccessibleList::getAccessibleChildCount (void)
385 throw (RuntimeException
)
387 SolarMutexGuard aSolarGuard
;
388 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
390 sal_Int32 nCount
= 0;
391 if ( m_pListBoxHelper
)
392 nCount
= m_pListBoxHelper
->GetEntryCount();
396 // -----------------------------------------------------------------------------
398 Reference
<XAccessible
> SAL_CALL
VCLXAccessibleList::getAccessibleChild (sal_Int32 i
)
399 throw (IndexOutOfBoundsException
, RuntimeException
)
401 SolarMutexGuard aSolarGuard
;
402 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
404 if ( i
< 0 || i
>= getAccessibleChildCount() )
405 throw IndexOutOfBoundsException();
407 Reference
< XAccessible
> xChild
;
408 // search for the child
409 if ( static_cast<sal_uInt16
>(i
) >= m_aAccessibleChildren
.size() )
410 xChild
= CreateChild (i
);
413 xChild
= m_aAccessibleChildren
[i
];
415 xChild
= CreateChild (i
);
417 OSL_ENSURE( xChild
.is(), "VCLXAccessibleList::getAccessibleChild: returning empty child!" );
420 // -----------------------------------------------------------------------------
422 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleList::getAccessibleParent( )
423 throw (RuntimeException
)
425 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
429 // -----------------------------------------------------------------------------
431 sal_Int32 SAL_CALL
VCLXAccessibleList::getAccessibleIndexInParent (void)
432 throw (::com::sun::star::uno::RuntimeException
)
434 if (m_nIndexInParent
!= DEFAULT_INDEX_IN_PARENT
)
435 return m_nIndexInParent
;
437 return VCLXAccessibleComponent::getAccessibleIndexInParent();
439 // -----------------------------------------------------------------------------
441 sal_Int16 SAL_CALL
VCLXAccessibleList::getAccessibleRole (void)
442 throw (RuntimeException
)
444 return AccessibleRole::LIST
;
446 // -----------------------------------------------------------------------------
448 //===== XAccessibleComponent ================================================
450 sal_Bool SAL_CALL
VCLXAccessibleList::contains( const awt::Point
& rPoint
) throw (RuntimeException
)
452 SolarMutexGuard aSolarGuard
;
453 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
455 sal_Bool bInside
= sal_False
;
457 Window
* pListBox
= GetWindow();
460 Rectangle
aRect( Point(0,0), pListBox
->GetSizePixel() );
461 bInside
= aRect
.IsInside( VCLPoint( rPoint
) );
466 // -----------------------------------------------------------------------------
468 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleList::getAccessibleAt( const awt::Point
& rPoint
)
469 throw (RuntimeException
)
471 SolarMutexGuard aSolarGuard
;
472 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
474 Reference
< XAccessible
> xChild
;
475 if ( m_pListBoxHelper
)
477 UpdateVisibleLineCount();
478 if ( contains( rPoint
) && m_nVisibleLineCount
> 0 )
480 Point aPos
= VCLPoint( rPoint
);
481 sal_uInt16 nEndPos
= m_pListBoxHelper
->GetTopEntry() + (sal_uInt16
)m_nVisibleLineCount
;
482 for ( sal_uInt16 i
= m_pListBoxHelper
->GetTopEntry(); i
< nEndPos
; ++i
)
484 if ( m_pListBoxHelper
->GetBoundingRectangle(i
).IsInside( aPos
) )
486 xChild
= getAccessibleChild(i
);
495 // -----------------------------------------------------------------------------
497 //===== XServiceInfo ==========================================================
499 OUString
VCLXAccessibleList::getImplementationName (void)
500 throw (RuntimeException
)
502 return OUString( "com.sun.star.comp.toolkit.AccessibleList" );
504 // -----------------------------------------------------------------------------
506 Sequence
< OUString
> VCLXAccessibleList::getSupportedServiceNames (void)
507 throw (RuntimeException
)
509 Sequence
< OUString
> aNames
= VCLXAccessibleComponent::getSupportedServiceNames();
510 sal_Int32 nLength
= aNames
.getLength();
511 aNames
.realloc( nLength
+ 1 );
512 aNames
[nLength
] = "com.sun.star.accessibility.AccessibleList";
515 // -----------------------------------------------------------------------------
517 void VCLXAccessibleList::UpdateVisibleLineCount()
519 if ( m_pListBoxHelper
)
521 if ( (m_pListBoxHelper
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
)
522 m_nVisibleLineCount
= m_pListBoxHelper
->GetDisplayLineCount();
525 sal_uInt16 nCols
= 0,
527 m_pListBoxHelper
->GetMaxVisColumnsAndLines (nCols
, nLines
);
528 m_nVisibleLineCount
= nLines
;
533 // -----------------------------------------------------------------------------
534 void VCLXAccessibleList::UpdateEntryRange_Impl()
536 SolarMutexGuard aSolarGuard
;
537 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
539 sal_Int32 nTop
= m_nLastTopEntry
;
541 if ( m_pListBoxHelper
)
542 nTop
= m_pListBoxHelper
->GetTopEntry();
543 if ( nTop
!= m_nLastTopEntry
)
545 UpdateVisibleLineCount();
546 sal_Int32 nBegin
= std::min( m_nLastTopEntry
, nTop
);
547 sal_Int32 nEnd
= std::max( m_nLastTopEntry
+ m_nVisibleLineCount
, nTop
+ m_nVisibleLineCount
);
548 for (sal_uInt16 i
= static_cast<sal_uInt16
>(nBegin
); (i
<= static_cast<sal_uInt16
>(nEnd
)); ++i
)
550 sal_Bool bVisible
= ( i
>= nTop
&& i
< ( nTop
+ m_nVisibleLineCount
) );
551 Reference
< XAccessible
> xHold
;
552 if ( i
< m_aAccessibleChildren
.size() )
553 xHold
= m_aAccessibleChildren
[i
];
555 xHold
= CreateChild(i
);
558 static_cast< VCLXAccessibleListItem
* >( xHold
.get() )->SetVisible( m_bVisible
&& bVisible
);
562 m_nLastTopEntry
= nTop
;
564 // -----------------------------------------------------------------------------
565 sal_Bool
VCLXAccessibleList::checkEntrySelected(sal_uInt16 _nPos
,Any
& _rNewValue
,Reference
< XAccessible
>& _rxNewAcc
)
567 OSL_ENSURE(m_pListBoxHelper
,"Helper is not valid!");
568 sal_Bool bNowSelected
= sal_False
;
569 if ( m_pListBoxHelper
)
571 bNowSelected
= m_pListBoxHelper
->IsEntryPosSelected (_nPos
);
574 _rxNewAcc
= CreateChild(_nPos
);
575 _rNewValue
<<= _rxNewAcc
;
580 // -----------------------------------------------------------------------------
582 void VCLXAccessibleList::UpdateSelection_Impl(sal_uInt16
)
584 uno::Any aOldValue
, aNewValue
;
587 SolarMutexGuard aSolarGuard
;
588 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
589 Reference
< XAccessible
> xNewAcc
;
591 if ( m_pListBoxHelper
)
594 for ( ListItems::iterator aIter
= m_aAccessibleChildren
.begin();
595 aIter
!= m_aAccessibleChildren
.end(); ++aIter
,++i
)
597 Reference
< XAccessible
> xHold
= *aIter
;
600 VCLXAccessibleListItem
* pItem
= static_cast< VCLXAccessibleListItem
* >( xHold
.get() );
601 // Retrieve the item's index from the list entry.
602 sal_Bool bNowSelected
= m_pListBoxHelper
->IsEntryPosSelected (i
);
604 if ( bNowSelected
&& !pItem
->IsSelected() )
607 aNewValue
<<= xNewAcc
;
609 else if ( pItem
->IsSelected() )
610 m_nLastSelectedPos
= i
;
612 pItem
->SetSelected( bNowSelected
);
615 { // it could happen that a child was not created before
616 checkEntrySelected(i
,aNewValue
,xNewAcc
);
619 sal_uInt16 nCount
= m_pListBoxHelper
->GetEntryCount();
620 if ( i
< nCount
) // here we have to check the if any other listbox entry is selected
622 for (; i
< nCount
&& !checkEntrySelected(i
,aNewValue
,xNewAcc
) ;++i
)
625 if ( xNewAcc
.is() && GetWindow()->HasFocus() )
627 if ( m_nLastSelectedPos
!= LISTBOX_ENTRY_NOTFOUND
)
628 aOldValue
<<= getAccessibleChild( (sal_Int32
)m_nLastSelectedPos
);
629 aNewValue
<<= xNewAcc
;
634 if ( aNewValue
.hasValue() || aOldValue
.hasValue() )
635 NotifyAccessibleEvent(
636 AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
,
640 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED
, Any(), Any() );
643 // -----------------------------------------------------------------------------
644 // XAccessibleSelection
645 // -----------------------------------------------------------------------------
646 void SAL_CALL
VCLXAccessibleList::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
648 sal_Bool bNotify
= sal_False
;
651 SolarMutexGuard aSolarGuard
;
652 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
654 if ( m_pListBoxHelper
)
656 checkSelection_Impl(nChildIndex
,*m_pListBoxHelper
,sal_False
);
658 m_pListBoxHelper
->SelectEntryPos( (sal_uInt16
)nChildIndex
, sal_True
);
659 // call the select handler, don't handle events in this time
660 m_bDisableProcessEvent
= true;
661 m_pListBoxHelper
->Select();
662 m_bDisableProcessEvent
= false;
668 UpdateSelection_Impl();
670 // -----------------------------------------------------------------------------
671 sal_Bool SAL_CALL
VCLXAccessibleList::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
673 SolarMutexGuard aSolarGuard
;
674 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
676 sal_Bool bRet
= sal_False
;
677 if ( m_pListBoxHelper
)
679 checkSelection_Impl(nChildIndex
,*m_pListBoxHelper
,sal_False
);
681 bRet
= m_pListBoxHelper
->IsEntryPosSelected( (sal_uInt16
)nChildIndex
);
685 // -----------------------------------------------------------------------------
686 void SAL_CALL
VCLXAccessibleList::clearAccessibleSelection( ) throw (RuntimeException
)
688 sal_Bool bNotify
= sal_False
;
691 SolarMutexGuard aSolarGuard
;
692 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
694 if ( m_pListBoxHelper
)
696 m_pListBoxHelper
->SetNoSelection();
702 UpdateSelection_Impl();
704 // -----------------------------------------------------------------------------
705 void SAL_CALL
VCLXAccessibleList::selectAllAccessibleChildren( ) throw (RuntimeException
)
707 sal_Bool bNotify
= sal_False
;
710 SolarMutexGuard aSolarGuard
;
711 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
713 if ( m_pListBoxHelper
)
715 sal_uInt16 nCount
= m_pListBoxHelper
->GetEntryCount();
716 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
717 m_pListBoxHelper
->SelectEntryPos( i
, sal_True
);
718 // call the select handler, don't handle events in this time
719 m_bDisableProcessEvent
= true;
720 m_pListBoxHelper
->Select();
721 m_bDisableProcessEvent
= false;
727 UpdateSelection_Impl();
729 // -----------------------------------------------------------------------------
730 sal_Int32 SAL_CALL
VCLXAccessibleList::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
732 SolarMutexGuard aSolarGuard
;
733 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
735 sal_Int32 nCount
= 0;
736 if ( m_pListBoxHelper
)
737 nCount
= m_pListBoxHelper
->GetSelectEntryCount();
740 // -----------------------------------------------------------------------------
741 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
743 SolarMutexGuard aSolarGuard
;
744 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
746 if ( m_pListBoxHelper
)
748 checkSelection_Impl(nSelectedChildIndex
,*m_pListBoxHelper
,sal_True
);
749 return getAccessibleChild( (sal_Int32
)m_pListBoxHelper
->GetSelectEntryPos( (sal_uInt16
)nSelectedChildIndex
) );
754 // -----------------------------------------------------------------------------
755 void SAL_CALL
VCLXAccessibleList::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
757 sal_Bool bNotify
= sal_False
;
760 SolarMutexGuard aSolarGuard
;
761 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
763 if ( m_pListBoxHelper
)
765 checkSelection_Impl(nSelectedChildIndex
,*m_pListBoxHelper
,sal_False
);
767 m_pListBoxHelper
->SelectEntryPos( (sal_uInt16
)nSelectedChildIndex
, sal_False
);
768 // call the select handler, don't handle events in this time
769 m_bDisableProcessEvent
= true;
770 m_pListBoxHelper
->Select();
771 m_bDisableProcessEvent
= false;
777 UpdateSelection_Impl();
779 // -----------------------------------------------------------------------------
780 awt::Rectangle
VCLXAccessibleList::implGetBounds() throw (uno::RuntimeException
)
782 awt::Rectangle
aBounds ( 0, 0, 0, 0 );
783 if ( m_pListBoxHelper
784 && (m_pListBoxHelper
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
)
786 if ( m_pListBoxHelper
->IsInDropDown() )
787 aBounds
= AWTRectangle(m_pListBoxHelper
->GetDropDownPosSizePixel());
791 // a list has the same bounds as his parent but starts at (0,0)
792 aBounds
= VCLXAccessibleComponent::implGetBounds();
795 if ( m_aBoxType
== COMBOBOX
)
797 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
800 Size aSize
= pBox
->GetSubEdit()->GetSizePixel();
801 aBounds
.X
+= aSize
.Height();
802 aBounds
.Y
+= aSize
.Width();
803 aBounds
.Height
-= aSize
.Height();
804 aBounds
.Width
-= aSize
.Width();
810 // -----------------------------------------------------------------------------
812 awt::Point
VCLXAccessibleList::getLocationOnScreen( ) throw (uno::RuntimeException
)
814 SolarMutexGuard aSolarGuard
;
815 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
818 if ( m_pListBoxHelper
819 && (m_pListBoxHelper
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
)
821 if ( m_pListBoxHelper
->IsInDropDown() )
822 aPos
= AWTPoint(m_pListBoxHelper
->GetDropDownPosSizePixel().TopLeft());
826 aPos
= VCLXAccessibleComponent::getLocationOnScreen();
827 if ( m_aBoxType
== COMBOBOX
)
829 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
832 aPos
.X
+= pBox
->GetSubEdit()->GetSizePixel().Height();
833 aPos
.Y
+= pBox
->GetSubEdit()->GetSizePixel().Width();
839 // -----------------------------------------------------------------------------
841 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */