LibreOffice Module svtools (master) 1
valueacc.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
20#include <vcl/svapp.hxx>
21#include <vcl/settings.hxx>
22#include <sal/log.hxx>
23#include <tools/debug.hxx>
25#include <svtools/valueset.hxx>
26#include "valueimp.hxx"
28#include <com/sun/star/accessibility/AccessibleEventId.hpp>
29#include <com/sun/star/accessibility/AccessibleRole.hpp>
30#include <com/sun/star/accessibility/AccessibleStateType.hpp>
31#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
32
33using namespace ::com::sun::star;
34
35
37 : mrParent(rParent)
38 , mpData(nullptr)
39 , mxAcc()
40 , mnId(0)
42 , mbVisible(true)
43{
44}
45
46
48{
49 if( mxAcc.is() )
50 {
51 mxAcc->ParentDestroyed();
52 }
53}
54
55uno::Reference< accessibility::XAccessible > ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled )
56{
57 if( !mxAcc.is() )
58 mxAcc = new ValueItemAcc( this, bIsTransientChildrenDisabled );
59
60 return mxAcc;
61}
62
63ValueItemAcc::ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled ) :
64 mpParent( pParent ),
65 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
66{
67}
68
70{
71}
72
74{
75 std::scoped_lock aGuard( maMutex );
76 mpParent = nullptr;
77}
78
79ValueItemAcc* ValueItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
80 noexcept
81{
82 return dynamic_cast<ValueItemAcc*>(rxData.get());
83}
84
85
86uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueItemAcc::getAccessibleContext()
87{
88 return this;
89}
90
91
93{
94 return 0;
95}
96
97
98uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleChild( sal_Int64 )
99{
100 throw lang::IndexOutOfBoundsException();
101}
102
103
104uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleParent()
105{
106 const SolarMutexGuard aSolarGuard;
107 uno::Reference< accessibility::XAccessible > xRet;
108
109 if( mpParent )
111
112 return xRet;
113}
114
115
117{
118 const SolarMutexGuard aSolarGuard;
119 // The index defaults to -1 to indicate the child does not belong to its
120 // parent.
121 sal_Int64 nIndexInParent = -1;
122
123 if( mpParent )
124 {
125 bool bDone = false;
126
128 ValueSetItem* pItem;
129 for (sal_uInt16 i=0; i<nCount && !bDone; i++)
130 {
131 // Guard the retrieval of the i-th child with a try/catch block
132 // just in case the number of children changes in the meantime.
133 try
134 {
135 pItem = mpParent->mrParent.ImplGetItem(i);
136 }
137 catch (const lang::IndexOutOfBoundsException&)
138 {
139 pItem = nullptr;
140 }
141
142 // Do not create an accessible object for the test.
143 if (pItem != nullptr && pItem->mxAcc.is())
144 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
145 {
146 nIndexInParent = i;
147 bDone = true;
148 }
149 }
150 }
151
152 //if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0.
153 if ( mpParent && ( (mpParent->mrParent.GetStyle() & WB_NONEFIELD) != 0 ) )
154 {
156 if( pFirstItem && pFirstItem ->GetAccessible(mbIsTransientChildrenDisabled).get() == this )
157 nIndexInParent = 0;
158 else
159 nIndexInParent++;
160 }
161 return nIndexInParent;
162}
163
164
166{
167 return accessibility::AccessibleRole::LIST_ITEM;
168}
169
170
172{
173 return OUString();
174}
175
176
178{
179 const SolarMutexGuard aSolarGuard;
180
181 if( mpParent )
182 {
183 if (mpParent->maText.isEmpty())
184 return "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId));
185 else
186 return mpParent->maText;
187 }
188
189 return OUString();
190}
191
192
193uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::getAccessibleRelationSet()
194{
195 return uno::Reference< accessibility::XAccessibleRelationSet >();
196}
197
198
200{
201 const SolarMutexGuard aSolarGuard;
202 sal_Int64 nStateSet = 0;
203
204 if( mpParent )
205 {
206 nStateSet |= accessibility::AccessibleStateType::ENABLED;
207 nStateSet |= accessibility::AccessibleStateType::SENSITIVE;
208 nStateSet |= accessibility::AccessibleStateType::SHOWING;
209 nStateSet |= accessibility::AccessibleStateType::VISIBLE;
211 nStateSet |= accessibility::AccessibleStateType::TRANSIENT;
212
213 nStateSet |= accessibility::AccessibleStateType::SELECTABLE;
214 nStateSet |= accessibility::AccessibleStateType::FOCUSABLE;
215
217 {
218
219 nStateSet |= accessibility::AccessibleStateType::SELECTED;
221 nStateSet |= accessibility::AccessibleStateType::FOCUSED;
222 }
223 }
224
225 return nStateSet;
226}
227
228
229lang::Locale SAL_CALL ValueItemAcc::getLocale()
230{
231 const SolarMutexGuard aSolarGuard;
232 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
233 lang::Locale aRet( "", "", "" );
234
235 if( xParent.is() )
236 {
237 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
238
239 if( xParentContext.is() )
240 aRet = xParentContext->getLocale();
241 }
242
243 return aRet;
244}
245
246
247void SAL_CALL ValueItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
248{
249 std::scoped_lock aGuard( maMutex );
250
251 if( !rxListener.is() )
252 return;
253
254 bool bFound = false;
255
256 for (auto const& eventListener : mxEventListeners)
257 {
258 if(eventListener == rxListener)
259 {
260 bFound = true;
261 break;
262 }
263 }
264
265 if (!bFound)
266 mxEventListeners.push_back( rxListener );
267}
268
269
270void SAL_CALL ValueItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
271{
272 std::scoped_lock aGuard( maMutex );
273
274 if( rxListener.is() )
275 {
276 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
277 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
278
279 if (aIter != mxEventListeners.end())
280 mxEventListeners.erase(aIter);
281 }
282}
283
284
285sal_Bool SAL_CALL ValueItemAcc::containsPoint( const awt::Point& aPoint )
286{
287 const awt::Rectangle aRect( getBounds() );
288 const Point aSize( aRect.Width, aRect.Height );
289 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
290
291 return tools::Rectangle( aNullPoint, aSize ).Contains( aTestPoint );
292}
293
294uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleAtPoint( const awt::Point& )
295{
296 uno::Reference< accessibility::XAccessible > xRet;
297 return xRet;
298}
299
300awt::Rectangle SAL_CALL ValueItemAcc::getBounds()
301{
302 const SolarMutexGuard aSolarGuard;
303 awt::Rectangle aRet;
304
305 if( mpParent )
306 {
309
310 aRect.Intersection( aParentRect );
311
312 aRet.X = aRect.Left();
313 aRet.Y = aRect.Top();
314 aRet.Width = aRect.GetWidth();
315 aRet.Height = aRect.GetHeight();
316 }
317
318 return aRet;
319}
320
321awt::Point SAL_CALL ValueItemAcc::getLocation()
322{
323 const awt::Rectangle aRect( getBounds() );
324 awt::Point aRet;
325
326 aRet.X = aRect.X;
327 aRet.Y = aRect.Y;
328
329 return aRet;
330}
331
333{
334 const SolarMutexGuard aSolarGuard;
335 awt::Point aRet;
336
337 if( mpParent )
338 {
341
342 aRet.X = aPos.X() + aScreenPos.X();
343 aRet.Y = aPos.Y() + aScreenPos.Y();
344 }
345
346 return aRet;
347}
348
349awt::Size SAL_CALL ValueItemAcc::getSize()
350{
351 const awt::Rectangle aRect( getBounds() );
352 awt::Size aRet;
353
354 aRet.Width = aRect.Width;
355 aRet.Height = aRect.Height;
356
357 return aRet;
358}
359
361{
362 // nothing to do
363}
364
365sal_Int32 SAL_CALL ValueItemAcc::getForeground( )
366{
368 return static_cast<sal_Int32>(nColor);
369}
370
371sal_Int32 SAL_CALL ValueItemAcc::getBackground( )
372{
373 Color nColor;
375 nColor = mpParent->maColor;
376 else
378 return static_cast<sal_Int32>(nColor);
379}
380
381void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
382{
383 if( !nEventId )
384 return;
385
386 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
387 accessibility::AccessibleEventObject aEvtObject;
388
389 aEvtObject.EventId = nEventId;
390 aEvtObject.Source = getXWeak();
391 aEvtObject.NewValue = rNewValue;
392 aEvtObject.OldValue = rOldValue;
393
394 for (auto const& tmpListener : aTmpListeners)
395 {
396 tmpListener->notifyEvent( aEvtObject );
397 }
398}
399
401 mpParent( pParent ),
402 mbIsFocused(false)
403{
404}
405
406
408{
409}
410
411
412void ValueSetAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
413{
414 if( !nEventId )
415 return;
416
417 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
418 accessibility::AccessibleEventObject aEvtObject;
419
420 aEvtObject.EventId = nEventId;
421 aEvtObject.Source = getXWeak();
422 aEvtObject.NewValue = rNewValue;
423 aEvtObject.OldValue = rOldValue;
424 aEvtObject.IndexHint = -1;
425
426 for (auto const& tmpListener : aTmpListeners)
427 {
428 try
429 {
430 tmpListener->notifyEvent( aEvtObject );
431 }
432 catch(const uno::Exception&)
433 {
434 }
435 }
436}
437
438ValueSetAcc* ValueSetAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
439 noexcept
440{
441 return dynamic_cast<ValueSetAcc*>(rxData.get());
442}
443
444
446{
447 mbIsFocused = true;
448
449 // Broadcast the state change.
450 css::uno::Any aOldState, aNewState;
451 aNewState <<= css::accessibility::AccessibleStateType::FOCUSED;
453 css::accessibility::AccessibleEventId::STATE_CHANGED,
454 aOldState, aNewState);
455}
456
457
459{
460 mbIsFocused = false;
461
462 // Broadcast the state change.
463 css::uno::Any aOldState, aNewState;
464 aOldState <<= css::accessibility::AccessibleStateType::FOCUSED;
466 css::accessibility::AccessibleEventId::STATE_CHANGED,
467 aOldState, aNewState);
468}
469
470
471uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueSetAcc::getAccessibleContext()
472{
474 return this;
475}
476
477
479{
480 const SolarMutexGuard aSolarGuard;
482
484 if (HasNoneField())
485 nCount += 1;
486 return nCount;
487}
488
489
490uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleChild( sal_Int64 i )
491{
493 const SolarMutexGuard aSolarGuard;
494
495 if (i < 0 || i >= getAccessibleChildCount())
496 throw lang::IndexOutOfBoundsException();
497
498 ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
499
500 if( !pItem )
501 throw lang::IndexOutOfBoundsException();
502
503 uno::Reference< accessibility::XAccessible > xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
504 return xRet;
505}
506
507uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleParent()
508{
510 const SolarMutexGuard aSolarGuard;
512}
513
515{
517 const SolarMutexGuard aSolarGuard;
518
519 // -1 for child not found/no parent (according to specification)
520 sal_Int64 nRet = -1;
521
522 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
523 if (!xParent)
524 return nRet;
525
526 try
527 {
528 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
529
530 // iterate over parent's children and search for this object
531 if ( xParentContext.is() )
532 {
533 sal_Int64 nChildCount = xParentContext->getAccessibleChildCount();
534 for ( sal_Int64 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild )
535 {
536 uno::Reference<XAccessible> xChild(xParentContext->getAccessibleChild(nChild));
537 if ( xChild.get() == this )
538 nRet = nChild;
539 }
540 }
541 }
542 catch (const uno::Exception&)
543 {
544 TOOLS_WARN_EXCEPTION( "svtools", "ValueSetAcc::getAccessibleIndexInParent" );
545 }
546
547 return nRet;
548}
549
551{
553 return accessibility::AccessibleRole::LIST;
554}
555
556
558{
560 const SolarMutexGuard aSolarGuard;
561 OUString aRet;
562
563 if (mpParent)
564 {
566 }
567
568 return aRet;
569}
570
571
573{
575 const SolarMutexGuard aSolarGuard;
576 OUString aRet;
577
578 if (mpParent)
579 {
580 aRet = mpParent->GetAccessibleName();
581 }
582
583 return aRet;
584}
585
586uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::getAccessibleRelationSet()
587{
591}
592
594{
596 sal_Int64 nStateSet = 0;
597
598 // Set some states.
599 nStateSet |= accessibility::AccessibleStateType::ENABLED;
600 nStateSet |= accessibility::AccessibleStateType::SENSITIVE;
601 nStateSet |= accessibility::AccessibleStateType::SHOWING;
602 nStateSet |= accessibility::AccessibleStateType::VISIBLE;
603 nStateSet |= accessibility::AccessibleStateType::MANAGES_DESCENDANTS;
604 nStateSet |= accessibility::AccessibleStateType::FOCUSABLE;
605 if (mbIsFocused)
606 nStateSet |= accessibility::AccessibleStateType::FOCUSED;
607
608 return nStateSet;
609}
610
611
612lang::Locale SAL_CALL ValueSetAcc::getLocale()
613{
615 const SolarMutexGuard aSolarGuard;
616 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
617 lang::Locale aRet( "", "", "" );
618
619 if( xParent.is() )
620 {
621 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
622
623 if( xParentContext.is() )
624 aRet = xParentContext->getLocale ();
625 }
626
627 return aRet;
628}
629
630
631void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
632{
634 std::unique_lock aGuard (m_aMutex);
635
636 if( !rxListener.is() )
637 return;
638
639 bool bFound = false;
640
641 for (auto const& eventListener : mxEventListeners)
642 {
643 if(eventListener == rxListener)
644 {
645 bFound = true;
646 break;
647 }
648 }
649
650 if (!bFound)
651 mxEventListeners.push_back( rxListener );
652}
653
654
655void SAL_CALL ValueSetAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
656{
658 std::unique_lock aGuard (m_aMutex);
659
660 if( rxListener.is() )
661 {
662 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
663 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
664
665 if (aIter != mxEventListeners.end())
666 mxEventListeners.erase(aIter);
667 }
668}
669
670
671sal_Bool SAL_CALL ValueSetAcc::containsPoint( const awt::Point& aPoint )
672{
674 const awt::Rectangle aRect( getBounds() );
675 const Point aSize( aRect.Width, aRect.Height );
676 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
677
678 return tools::Rectangle( aNullPoint, aSize ).Contains( aTestPoint );
679}
680
681
682uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
683{
685 const SolarMutexGuard aSolarGuard;
686 const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
687 uno::Reference< accessibility::XAccessible > xRet;
688
689 if ( nItemId )
690 {
691 const size_t nItemPos = mpParent->GetItemPos( nItemId );
692
693 if( VALUESET_ITEM_NONEITEM != nItemPos )
694 {
695 ValueSetItem *const pItem = mpParent->mItemList[nItemPos].get();
696 xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
697 }
698 }
699
700 return xRet;
701}
702
703
704awt::Rectangle SAL_CALL ValueSetAcc::getBounds()
705{
707 const SolarMutexGuard aSolarGuard;
708 const Point aOutPos;
709 const Size aOutSize( mpParent->GetOutputSizePixel() );
710 awt::Rectangle aRet;
711
712 aRet.X = aOutPos.X();
713 aRet.Y = aOutPos.Y();
714 aRet.Width = aOutSize.Width();
715 aRet.Height = aOutSize.Height();
716
717 return aRet;
718}
719
720awt::Point SAL_CALL ValueSetAcc::getLocation()
721{
723 const awt::Rectangle aRect( getBounds() );
724 awt::Point aRet;
725
726 aRet.X = aRect.X;
727 aRet.Y = aRect.Y;
728
729 return aRet;
730}
731
733{
735 const SolarMutexGuard aSolarGuard;
736 awt::Point aScreenLoc(0, 0);
737
738 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
739 if (xParent)
740 {
741 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
742 uno::Reference<accessibility::XAccessibleComponent> xParentComponent(xParentContext, css::uno::UNO_QUERY);
743 OSL_ENSURE( xParentComponent.is(), "ValueSetAcc::getLocationOnScreen: no parent component!" );
744 if ( xParentComponent.is() )
745 {
746 awt::Point aParentScreenLoc( xParentComponent->getLocationOnScreen() );
747 awt::Point aOwnRelativeLoc( getLocation() );
748 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X;
749 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y;
750 }
751 }
752
753 return aScreenLoc;
754}
755
756awt::Size SAL_CALL ValueSetAcc::getSize()
757{
759 const awt::Rectangle aRect( getBounds() );
760 awt::Size aRet;
761
762 aRet.Width = aRect.Width;
763 aRet.Height = aRect.Height;
764
765 return aRet;
766}
767
769{
771 const SolarMutexGuard aSolarGuard;
773}
774
775sal_Int32 SAL_CALL ValueSetAcc::getForeground( )
776{
779 return static_cast<sal_Int32>(nColor);
780}
781
782sal_Int32 SAL_CALL ValueSetAcc::getBackground( )
783{
786 return static_cast<sal_Int32>(nColor);
787}
788
789void SAL_CALL ValueSetAcc::selectAccessibleChild( sal_Int64 nChildIndex )
790{
792 const SolarMutexGuard aSolarGuard;
793
794 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
795 throw lang::IndexOutOfBoundsException();
796
797 ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
798
799 if(pItem == nullptr)
800 throw lang::IndexOutOfBoundsException();
801
802 mpParent->SelectItem( pItem->mnId );
803}
804
805
806sal_Bool SAL_CALL ValueSetAcc::isAccessibleChildSelected( sal_Int64 nChildIndex )
807{
809 const SolarMutexGuard aSolarGuard;
810
811 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
812 throw lang::IndexOutOfBoundsException();
813
814 ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
815
816 if (pItem == nullptr)
817 throw lang::IndexOutOfBoundsException();
818
819 bool bRet = mpParent->IsItemSelected( pItem->mnId );
820 return bRet;
821}
822
823
825{
827 const SolarMutexGuard aSolarGuard;
829}
830
831
833{
835 // unsupported due to single selection only
836}
837
838
840{
842 const SolarMutexGuard aSolarGuard;
843 sal_Int64 nRet = 0;
844
845 for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
846 {
847 ValueSetItem* pItem = getItem (i);
848
849 if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
850 ++nRet;
851 }
852
853 return nRet;
854}
855
856
857uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
858{
860 const SolarMutexGuard aSolarGuard;
861 uno::Reference< accessibility::XAccessible > xRet;
862
863 for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
864 {
865 ValueSetItem* pItem = getItem(i);
866
867 if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int64 >( nSel++ ) ) )
868 xRet = pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ );
869 }
870
871 return xRet;
872}
873
874
875void SAL_CALL ValueSetAcc::deselectAccessibleChild( sal_Int64 nChildIndex )
876{
878 const SolarMutexGuard aSolarGuard;
879
880 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
881 throw lang::IndexOutOfBoundsException();
882
883 // Because of the single selection we can reset the whole selection when
884 // the specified child is currently selected.
885 if (isAccessibleChildSelected(nChildIndex))
887}
888
889
890void ValueSetAcc::disposing(std::unique_lock<std::mutex>& rGuard)
891{
892 // Make a copy of the list and clear the original.
893 ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy = std::move(mxEventListeners);
894
895 // Reset the pointer to the parent. It has to be the one who has
896 // disposed us because he is dying.
897 mpParent = nullptr;
898
899 if (aListenerListCopy.empty())
900 return;
901
902 rGuard.unlock();
903 // Inform all listeners that this objects is disposing.
904 lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
905 for (auto const& listenerCopy : aListenerListCopy)
906 {
907 try
908 {
909 listenerCopy->disposing (aEvent);
910 }
911 catch(const uno::Exception&)
912 {
913 // Ignore exceptions.
914 }
915 }
916}
917
918
920{
922 // When the None-Item is visible then increase the number of items by
923 // one.
924 if (HasNoneField())
925 nCount += 1;
926 return nCount;
927}
928
929ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const
930{
931 ValueSetItem* pItem = nullptr;
932
933 if (HasNoneField())
934 {
935 if (nIndex == 0)
936 // When present the first item is the then always visible none field.
938 else
939 // Shift down the index to compensate for the none field.
940 nIndex -= 1;
941 }
942 if (pItem == nullptr)
943 pItem = mpParent->ImplGetItem (nIndex);
944
945 return pItem;
946}
947
948
950{
951 if (m_bDisposed)
952 {
953 SAL_WARN("svx", "Calling disposed object. Throwing exception:");
954 throw lang::DisposedException (
955 "object has been already disposed",
956 getXWeak());
957 }
958 else
959 {
960 DBG_ASSERT (mpParent!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
961 }
962}
963
965{
966 assert(mpParent && "ValueSetAcc::HasNoneField called with mpParent==NULL");
967 return ((mpParent->GetStyle() & WB_NONEFIELD) != 0);
968}
969
970/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BaseContainerNodeSharedPtr & mrParent
AnyEventRef aEvent
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetWindowColor() const
const Color & GetWindowTextColor() const
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: valueacc.cxx:247
virtual ~ValueItemAcc() override
Definition: valueacc.cxx:69
virtual sal_Int32 SAL_CALL getBackground() override
Definition: valueacc.cxx:371
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
Definition: valueacc.cxx:199
virtual sal_Int32 SAL_CALL getForeground() override
Definition: valueacc.cxx:365
virtual css::awt::Rectangle SAL_CALL getBounds() override
Definition: valueacc.cxx:300
static ValueItemAcc * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
Definition: valueacc.cxx:79
ValueItemAcc(ValueSetItem *pParent, bool bIsTransientChildrenDisabled)
Definition: valueacc.cxx:63
virtual OUString SAL_CALL getAccessibleDescription() override
Definition: valueacc.cxx:171
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: valueacc.cxx:104
ValueSetItem * mpParent
Definition: valueimp.hxx:193
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: valueacc.cxx:294
virtual void SAL_CALL grabFocus() override
Definition: valueacc.cxx:360
std::mutex maMutex
Definition: valueimp.hxx:192
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: valueacc.cxx:270
void FireAccessibleEvent(short nEventId, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue)
Definition: valueacc.cxx:381
virtual css::awt::Size SAL_CALL getSize() override
Definition: valueacc.cxx:349
virtual css::awt::Point SAL_CALL getLocation() override
Definition: valueacc.cxx:321
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Definition: valueacc.cxx:92
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Definition: valueacc.cxx:193
bool mbIsTransientChildrenDisabled
Definition: valueimp.hxx:194
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
Definition: valueacc.cxx:285
void ParentDestroyed()
Definition: valueacc.cxx:73
virtual OUString SAL_CALL getAccessibleName() override
Definition: valueacc.cxx:177
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: valueacc.cxx:165
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
Definition: valueacc.cxx:332
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
Definition: valueacc.cxx:86
virtual css::lang::Locale SAL_CALL getLocale() override
Definition: valueacc.cxx:229
::std::vector< css::uno::Reference< css::accessibility::XAccessibleEventListener > > mxEventListeners
Definition: valueimp.hxx:191
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
Definition: valueacc.cxx:98
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
Definition: valueacc.cxx:116
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Definition: valueacc.cxx:478
virtual sal_Int32 SAL_CALL getBackground() override
Definition: valueacc.cxx:782
virtual css::awt::Point SAL_CALL getLocation() override
Definition: valueacc.cxx:720
virtual css::awt::Size SAL_CALL getSize() override
Definition: valueacc.cxx:756
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Definition: valueacc.cxx:586
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
Definition: valueacc.cxx:471
virtual ~ValueSetAcc() override
Definition: valueacc.cxx:407
bool mbIsFocused
The current FOCUSED state.
Definition: valueimp.hxx:144
virtual void disposing(std::unique_lock< std::mutex > &) override
Tell all listeners that the object is dying.
Definition: valueacc.cxx:890
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: valueacc.cxx:550
static ValueSetAcc * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
Definition: valueacc.cxx:438
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: valueacc.cxx:655
void GetFocus()
Called by the corresponding ValueSet when it gets the focus.
Definition: valueacc.cxx:445
::std::vector< css::uno::Reference< css::accessibility::XAccessibleEventListener > > mxEventListeners
Definition: valueimp.hxx:141
ValueSet * mpParent
Definition: valueimp.hxx:142
virtual OUString SAL_CALL getAccessibleDescription() override
Definition: valueacc.cxx:557
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: valueacc.cxx:507
virtual void SAL_CALL clearAccessibleSelection() override
Definition: valueacc.cxx:824
void LoseFocus()
Called by the corresponding ValueSet when it loses the focus.
Definition: valueacc.cxx:458
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
Definition: valueacc.cxx:593
bool HasNoneField() const
Check whether the value set has a 'none' field, i.e.
Definition: valueacc.cxx:964
ValueSetAcc(ValueSet *pParent)
Definition: valueacc.cxx:400
virtual OUString SAL_CALL getAccessibleName() override
Definition: valueacc.cxx:572
virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
Definition: valueacc.cxx:789
virtual css::lang::Locale SAL_CALL getLocale() override
Definition: valueacc.cxx:612
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
Definition: valueacc.cxx:857
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: valueacc.cxx:832
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
Definition: valueacc.cxx:514
virtual css::awt::Rectangle SAL_CALL getBounds() override
Definition: valueacc.cxx:704
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
Definition: valueacc.cxx:806
virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
Definition: valueacc.cxx:839
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
Definition: valueacc.cxx:671
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: valueacc.cxx:631
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
Definition: valueacc.cxx:490
virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nSelectedChildIndex) override
Definition: valueacc.cxx:875
virtual void SAL_CALL grabFocus() override
Definition: valueacc.cxx:768
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: valueacc.cxx:682
void FireAccessibleEvent(short nEventId, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue)
Definition: valueacc.cxx:412
void ThrowIfDisposed()
Check whether or not the object has been disposed (or is in the state of being disposed).
Definition: valueacc.cxx:949
virtual sal_Int32 SAL_CALL getForeground() override
Definition: valueacc.cxx:775
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
Definition: valueacc.cxx:732
ValueSetItem * getItem(sal_uInt16 nIndex) const
Return the item associated with the given index.
Definition: valueacc.cxx:929
sal_uInt16 getItemCount() const
Return the number of items.
Definition: valueacc.cxx:919
void SelectItem(sal_uInt16 nItemId)
Definition: valueset.cxx:735
sal_uInt16 GetSelectedItemId() const
Definition: valueset.hxx:333
css::uno::Reference< css::accessibility::XAccessible > mxAccessible
Definition: valueset.hxx:188
SVT_DLLPRIVATE size_t ImplGetItem(const Point &rPoint) const
Definition: valueset.cxx:165
WinBits GetStyle() const
Definition: valueset.hxx:292
SVT_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const
Definition: valueset.cxx:215
ValueItemList mItemList
Definition: valueset.hxx:189
bool IsItemSelected(sal_uInt16 nItemId) const
Definition: valueset.hxx:341
tools::Rectangle GetItemRect(sal_uInt16 nItemId) const
Definition: valueset.cxx:629
void SetNoSelection()
Definition: valueset.cxx:840
size_t GetItemPos(sal_uInt16 nItemId) const
Definition: valueset.cxx:605
sal_uInt16 GetItemId(size_t nPos) const
Definition: valueset.cxx:615
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr tools::Long GetHeight() const
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
constexpr tools::Long Left() const
OUString GetAccessibleName() const
weld::DrawingArea * GetDrawingArea() const
OUString GetAccessibleDescription() const
Size const & GetOutputSizePixel() const
virtual a11yrelationset get_accessible_relation_set()=0
virtual a11yref get_accessible_parent()=0
virtual Point get_accessible_location_on_screen()=0
int nCount
#define DBG_ASSERT(sCon, aError)
sal_uInt16 mnId
#define TOOLS_WARN_EXCEPTION(area, stream)
RegionData_Impl * mpParent
sal_Int32 nIndex
#define SAL_WARN(area, stream)
int i
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
ValueSetItem(ValueSet &rParent)
Definition: valueacc.cxx:36
OUString maText
Definition: valueimp.hxx:52
sal_uInt16 mnId
Definition: valueimp.hxx:57
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bIsTransientChildrenDisabled)
Definition: valueacc.cxx:55
sal_uInt8 meType
Definition: valueimp.hxx:58
rtl::Reference< ValueItemAcc > mxAcc
Definition: valueimp.hxx:54
ValueSet & mrParent
Definition: valueimp.hxx:51
Color maColor
Definition: valueimp.hxx:56
bool mbVisible
unsigned char sal_Bool
#define VALUESET_ITEM_NONEITEM
Definition: valueimp.hxx:35
@ VALUESETITEM_COLOR
Definition: valueimp.hxx:42
@ VALUESETITEM_NONE
Definition: valueimp.hxx:39
#define WB_NONEFIELD
Definition: valueset.hxx:176
RedlineType meType