LibreOffice Module accessibility (master) 1
accessiblelistboxentry.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
25#include <com/sun/star/awt/Rectangle.hpp>
26#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
27#include <com/sun/star/accessibility/AccessibleRole.hpp>
28#include <com/sun/star/accessibility/AccessibleStateType.hpp>
29#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31#include <vcl/svapp.hxx>
32#include <vcl/settings.hxx>
37#include <helper/accresmgr.hxx>
38#include <strings.hrc>
39
40#define ACCESSIBLE_ACTION_COUNT 1
41
42namespace
43{
45 void checkActionIndex_Impl( sal_Int32 _nIndex )
46 {
47 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
48 // only three actions
49 throw css::lang::IndexOutOfBoundsException();
50 }
51}
52
53
54namespace accessibility
55{
56 // class AccessibleListBoxEntry -----------------------------------------------------
57
58 using namespace ::com::sun::star::accessibility;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star;
62 using namespace ::comphelper;
63
64
65 // Ctor() and Dtor()
66
68 SvTreeListEntry& rEntry,
69 AccessibleListBox & rListBox)
71
72 , m_pTreeListBox( &_rListBox )
73 , m_pSvLBoxEntry(&rEntry)
74 , m_nClientId( 0 )
75 , m_wListBox(&rListBox)
76 , m_rListBox(rListBox)
77 {
78 m_pTreeListBox->AddEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) );
80 }
81
83 {
84 if ( IsAlive_Impl() )
85 {
86 // increment ref count to prevent double call of Dtor
87 osl_atomic_increment( &m_refCount );
88 dispose();
89 }
90 }
91
92 IMPL_LINK( AccessibleListBoxEntry, WindowEventListener, VclWindowEvent&, rEvent, void )
93 {
94 OSL_ENSURE( rEvent.GetWindow() , "AccessibleListBoxEntry::WindowEventListener: no event window!" );
95 OSL_ENSURE( rEvent.GetWindow() == m_pTreeListBox, "AccessibleListBoxEntry::WindowEventListener: where did this come from?" );
96
97 if ( m_pTreeListBox == nullptr )
98 return;
99
100 switch ( rEvent.GetId() )
101 {
102 case VclEventId::ObjectDying :
103 {
104 if ( m_pTreeListBox )
105 m_pTreeListBox->RemoveEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) );
106 m_pTreeListBox = nullptr;
107 dispose();
108 break;
109 }
110 default: break;
111 }
112 }
113
115 const css::uno::Any& _aOldValue,
116 const css::uno::Any& _aNewValue )
117 {
118 Reference< uno::XInterface > xSource( *this );
119 AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue, -1 );
120
121 if (m_nClientId)
123 }
124
125
127 {
128 tools::Rectangle aRect;
129 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
130 if ( pEntry )
131 {
132 aRect = m_pTreeListBox->GetBoundingRect( pEntry );
133 SvTreeListEntry* pParent = m_pTreeListBox->GetParent( pEntry );
134 if ( pParent )
135 {
136 // position relative to parent entry
137 Point aTopLeft = aRect.TopLeft();
138 aTopLeft -= m_pTreeListBox->GetBoundingRect( pParent ).TopLeft();
139 aRect = tools::Rectangle( aTopLeft, aRect.GetSize() );
140 }
141 }
142
143 return aRect;
144 }
145
147 {
148 tools::Rectangle aRect;
149 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
150 if ( pEntry )
151 {
152 aRect = m_pTreeListBox->GetBoundingRect( pEntry );
153 Point aTopLeft = aRect.TopLeft();
154 aTopLeft += m_pTreeListBox->GetWindowExtentsAbsolute().TopLeft();
155 aRect = tools::Rectangle( aTopLeft, aRect.GetSize() );
156 }
157
158 return aRect;
159 }
160
162 {
163 return !rBHelper.bDisposed && !rBHelper.bInDispose && (m_pTreeListBox != nullptr);
164 }
165
167 {
169
170 bool bShowing = false;
171 Reference< XAccessibleContext > xParentContext =
172 xParent.is() ? xParent->getAccessibleContext() : Reference< XAccessibleContext >();
173 if( xParentContext.is() )
174 {
175 Reference< XAccessibleComponent > xParentComp( xParentContext, uno::UNO_QUERY );
176 if( xParentComp.is() )
177 bShowing = GetBoundingBox_Impl().Overlaps( VCLRectangle( xParentComp->getBounds() ) );
178 }
179
180 return bShowing;
181 }
182
184 {
185 SolarMutexGuard aSolarGuard;
186 ::osl::MutexGuard aGuard( m_aMutex );
187
189 return GetBoundingBox_Impl();
190 }
191
193 {
194 SolarMutexGuard aSolarGuard;
195 ::osl::MutexGuard aGuard( m_aMutex );
196
199 }
200
202 {
203 if ( !IsAlive_Impl() )
204 throw lang::DisposedException();
205 }
206
208 {
209 OUString sRet;
210 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
211 if ( pEntry )
213 return sRet;
214 }
215
217 {
219 }
220 void AccessibleListBoxEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
221 {
222 nStartIndex = 0;
223 nEndIndex = 0;
224 }
225
226 // XTypeProvider
227
228
230 {
231 return css::uno::Sequence<sal_Int8>();
232 }
233
234
235 // XComponent
236
238 {
239 SolarMutexGuard aSolarGuard;
240 ::osl::MutexGuard aGuard( m_aMutex );
241
242 Reference< XAccessible > xKeepAlive( this );
243
244 // Send a disposing to all listeners.
245 if ( m_nClientId )
246 {
248 m_nClientId = 0;
250 }
251
252 // clean up
253 m_wListBox.clear();
254
255 if ( m_pTreeListBox )
256 m_pTreeListBox->RemoveEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) );
257 m_pTreeListBox = nullptr;
258 }
259
260 // XServiceInfo
261
263 {
264 return "com.sun.star.comp.svtools.AccessibleTreeListBoxEntry";
265 }
266
268 {
269 return {"com.sun.star.accessibility.AccessibleContext",
270 "com.sun.star.accessibility.AccessibleComponent",
271 "com.sun.star.awt.AccessibleTreeListBoxEntry"};
272 }
273
274 sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const OUString& _rServiceName )
275 {
276 return cppu::supportsService(this, _rServiceName);
277 }
278
279 // XAccessible
280
282 {
284 return this;
285 }
286
287 // XAccessibleContext
288
290 {
291 SolarMutexGuard aSolarGuard;
292 ::osl::MutexGuard aGuard( m_aMutex );
293
295 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
296 sal_Int32 nCount = 0;
297 if ( pEntry )
298 nCount = m_pTreeListBox->GetLevelChildCount( pEntry );
299
300 return nCount;
301 }
302
304 {
305 SolarMutexGuard aSolarGuard;
306 ::osl::MutexGuard aGuard( m_aMutex );
308
309 SvTreeListEntry* pEntry = GetRealChild(i);
310 if ( !pEntry )
311 throw IndexOutOfBoundsException();
312
314 assert(xListBox.is());
315
316 return m_rListBox.implGetAccessible(*pEntry);
317 }
318
320 {
322 assert( m_aEntryPath.size() ); // invalid path
323 if ( m_aEntryPath.size() == 1 )
324 { // we're a top level entry
325 // -> our parent is the tree listbox itself
326 if ( m_pTreeListBox )
327 xParent = m_pTreeListBox->GetAccessible( );
328 }
329 else
330 { // we have an entry as parent -> get its accessible
331
332 // shorten our access path by one
333 std::deque< sal_Int32 > aParentPath( m_aEntryPath );
334 aParentPath.pop_back();
335
336 // get the entry for this shortened access path
337 SvTreeListEntry* pParentEntry = m_pTreeListBox->GetEntryFromPath( aParentPath );
338 assert(pParentEntry && "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!");
339 if ( pParentEntry )
340 {
342 assert(xListBox.is());
343 return m_rListBox.implGetAccessible(*pParentEntry);
344 // the AccessibleListBoxEntry class will create its parent
345 // when needed
346 }
347 }
348
349 return xParent;
350 }
351
352
354 {
355 SolarMutexGuard aSolarGuard;
356 ::osl::MutexGuard aGuard( m_aMutex );
358
359 return implGetParentAccessible( );
360 }
361
363 {
364 ::osl::MutexGuard aGuard( m_aMutex );
365
366 OSL_ENSURE( !m_aEntryPath.empty(), "empty path" );
367 return m_aEntryPath.empty() ? -1 : m_aEntryPath.back();
368 }
369
371 {
372 sal_Int32 nCase = 0;
373 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry(0);
374 if ( pEntry )
375 {
376 if( pEntry->HasChildrenOnDemand() || m_pTreeListBox->GetChildCount(pEntry) > 0 )
377 {
378 nCase = 1;
379 return nCase;
380 }
381 }
382
383 bool bHasButtons = (m_pTreeListBox->GetStyle() & WB_HASBUTTONS)!=0;
384 if( !(m_pTreeListBox->GetTreeFlags() & SvTreeFlags::CHKBTN) )
385 {
386 if( bHasButtons )
387 nCase = 1;
388 }
389 else
390 {
391 if( bHasButtons )
392 nCase = 2;
393 else
394 nCase = 3;
395 }
396 return nCase;
397 }
398
400 {
401 SolarMutexGuard aSolarGuard;
402 ::osl::MutexGuard aGuard( m_aMutex );
403
405 if(!pBox)
406 return AccessibleRole::UNKNOWN;
407
408 SvTreeFlags treeFlag = pBox->GetTreeFlags();
409 if(treeFlag & SvTreeFlags::CHKBTN )
410 {
412 SvButtonState eState = pBox->GetCheckButtonState( pEntry );
413 switch( eState )
414 {
415 case SvButtonState::Checked:
416 case SvButtonState::Unchecked:
417 return AccessibleRole::CHECK_BOX;
418 case SvButtonState::Tristate:
419 default:
420 return AccessibleRole::LABEL;
421 }
422 }
423 if (GetRoleType() == 0)
424 return AccessibleRole::LIST_ITEM;
425 else
426 //o is: return AccessibleRole::LABEL;
427 return AccessibleRole::TREE_ITEM;
428 }
429
431 {
432 SolarMutexGuard aSolarGuard;
433 ::osl::MutexGuard aGuard( m_aMutex );
434
435 if( getAccessibleRole() == AccessibleRole::TREE_ITEM )
436 {
437 return OUString();
438 }
439 return m_pTreeListBox->GetEntryAccessibleDescription(
440 m_pTreeListBox->GetEntryFromPath(m_aEntryPath));
441 }
442
444 {
445 ::osl::MutexGuard aGuard( m_aMutex );
446
448
449 return implGetText();
450 }
451
453 {
456 if ( m_aEntryPath.size() > 1 ) // not a root entry
457 xParent = implGetParentAccessible();
458 if ( xParent.is() )
459 {
461 Sequence< Reference< XInterface > > aSequence { xParent };
462 pRelationSetHelper->AddRelation(
463 AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF, aSequence ) );
464 xRelSet = pRelationSetHelper;
465 }
466 return xRelSet;
467 }
468
470 {
471 ::osl::MutexGuard aGuard( m_aMutex );
472
473 sal_Int64 nStateSet = 0;
474
475 if ( IsAlive_Impl() )
476 {
477 switch(getAccessibleRole())
478 {
479 case AccessibleRole::LABEL:
480 nStateSet |= AccessibleStateType::TRANSIENT;
481 nStateSet |= AccessibleStateType::SELECTABLE;
482 nStateSet |= AccessibleStateType::ENABLED;
483 if (m_pTreeListBox->IsInplaceEditingEnabled())
484 nStateSet |= AccessibleStateType::EDITABLE;
485 if (IsShowing_Impl())
486 nStateSet |= AccessibleStateType::SHOWING;
487 break;
488 case AccessibleRole::CHECK_BOX:
489 nStateSet |= AccessibleStateType::TRANSIENT;
490 nStateSet |= AccessibleStateType::SELECTABLE;
491 nStateSet |= AccessibleStateType::ENABLED;
492 if (IsShowing_Impl())
493 nStateSet |= AccessibleStateType::SHOWING;
494 break;
495 }
496 SvTreeListEntry *pEntry = m_pTreeListBox->GetEntryFromPath(m_aEntryPath);
497 if (pEntry)
498 m_pTreeListBox->FillAccessibleEntryStateSet(pEntry, nStateSet);
499 }
500 else
501 nStateSet |= AccessibleStateType::DEFUNC;
502
503 return nStateSet;
504 }
505
507 {
508 SolarMutexGuard aSolarGuard;
509 ::osl::MutexGuard aGuard( m_aMutex );
510
511 return implGetLocale();
512 }
513
514 // XAccessibleComponent
515
516 sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint )
517 {
518 return tools::Rectangle( Point(), GetBoundingBox().GetSize() ).Contains( VCLPoint( rPoint ) );
519 }
520
522 {
523 SolarMutexGuard aSolarGuard;
524 ::osl::MutexGuard aGuard( m_aMutex );
525
527 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( VCLPoint( _aPoint ) );
528 if ( !pEntry )
529 throw RuntimeException("AccessibleListBoxEntry::getAccessibleAtPoint - pEntry cannot be empty!");
530
533 assert(xListBox.is());
534 auto pAccEntry = m_rListBox.implGetAccessible(*pEntry);
535 tools::Rectangle aRect = pAccEntry->GetBoundingBox_Impl();
536 if ( aRect.Contains( VCLPoint( _aPoint ) ) )
537 xAcc = pAccEntry.get();
538 return xAcc;
539 }
540
541 awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds( )
542 {
543 return AWTRectangle( GetBoundingBox() );
544 }
545
547 {
548 return AWTPoint( GetBoundingBox().TopLeft() );
549 }
550
552 {
554 }
555
557 {
558 return AWTSize( GetBoundingBox().GetSize() );
559 }
560
562 {
563 // do nothing, because no focus for each item
564 }
565
567 {
568 SolarMutexGuard aSolarGuard;
569 ::osl::MutexGuard aGuard( m_aMutex );
570
571 sal_Int32 nColor = 0;
573 if ( xParent.is() )
574 {
575 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
576 if ( xParentComp.is() )
577 nColor = xParentComp->getForeground();
578 }
579
580 return nColor;
581 }
582
584 {
585 SolarMutexGuard aSolarGuard;
586 ::osl::MutexGuard aGuard( m_aMutex );
587
588 sal_Int32 nColor = 0;
590 if ( xParent.is() )
591 {
592 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
593 if ( xParentComp.is() )
594 nColor = xParentComp->getBackground();
595 }
596
597 return nColor;
598 }
599
600 // XAccessibleText
601
602
603 awt::Rectangle SAL_CALL AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex )
604 {
605 SolarMutexGuard aSolarGuard;
606 ::osl::MutexGuard aGuard( m_aMutex );
607
609
611 throw IndexOutOfBoundsException();
612
613 awt::Rectangle aBounds( 0, 0, 0, 0 );
614 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
615 if ( pEntry )
616 {
617 vcl::ControlLayoutData aLayoutData;
618 tools::Rectangle aItemRect = GetBoundingBox();
619 m_pTreeListBox->RecordLayoutData( &aLayoutData, aItemRect );
620 tools::Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex );
621 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
622 aBounds = AWTRectangle( aCharRect );
623 }
624
625 return aBounds;
626 }
627
628 sal_Int32 SAL_CALL AccessibleListBoxEntry::getIndexAtPoint( const awt::Point& aPoint )
629 {
630 SolarMutexGuard aSolarGuard;
631 ::osl::MutexGuard aGuard( m_aMutex );
633 if(aPoint.X==0 && aPoint.Y==0) return 0;
634
635 sal_Int32 nIndex = -1;
636 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
637 if ( pEntry )
638 {
639 vcl::ControlLayoutData aLayoutData;
640 tools::Rectangle aItemRect = GetBoundingBox();
641 m_pTreeListBox->RecordLayoutData( &aLayoutData, aItemRect );
642 Point aPnt( VCLPoint( aPoint ) );
643 aPnt += aItemRect.TopLeft();
644 nIndex = aLayoutData.GetIndexForPoint( aPnt );
645 }
646
647 return nIndex;
648 }
649
650 sal_Bool SAL_CALL AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
651 {
652 SolarMutexGuard aSolarGuard;
653 ::osl::MutexGuard aGuard( m_aMutex );
655
656 OUString sText = implGetText();
657 if ( ( 0 > nStartIndex ) || ( sText.getLength() <= nStartIndex )
658 || ( 0 > nEndIndex ) || ( sText.getLength() <= nEndIndex ) )
659 throw IndexOutOfBoundsException();
660
661 sal_Int32 nLen = nEndIndex - nStartIndex + 1;
662 ::svt::OStringTransfer::CopyString( sText.copy( nStartIndex, nLen ), m_pTreeListBox );
663
664 return true;
665 }
666
667 sal_Bool SAL_CALL AccessibleListBoxEntry::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType )
668 {
669 return false;
670 }
671
672 // XAccessibleEventBroadcaster
673
675 {
676 if (xListener.is())
677 {
678 ::osl::MutexGuard aGuard( m_aMutex );
679 if (!m_nClientId)
682 }
683 }
684
686 {
687 if (!xListener.is())
688 return;
689
690 ::osl::MutexGuard aGuard( m_aMutex );
691
692 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
693 if ( !nListenerCount )
694 {
695 // no listeners anymore
696 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
697 // and at least to us not firing any events anymore, in case somebody calls
698 // NotifyAccessibleEvent, again
699 sal_Int32 nId = m_nClientId;
700 m_nClientId = 0;
702
703 }
704 }
705
706 // XAccessibleAction
707
709 {
710 ::osl::MutexGuard aGuard( m_aMutex );
711
712 // three actions supported
713 SvTreeFlags treeFlag = m_pTreeListBox->GetTreeFlags();
714 bool bHasButtons = (m_pTreeListBox->GetStyle() & WB_HASBUTTONS)!=0;
715 if( (treeFlag & SvTreeFlags::CHKBTN) && !bHasButtons)
716 {
717 sal_Int16 role = getAccessibleRole();
718 if ( role == AccessibleRole::CHECK_BOX )
719 return 2;
720 else if ( role == AccessibleRole::LABEL )
721 return 0;
722 }
723 else
725 return 0;
726 }
727
729 {
730 SolarMutexGuard aSolarGuard;
731 ::osl::MutexGuard aGuard( m_aMutex );
732
733 bool bRet = false;
734 checkActionIndex_Impl( nIndex );
736
737 SvTreeFlags treeFlag = m_pTreeListBox->GetTreeFlags();
738 if( nIndex == 0 && (treeFlag & SvTreeFlags::CHKBTN) )
739 {
740 if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
741 {
742 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
743 SvButtonState state = m_pTreeListBox->GetCheckButtonState( pEntry );
744 if ( state == SvButtonState::Checked )
745 m_pTreeListBox->SetCheckButtonState(pEntry, SvButtonState::Unchecked);
746 else if (state == SvButtonState::Unchecked)
747 m_pTreeListBox->SetCheckButtonState(pEntry, SvButtonState::Checked);
748 }
749 }
750 else if( (nIndex == 1 && (treeFlag & SvTreeFlags::CHKBTN) ) || (nIndex == 0) )
751 {
752 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
753 if ( pEntry )
754 {
755 if ( m_pTreeListBox->IsExpanded( pEntry ) )
756 m_pTreeListBox->Collapse( pEntry );
757 else
758 m_pTreeListBox->Expand( pEntry );
759 bRet = true;
760 }
761 }
762
763 return bRet;
764 }
765
766 OUString SAL_CALL AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex )
767 {
768 SolarMutexGuard aSolarGuard;
769 ::osl::MutexGuard aGuard( m_aMutex );
770
771 checkActionIndex_Impl( nIndex );
773
774 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
775 SvButtonState state = m_pTreeListBox->GetCheckButtonState( pEntry );
776 SvTreeFlags treeFlag = m_pTreeListBox->GetTreeFlags();
777 if(nIndex == 0 && (treeFlag & SvTreeFlags::CHKBTN))
778 {
779 if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
780 {
781 if ( state == SvButtonState::Checked )
782 return "UnCheck";
783 else if (state == SvButtonState::Unchecked)
784 return "Check";
785 }
786 else
787 {
788 //Sometimes, a List or Tree may have both checkbox and label at the same time
789 return OUString();
790 }
791 }else if( (nIndex == 1 && (treeFlag & SvTreeFlags::CHKBTN)) || nIndex == 0 )
792 {
793 if( pEntry->HasChildren() || pEntry->HasChildrenOnDemand() )
794 return m_pTreeListBox->IsExpanded( pEntry ) ?
795 AccResId(STR_SVT_ACC_ACTION_COLLAPSE) :
796 AccResId(STR_SVT_ACC_ACTION_EXPAND);
797 return OUString();
798
799 }
800 throw IndexOutOfBoundsException();
801 }
802
804 {
806 checkActionIndex_Impl( nIndex );
807 // ... which key?
808 return xRet;
809 }
810
811 // XAccessibleSelection
812
813 void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int64 nChildIndex )
814 {
815 SolarMutexGuard aSolarGuard;
816 ::osl::MutexGuard aGuard( m_aMutex );
817
819
820 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
821 throw IndexOutOfBoundsException();
822
823 SvTreeListEntry* pEntry = GetRealChild(nChildIndex);
824 if ( !pEntry )
825 throw IndexOutOfBoundsException();
826
827 m_pTreeListBox->Select( pEntry );
828 }
829
831 {
832 SolarMutexGuard aSolarGuard;
833 ::osl::MutexGuard aGuard( m_aMutex );
834
836
837 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
838 throw IndexOutOfBoundsException();
839
840 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
841 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, nChildIndex );
842 if ( !pEntry )
843 throw IndexOutOfBoundsException();
844
845 return m_pTreeListBox->IsSelected( pEntry );
846 }
847
849 {
850 SolarMutexGuard aSolarGuard;
851 ::osl::MutexGuard aGuard( m_aMutex );
852
854
855 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
856 if ( !pParent )
857 throw RuntimeException("AccessibleListBoxEntry::clearAccessibleSelection - pParent cannot be empty!");
858 sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
859 for ( sal_Int32 i = 0; i < nCount; ++i )
860 {
861 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
862 if ( m_pTreeListBox->IsSelected( pEntry ) )
863 m_pTreeListBox->Select( pEntry, false );
864 }
865 }
866
868 {
869 SolarMutexGuard aSolarGuard;
870 ::osl::MutexGuard aGuard( m_aMutex );
871
873
874 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
875 if ( !pParent )
876 throw RuntimeException("AccessibleListBoxEntry::selectAllAccessibleChildren - pParent cannot be empty!");
877 sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
878 for ( sal_Int32 i = 0; i < nCount; ++i )
879 {
880 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
881 if ( !m_pTreeListBox->IsSelected( pEntry ) )
882 m_pTreeListBox->Select( pEntry );
883 }
884 }
885
887 {
888 SolarMutexGuard aSolarGuard;
889 ::osl::MutexGuard aGuard( m_aMutex );
890
892
893 sal_Int64 nSelCount = 0;
894
895 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
896 if ( !pParent )
897 throw RuntimeException("AccessibleListBoxEntry::getSelectedAccessibleChildCount - pParent cannot be empty!");
898 sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
899 for (sal_Int32 i = 0; i < nCount; ++i )
900 {
901 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
902 if ( m_pTreeListBox->IsSelected( pEntry ) )
903 ++nSelCount;
904 }
905
906 return nSelCount;
907 }
908
910 {
911 SolarMutexGuard aSolarGuard;
912 ::osl::MutexGuard aGuard( m_aMutex );
913
915
916 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
917 throw IndexOutOfBoundsException();
918
920 sal_Int64 nSelCount = 0;
921
922 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
923 if ( !pParent )
924 throw RuntimeException("AccessibleListBoxEntry::getSelectedAccessibleChild - pParent cannot be empty!");
925 sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
926 for (sal_Int32 i = 0; i < nCount; ++i )
927 {
928 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
929 if ( m_pTreeListBox->IsSelected( pEntry ) )
930 ++nSelCount;
931
932 if ( nSelCount == ( nSelectedChildIndex + 1 ) )
933 {
935 assert(xListBox.is());
936 xChild = m_rListBox.implGetAccessible(*pEntry).get();
937 break;
938 }
939 }
940
941 return xChild;
942 }
943
944 void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int64 nSelectedChildIndex )
945 {
946 SolarMutexGuard aSolarGuard;
947 ::osl::MutexGuard aGuard( m_aMutex );
948
950
951 if (nSelectedChildIndex < 0 || nSelectedChildIndex >= getAccessibleChildCount())
952 throw IndexOutOfBoundsException();
953
954 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
955 SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, nSelectedChildIndex );
956 if ( !pEntry )
957 throw IndexOutOfBoundsException();
958
959 m_pTreeListBox->Select( pEntry, false );
960 }
962 {
963 return -1;
964 }
966 {
967 SolarMutexGuard aSolarGuard;
968 ::osl::MutexGuard aGuard( m_aMutex );
970
972 throw IndexOutOfBoundsException();
973
974 return false;
975 }
977 {
978 SolarMutexGuard aSolarGuard;
979 ::osl::MutexGuard aGuard( m_aMutex );
982 }
983 css::uno::Sequence< css::beans::PropertyValue > SAL_CALL AccessibleListBoxEntry::getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& )
984 {
985 SolarMutexGuard aSolarGuard;
986 ::osl::MutexGuard aGuard( m_aMutex );
988
989 OUString sText( implGetText() );
990
991 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
992 throw IndexOutOfBoundsException();
993
994 return css::uno::Sequence< css::beans::PropertyValue >();
995 }
997 {
998 SolarMutexGuard aSolarGuard;
999 ::osl::MutexGuard aGuard( m_aMutex );
1000 EnsureIsAlive();
1001 return implGetText().getLength();
1002 }
1003
1005 {
1006 SolarMutexGuard aSolarGuard;
1007 ::osl::MutexGuard aGuard( m_aMutex );
1008 EnsureIsAlive();
1009 return OUString();
1010 }
1012 {
1013 SolarMutexGuard aSolarGuard;
1014 ::osl::MutexGuard aGuard( m_aMutex );
1015 EnsureIsAlive();
1016 return 0;
1017 }
1019 {
1020 SolarMutexGuard aSolarGuard;
1021 ::osl::MutexGuard aGuard( m_aMutex );
1022 EnsureIsAlive();
1023 return 0;
1024 }
1025 sal_Bool SAL_CALL AccessibleListBoxEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
1026 {
1027 SolarMutexGuard aSolarGuard;
1028 ::osl::MutexGuard aGuard( m_aMutex );
1029 EnsureIsAlive();
1030
1031 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
1032 throw IndexOutOfBoundsException();
1033
1034 return false;
1035 }
1037 {
1038 SolarMutexGuard aSolarGuard;
1039 ::osl::MutexGuard aGuard( m_aMutex );
1040 EnsureIsAlive();
1041 return implGetText( );
1042 }
1043 OUString SAL_CALL AccessibleListBoxEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
1044 {
1045 SolarMutexGuard aSolarGuard;
1046 ::osl::MutexGuard aGuard( m_aMutex );
1047 EnsureIsAlive();
1048 return OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex );
1049 }
1050 css::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1051 {
1052 SolarMutexGuard aSolarGuard;
1053 ::osl::MutexGuard aGuard( m_aMutex );
1054 EnsureIsAlive();
1056 }
1057 css::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1058 {
1059 SolarMutexGuard aSolarGuard;
1060 ::osl::MutexGuard aGuard( m_aMutex );
1061 EnsureIsAlive();
1063 }
1064 css::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType )
1065 {
1066 SolarMutexGuard aSolarGuard;
1067 ::osl::MutexGuard aGuard( m_aMutex );
1068 EnsureIsAlive();
1069
1071 }
1072
1073 // XAccessibleValue
1074
1075
1077 {
1078 ::osl::MutexGuard aGuard( m_aMutex );
1079 Any aValue;
1080 sal_Int32 level = static_cast<sal_Int32>(m_aEntryPath.size()) - 1;
1081 level = level < 0 ? 0: level;
1082 aValue <<= level;
1083 return aValue;
1084 }
1085
1086
1088 {
1089 ::osl::MutexGuard aGuard( m_aMutex );
1090
1091
1092 bool bReturn = false;
1094 if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
1095 {
1097 if ( pEntry )
1098 {
1099 sal_Int32 nValue(0), nValueMin(0), nValueMax(0);
1100 aNumber >>= nValue;
1101 getMinimumValue() >>= nValueMin;
1102 getMaximumValue() >>= nValueMax;
1103
1104 if ( nValue < nValueMin )
1105 nValue = nValueMin;
1106 else if ( nValue > nValueMax )
1107 nValue = nValueMax;
1108
1109 pBox->SetCheckButtonState(pEntry, static_cast<SvButtonState>(nValue) );
1110 bReturn = true;
1111 }
1112 }
1113
1114 return bReturn;
1115 }
1116
1117
1119 {
1120 ::osl::MutexGuard aGuard( m_aMutex );
1121
1122 Any aValue;
1123 // SvTreeListBox* pBox = m_pTreeListBox;
1124 switch(getAccessibleRole())
1125 {
1126 case AccessibleRole::CHECK_BOX:
1127 aValue <<= sal_Int32(1);
1128 break;
1129 case AccessibleRole::LABEL:
1130 default:
1131 break;
1132 }
1133
1134 return aValue;
1135 }
1136
1137
1139 {
1140 ::osl::MutexGuard aGuard( m_aMutex );
1141
1142 Any aValue;
1143 // SvTreeListBox* pBox = m_pTreeListBox;
1144 switch(getAccessibleRole())
1145 {
1146 case AccessibleRole::CHECK_BOX:
1147 aValue <<= sal_Int32(0);
1148 break;
1149 case AccessibleRole::LABEL:
1150 default:
1151 break;
1152 }
1153
1154 return aValue;
1155 }
1156
1158 {
1159 ::osl::MutexGuard aGuard( m_aMutex );
1160
1161 Any aValue;
1162 switch(getAccessibleRole())
1163 {
1164 case AccessibleRole::CHECK_BOX:
1165 aValue <<= sal_Int32(1);
1166 break;
1167 case AccessibleRole::LABEL:
1168 default:
1169 break;
1170 }
1171
1172 return aValue;
1173 }
1174
1176 {
1177 SvTreeListEntry* pEntry = nullptr;
1178 SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
1179 if (pParent)
1180 {
1181 pEntry = m_pTreeListBox->GetEntry( pParent, nIndex );
1182 if ( !pEntry && getAccessibleChildCount() > 0 )
1183 {
1184 m_pTreeListBox->RequestingChildren(pParent);
1185 pEntry = m_pTreeListBox->GetEntry( pParent, nIndex );
1186 }
1187 }
1188 return pEntry;
1189 }
1190
1191}// namespace accessibility
1192
1193
1194/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ACCESSIBLE_ACTION_COUNT
OUString AccResId(TranslateId aId)
Definition: accresmgr.cxx:22
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
SvTreeListEntry * GetEntryFromPath(const ::std::deque< sal_Int32 > &_rPath) const
SvTreeFlags GetTreeFlags() const
void SetCheckButtonState(SvTreeListEntry *, SvButtonState)
void FillEntryPath(SvTreeListEntry *pEntry, ::std::deque< sal_Int32 > &_rPath) const
SvButtonState GetCheckButtonState(SvTreeListEntry *) const
static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry *pEntry)
bool HasChildren() const
bool HasChildrenOnDemand() const
the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry
css::uno::WeakReference< css::accessibility::XAccessible > m_wListBox
virtual css::awt::Rectangle SAL_CALL getBounds() override
void SAL_CALL selectAllAccessibleChildren() override
css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
virtual void SAL_CALL disposing() override
this function is called upon disposing the component
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::lang::Locale SAL_CALL getLocale() override
virtual css::awt::Point SAL_CALL getLocation() override
virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding(sal_Int32 nIndex) override
css::uno::Reference< css::accessibility::XAccessible > implGetParentAccessible() const
virtual sal_Bool SAL_CALL setCurrentValue(const css::uno::Any &aNumber) override
virtual sal_Int32 SAL_CALL getCaretPosition() override
virtual sal_Int32 SAL_CALL getSelectionEnd() override
void NotifyAccessibleEvent(sal_Int16 _nEventId, const css::uno::Any &_aOldValue, const css::uno::Any &_aNewValue)
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getAccessibleName() override
sal_uInt32 m_nClientId
client id in the AccessibleEventNotifier queue
SvTreeListEntry * GetRealChild(sal_Int32 nIndex)
virtual OUString SAL_CALL getText() override
tools::Rectangle GetBoundingBoxOnScreen_Impl() const
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
std::deque< sal_Int32 > m_aEntryPath
The treelistbox control.
AccessibleListBoxEntry(SvTreeListBox &_rListBox, SvTreeListEntry &rEntry, AccessibleListBox &rListBox)
Ctor()
virtual css::awt::Size SAL_CALL getSize() override
virtual sal_Int32 SAL_CALL getAccessibleActionCount() override
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
virtual css::uno::Any SAL_CALL getMinimumIncrement() override
virtual sal_Int32 SAL_CALL getSelectionStart() override
sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void implGetSelection(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex) override
virtual css::uno::Any SAL_CALL getMaximumValue() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
virtual sal_Int32 SAL_CALL getBackground() override
void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
virtual OUString SAL_CALL getAccessibleActionDescription(sal_Int32 nIndex) override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
void SAL_CALL deselectAccessibleChild(sal_Int64 nSelectedChildIndex) override
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
virtual sal_Int32 SAL_CALL getCharacterCount() override
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
virtual css::uno::Any SAL_CALL getCurrentValue() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual css::uno::Any SAL_CALL getMinimumValue() override
virtual css::lang::Locale implGetLocale() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
virtual sal_Bool SAL_CALL doAccessibleAction(sal_Int32 nIndex) override
virtual OUString SAL_CALL getSelectedText() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &aPoint) override
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox ent...
rtl::Reference< AccessibleListBoxEntry > implGetAccessible(SvTreeListEntry &rEntry)
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void revokeClient(const TClientId _nClient)
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
css::accessibility::TextSegment getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType)
css::accessibility::TextSegment getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType)
static bool implIsValidIndex(sal_Int32 nIndex, sal_Int32 nLength)
static bool implIsValidRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength)
static sal_Unicode implGetCharacter(std::u16string_view rText, sal_Int32 nIndex)
css::accessibility::TextSegment getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType)
static OUString implGetTextRange(std::u16string_view rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex)
mutable::osl::Mutex m_aMutex
static SVT_DLLPUBLIC void CopyString(const OUString &_rContent, vcl::Window *_pWindow)
bool Contains(const Point &rPOINT) const
bool Overlaps(const tools::Rectangle &rRect) const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Left() const
css::awt::Size AWTSize(const Size &rVCLSize)
css::awt::Point AWTPoint(const ::Point &rVCLPoint)
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
inline ::tools::Rectangle VCLRectangle(const css::awt::Rectangle &rAWTRect)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
int nCount
ULONG m_refCount
sal_Int16 nValue
std::mutex m_aMutex
sal_Int32 nIndex
IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener, VclWindowEvent &, rEvent, void)
double getLength(const B2DPolygon &rCandidate)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
void dispose()
sal_Int16 nId
tools::Long GetIndexForPoint(const Point &rPoint) const
tools::Rectangle GetCharacterBounds(tools::Long nIndex) const
SvButtonState
SvTreeFlags
unsigned char sal_Bool
sal_uInt16 sal_Unicode
WinBits const WB_HASBUTTONS